Add a version
const url = 'https://example.com/v1/files/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/versions';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('expectedVersion', '1');
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/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/versions \ --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 expectedVersion=1Multipart upload of a file’s next version, which becomes Latest. The file part carries the bytes; the other form fields are name (a new name for the file), contentType, tags (JSON), expectedVersion and expectedHash. With expectedVersion, a Latest that isn’t it is 409 file-version-conflict, and nothing is written; without it, the last write wins, and the version in between stays in the history. Bytes that are already Latest’s add no version (200, created: false); bytes an earlier version has are kept once. Needs write on the file’s project, even for a file of the caller’s own. Over the runtime’s cap is 413 file-too-large. A version 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”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Multipart form. file is the byte stream (required); the other fields are optional. The version stays in its file’s project.
object
Responses
Section titled “Responses”The bytes were already Latest’s: Latest, with created: false.
object
Example
{ "version": { "madeVia": "upload" }}The new version.
object
Example
{ "version": { "madeVia": "upload" }}Malformed multipart body, bad tag JSON, an expectedVersion that is not a version number, an ownerRunId or projectId (a version stays in its file’s project), hash mismatch (blob-hash-mismatch), or declared size mismatch (blob-size-mismatch).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No write on its project (permission-denied), or the workspace’s storage limit has no room for the version (storage-limit-reached; details.storageMiB, usedBytes and neededBytes say how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}file-not-found: no such file in this workspace, a deleted one, or one in a project the caller can’t read that isn’t a file of their own.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}file-version-conflict: expectedVersion isn’t Latest (details.expectedVersion, details.latestVersion). Nothing was written. 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
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Over the upload cap (file-too-large; details.maxBytes says how much).
object
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
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
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
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/files/{fileId}/versions: List a file's versionsGET /v1/files/{fileId}: Get a fileDELETE /v1/files/{fileId}: Delete a fileGET /v1/files/{fileId}/versions/{version}: Get a version- Error code
authz-backend-unavailable - Error code
blob-hash-mismatch - Error code
blob-size-mismatch - Error code
database-busy - Error code
file-not-found - Error code
file-too-large - Error code
file-version-conflict - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
storage-limit-reached - Error code
tenant-state-unavailable - Every error code