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

# Introduction

> API v3 overview: base URL, resource model, keyset pagination, idempotency, response headers, and the error envelope.

anyformat API **v3** is the current stable major. It runs the same extraction engine as v2 behind a smaller, flatter surface. Three resources cover it: [workflows](https://docs.anyformat.ai/concepts/workflows.md), [document packets](https://docs.anyformat.ai/concepts/document-packets.md), and [runs](https://docs.anyformat.ai/concepts/runs-and-results.md).

Coming from v2? The [migration guide](https://docs.anyformat.ai/api-reference-v3/migrating-from-v2.md) maps every v2 path to its v3 successor. API v2 is retired and answers `410 Gone`.

***

## Base URL

```
https://api.anyformat.ai/v3/
```

All endpoint paths require a trailing slash. Requests without one receive a `307 Temporary Redirect`, which preserves the request method and body.

***

## Authentication

All endpoints require an API key, passed as a Bearer token:

```bash theme={null}
curl -H "Authorization: Bearer YOUR_API_KEY" https://api.anyformat.ai/v3/workflows/
```

See [Authentication](https://docs.anyformat.ai/api-reference-v3/authentication.md) to create and manage keys.

***

## Resource model

| Resource | What it is | Identifier |
| - | - | - |
| **Workflow** | The extraction template: a typed graph of nodes. The node types are parse, extract, classify, splitter, validate, if\_else, slack\_alert, edit, code, report\_generator and knowledge. See [Nodes](https://docs.anyformat.ai/guides/nodes/overview.md) and [Node schemas](https://docs.anyformat.ai/api-reference-v3/node-schemas.md). | `workflow_id` |
| **Document packet** | The unit a workflow runs on: one or more files treated as a single document. Uploading creates one. | `document_packet_id` |
| **Run** | One execution attempt of a workflow against a packet. One packet can have many runs. | `run_id` |

All identifiers are hyphenated UUIDs, such as `069dcc2c-e14c-7606-8000-2ee4fb17b4e1`. Path parameters are always snake\_case: `workflow_id`, `document_packet_id`, `run_id`.

The typical flow:

1. [Create a workflow](https://docs.anyformat.ai/api-reference-v3/workflows/create.md) (or build it visually in the [dashboard](https://app.anyformat.ai)).
2. [Upload and run](https://docs.anyformat.ai/api-reference-v3/workflows/upload-and-run.md) a document in one call. The response carries a `run_id`.
3. [Get the run](https://docs.anyformat.ai/api-reference-v3/runs/get.md) until `status` is `processed`; the results envelope is inline on the same response.

***

## Pagination

Every list endpoint is **keyset-paginated** and returns the same page shape:

```json theme={null}
{
  "items": [ ... ],
  "next_cursor": "eyJjcmVhdGVkX2F0Ijoi..."
}
```

* `?limit=` sets the page size. The default is `20` and the maximum is `100`. A larger value returns `400`; the API does not clamp it.
* `?cursor=` takes the opaque `next_cursor` token from the previous page.
* Iterate by following `next_cursor` until it is `null`.
* Sort order is fixed at newest-first (`-created_at, -id`).

v3 returns **no totals, counts, or page numbers**. A count over a growing collection is stale the moment it is computed. List endpoints also reject an unknown query parameter with `400` rather than ignoring it, so a typo like `?pagesize=` fails loudly.

***

## Idempotency

The POSTs that create packets, trigger runs or launch evals accept an optional `Idempotency-Key` header. The value is any unique string you choose, such as a UUID.

* [`POST /v3/workflows/{workflow_id}/upload/`](https://docs.anyformat.ai/api-reference-v3/workflows/upload)
* [`POST /v3/workflows/{workflow_id}/upload/run/`](https://docs.anyformat.ai/api-reference-v3/workflows/upload-and-run)
* [`POST /v3/workflows/{workflow_id}/dataset/upload/`](https://docs.anyformat.ai/api-reference-v3/datasets/upload)
* [`POST /v3/document-packets/{document_packet_id}/run/`](https://docs.anyformat.ai/api-reference-v3/document-packets/run)
* [`POST /v3/workflows/{workflow_id}/evals/`](https://docs.anyformat.ai/api-reference-v3/evals/launch)
* [`POST /v3/parse/`](https://docs.anyformat.ai/api-reference-v3/parse/parse)

Retrying a request with the same key **replays the original response**. The API creates no duplicate packet, and triggers and bills no second extraction or eval. Use it to make network-timeout retries safe. A replayed response carries the header `Idempotent-Replayed: true`; a first response does not.

### How long a key lasts, and what it covers

* **Lifetime.** The API remembers a key for 24 hours after its first request, and forgets it within the hour after that. A key sent again once it is forgotten starts a new request.
* **Scope.** A key belongs to the user behind your API key and to the resource the request addresses, such as the workflow you upload to or the packet you run. It is not shared across your organization: the same key sent by another user, or to another workflow, is an unrelated request.

### What counts as the same request

The same method on the same resource, with byte-identical content as the API forwards it:

* **Uploads:** the same files, in the same order, with the same names, bytes and content types, and the same `metadata` or `ground_truth`.
* **Evals:** the same `version_id`, the same `dataset_tag_ids` in the same order, and the same `untagged`.
* **Runs:** a run on the same packet. A run has no body to differ, so a retry always replays it.

Order matters: `dataset_tag_ids: ["a", "b"]` and `["b", "a"]` are different requests. An omitted field is not the same as the field sent with an empty value: `metadata` left out differs from `metadata: {}`. An eval that omits `version_id` targets the version that is current when it arrives, so a retry after a new version is published is a different request. Pass `version_id` for a replay that survives a publish.

### A reused key

Reusing a key with a **different** request returns `422` `IDEMPOTENCY_KEY_REUSED`. When the first request created one resource, `params` names it:

| `params` key | Value |
| - | - |
| `resource_type` | `document_packet` for an upload, including upload-and-run and parse; `eval` for an eval launch. |
| `resource_id` | The id that the first request's response gave, such as its `document_packet_id` or `eval_id`. |

An upload whose files' names, sizes or types changed is refused before any packet is named, so its error carries no `params`.

Never reuse a key for an upload with different files. The API may already have received the new files when it refuses the request.

To recover, resend the original request unchanged to get its result, or read the resource that `params.resource_id` names. Use a new key only for a genuinely new request: a new key on a retried eval or run launches, and bills, a second one.

```bash theme={null}
curl -X POST 'https://api.anyformat.ai/v3/document-packets/069dcc2c-e14c-7606-8000-2ee4fb17b4e1/run/' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Idempotency-Key: 5f2b6c3e-8a1d-4f7e-9c0b-1a2b3c4d5e6f'
```

***

## Rate limits

Submission endpoints have a stricter limit, and so does downloading a split, which renders a document on every request. Everything else shares a higher general limit. Each tier counts separately.

| Tier | v3 endpoints | Limit |
| - | - | - |
| **Submission** | Every endpoint that starts work or asks a question: `POST /v3/workflows/{id}/upload/`, `POST /v3/workflows/{id}/upload/run/`, `POST /v3/workflows/{id}/upload/from-url/`, `POST /v3/workflows/{id}/dataset/upload/`, `POST /v3/workflows/{id}/evals/`, `POST /v3/workflows/{id}/knowledge/ask`, `POST /v3/document-packets/{id}/run/`, `POST /v3/parse/`, `POST /v3/parse/from-url/` | 60 requests/min |
| **Download** | `GET /v3/splits/{split_id}/pdf/` | 60 requests/min |
| **General** | Reading and editing: workflows, runs, document packets, versions, evals results | 600 requests/min |

Exceeding a limit returns `429 Too Many Requests`; wait for the number of seconds in the `Retry-After` header. Every response carries `x-ratelimit-limit`, `x-ratelimit-remaining`, and `x-ratelimit-reset` for the tier that applies.

***

## Response headers

Every `/v3/` response is stamped with the API version:

```http theme={null}
X-API-Version: 3.0.0
```

Every `/v3/` and `/mcp` response also carries a request id, a success as well as an error:

```http theme={null}
X-Request-ID: a1b2c3d4e5f67890abcdef1234567890
```

On an error it equals the body's `request_id`. Quote it when you contact support.

v3 responses carry **no** `Deprecation` or `Sunset` headers. A version on the retirement path would add them, per [RFC 8594](https://datatracker.ietf.org/doc/html/rfc8594), so alerting on `Sunset` catches a future retirement early.

***

## Compression

Send `Accept-Encoding: gzip` and JSON responses over 1 KB come back gzip-compressed, with `Content-Encoding: gzip`. A run's results compress about 4x, so a large run downloads faster. Without the header, you get the same response uncompressed.

The [SDKs](https://docs.anyformat.ai/api-reference-v3/sdks.md), the [CLI](https://docs.anyformat.ai/api-reference-v3/cli.md), Python `requests` and `httpx`, and JavaScript `fetch` send the header and decompress for you. Some clients need it set by hand:

```bash curl theme={null}
curl --compressed https://api.anyformat.ai/v3/runs/$RUN_ID/ \
  -H "Authorization: Bearer $ANYFORMAT_API_KEY"
```

```python Python urllib theme={null}
import gzip, json, urllib.request

request = urllib.request.Request(
    f"https://api.anyformat.ai/v3/runs/{run_id}/",
    headers={"Authorization": f"Bearer {api_key}", "Accept-Encoding": "gzip"},
)
with urllib.request.urlopen(request) as response:
    body = response.read()
    if response.headers.get("Content-Encoding") == "gzip":
        body = gzip.decompress(body)
run = json.loads(body)
```

```java Java HttpClient theme={null}
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.anyformat.ai/v3/runs/" + runId + "/"))
    .header("Authorization", "Bearer " + apiKey)
    .header("Accept-Encoding", "gzip")
    .build();
HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
boolean gzipped = response.headers().firstValue("Content-Encoding").orElse("").equals("gzip");
try (InputStream body = gzipped ? new GZIPInputStream(response.body()) : response.body()) {
    String json = new String(body.readAllBytes(), StandardCharsets.UTF_8);
}
```

***

## Errors

Error responses use the same structured envelope as v2:

```json theme={null}
{
  "error": "Brief, human-readable error description",
  "detail": "Detailed explanation of what went wrong",
  "error_code": "MACHINE_READABLE_ERROR_CODE",
  "retryable": false,
  "request_id": "a1b2c3d4e5f67890abcdef1234567890"
}
```

`retryable: true` means the same request may succeed on retry, with backoff. `retryable: false` means you must change the request first. See [Errors](https://docs.anyformat.ai/api-reference-v3/errors.md) for the complete code reference. Two codes are worth knowing up front:

* `402 PAYMENT_REQUIRED`: the organization is out of extraction credit, so the API rejected the run trigger.
* `400 TOPOLOGY_INVALID`: a workflow create or update body failed graph validation. `detail.violations` lists each broken rule with the offending node ids.

> [!NOTE]
>
> v3 never returns `412 Precondition Failed`. Where v2 used 412 to signal "results not ready yet", v3 returns `200` with the run's `status` field. See [Get run](https://docs.anyformat.ai/api-reference-v3/runs/get.md).

***

## Endpoints at a glance

### Workflows

| Method | Endpoint | Description |
| - | - | - |
| POST | `/v3/workflows/` | [Create a workflow](https://docs.anyformat.ai/api-reference-v3/workflows/create.md) |
| GET | `/v3/workflows/` | [List workflows](https://docs.anyformat.ai/api-reference-v3/workflows/list.md) |
| GET | `/v3/workflows/{workflow_id}/` | [Get a workflow](https://docs.anyformat.ai/api-reference-v3/workflows/get.md), with the full typed graph inline |
| GET | `/v3/workflows/{workflow_id}/versions/` | [List a workflow's versions](https://docs.anyformat.ai/api-reference-v3/workflows/versions.md). Read-only, for comparison and audit |
| PATCH | `/v3/workflows/{workflow_id}/` | [Update a workflow](https://docs.anyformat.ai/api-reference-v3/workflows/update.md) |
| DELETE | `/v3/workflows/{workflow_id}/` | [Delete a workflow](https://docs.anyformat.ai/api-reference-v3/workflows/delete.md) |

### Upload

| Method | Endpoint | Description |
| - | - | - |
| POST | `/v3/workflows/{workflow_id}/upload/` | [Upload a document packet](https://docs.anyformat.ai/api-reference-v3/workflows/upload.md) (no processing) |
| POST | `/v3/workflows/{workflow_id}/upload/run/` | [Upload and run](https://docs.anyformat.ai/api-reference-v3/workflows/upload-and-run.md) in one call |
| POST | `/v3/workflows/{workflow_id}/upload/from-url/` | [Create a packet from URLs](https://docs.anyformat.ai/api-reference-v3/workflows/upload-from-url.md) |

### Document packets

| Method | Endpoint | Description |
| - | - | - |
| GET | `/v3/workflows/{workflow_id}/document-packets/` | [List a workflow's packets](https://docs.anyformat.ai/api-reference-v3/document-packets/list.md) |
| GET | `/v3/document-packets/{document_packet_id}/` | [Get a packet](https://docs.anyformat.ai/api-reference-v3/document-packets/get.md), with its files and `latest_run_id` |
| POST | `/v3/document-packets/{document_packet_id}/run/` | [Run a packet](https://docs.anyformat.ai/api-reference-v3/document-packets/run.md). Returns a new `run_id` |
| DELETE | `/v3/document-packets/{document_packet_id}/` | [Delete a packet](https://docs.anyformat.ai/api-reference-v3/document-packets/delete.md) |

### Runs

| Method | Endpoint | Description |
| - | - | - |
| GET | `/v3/workflows/{workflow_id}/runs/` | [List a workflow's runs](https://docs.anyformat.ai/api-reference-v3/runs/list.md) |
| GET | `/v3/runs/{run_id}/` | [Get a run](https://docs.anyformat.ai/api-reference-v3/runs/get.md), with status and results inline |

***

## OpenAPI schema

The full OpenAPI specification is available at:

* **JSON**: [https://api.anyformat.ai/schema/?format=json](https://api.anyformat.ai/schema/?format=json)
* **Swagger UI**: [https://api.anyformat.ai/docs/](https://api.anyformat.ai/docs/)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.