# Analyze document figures

Extract numbers from a spreadsheet or PDF, then recompute and compare them.

Documentation index: https://webcite.co/llms.txt
Canonical page: https://webcite.co/api-docs/analyze-document
API origin: https://api.webcite.co
Authentication: x-api-key header. Keep keys on your server.

## When to use it

Use this when your starting point is a file. Use [Compare figures](/api-docs/conflicts) when you already have structured figures. The public OpenAPI does not yet define a complete response schema.

## Request

POST /api/v1/analyze/document

3 credits.

### curl

```curl
curl --fail-with-body -X POST 'https://api.webcite.co/api/v1/analyze/document' \
  -H "x-api-key: $WEBCITE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "asset_id": "YOUR_ASSET_ID"
}'
```

### Node.js

```javascript
const response = await fetch("https://api.webcite.co/api/v1/analyze/document", {
  method: "POST",
  headers: {
    "x-api-key": process.env.WEBCITE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "asset_id": "YOUR_ASSET_ID"
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.json());
```

### python

```python
import os
import json
import requests

payload = json.loads("{\n  \"asset_id\": \"YOUR_ASSET_ID\"\n}")
response = requests.post(
    "https://api.webcite.co/api/v1/analyze/document",
    headers={"x-api-key": os.environ["WEBCITE_API_KEY"]},
    json=payload,
    timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
```

## Response

Returns extracted figures alongside conflicts, recomputations, and review information. Inspect extraction coverage as well as numeric findings.

## Errors

For 400, check the request fields and source identifiers. For 401, check your API key. For 429, wait for the retry interval. See the errors guide before retrying a billable request.

## OpenAPI operation

```json
{
  "path": "/api/v1/analyze/document",
  "method": "POST",
  "operation": {
    "description": "Document-in numeric analysis. Give an uploaded asset id; the document is downloaded, its figures are extracted, then recomputed and cross-checked. Returns the extracted figures alongside conflicts, recomputations, and a review flag.\n\n- **Spreadsheets** (xlsx/xls/csv): extracted deterministically with exact cell provenance. A cell read is exact, so these are rule reads. No LLM calls — server compute and file I/O only.\n- **PDFs**: a vision model reads the printed figures (it never computes); these are model reads, capped at needs_review and never presented as verified. Their value is cross-source, e.g. a deck figure that disagrees with the spreadsheet. **This path makes a vision-model (LLM) call per page.**\n\n**Cost: 3 credits.** The document is downloaded and parsed; PDF pages may also use a vision model. Rate-limited more strictly than compute-only endpoints.",
    "operationId": "ApiV1Controller_analyzeDocument",
    "parameters": [],
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/AnalyzeDocumentRequestDto"
          }
        }
      },
      "required": true
    },
    "responses": {
      "200": {
        "description": "Extracted figures with conflicts, recomputations, and a review flag"
      },
      "400": {
        "description": "Asset not found or unsupported type"
      },
      "401": {
        "description": "Unauthorized - API key required"
      },
      "429": {
        "description": "Rate limit exceeded"
      }
    },
    "security": [
      {
        "x-api-key": []
      },
      {
        "bearer": []
      }
    ],
    "summary": "Analyze a spreadsheet or PDF document for conflicts and mismatches",
    "tags": [
      "Public API"
    ]
  },
  "schemas": {
    "AnalyzeDocumentRequestDto": {
      "properties": {
        "asset_id": {
          "description": "Uploaded asset id (from POST /upload). The spreadsheet is downloaded, figures are extracted deterministically with cell provenance, then recomputed and cross-checked.",
          "example": "123e4567-e89b-12d3-a456-426614174000",
          "type": "string"
        }
      },
      "required": [
        "asset_id"
      ],
      "type": "object"
    }
  }
}
```
