> ## 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 without triggering processing

<Note>
  This endpoint uploads a file. It does **not** trigger processing. To upload and process in one step, use [Run Workflow](/api-reference/workflows/run) instead.
</Note>

## Request Body

This endpoint uses `multipart/form-data`:

| Field   | Type | Required | Description        |
| ------- | ---- | -------- | ------------------ |
| `files` | file | Yes      | The file to upload |

<RequestExample>
  ```bash curl theme={null}
  curl -X POST 'https://api.anyformat.ai/v2/workflows/550e8400-e29b-41d4-a716-446655440000/files/' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -F 'files=@invoice.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}/files/"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  with open("invoice.pdf", "rb") as f:
      files = [("files", ("invoice.pdf", f, "application/pdf"))]

      response = requests.post(url, headers=headers, files=files)
      print(response.json())
  ```

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

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

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

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

  interface UploadFileResponse {
    id: string;
    name: string | null;
    files: FileItem[];
    workflow_id: string;
  }

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

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

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

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

<ResponseExample>
  ```json Response (201 Created) theme={null}
  {
    "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "name": null,
    "files": [
      {
        "filename": "invoice.pdf",
        "status": "uploaded"
      }
    ],
    "workflow_id": "550e8400-e29b-41d4-a716-446655440000"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v2/workflows/{workflow_id}/files/
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}/files/:
    post:
      tags:
        - files
      summary: Create file collection
      description: >-
        Upload one or more files to a workflow, creating a new file collection.


        Use this when you want to upload files without immediately running
        extraction.

        To upload and extract in one step, use `POST
        /v2/workflows/{workflow_id}/run/` instead.


        Supported file types: PDF, PNG, JPG, TIFF, TXT, DOCX, XLSX, CSV, and
        more.
      operationId: v2_create_workflow_file
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: string
            title: Workflow Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_v2_create_workflow_file'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCollectionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Body_v2_create_workflow_file:
      properties:
        files:
          items:
            type: string
            contentMediaType: application/octet-stream
          type: array
          title: Files
      type: object
      required:
        - files
      title: Body_v2_create_workflow_file
    CreateCollectionResponse:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the newly created file collection.
          examples:
            - 069dcc2c-e14c-7606-8000-2ee4fb17b4e1
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Human-readable name for the collection.
        files:
          items:
            $ref: '#/components/schemas/FileItem'
          type: array
          title: Files
          description: List of files included in the collection, with their upload status.
        workflow_id:
          type: string
          title: Workflow Id
          description: The UUID of the workflow this collection belongs to.
          examples:
            - 0686bb97-8c30-70f0-8000-97669e000eb8
      type: object
      required:
        - id
        - files
        - workflow_id
      title: CreateCollectionResponse
      description: >-
        Response from creating a file collection. Contains the collection ID and
        the status of each uploaded file.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FileItem:
      properties:
        filename:
          type: string
          title: Filename
          description: Name of the uploaded file.
          examples:
            - invoice.pdf
        status:
          type: string
          title: Status
          description: 'Upload status: `uploaded` or `failed`.'
          examples:
            - uploaded
      type: object
      required:
        - filename
        - status
      title: FileItem
      description: A single file within a collection, showing its name and upload status.
    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

````