---
title: "File a new document, as raw bytes"
method: POST
path: "/api/v1/documents"
tags: ["Documents"]
---

# File a new document, as raw bytes

`POST /api/v1/documents`

## Request

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

The large-file counterpart of `documents_upload`. Same result, same pipeline, same `documents:write` scope — but the body is the file rather than base64 in JSON, so it takes up to 256 MB instead of 8 MB. Prefer the tool for small files and anything an assistant calls; prefer this for a bulk import or a scan.

Omit `documentTypeId` and pass `autoType=true` to have the type recognised from the document itself.

Pass `versionSameName=true` to file a file whose name is already in the archive as that document’s next version: the answer is then that document, still `201`, with `versioned: true`. Pass `suffixSameName=true` to keep both instead: the file becomes a new document named with the first free `_2`, `_3`… (`201`, `renamed: true`).

## Query parameters

- `filename` string, required
- `contentType` string
- `documentTypeId` string, uuid
- `autoType` boolean
- `title` string
- `direction` 'in_entrata' | 'in_uscita'
- `partyIds` string
- `originPath` string
- `skipDuplicates` boolean
- `versionSameName` boolean
- `suffixSameName` boolean

## Headers

- `X-Tenant-Id` string, uuid
- `Idempotency-Key` string

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