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

# /documents

> Create new document.

### Body

<ParamField body="name" type="string">
  A name for the document.
</ParamField>

<ParamField body="type" type="string">
  The document type. Options: `TXT`, `PDF`, `YOUTUBE`, `CSV` or `URL`.
</ParamField>

<ParamField body="url" type="string">
  A publicly available `URL` for the document.
</ParamField>

<ParamField body="from_page" type="number">
  The first page to ingest.
</ParamField>

<ParamField body="to_page" type="string">
  The last page to ingest.
</ParamField>

<ParamField body="authorization" type="object">
  Any authorization/authentication needed to access the document

  <Expandable title="authorization object">
    <ResponseField name="type" type="string">
      Valid options `header`.
    </ResponseField>

    <ResponseField name="key" type="string">
      The header or query param key.
    </ResponseField>

    <ResponseField name="value" type="string">
      The header or query param value.
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField body="splitter" type="object">
  The desired text splitter for the document, defaults to
  `CharacterTextSplitter`.

  <Expandable title="authorization object">
    <ResponseField name="type" type="string">
      Valid options, `character`, `recursive`, `token`, `spacy`, `nltk`,
      `huggingface`.
    </ResponseField>

    <ResponseField name="chunk_size" type="number">
      The `chunk_size` of the text splitter.
    </ResponseField>

    <ResponseField name="chunk_overlap" type="number">
      The `chunk_overlap` of the text splitter.
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField body="metadata" type="object">
  Any key values necessary to ingest the document.
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates whether the call was successful.
</ResponseField>

<ResponseField name="data" type="object">
  A `document` object.
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl --location --request POST 'https://api.rapidagent.ai/api/v1/documents' \
  --header 'Content-Type: application/json' \
  --header 'Autorization: Bearer <token>' \
  --data-raw '{
      "name": "My document",
      "type": "PDF",
      "url": "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q1-2023-Update", 
      "authorization": null,
      "splitter": null
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": "clhnyae1t00016i2ixo0027c5",
      "userId": "clhj28u1300006ig02ptpm1sh",
      "user": {},
      "type": "PDF",
      "url": "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q1-2023-Update",
      "createdAt": "2023-05-14T21:50:59.349000+00:00",
      "updatedAt": "2023-05-14T21:50:59.349000+00:00",
      "index": null,
      "Agent": null
    }
  }
  ```
</ResponseExample>
