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

# Delete a file

> Removes the file. Its change history goes with it, so this is not reversible through this API. A protected file, or one with changes still in review, is refused and nothing is removed, so a caller that did not mean to discard that work can deal with it first.



## OpenAPI

````yaml api-reference/public-api.json DELETE /v1/files/{id}
openapi: 3.0.0
info:
  title: Qontext API
  description: Read and write the knowledge a workspace has ingested.
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.qontext.ai
    description: Production
security: []
tags:
  - name: Files
    description: >-
      Read and write the files in a workspace. What you read, and what an
      accepted change goes into, is the live files: the accepted state of the
      world. A change to a protected file goes to review instead of being
      accepted automatically, and stays in review until somebody accepts or
      rejects it.
  - name: Folders
    description: >-
      The tree the files sit in. A folder id survives a rename and a move, and
      so does every id below it, so ids a client holds stay valid while paths
      change.
  - name: Search
    description: >-
      Find files by meaning or by a regular expression. Both search the live
      files, both answer one page of the best matches, and both drop a file this
      key may not read.
paths:
  /v1/files/{id}:
    delete:
      tags:
        - Files
      summary: Delete a file
      description: >-
        Removes the file. Its change history goes with it, so this is not
        reversible through this API. A protected file, or one with changes still
        in review, is refused and nothing is removed, so a caller that did not
        mean to discard that work can deal with it first.
      operationId: FilesController_deleteFile
      parameters:
        - name: id
          required: true
          in: path
          description: >-
            The file id, as an earlier response reported it. Always `doc_…`; a
            composite id is refused.
          schema:
            example: doc_9f2k1x8b3m7q0v
            type: string
      responses:
        '204':
          description: Deleted. No body.
        '400':
          description: '`invalid_id`: not a file id of the form `doc_…`'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                invalid_id:
                  summary: Invalid id
                  value:
                    type: https://docs.qontext.ai/errors/invalid-id
                    title: Invalid id
                    status: 400
                    code: invalid_id
                    detail: >-
                      This id is not in a form this API issues. Use one from an
                      earlier response.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '401':
          description: '`unauthenticated`: missing or invalid API key'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                unauthenticated:
                  summary: Unauthenticated
                  value:
                    type: https://docs.qontext.ai/errors/unauthenticated
                    title: Unauthenticated
                    status: 401
                    code: unauthenticated
                    detail: The API key is missing or not valid.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '403':
          description: '`forbidden`: this key may not delete this file'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                forbidden:
                  summary: Not permitted
                  value:
                    type: https://docs.qontext.ai/errors/forbidden
                    title: Not permitted
                    status: 403
                    code: forbidden
                    detail: This key is not allowed to do that.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '404':
          description: '`file_not_found`: no such file deletable with this key'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                file_not_found:
                  summary: File not found
                  value:
                    type: https://docs.qontext.ai/errors/file-not-found
                    title: File not found
                    status: 404
                    code: file_not_found
                    detail: No file with that id, or none this key is allowed to read.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '409':
          description: >-
            `changes_in_review`: the file has changes in review; try again once
            those are accepted or rejected. `file_protected`: the file is
            protected; clear `protected` on it first
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                changes_in_review:
                  summary: Changes in review
                  value:
                    type: https://docs.qontext.ai/errors/changes-in-review
                    title: Changes in review
                    status: 409
                    code: changes_in_review
                    detail: >-
                      This folder contains files with changes in review. Try
                      again after those changes are accepted or rejected.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
                file_protected:
                  summary: File protected
                  value:
                    type: https://docs.qontext.ai/errors/file-protected
                    title: File protected
                    status: 409
                    code: file_protected
                    detail: >-
                      This file is protected. Clear `protected` on it first if
                      you mean to delete it.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '500':
          description: '`internal_error`: unexpected failure, already reported'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                internal_error:
                  summary: Internal error
                  value:
                    type: https://docs.qontext.ai/errors/internal-error
                    title: Internal error
                    status: 500
                    code: internal_error
                    detail: An unexpected error occurred.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
        '503':
          description: >-
            `service_unavailable`: temporarily unreachable. Honour
            `Retry-After`.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                service_unavailable:
                  summary: Temporarily unavailable
                  value:
                    type: https://docs.qontext.ai/errors/service-unavailable
                    title: Temporarily unavailable
                    status: 503
                    code: service_unavailable
                    detail: This workspace is temporarily unavailable.
                    requestId: 3f9c2b7e4d1a48c0b6e5f2a19d7c3e8b
      security:
        - Authorization: []
        - X-API-Key: []
components:
  schemas:
    Problem:
      type: object
      properties:
        type:
          type: string
          example: https://docs.qontext.ai/errors/file-not-found
          description: >-
            Stable URI for this kind of failure. Branch on this or on `code`,
            never on `title` or `detail`.
        title:
          type: string
          example: File not found
          description: Human label. Not for branching on.
        status:
          type: number
          example: 404
          description: Matches the HTTP status.
        code:
          type: string
          example: file_not_found
          description: Stable machine code. This is what a client branches on.
        detail:
          type: string
          description: >-
            Human explanation, safe to display. Never a stack trace or engine
            detail.
        requestId:
          type: string
          description: >-
            Echoes the `X-Request-Id` response header. One string locates the
            log line for this call.
        errors:
          description: Present when the failure is attributable to specific inputs.
          type: array
          items:
            $ref: '#/components/schemas/FieldError'
      required:
        - type
        - title
        - status
        - code
        - detail
        - requestId
    FieldError:
      type: object
      properties:
        code:
          type: string
          example: out_of_range
          description: Stable machine token for what was wrong with this field.
        pointer:
          type: string
          example: /limit
          description: JSON Pointer to the offending member.
        detail:
          type: string
          example: limit must not be greater than 1000
          description: >-
            Human explanation for this field alone. Branch on `code`, not on
            this.
      required:
        - code
        - pointer
        - detail
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: >-
        Workspace-scoped API key, sent as a bearer token. The recommended
        header. The workspace is implicit in the key and never appears in a URL.
    X-API-Key:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        The same workspace-scoped API key under its original header. Still
        supported, and still enough on its own. Prefer `Authorization: Bearer`
        for a new client.

````