# Add a version to a file for a pack tool's call

POST

/v1/tool-files/{fileId}/versions

```sh
curl --request POST \
  --url https://example.com/v1/tool-files/example/versions \
  --header 'Content-Type: */*' \
  --header 'Kindgi-Expected-Version: 1' \
  --data binary
```

A 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

### Path Parameters

**fileId**

required

string

The file value’s `fileId`.

### Header Parameters

**Kindgi-Expected-Version**

required

integer

\>= 1

The version the tool read, which must still be Latest: a whole number from 1.

**Kindgi-File-Name**

string

A new name for the version, percent-encoded UTF-8. Absent or empty: Latest’s name.

## Request Bodyrequired

The new bytes, with their type as `Content-Type`.

\*/\*

string format: binary

## Responses

### 200

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`.

application/json

One of:

- **object**

  object

  **file**

  required

  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

  **type**

  required

  string

  Allowed value: kindgi.file

  **artifactId**

  required

  The stored file (`POST /v1/artifacts`): its `blobId`.

  string

  \>= 1 characters

  **fileId**

  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.

  string

  \>= 1 characters

  **version**

  Which version of `fileId` these bytes are. Set with `fileId`.

  integer

  \>= 1

  **name**

  The file’s name.

  string

  **contentType**

  required

  Its type, as checked from its bytes.

  string

  **size**

  required

  Its size in bytes.

  integer

  **sha256**

  required

  Sha256 of its bytes, hex-encoded, lowercase.

  string

  /^\[0-9a-f]{64}$/

  **pages**

  A PDF’s page count, as checked from its bytes.

  integer

  \>= 1

  **notShown**

  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).

  string

  Allowed values: type size model limit store gone changed refused storage reading

- **object**

  object

  **same**

  required

  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

  **type**

  required

  string

  Allowed value: kindgi.file

  **artifactId**

  required

  The stored file (`POST /v1/artifacts`): its `blobId`.

  string

  \>= 1 characters

  **fileId**

  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.

  string

  \>= 1 characters

  **version**

  Which version of `fileId` these bytes are. Set with `fileId`.

  integer

  \>= 1

  **name**

  The file’s name.

  string

  **contentType**

  required

  Its type, as checked from its bytes.

  string

  **size**

  required

  Its size in bytes.

  integer

  **sha256**

  required

  Sha256 of its bytes, hex-encoded, lowercase.

  string

  /^\[0-9a-f]{64}$/

  **pages**

  A PDF’s page count, as checked from its bytes.

  integer

  \>= 1

  **notShown**

  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).

  string

  Allowed values: type size model limit store gone changed refused storage reading

- **object**

  object

  **conflict**

  required

  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

  **type**

  required

  string

  Allowed value: kindgi.file

  **artifactId**

  required

  The stored file (`POST /v1/artifacts`): its `blobId`.

  string

  \>= 1 characters

  **fileId**

  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.

  string

  \>= 1 characters

  **version**

  Which version of `fileId` these bytes are. Set with `fileId`.

  integer

  \>= 1

  **name**

  The file’s name.

  string

  **contentType**

  required

  Its type, as checked from its bytes.

  string

  **size**

  required

  Its size in bytes.

  integer

  **sha256**

  required

  Sha256 of its bytes, hex-encoded, lowercase.

  string

  /^\[0-9a-f]{64}$/

  **pages**

  A PDF’s page count, as checked from its bytes.

  integer

  \>= 1

  **notShown**

  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).

  string

  Allowed values: type size model limit store gone changed refused storage reading

- **object**

  object

  **notUpdated**

  required

  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).

  string

  Allowed values: rule denied gone type size storage

##### Example

```json
{
  "file": {
    "type": "kindgi.file",
    "notShown": "type"
  }
}
```

### 400

`bad-input`: `Kindgi-Expected-Version` is missing or not a whole number from 1, or `Kindgi-File-Name` is not percent-encoded UTF-8.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 404

`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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 409

`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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 413

The request body is over the API’s limit (`request-too-large`; `details.maxBytes` says how much).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 429

`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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

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.

### 503

`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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

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`](https://docs.kindgi.com/v0.8.1/reference/errors.md#bad-input)
- [Error code `project-suspended`](https://docs.kindgi.com/v0.8.1/reference/errors.md#project-suspended)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.8.1/reference/errors.md#rate-limit-exceeded)
- [Error code `request-too-large`](https://docs.kindgi.com/v0.8.1/reference/errors.md#request-too-large)
- [Error code `tenant-closing`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tenant-closing)
- [Error code `tenant-state-unavailable`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tenant-state-unavailable)
- [Error code `tenant-suspended`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tenant-suspended)
- [Error code `tool-file-token-closed`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tool-file-token-closed)
- [Error code `tool-file-token-not-found`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tool-file-token-not-found)
- [Error code `tool-files-busy`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tool-files-busy)
- [Every error code](https://docs.kindgi.com/v0.8.1/reference/errors.md)
