> ## 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.

# Parse a Document

> Parse one document with the platform's fast lite parse

*Rate limit tier: **submission**, 60 requests/min. See [Rate limits](/api-reference-v3/introduction#rate-limits).*

The platform's fast lite parse handles **one document** per call. It is a one-call shortcut over the [workflow upload](/api-reference-v3/workflows/upload) and [run](/api-reference-v3/document-packets/run) primitives. It runs on your organization's system parse workflow, which the platform provisions on first use.

Send the file as multipart form data under the `file` field. The response references a [run](/concepts/runs-and-results). Poll [`GET /v3/runs/{run_id}/`](/api-reference-v3/runs/get) until `status` is `processed`. The parsed markdown sits at `results.parse.markdown`.

The results envelope carries the **first** file's parse output. For a multi-file extraction workflow, use [workflow upload](/api-reference-v3/workflows/upload) and [document-packets/run](/api-reference-v3/document-packets/run) directly.

<RequestExample>
  ```bash curl theme={null}
  curl -X POST 'https://api.anyformat.ai/v3/parse/' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -F 'file=@/path/to/invoice.pdf'
  ```

  ```python Python (requests) theme={null}
  import requests

  url = "https://api.anyformat.ai/v3/parse/"
  headers = {"Authorization": "Bearer YOUR_API_KEY"}

  with open("invoice.pdf", "rb") as f:
      triggered = requests.post(url, headers=headers, files={"file": f}).json()

  print(triggered["run_id"])
  ```

  ```typescript TypeScript theme={null}
  interface RunTriggered {
    run_id: string;
    document_packet_id: string;
    workflow_id: string;
    status: 'queued' | 'in_progress' | 'processed' | 'error' | 'cancelled';
  }

  const formData = new FormData();
  formData.append('file', fileInput.files[0]);

  const response = await fetch('https://api.anyformat.ai/v3/parse/', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
    body: formData,
  });

  if (!response.ok) {
    throw new Error(`API error: ${response.status}`);
  }

  const triggered: RunTriggered = await response.json();
  console.log(triggered.run_id);
  ```
</RequestExample>

<ResponseExample>
  ```json Response (202 Accepted) theme={null}
  {
    "run_id": "069dcc2c-e14c-7606-8000-2ee4fb17b4fa",
    "document_packet_id": "069dcc2c-e14c-7606-8000-2ee4fb17b4e1",
    "workflow_id": "0686bb97-8c30-70f0-8000-97669e000eb8",
    "status": "queued"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v3/parse/
openapi: 3.1.0
info:
  title: anyformat API
  description: >
    Document extraction and workflow automation API.


    AnyFormat lets you define extraction workflows that pull structured data
    from any document — PDFs, images, scanned files, or plain text. Upload a
    file, run it through a workflow, and get back structured fields with
    confidence scores and source evidence.


    ## Quick start


    See the [Quick start
    guide](https://docs.anyformat.ai/api-reference/introduction) for a
    walkthrough.


    ## Authentication


    All endpoints (except `/health/`) require a Bearer token in the
    `Authorization` header:


    ```

    Authorization: Bearer <your-api-key>

    ```


    Get your API key from
    [app.anyformat.ai/api-key](https://app.anyformat.ai/api-key).


    ## Versioning


    Endpoints are versioned by path prefix (`/v2/`, `/v3/`). Every response
    under

    a versioned prefix includes `X-API-Version`.
  version: 2.0.0
servers:
  - url: https://api.anyformat.ai
    description: API server
security: []
tags:
  - name: workflows
    description: >-
      Workflows define extraction templates — what fields to extract from
      documents. Create workflows, upload files, run extractions, and fetch
      results.
  - name: files
    description: >-
      File collections group uploaded documents and track their extraction
      progress. Upload files, check status, and retrieve extraction results.
  - name: suggestions
    description: >-
      AI-powered schema and workflow suggestion endpoints for the AnyFormat
      webapp. Authenticated with a Cognito JWT rather than an API key.
  - name: document-packets
    description: >-
      Document packets group uploaded documents for a workflow (v3). Address a
      packet directly to (re-)run its workflow.
  - name: runs
    description: >-
      Extraction runs — the v3 first-class result entity. Each run is a single
      execution of a workflow against a document packet; fetch its status and
      results flat by run id.
  - name: parse
    description: >-
      Parse a single document with the platform's fast lite parse — a one-call
      shortcut over the workflow upload + run primitives, backed by your
      organization's system parse workflow.
  - name: health
    description: Health check endpoints to verify API availability.
paths:
  /v3/parse/:
    post:
      tags:
        - parse
      summary: Parse a document
      description: |-
        Parse one document with the platform's fast lite parse (atomic).

        One file per call. The upload runs against your organization's system
        parse workflow, provisioned automatically on first use. Poll
        `GET /v3/runs/{run_id}/` until `status` is `processed`; the markdown is
        at `results.parse.markdown`.

        Honors `Idempotency-Key`: a retried request with the same key replays
        the original packet and run.
      operationId: v3_parse
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Optional caller-supplied key (Stripe convention). Retrying the
              request with the same key replays the original packet AND run — no
              duplicate upload, no second extraction.
            title: Idempotency-Key
          description: >-
            Optional caller-supplied key (Stripe convention). Retrying the
            request with the same key replays the original packet AND run — no
            duplicate upload, no second extraction.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_v3_parse'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunTriggeredV3'
          headers:
            X-RateLimit-Limit:
              description: Requests allowed per window (60s).
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
        '400':
          description: |-
            `VALIDATION_ERROR` — The request failed validation.
            `UNSUPPORTED_FILE_TYPE` — The file type is not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                VALIDATION_ERROR:
                  value:
                    error: The request failed validation.
                    detail: The request failed validation.
                    error_code: VALIDATION_ERROR
                    retryable: false
                    request_id: req_abc123
                UNSUPPORTED_FILE_TYPE:
                  value:
                    error: The file type is not supported.
                    detail: The file type is not supported.
                    error_code: UNSUPPORTED_FILE_TYPE
                    retryable: false
                    request_id: req_abc123
        '401':
          description: Authentication failed — missing, invalid, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                AUTH_FAILED:
                  value:
                    error: Authentication failed.
                    detail: Authentication failed.
                    error_code: AUTH_FAILED
                    retryable: false
                    request_id: req_abc123
        '402':
          description: >-
            `INSUFFICIENT_CREDIT` — The organization has no extraction credit
            left.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                INSUFFICIENT_CREDIT:
                  value:
                    error: The organization has no extraction credit left.
                    detail: The organization has no extraction credit left.
                    error_code: INSUFFICIENT_CREDIT
                    retryable: false
                    request_id: req_abc123
        '403':
          description: >-
            Access denied — the API key lacks access to this resource or the
            scope this call needs (`ACCESS_DENIED`,
            `INSUFFICIENT_API_KEY_SCOPE`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                ACCESS_DENIED:
                  value:
                    error: You do not have access to this resource.
                    detail: You do not have access to this resource.
                    error_code: ACCESS_DENIED
                    retryable: false
                    request_id: req_abc123
        '429':
          description: >-
            Rate limited — retry after the `Retry-After` header. Default
            windows: 60 requests/minute for extraction submission, 600
            requests/minute for general endpoints.
          headers:
            Retry-After:
              description: Seconds until the next request is allowed.
              schema:
                type: integer
            X-RateLimit-Limit:
              description: Requests allowed per window (60s).
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                RATE_LIMITED:
                  value:
                    error: Rate limit exceeded — retry after backoff.
                    detail: Rate limit exceeded — retry after backoff.
                    error_code: RATE_LIMITED
                    retryable: true
                    request_id: req_abc123
        '500':
          description: >-
            An internal error stopped the request — `retryable=true`. Retry with
            backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                INTERNAL_ERROR:
                  value:
                    error: An internal error stopped the request.
                    detail: An internal error stopped the request.
                    error_code: INTERNAL_ERROR
                    retryable: true
                    request_id: req_abc123
        '502':
          description: >-
            `OBJECT_STORAGE_UNAVAILABLE` — Object storage did not complete the
            request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                OBJECT_STORAGE_UNAVAILABLE:
                  value:
                    error: Object storage did not complete the request.
                    detail: Object storage did not complete the request.
                    error_code: OBJECT_STORAGE_UNAVAILABLE
                    retryable: true
                    request_id: req_abc123
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Body_v3_parse:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
          description: The document to parse.
      type: object
      required:
        - file
      title: Body_v3_parse
    RunTriggeredV3:
      properties:
        run_id:
          type: string
          title: Run Id
          description: Unique identifier of the new run (hyphenated UUID).
          examples:
            - 069dcc2c-e14c-7606-8000-2ee4fb17b4f9
        document_packet_id:
          type: string
          title: Document Packet Id
          description: The document packet the run executes on (hyphenated UUID).
          examples:
            - 069dcc2c-e14c-7606-8000-2ee4fb17b4e1
        workflow_id:
          type: string
          title: Workflow Id
          description: The workflow being run (hyphenated UUID).
          examples:
            - 0686bb97-8c30-70f0-8000-97669e000eb8
        status:
          $ref: '#/components/schemas/RunStatus'
          description: Status at acceptance time — normally `queued`.
          examples:
            - queued
      type: object
      required:
        - run_id
        - document_packet_id
        - workflow_id
        - status
      title: RunTriggeredV3
      description: |-
        202 response for both run triggers (`upload/run/` and
        `document-packets/{id}/run/`).
    ErrorEnvelope:
      type: object
      title: ErrorEnvelope
      description: >-
        Uniform error response. `retryable=true` means the same request may
        succeed on retry (with backoff); `retryable=false` means the caller must
        change the request before retrying.
      required:
        - error
        - error_code
        - retryable
        - request_id
      properties:
        error:
          type: string
          description: Short human-readable summary.
        detail:
          description: >-
            Machine-readable detail, any JSON value. A string for most errors, a
            list of field errors for validation failures, and an object for a
            structured error such as `FILENAME_CONFLICT` (`detail.conflicts`).
        error_code:
          type: string
          description: Stable identifier for programmatic handling.
          examples:
            - VALIDATION_ERROR
            - AUTH_FAILED
            - NOT_FOUND
            - PRECONDITION_FAILED
            - RATE_LIMITED
            - INTERNAL_ERROR
            - GATEWAY_TIMEOUT
        retryable:
          type: boolean
          description: True when the caller should retry (with backoff for 429/412/5xx).
        request_id:
          type: string
          description: Correlates this response with server logs.
    RunStatus:
      type: string
      enum:
        - queued
        - in_progress
        - processed
        - error
        - cancelled
      title: RunStatus
      description: |-
        Execution lifecycle of a run. Non-terminal: ``queued``,
        ``in_progress``. Terminal: ``processed`` (success), ``error``,
        ``cancelled``.
  securitySchemes:
    ApiKeyAuth:
      type: http
      description: >-
        API key issued from app.anyformat.ai/api-key. Send as `Authorization:
        Bearer <key>`.
      scheme: bearer

````