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

# Delete Document By External Id

> Delete document(s) by external ID with version control.

- **latest_only=true** (default): Deletes only the most recent version of the document
- **latest_only=false**: Deletes all versions of documents with this external_id

Returns the count and IDs of deleted documents.



## OpenAPI

````yaml delete /api/v1/documents/external/{external_id}
openapi: 3.1.0
info:
  title: Fieldwise API
  description: API for the Fieldwise platform.
  version: 1.0.0
servers:
  - url: https://api.fieldwise.ai
security:
  - ApiKeyAuth: []
paths:
  /api/v1/documents/external/{external_id}:
    delete:
      tags:
        - Documents
      summary: Delete Document By External Id
      description: >-
        Delete document(s) by external ID with version control.


        - **latest_only=true** (default): Deletes only the most recent version
        of the document

        - **latest_only=false**: Deletes all versions of documents with this
        external_id


        Returns the count and IDs of deleted documents.
      operationId: >-
        delete_document_by_external_id_api_v1_documents_external__external_id__delete
      parameters:
        - name: external_id
          in: path
          required: true
          schema:
            type: string
            title: External Id
        - name: latest_only
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              If True, delete only the latest version. If False, delete all
              versions with this external_id.
            default: true
            title: Latest Only
          description: >-
            If True, delete only the latest version. If False, delete all
            versions with this external_id.
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteResponse'
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
components:
  schemas:
    DeleteResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          allOf:
            - $ref: '#/components/schemas/DeleteResponseData'
          description: Response data
        error:
          anyOf:
            - $ref: '#/components/schemas/ErrorDetail'
            - type: 'null'
        meta:
          $ref: '#/components/schemas/MetaData'
      type: object
      required:
        - data
      title: DeleteResponse
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        error_code:
          type: string
          title: Error Code
          description: Error code identifier
        details:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          title: Details
          description: Additional error details
      type: object
      required:
        - message
        - error_code
      title: ErrorDetail
      description: Schema for API error responses.
      example:
        error_code: RESOURCE_NOT_FOUND
        message: Resource not found
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DeleteResponseData:
      properties:
        deleted_count:
          type: integer
          title: Deleted Count
          description: Number of documents deleted
        deleted_ids:
          items:
            type: integer
          type: array
          title: Deleted Ids
          description: List of deleted document IDs
      type: object
      required:
        - deleted_count
        - deleted_ids
      title: DeleteResponseData
      description: Response data for delete operations.
    MetaData:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
        version:
          type: string
          title: Version
          default: '1.0'
      type: object
      title: MetaData
      description: Metadata for API responses
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````