Search and export extracted document data across all cases

Documents


The documents endpoints provide cross-case search and bulk export of extraction results. They operate on documents that have already been processed through the pipeline within cases.


Endpoints

Search Documents

GET /v1/documents/search

Requires scope: read. Full-text and filtered search across extraction results from all cases.

Query parameters:

tenant_idstring

Filter to documents belonging to this tenant.

document_typestring

Filter by document type ID (e.g. "pan_card", "aadhaar").

statusstring

Filter by processing status: pending, processing, done, failed.

querystring

Text search within extracted field values.

limitnumber

Number of results to return. Default 50, max 200.

offsetnumber

Number of records to skip for pagination. Default 0.

Example request:

GET /v1/documents/search?tenant_id=acme-corp&document_type=pan_card&status=done&limit=20

Response (200): Array of Document Search Result objects.

doc_idstring
UUID of the document record.
session_idstring
UUID of the case this document belongs to.
session_goalstring
Agent goal of the parent case (e.g. "kyc_verification").
filenamestring
Original filename.
document_typestring
Classified document type ID.
confidencestring
Classification confidence score.
statusstring
Processing status.
extractedobject
All extracted field values for this document.
created_atstring
ISO 8601 timestamp.

Example response:

[
  {
    "doc_id": "a1b2c3d4-...",
    "session_id": "e5f6a7b8-...",
    "session_goal": "kyc_verification",
    "filename": "pan_front.jpg",
    "document_type": "pan_card",
    "confidence": "0.98",
    "status": "done",
    "extracted": {
      "name": "John Doe",
      "pan_number": "ABCDE1234F",
      "date_of_birth": "1990-01-15",
      "fathers_name": "James Doe"
    },
    "created_at": "2026-03-25T10:30:00Z"
  }
]

Export Documents as CSV

GET /v1/documents/export

Requires scope: read. Exports extraction results as a CSV file. The CSV columns are dynamically determined from the union of all extracted fields found across the returned documents.

Query parameters:

tenant_idstring

Filter to documents belonging to this tenant.

document_typestring

Filter by document type ID.

limitnumber

Maximum number of records to export. Default 1000, max 10000.

Only documents with status = "done" are included in the export.

Response (200):

Content-Type: text/csv Content-Disposition: attachment; filename="extraction_export.csv"

CSV structure:

The header row always starts with these fixed columns:

doc_id, session_id, document_type, filename, created_at

Followed by one column per unique extracted field name found across all returned documents. Fields missing from a given document are exported as empty strings.

Example:

doc_id,session_id,document_type,filename,created_at,name,pan_number,date_of_birth
a1b2c3d4,...,e5f6a7b8,...,pan_card,pan_front.jpg,2026-03-25T10:30:00Z,John Doe,ABCDE1234F,1990-01-15

Returns 404 if no matching documents are found.