Add a version to a file for a pack tool's call
const url = 'https://example.com/v1/tool-files/example/versions';const options = { method: 'POST', headers: {'Kindgi-Expected-Version': '1', 'Content-Type': '*/*'}, body: 'binary'};
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/tool-files/example/versions \ --header 'Content-Type: */*' \ --header 'Kindgi-Expected-Version: 1' \ --data binaryA pack tool that declares updatesFiles gets the call’s tool files with each call, and its pack service posts each new version the tool adds here, by its file value’s fileId. No API key: Authorization: Bearer carries the call’s token (kgi_tf_…). The call updates a file its run may be shown, where the run may write: the file’s project, or the workspace for a file with no project. The body is the new bytes, at most 10 MB read; Content-Type is the type, and only the bytes decide it. Kindgi-Expected-Version is the version the tool read: when Latest has moved past it, nothing is added and the answer is Latest (conflict). The new version keeps Latest’s tags, and is listed among the run’s files. The same bytes again in the same call, a re-run of it included, answer the first version. The token closes when the call answers, when its time passes, or when its run ends.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The file value’s fileId.
Header Parameters
Section titled “Header Parameters”The version the tool read, which must still be Latest: a whole number from 1.
A new name for the version, percent-encoded UTF-8. Absent or empty: Latest’s name.
Request Bodyrequired
Section titled “Request Bodyrequired”The new bytes, with their type as Content-Type.
Responses
Section titled “Responses”The new version (file), for the tool to return in its result’s top-level files; Latest, when it already has these bytes (same) or isn’t the expected version any more (conflict); or no version added, and why (notUpdated): rule, denied, gone, type, size (over its type’s limit, or a body past 10 MB, not read to its end) or storage.
object
A stored file as a value: in a run’s input, a tool’s result or a conversation message. Only artifactId is trusted: the runtime shows a model a file by its own checked record of it, never by the value’s other fields. A message’s files are the ones its run admitted, with the record’s fields.
object
The stored file (POST /v1/artifacts): its blobId.
The file these bytes are a version of, on a runtime that keeps file versions. Set with version: a value is admitted only when the two name artifactId’s bytes.
Which version of fileId these bytes are. Set with fileId.
The file’s name.
Its type, as checked from its bytes.
Its size in bytes.
Sha256 of its bytes, hex-encoded, lowercase.
A PDF’s page count, as checked from its bytes.
Set when the model isn’t shown it, and reads a line naming it instead: type (not a type a model is shown), size (over its type’s limit), model (the agent or its model doesn’t take images and PDFs), limit (over a call’s or a list’s limits), store (no file store), gone (no longer stored), changed (not the bytes that were checked), refused (the model couldn’t read it when it was attached), storage (a tool’s store found the workspace’s storage full), reading (what the model is sent in its place, an image or a text made from it, isn’t made yet).
object
A stored file as a value: in a run’s input, a tool’s result or a conversation message. Only artifactId is trusted: the runtime shows a model a file by its own checked record of it, never by the value’s other fields. A message’s files are the ones its run admitted, with the record’s fields.
object
The stored file (POST /v1/artifacts): its blobId.
The file these bytes are a version of, on a runtime that keeps file versions. Set with version: a value is admitted only when the two name artifactId’s bytes.
Which version of fileId these bytes are. Set with fileId.
The file’s name.
Its type, as checked from its bytes.
Its size in bytes.
Sha256 of its bytes, hex-encoded, lowercase.
A PDF’s page count, as checked from its bytes.
Set when the model isn’t shown it, and reads a line naming it instead: type (not a type a model is shown), size (over its type’s limit), model (the agent or its model doesn’t take images and PDFs), limit (over a call’s or a list’s limits), store (no file store), gone (no longer stored), changed (not the bytes that were checked), refused (the model couldn’t read it when it was attached), storage (a tool’s store found the workspace’s storage full), reading (what the model is sent in its place, an image or a text made from it, isn’t made yet).
object
A stored file as a value: in a run’s input, a tool’s result or a conversation message. Only artifactId is trusted: the runtime shows a model a file by its own checked record of it, never by the value’s other fields. A message’s files are the ones its run admitted, with the record’s fields.
object
The stored file (POST /v1/artifacts): its blobId.
The file these bytes are a version of, on a runtime that keeps file versions. Set with version: a value is admitted only when the two name artifactId’s bytes.
Which version of fileId these bytes are. Set with fileId.
The file’s name.
Its type, as checked from its bytes.
Its size in bytes.
Sha256 of its bytes, hex-encoded, lowercase.
A PDF’s page count, as checked from its bytes.
Set when the model isn’t shown it, and reads a line naming it instead: type (not a type a model is shown), size (over its type’s limit), model (the agent or its model doesn’t take images and PDFs), limit (over a call’s or a list’s limits), store (no file store), gone (no longer stored), changed (not the bytes that were checked), refused (the model couldn’t read it when it was attached), storage (a tool’s store found the workspace’s storage full), reading (what the model is sent in its place, an image or a text made from it, isn’t made yet).
object
Why no version was added: rule (the call’s run may not be shown a file of that id, whether or not the id names a file elsewhere), denied (the run may not write where the file is), gone (the file is deleted), type (the bytes aren’t the type they claim, or they’re a type no model is shown and no tool the run can call reads files), size (over its type’s limit, or a body past 10 MB), storage (the workspace’s storage is full).
Example
{ "file": { "type": "kindgi.file", "notShown": "type" }}bad-input: Kindgi-Expected-Version is missing or not a whole number from 1, or Kindgi-File-Name is not percent-encoded UTF-8.
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" }}tool-file-token-not-found: no tool call’s files match the bearer (none sent, an unknown token, a wrong secret, and a call that doesn’t update files alike), or this runtime adds no versions for tools.
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" }}tool-file-token-closed: the call has answered, its time has passed, or its run has ended. tenant-closing, tenant-suspended (details.state) or project-suspended: nothing runs where the run is, so nothing was added. Told only for a token that matches.
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 request body is over the API’s limit (request-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: too many requests from this client in a minute, counted before the token is looked up, so nothing was added. Retry-After says when to send the version 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.
tenant-state-unavailable: the run’s workspace’s state couldn’t be read, so nothing was added. tool-files-busy: the runtime’s memory for files had no room for the bytes in time, so nothing was added. Retry-After says when to send the version 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.
See also
- Error code
bad-input - Error code
project-suspended - Error code
rate-limit-exceeded - Error code
request-too-large - Error code
tenant-closing - Error code
tenant-state-unavailable - Error code
tenant-suspended - Error code
tool-file-token-closed - Error code
tool-file-token-not-found - Error code
tool-files-busy - Every error code