---
title: "Add Document"
method: POST
path: "/documents/add-document"
tags: ["Documents"]
---

# Add Document

`POST /documents/add-document`

Adds a document to a given collection.

A status code of `201 Created` will be returned if a document was successfully added. A status code of `409 Conflict` will be returned if the given collection already has a document with the same path.

If `overwrite` is given a value of `true`, then a status code of `200 OK` will be returned if a document was overwritten (Rather than a status code of `409 Conflict`).

When a document is inserted, it can take time to appear in the index. Check the `/status/get-status` endpoint to see progress.

## Request body

- AddDocumentRequest
  - `collection_name` string, required — The name of the collection to be used for this request. A `404 Not Found` status code will be returned if this collection name does not exist.
  - `path` string, required — The filepath of the document that you are adding. A `409 Conflict` status code will be returned if this path already exists, unless `overwrite` is set to `true`.
  - `content` union, required — The content of the document. There are three possible JSON types that can be passed into this parameter: `APITextDocument`, `APITextPagesDocument`, `APIBinaryDocument`. The `type` field is how ZeroEntropy will know which document object you have passed in.
    - APITextDocument
      - `type` 'text', required — This field must be `text`
      - `text` string, required — The content of this document, as a text string
    - APITextPagesDocument
      - `type` 'text-pages' | 'text-pages-unordered', required — This field must be `text-pages` or `text-pages-unordered`. When `unordered` is provided, it is assumed that consecutive pages aren't meant to be read one after another. For example, PDFs are ordered, and CSVs are unordered.
      - `pages` string[], required — The content of this document, as an array of strings. Each string will be the content of a full page, and can be retrieved using the Top Pages endpoint. Pages are 0-indexed, so that the first string has index 0, the second string has index 1.
    - APIBinaryDocument
      - `type` 'auto', required — When this is set to `auto`, then the file extension and binary data will be used to deduce a filetype automatically. Currently, only `auto` is supported.
      - `base64_data` string, required — The file's raw data, as a base64-encoded string
  - `metadata` DocumentMetadataJson
  - `overwrite` boolean — Setting this property to true will put this endpoint in "upsert" mode: If the document already exists, this action will atomically replace it.

## Response `200`

Successful Response

- DefaultResponse
  - `message` string — This string will always be "Success!". This may change in the future.

## Other responses

- `201` — Created
- `400` — Bad Request
- `404` — Not Found
- `409` — Conflict
- `422` — Validation Error

## Changes

- **2025-11-24** `c95681b13dc5` — 3 info
  - the `type` request property const value `text-pages` was removed
  - added `text-pages-unordered` discriminator mapping keys to the `content` request property
  - added the new `text-pages-unordered` enum value to the request property `content/oneOf[subschema #2: APITextPagesDocument]/type`

[Change history](https://skmtc.dev/zeroentropy-ai/apis/zeroentropy-api/changes/documents/add-document/post.md)

---

[API](https://skmtc.dev/zeroentropy-ai/apis/zeroentropy-api.md) · [All operations](https://skmtc.dev/zeroentropy-ai/apis/zeroentropy-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/zeroentropy-ai/zeroentropy-api/revisions/b5badb138367/schema)
