> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/document-ai/api-reference/classification.md).

# Doc AI Classification

{% if false %}
Classification answers a narrower question than extraction: not *what does this document say* but *what kind of document is this*. It is what you reach for when a file arrives without a reliable label — an emailed attachment, a scanned packet, a customer upload — and you need to route it before you can extract from it.

The shape mirrors Extraction exactly. `/classify/sync` returns the answer in the response, `/classify` returns a job ID, and `/classify/bulk` handles a set. Feed the result into `documentType` on an extraction call and you have the routing pattern most integrations end up building.

### Generated endpoint reference

The generated reference is the source of truth for schemas and responses.

* [Synchronous document classification](/document-ai/developer-documentation/classification-1/synchronous-document-classification.md)
* [Get classification details](/document-ai/developer-documentation/classification-1/get-classification-details.md)

Use the generated reference navigation for asynchronous and bulk classification. This guide keeps routing behavior and ZIP-specific details.

{% hint style="info" %}
A ZIP upload is classified per member document, and those results carry `classificationGroupId`, `classificationGroupIndex` and `classificationGroupTotal` so you can reassemble the set. Plain PDF and Excel classifications do not carry those fields.
{% endhint %}

For the categories, confidence behaviour, and how classification is reviewed in the product, see [Document Classification](/document-ai/guides-1/document-classification.md).

### Get classification details

`GET /classifications/{classification_id}`

Requires the `X-Api-Key` header.

**Path and query parameters**

| Parameter           | In   | Type   | Required | Description |
| ------------------- | ---- | ------ | -------- | ----------- |
| `classification_id` | path | string | Yes      |             |

**Responses**

| Status | Description                                                             | Schema                         |
| ------ | ----------------------------------------------------------------------- | ------------------------------ |
| `200`  | OK                                                                      | `SingleClassificationResponse` |
| `400`  | Bad Request                                                             | `ValidationError`              |
| `401`  | Authentication required — the `X-Api-Key` header is missing or invalid. |                                |
| `404`  | No classification exists with that ID.                                  |                                |

**Example**

```bash
curl -X GET "https://<api-host>/classifications/{classification_id}" \
  -H "X-Api-Key: $DOCAI_API_KEY"
```

### Classify document type (Async)

`POST /classify`

Requires the `X-Api-Key` header.

**Request body** — `application/json`, required: `ClassifyRequest`

| Property                    | Type           | Description                                                                                                                                                                    |
| --------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `content`                   | string         | Base64-encoded file content                                                                                                                                                    |
| `context`                   | string         | Additional context to guide the classification                                                                                                                                 |
| `custom_document_types`     | array\<string> | Custom document types to classify against. If provided, classification is restricted to these types.                                                                           |
| `custom_document_types_url` | string         | URL to a JSON file containing custom document types. Merged with custom\_document\_types if both provided.                                                                     |
| `entities`                  | object         | Entity ID-to-name mapping for Excel workbook classification: {entityId: entityName, ...}                                                                                       |
| `file_url`                  | string         | Public URL to file                                                                                                                                                             |
| `metadata`                  | object         | Custom metadata                                                                                                                                                                |
| `model`                     | string         | LLM model for classification. Must be one of the supported models. One of: `gpt-4.1`, `gpt-5.1`, `gemini-3`, `openrouter/z-ai/glm-5.2`, `openrouter/deepseek/deepseek-v4-pro`. |
| `use_custom_types_only`     | boolean        | If true, only custom\_document\_types are valid classification results. Requires custom\_document\_types or custom\_document\_types\_url to be provided.                       |

**Responses**

| Status | Description                                                                              | Schema             |
| ------ | ---------------------------------------------------------------------------------------- | ------------------ |
| `200`  | OK                                                                                       | `ClassifyResponse` |
| `400`  | Bad Request                                                                              | `ValidationError`  |
| `401`  | Authentication required — the `X-Api-Key` header is missing or invalid.                  |                    |
| `500`  | Returned instead of `400` when the request body is missing or invalid. **Known defect.** |                    |

**Example**

```bash
curl -X POST "https://<api-host>/classify" \
  -H "X-Api-Key: $DOCAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
         "file_url": "https://example.com/unknown-document.pdf"
       }'
```

### Bulk document classification

`POST /classify/bulk`

Requires the `X-Api-Key` header.

**Request body** — `application/json`, required: `ClassifyBulkRequest`

| Property                    | Type                             | Description                                                                                                                                                                                             |
| --------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `context`                   | array\<string> \| null           | Per-file classification context strings. Length must match files array.                                                                                                                                 |
| `custom_document_types`     | array\<string> \| null           | Custom document types applied to all files. If provided, classification is restricted to these types.                                                                                                   |
| `custom_document_types_url` | string \| null                   | URL to custom document types JSON file. Merged with custom\_document\_types for all files.                                                                                                              |
| `entities`                  | object \| null                   | Entity ID-to-name mapping for Excel workbook classification across all files: {entityId: entityName, ...}                                                                                               |
| `files`                     | array<`ClassifyBulkRequestFile`> | List of files to classify                                                                                                                                                                               |
| `metadata`                  | array\<object> \| null           | Per-file metadata dicts. Length must match files array.                                                                                                                                                 |
| `model`                     | string \| null                   | LLM model for classification (applies to all files). Defaults to gemini-3 if not specified. One of: `gpt-4.1`, `gpt-5.1`, `gemini-3`, `openrouter/z-ai/glm-5.2`, `openrouter/deepseek/deepseek-v4-pro`. |
| `use_custom_types_only`     | boolean \| null                  | If true, only custom\_document\_types are valid. Applied to all files.                                                                                                                                  |

**Nested objects**

`ClassifyBulkRequestFile`

| Property   | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| `content`  | string | Base64-encoded file content |
| `file_url` | string | Public URL to file          |

**Responses**

| Status | Description                                                             | Schema                 |
| ------ | ----------------------------------------------------------------------- | ---------------------- |
| `200`  | OK                                                                      | `ClassifyBulkResponse` |
| `400`  | Bad Request                                                             | `ValidationError`      |
| `401`  | Authentication required — the `X-Api-Key` header is missing or invalid. |                        |

**Example**

```bash
curl -X POST "https://<api-host>/classify/bulk" \
  -H "X-Api-Key: $DOCAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
         "files": [
           {
             "file_url": "https://example.com/doc-1.pdf"
           },
           {
             "file_url": "https://example.com/doc-2.pdf"
           }
         ]
       }'
```

### Synchronous document classification

`POST /classify/sync`

Requires the `X-Api-Key` header.

**Request body** — `application/json`, required: `ClassifySyncRequest`

| Property                    | Type           | Description                                                                                                                                                                    |
| --------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `content`                   | string         | Base64-encoded file content                                                                                                                                                    |
| `context`                   | string         | Additional context to guide the classification                                                                                                                                 |
| `custom_document_types`     | array\<string> | Custom document types to classify against. If provided, classification is restricted to these types.                                                                           |
| `custom_document_types_url` | string         | URL to a JSON file containing custom document types. Merged with custom\_document\_types if both provided.                                                                     |
| `entities`                  | object         | Entity ID-to-name mapping for Excel workbook classification: {entityId: entityName, ...}                                                                                       |
| `file_url`                  | string         | Public URL to file                                                                                                                                                             |
| `metadata`                  | object         | Custom metadata                                                                                                                                                                |
| `model`                     | string         | LLM model for classification. Must be one of the supported models. One of: `gpt-4.1`, `gpt-5.1`, `gemini-3`, `openrouter/z-ai/glm-5.2`, `openrouter/deepseek/deepseek-v4-pro`. |
| `use_custom_types_only`     | boolean        | If true, only custom\_document\_types are valid classification results. Requires custom\_document\_types or custom\_document\_types\_url to be provided.                       |

**Responses**

| Status | Description                                                                              | Schema                 |
| ------ | ---------------------------------------------------------------------------------------- | ---------------------- |
| `200`  | OK                                                                                       | `ClassifySyncResponse` |
| `400`  | Bad Request                                                                              | `ValidationError`      |
| `401`  | Authentication required — the `X-Api-Key` header is missing or invalid.                  |                        |
| `500`  | Returned instead of `400` when the request body is missing or invalid. **Known defect.** |                        |

**Example**

```bash
curl -X POST "https://<api-host>/classify/sync" \
  -H "X-Api-Key: $DOCAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
         "file_url": "https://example.com/unknown-document.pdf"
       }'
```

### Related pages

* [Document Classification](/document-ai/guides-1/document-classification.md) — the same capability through the UI.
* [Document Types](/document-ai/guides-1/document-types.md) — the registry the classifier draws from.
* [Classify, then extract](/document-ai/cookbooks/classify-then-extract.md) — the routing recipe.
* [Extraction API](broken://pages/vSGQzOYgGEf7RDcpwe08) — where a classification result usually goes next.
  {% endif %}

Classification identifies a document type before routing it for extraction. Use it when a file arrives without a reliable label.

`/classify/sync` returns the result in the response. `/classify` returns a job ID. `/classify/bulk` processes a set of files.

Use the resulting type as `documentType` in an extraction request.

### Endpoint reference

Use the generated endpoint reference for complete schemas and responses:

* [Synchronous document classification](/document-ai/developer-documentation/classification-1/synchronous-document-classification.md)
* [Get classification details](/document-ai/developer-documentation/classification-1/get-classification-details.md)

Use the generated reference navigation for asynchronous and bulk classification.

{% hint style="info" %}
A ZIP upload is classified per member document. Results include `classificationGroupId`, `classificationGroupIndex`, and `classificationGroupTotal`. Use these fields to reassemble the set. PDF and Excel classifications do not include them.
{% endhint %}

For categories, confidence behavior, and product review workflows, see [Document Classification](/document-ai/guides-1/document-classification.md).

### Related pages

* [Document Classification](/document-ai/guides-1/document-classification.md) — classify documents in the UI.
* [Document Types](/document-ai/guides-1/document-types.md) — the classifier’s document-type registry.
* [Classify, then extract](/document-ai/cookbooks/classify-then-extract.md) — a routing recipe.
* [Extraction API](broken://spaces/mwA6l7LmuazHsFgRVEq8/pages/vSGQzOYgGEf7RDcpwe08) — submit classified documents for extraction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.uptiq.ai/document-ai/api-reference/classification.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
