Create a file
const url = 'https://example.com/v1/files';const form = new FormData();form.append('file', 'file');form.append('contentType', 'example');form.append('tags', '"example"');form.append('expectedHash', 'example');form.append('name', 'example');form.append('ownerRunId', '2489E9AD-2EE2-8E00-8EC9-32D5F69181C0');form.append('projectId', 'example');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/files \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form file=@file \ --form contentType=example \ --form 'tags="example"' \ --form expectedHash=example \ --form name=example \ --form ownerRunId=2489E9AD-2EE2-8E00-8EC9-32D5F69181C0 \ --form projectId=exampleMultipart upload of a new file’s version 1. The file part carries the bytes; the other form fields are name, contentType, tags (JSON), ownerRunId, projectId and expectedHash. The file’s id is the new bytes’ blobId. It belongs to its owner run’s project, else projectId, else the project the caller’s API key is limited to, else the workspace’s default project. Creating needs write there, and a key limited to a project creates in that project only; a person with run there and no write may create a file that names no ownerRunId: an input for a run they start. An upload over the runtime’s cap (default 100 MiB) is 413 file-too-large. One that the workspace’s storage limit has no room for is 403 storage-limit-reached, and nothing is stored.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the workspace is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5). A request whose key store can’t be read before it runs is answered 503 idempotency-store-unavailable with Retry-After: nothing ran, so retry with the same key (from 0.3.0).
Request Bodyrequired
Section titled “Request Bodyrequired”Multipart form. file is the byte stream (required); the other fields are optional.
object
Its MIME type. Default: the file part’s.
JSON-encoded Record<string, string>: labels for this version.
Caller-computed sha256, hex-encoded, lowercase. A mismatch is 400 blob-hash-mismatch.
Its name. Default: the file part’s filename.
The run that produced it: the file joins that run’s project.
The project it belongs to, when there’s no ownerRunId (with one, the run’s project, and this must agree). Default: the workspace’s default project.
Responses
Section titled “Responses”The file, at version 1.
object
One version of a file. Numbers start at 1, only grow, and are never reused. A deleted or purged version keeps its record, so the runs that used it still name it.
object
The file’s id: the blobId of its version 1’s bytes, which names the file through every later version.
The stored bytes. Two versions of one file can share them.
The file’s name when this version was made.
MIME type, as the writer declared it.
Sha256 of the bytes, hex-encoded, lowercase.
Labels the writer gave this version.
object
Latest when this version was made. Absent on version 1.
The version a restore copied the bytes of.
How it was made: a person’s or a key’s upload, a restore, a run’s tool, or a run’s model.
Who made it: user:<id> or service_account:<id>, or run:<id> for a run’s tool or model.
The run that made it, when one did.
The run’s tool call that made it.
The tool that made it.
When a newer version replaced it as Latest. Absent on Latest: when Latest is deleted, the version that’s Latest again has none.
A version’s keep mark: it can’t be deleted, and retention never purges it.
object
Who pinned it: user:<id> or service_account:<id>.
When retention dropped its bytes (the file_version domain). Its number, hash, size and maker stay.
false when the bytes were already Latest’s: no version was added, and version is Latest.
Example
{ "version": { "madeVia": "upload" }}Malformed multipart body, bad tag JSON, hash mismatch (blob-hash-mismatch), declared size mismatch (blob-size-mismatch), or a projectId that isn’t the owner run’s.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No write on the project, and no run there for a file of the caller’s own that names no run (permission-denied); the caller’s API key is limited to another project (key-project-mismatch); or the workspace’s storage limit has no room for the file (storage-limit-reached; details.storageMiB, usedBytes and neededBytes say how much).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No such owner run (run-not-found).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Idempotency-Key was reused with a different body, or resource-state conflict. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.
Over the upload cap (file-too-large; details.maxBytes says how much).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.
Server error (unmapped domain code or framework crash).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.
See also
GET /v1/files: List files- Files and versions
- Error code
authz-backend-unavailable - Error code
blob-hash-mismatch - Error code
blob-size-mismatch - Error code
database-busy - Error code
file-too-large - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
key-project-mismatch - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
run-not-found - Error code
storage-limit-reached - Error code
tenant-state-unavailable - Every error code