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

# Upload File

> Upload a file to a workflow without triggering processing

Useful when you want to stage files now and process them in a separate batch later.

<RequestExample>
  ```bash curl theme={null}
  curl -X POST 'https://api.anyformat.ai/v2/workflows/550e8400-e29b-41d4-a716-446655440000/upload/' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -F 'file=@/path/to/document.pdf'
  ```

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

  workflow_id = "550e8400-e29b-41d4-a716-446655440000"
  url = f"https://api.anyformat.ai/v2/workflows/{workflow_id}/upload/"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  with open('document.pdf', 'rb') as f:
      response = requests.post(
          url,
          headers=headers,
          files={'file': f}
      )

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const workflowId = '550e8400-e29b-41d4-a716-446655440000';
  const formData = new FormData();
  formData.append('file', fileInput.files[0]);

  const response = await fetch(`https://api.anyformat.ai/v2/workflows/${workflowId}/upload/`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: formData
  });

  const data = await response.json();
  console.log(data);
  ```

  ```typescript TypeScript theme={null}
  interface UploadResponse {
    status: string;
    filename: string | null;
  }

  const workflowId = '550e8400-e29b-41d4-a716-446655440000';
  const formData = new FormData();
  formData.append('file', fileInput.files[0]);

  const response = await fetch(
    `https://api.anyformat.ai/v2/workflows/${workflowId}/upload/`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      },
      body: formData
    }
  );

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

  const data: UploadResponse = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json Response (201 Created) theme={null}
  {
    "status": "uploaded",
    "filename": "document.pdf"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v2/workflows/{workflow_id}/upload/
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


    1. **Create a workflow** in the [AnyFormat
    dashboard](https://app.anyformat.ai) and define the fields you want to
    extract.

    2. **Run the workflow** via `POST /v2/workflows/{workflow_id}/run/` with a
    file attached.

    3. **Fetch results** via `GET
    /v2/workflows/{workflow_id}/files/{collection_id}/results/` once processing
    completes.


    ## 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/settings](https://app.anyformat.ai/settings).


    ## Versioning


    All endpoints use the `/v2/` path prefix. All responses include
    `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: webhooks
    description: >-
      Webhook subscriptions for asynchronous event notifications. Get notified
      when extractions complete or fail.
  - name: health
    description: Health check endpoints to verify API availability.
paths:
  /v2/workflows/{workflow_id}/upload/:
    post:
      tags:
        - workflows
      summary: Upload file
      description: >-
        Upload a file to a workflow without running extraction.


        Use this when you want to stage files for later processing. For
        upload-and-extract

        in one step, use `POST /v2/workflows/{workflow_id}/run/` instead.
      operationId: v2_upload_file
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: string
            title: Workflow Id
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_v2_upload_file'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadFileResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Body_v2_upload_file:
      properties:
        file:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: File
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
      type: object
      title: Body_v2_upload_file
    UploadFileResponse:
      properties:
        status:
          type: string
          title: Status
          description: 'Upload result: `uploaded` on success.'
          examples:
            - uploaded
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
          description: Name of the uploaded file.
          examples:
            - invoice.pdf
      type: object
      required:
        - status
      title: UploadFileResponse
      description: >-
        Confirmation that a file was uploaded successfully without triggering
        extraction.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: http
      description: >-
        API key issued from app.anyformat.ai/settings. Send as `Authorization:
        Bearer <key>`.
      scheme: bearer

````