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

# Delete File

> Permanently delete a file and its associated results

<Info>
  The `collection_id` in the URL is the `id` returned by `POST /v2/workflows/{id}/files/` or `POST /v2/workflows/{id}/run/`.
</Info>

<Warning>
  Deleting a file is permanent and cannot be undone. All associated results will also be deleted. If the file has in-progress processing, processing will be cancelled.
</Warning>

<RequestExample>
  ```bash curl theme={null}
  curl -X DELETE 'https://api.anyformat.ai/v2/files/b2c3d4e5-f6a7-8901-bcde-f12345678901/' \
    -H 'Authorization: Bearer YOUR_API_KEY'
  ```

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

  file_id = "b2c3d4e5-f6a7-8901-bcde-f12345678901"
  url = f"https://api.anyformat.ai/v2/files/{file_id}/"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.delete(url, headers=headers)
  print(f"Status: {response.status_code}")
  ```

  ```javascript JavaScript theme={null}
  const fileId = 'b2c3d4e5-f6a7-8901-bcde-f12345678901';
  const response = await fetch(`https://api.anyformat.ai/v2/files/${fileId}/`, {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  console.log(`Status: ${response.status}`);
  ```

  ```typescript TypeScript theme={null}
  const fileId = 'b2c3d4e5-f6a7-8901-bcde-f12345678901';
  const response = await fetch(
    `https://api.anyformat.ai/v2/files/${fileId}/`,
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  if (response.status !== 204) {
    const error = await response.json();
    throw new Error(`API error: ${error.error_code}`);
  }

  console.log('File deleted');
  ```
</RequestExample>

<ResponseExample>
  ```json Response (204 No Content) theme={null}
  // No response body - file successfully deleted
  ```
</ResponseExample>


## OpenAPI

````yaml DELETE /v2/files/{collection_id}/
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/files/{collection_id}/:
    delete:
      tags:
        - files
      summary: Delete file collection
      description: >-
        Delete a file collection and all its files permanently.


        This removes all uploaded files and any extraction results associated
        with

        the collection. This action is irreversible.
      operationId: delete_file_v2_files__collection_id___delete
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            title: Collection Id
      responses:
        '204':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    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

````