Maintenance

Bulk Delete Documents

Schedule an asynchronous job to delete multiple documents based on filter criteria. This is the recommended approach for bulk document deletion operations.

At least one filter parameter must be provided to identify which documents should be deleted. You can use document_id_prefix, created_after, created_before, and keep_documents parameters to control which documents are deleted.

The keep_documents parameter allows you to specify document IDs that should be excluded from deletion, even if they match the other filter criteria.

Upon successful job creation, the endpoint returns a jobId that can be used to track the deletion progress using the /api/async/jobs/{jobId} endpoint.

⚠️ Warning: Document deletion is permanent and cannot be undone. Ensure your filter criteria are correct before submitting the deletion job.

This endpoint is disabled by default. To enable it, set environment variable ENABLE_BULK_DOCUMENT_DELETION=true.

post/api/async/delete_documents

Request

  • Base URL: http://localhost:5000
  • URL: http://localhost:5000/api/async/delete_documents
  • Auth: one of:
    • API key in header Authorization
    • HTTP bearer

Request body

document_id_prefixstring

Only delete documents whose ID starts with this prefix

created_afterstring date-time

Only delete documents created after this ISO 8601 datetime

created_beforestring date-time

Only delete documents created before this ISO 8601 datetime

keep_documentsstring[]

Array of document IDs to exclude from deletion, even if they match other filter criteria

Example request

{
  "document_id_prefix": "temp_",
  "created_after": "2023-01-01T00:00:00Z",
  "created_before": "2023-12-31T23:59:59Z",
  "keep_documents": [
    "important_doc_1",
    "important_doc_2"
  ]
}

Response

Document deletion job was successfully scheduled

Example response

{
  "data": {
    "jobId": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.