---
title: "Add a version to an existing document, as raw bytes"
method: POST
path: "/api/v1/documents/{id}/versions"
tags: ["Documents"]
---

# Add a version to an existing document, as raw bytes

`POST /api/v1/documents/{id}/versions`

## Request

- Base URL: `https://api.custodo.ai`
- URL: `https://api.custodo.ai/api/v1/documents/{id}/versions`
- Auth: HTTP bearer

The large-file counterpart of `documents_add_version`. The document keeps its id, its type and its metadata; the new bytes become the current version and are reprocessed.

## Path parameters

- `id` string, uuid, required

## Query parameters

- `filename` string, required
- `contentType` string

## Headers

- `X-Tenant-Id` string, uuid

## Response `200`

Nothing was filed by this request: an `Idempotency-Key` replay (this exact file was already filed under that key), or — with `skipDuplicates=true` — the document whose current file already has these exact bytes, returned with `duplicate: true`.

- Document
  - `ok` true, required
  - `data` object, required
    - `id` string, uuid, required
    - `title` string, required
    - `status` string, required: `pending` on arrival. Poll `documents_get` until `ready`; `failed` means the pipeline gave up and the reason is on the document.
    - `documentType` object
      - `id` string, uuid
      - `key` string
      - `nameIt` string
      - `nameEn` string
    - `typeSource` string: `auto_pending` while the classifier has not run yet — the type you see now is the fallback, not the answer.
    - `currentVersionId` string, uuid, nullable
    - `createdAt` string, date-time

## Other responses

- `201`: Filed. Processing (conversion, then type recognition and extraction, then indexing) has been queued — the document comes back as `pending` and becomes `ready` in seconds to minutes.
- `400`: A query parameter is missing or contradictory.
- `403`: The module is off for this organisation, the credential lacks `documents:write`, the tier does not cover it, or the member may read that document type but not file into it (a per-type restriction on their account).
- `404`: No document with that id in this organisation.
- `409`: The `Idempotency-Key` was already used for different bytes, or — with `suffixSameName=true` — the first thousand suffixed names are all taken.
- `413`: Over 256 MB.
- `429`: The API key has spent its minute, or its day. Every request a key makes counts, this one included. See `Retry-After`.

---

[API](https://skmtc.dev/custodo/apis/custodo-integrazioni.md) · [All operations](https://skmtc.dev/custodo/apis/custodo-integrazioni/llms.txt) · [OpenAPI document](https://skmtc.dev/custodo/apis/custodo-integrazioni/revisions/16d336d3ec2a?raw)
