---
title: "Analyze Document"
method: POST
path: "/api/v1/analyze"
tags: ["analysis"]
---

# Analyze Document

`POST /api/v1/analyze`

## Request

- Base URL: `https://docs.thedrive.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://docs.thedrive.ai/api/v1/analyze`
- Auth: none declared

Analyze a document by asking questions. Unlike `/extract`, this endpoint
can **compute, reason, and derive** values that aren't explicitly written
in the document.

Upload a file (or provide a URL) along with a typed schema. Each field
must have a `type` and `description`.

**Example schema**:
```json
{
  "total_cost": {"type": "number", "description": "Sum all line item amounts"},
  "is_auto_renew": {"type": "boolean", "description": "Does this contract auto-renew?"},
  "risk_level": {"type": "string", "enum": ["low", "medium", "high"], "description": "Legal risk level"}
}
```

**Supported types**: `string`, `number`, `integer`, `boolean`, `array`, `object`

Every answer includes:
- The computed answer (type-enforced)
- Reasoning explaining how it was derived
- Source text snippets from the document
- Confidence level

**Pricing**: 2 credits/page (min 5) for documents, 10 credits for websites.

## Headers

- `X-API-Key` string

## Response `200`

Successful Response

- AnalyzeResponse: Response for document analysis — flat parallel dicts matching /extract.
  - `success` boolean
  - `data` object, required: Computed/derived values keyed by field name
  - `confidence` object: Per-field confidence scores (0.0–1.0)
  - `sources` object: Per-field source text snippets from the document
  - `reasoning` object: Per-field step-by-step explanation of how the answer was derived
  - `steps` object: Per-field agent reasoning trace (tool calls). Empty unless include_steps=true.
  - `filename` string, required: Original filename or URL
  - `content_type` string, nullable: Detected MIME type
  - `model_used` string, required: Model used for analysis
  - `text_length` integer, required: Length of extracted text
  - `total_pages` integer: Total pages in the document (0 for non-paginated files)
  - `credits_used` integer: Credits consumed
  - `schema_format` 'typed': Schema format used for extraction/analysis.

## Other responses

- `400`: Invalid request
- `413`: File too large
- `422`: Validation Error
- `503`: AI service unavailable

---

[API](https://skmtc.dev/thedrive/apis/the-drive-ai-api.md) · [All operations](https://skmtc.dev/thedrive/apis/the-drive-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/thedrive/apis/the-drive-ai-api/revisions/ee4e32647ebf?raw)
