> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroentropy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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



## OpenAPI

````yaml POST /documents/add-document
openapi: 3.1.0
info:
  title: ZeroEntropy API
  description: This API provides access to ZeroEntropy's SoTA retrieval pipeline. Enjoy!
  version: 0.1.0
servers:
  - url: https://api.zeroentropy.dev/v1
    description: ZeroEntropy API
  - url: https://eu-api.zeroentropy.dev/v1
    description: ZeroEntropy API (EU datacenters)
security: []
paths:
  /documents/add-document:
    post:
      tags:
        - Documents
      summary: Add Document
      description: >-
        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.
      operationId: add_document_documents_add_document_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddDocumentRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DefaultResponse'
        '201':
          description: Created
        '400':
          description: Bad Request
          content:
            application/json:
              example:
                detail: Description of Error
        '404':
          description: Not Found
          content:
            application/json:
              example:
                detail: Description of Error
        '409':
          description: Conflict
          content:
            application/json:
              example:
                detail: Description of Error
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    AddDocumentRequest:
      properties:
        collection_name:
          type: string
          title: Collection Name
          description: >-
            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:
          type: string
          title: Path
          description: >-
            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:
          oneOf:
            - $ref: '#/components/schemas/APITextDocument'
            - $ref: '#/components/schemas/APITextPagesDocument'
            - $ref: '#/components/schemas/APIBinaryDocument'
          title: Content
          description: >-
            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.
          discriminator:
            propertyName: type
            mapping:
              auto:
                $ref: '#/components/schemas/APIBinaryDocument'
              text:
                $ref: '#/components/schemas/APITextDocument'
              text-pages:
                $ref: '#/components/schemas/APITextPagesDocument'
              text-pages-unordered:
                $ref: '#/components/schemas/APITextPagesDocument'
        metadata:
          allOf:
            - $ref: '#/components/schemas/DocumentMetadataJson'
          description: >-
            This is a metadata JSON object that can be used to assign various
            metadata attributes to your document. The provided object must match
            the type `dict[str, str | list[str]]`. Please read [Metadata
            Filtering](/metadata-filtering) for more details. By default, the
            metadata will be set to `{}`.


            NOTE: The UTF-8-encoded JSON string must be less than 65536 bytes
            (Whitespace does not count). This limit can be increased upon
            request.
          default: {}
        overwrite:
          type: boolean
          title: Overwrite
          description: >-
            Setting this property to true will put this endpoint in "upsert"
            mode: If the document already exists, this action will atomically
            replace it.
          default: false
      type: object
      required:
        - collection_name
        - path
        - content
      title: AddDocumentRequest
    DefaultResponse:
      properties:
        message:
          type: string
          title: Message
          description: >-
            This string will always be "Success!". This may change in the
            future.
          default: Success!
      type: object
      title: DefaultResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    APITextDocument:
      properties:
        type:
          type: string
          enum:
            - text
          const: text
          title: Type
          description: This field must be `text`
        text:
          type: string
          title: Text
          description: The content of this document, as a text string
      type: object
      required:
        - type
        - text
      title: APITextDocument
    APITextPagesDocument:
      properties:
        type:
          type: string
          enum:
            - text-pages
            - text-pages-unordered
          title: Type
          description: >-
            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:
          items:
            type: string
          type: array
          title: Pages
          description: >-
            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.
      type: object
      required:
        - type
        - pages
      title: APITextPagesDocument
    APIBinaryDocument:
      properties:
        type:
          type: string
          enum:
            - auto
          const: auto
          title: Type
          description: >-
            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:
          type: string
          title: Base64 Data
          description: The file's raw data, as a base64-encoded string
      type: object
      required:
        - type
        - base64_data
      title: APIBinaryDocument
    DocumentMetadataJson:
      additionalProperties:
        anyOf:
          - type: string
          - items:
              type: string
            type: array
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        The `Authorization` header must be provided in the format `Bearer
        <your-api-key>`.


        You can get your API Key at the
        [Dashboard](https://dashboard.zeroentropy.dev/)!
      scheme: bearer

````