# Add PDF document

> POST https://api.nabrah.ai/api/ext/document/file

Group: Documents. Page: https://www.nabrah.ai/en/docs/api-reference/documents/add-pdf-document

Uploads a **PDF** into a knowledge base and queues it for ingestion. Send `multipart/form-data` with a `knowledge_base_id` and a `file`. The file must be a valid PDF (content-checked), max **20 MB**. The document is created with status `QUEUED` and processed asynchronously — text extraction → chunking → embedding → vector indexing; poll `GET /api/ext/document/{document_id}` for `status`. Returns the created document. Only PDF is supported today (`/url` and `/text` are not yet available).

## Form fields (multipart/form-data)

- **knowledge_base_id**: The target knowledge base `id` to attach the document to. Fields: `knowledge_base_id`.
- **file**: The PDF file to ingest. Must be a valid PDF (verified by content), maximum 20 MB. Fields: `file`.

The document returns immediately as `QUEUED` and is embedded in the background — it becomes retrievable once its status reaches `DONE`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (multipart/form-data)

## Response

### 201 Successful Response

Content type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "knowledge_base_id": "00000000-0000-4000-8000-000000000000",
  "type": "file",
  "status": "unknown",
  "title": "string",
  "summary": "string",
  "filename": "string",
  "created_at": "2026-01-15T12:00:00.000Z",
  "updated_at": "2026-01-15T12:00:00.000Z"
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/document/file' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/document/file"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.post(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const form = new FormData();

const response = await fetch("https://api.nabrah.ai/api/ext/document/file", {
  method: "POST",
  headers: { "X-API-Key": "<your-api-key>" },
  body: form,
});

const data = await response.json();
console.log(data);
```

### Go

```go
// Send multipart/form-data with mime/multipart:
// POST https://api.nabrah.ai/api/ext/document/file
```
