---
title: "Create an upload context for a job"
method: POST
path: "/preview/contexts"
tags: ["contexts"]
---

# Create an upload context for a job

`POST /preview/contexts`

## Request

- Base URL: `https://autoresearch.sfcompute.com`
- URL: `https://autoresearch.sfcompute.com/preview/contexts`
- Auth: HTTP bearer

Reserve a presigned upload for large bytes (over write_file's 4 MiB, up to 10 GiB): a job build context, or any input that exists only in your sandbox (a prepared dataset, an eval set, a wheel you built) headed for a node. Returns a `context_id` plus either a single PUT url or multipart part urls; tar a folder (`tar -c . | zstd`), upload the bytes STRAIGHT to object storage with `curl -T` (never through MCP), call finalize_context, then submit_job with `context_id` - or get_context for a download url to curl onto a node. One finalized upload serves both. The urls point at the object store's own hostname (currently fly.storage.tigris.dev), NOT the API's: an egress allowlist that only permits the API host 403s the PUT at your own proxy - allow the storage host too. For builds, tar determinism is yours: sorted paths and fixed mtimes hit the cache; a sloppy re-tar merely misses it. `context_id` composes with an inline `context` (inline overlays the tar, inline wins), so upload gigabytes once and iterate on the Dockerfile inline.

## Query parameters

- `workspace` string

## Request body

- object
  - `sha256` string, required: Declared sha256 of the uploaded bytes, the cache identity: exactly 64 lowercase hex chars, what `sha256sum` prints.
  - `size_bytes` integer, required: Declared size of the tar(.zst) to be uploaded (decoded bytes).

## Response `200`

The capability's JSON result.

- Result: The capability's result: the same object the MCP tool returns as structuredContent. Resources carry an `object` type discriminator and an immutable id; money is integer micro-dollars in `*_usd_micros` fields.
  - `object` string: The resource type, when the result is one resource.

## Other responses

- `400`: Malformed request: bad JSON, a parameter that does not parse, or a value outside its range. Code `invalid`.
- `401`: No bearer token, or one this API cannot verify. Code `unauthenticated`.
- `403`: Authenticated, but the token's scopes or the account's role do not reach this operation. The message names the scope word to request. Code `forbidden`.
- `404`: No such route. Code `not_found`; the body names the OpenAPI document.
- `422`: A well-formed request the platform declined: no such node, a cap reached, a state that forbids the move. The message says which, and what to do instead. Code `refused`.
- `429`: Over this door's per-customer budget. Wait `Retry-After` seconds. Code `rate_limited`.
- `500`: Our fault. Retry; if it persists, quote the request-id. Code `internal`.

---

[API](https://skmtc.dev/givemeanode/apis/autoresearch-customer-api.md) · [All operations](https://skmtc.dev/givemeanode/apis/autoresearch-customer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/givemeanode/apis/autoresearch-customer-api/revisions/f88dcb70ac6c?raw)
