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

# Create document

> Add a document to a knowledge base.

Adds a new document to a knowledge base. Documents are processed asynchronously — the endpoint returns immediately while processing continues in the background.

## Endpoint

`POST /user/knowledgebases/{knowledgebaseId}/documents`

## Path parameters

<ParamField path="knowledgebaseId" type="integer" required>
  Unique identifier of the knowledge base.
</ParamField>

## Request

<ParamField body="name" type="string" required>
  Name of the document. Maximum 255 characters.
</ParamField>

<ParamField body="type" type="string" required>
  Document type: `website`, `pdf`, `txt`, or `docx`.
</ParamField>

<ParamField body="description" type="string">
  Optional description. Maximum 255 characters.
</ParamField>

### Website documents

<ParamField body="url" type="string">
  Main URL to scrape. Required if `links` is not provided.
</ParamField>

<ParamField body="links" type="array">
  Specific URLs to scrape. Required if `url` is not provided.

  <Expandable title="Link properties">
    <ParamField body="link" type="string" required>A valid URL to include.</ParamField>
  </Expandable>
</ParamField>

<ParamField body="relative_links_limit" type="integer" default="10">
  Maximum number of relative links to follow when scraping. Range: 1–50.
</ParamField>

### File documents (PDF, TXT, DOCX)

<ParamField body="file" type="file" required>
  File to upload. Maximum 20 MB. Use `multipart/form-data` encoding.
</ParamField>

## Document types

| Type      | Description                         | Input               |
| --------- | ----------------------------------- | ------------------- |
| `website` | Scrapes web pages and extracts text | URL or list of URLs |
| `pdf`     | Extracts text from PDF files        | PDF file upload     |
| `txt`     | Plain text content                  | TXT file upload     |
| `docx`    | Extracts text from Word documents   | DOCX file upload    |

## Response

<ResponseField name="message" type="string">Confirmation message.</ResponseField>

<ResponseField name="data" type="object">
  The created document.

  <Expandable title="properties">
    <ResponseField name="id" type="integer">Unique identifier of the document.</ResponseField>
    <ResponseField name="name" type="string">Document name.</ResponseField>
    <ResponseField name="description" type="string">Document description.</ResponseField>
    <ResponseField name="type" type="string">Document type.</ResponseField>
    <ResponseField name="type_label" type="string">Human-readable type label.</ResponseField>
    <ResponseField name="status" type="string">Processing status — always `processing` initially.</ResponseField>
    <ResponseField name="status_label" type="string">Human-readable status label.</ResponseField>
    <ResponseField name="created_at" type="string">ISO 8601 creation timestamp.</ResponseField>
  </Expandable>
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL — website document theme={null}
  curl -X POST "https://portal.intellixent.ai/api/user/knowledgebases/1/documents" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Company Website",
      "type": "website",
      "url": "https://example.com",
      "relative_links_limit": 20
    }'
  ```

  ```bash cURL — PDF upload theme={null}
  curl -X POST "https://portal.intellixent.ai/api/user/knowledgebases/1/documents" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "name=Product Manual" \
    -F "type=pdf" \
    -F "file=@/path/to/document.pdf"
  ```

  ```javascript Node.js — website document theme={null}
  const response = await fetch('https://portal.intellixent.ai/api/user/knowledgebases/1/documents', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Company Website',
      type: 'website',
      url: 'https://example.com',
      relative_links_limit: 20
    })
  });

  const data = await response.json();
  console.log(data.data.id);
  ```
</CodeGroup>

```json 201 Created theme={null}
{
  "message": "Document created successfully. Processing will begin shortly.",
  "data": {
    "id": 1,
    "name": "Company Website",
    "type": "website",
    "type_label": "Website",
    "status": "processing",
    "status_label": "Processing",
    "created_at": "2025-01-08T10:30:00.000000Z"
  }
}
```

```json 404 Knowledge base not found theme={null}
{
  "error": "Knowledgebase not found."
}
```

<Note>
  Document processing is asynchronous. Poll the knowledge base status using [Get knowledge bases](/api-reference/knowledgebases/get-knowledgebases) to check when all documents are ready.
</Note>
