Authentication
Send a token as Authorization: Bearer <token>. Read API conventions.
Endpoints
| Method | Path | Purpose | Role |
|---|---|---|---|
| POST | /api/v1/docs/process | Upload a document, read its text, find key values and split it into passages | Any |
| POST | /api/v1/docs/batch | Process more than one document | Any |
| POST | /api/v1/docs/upload | Upload a document | Any |
| POST | /api/v1/docs/ocr | Read the text of a document | Any |
| POST | /api/v1/docs/classify | Classify a document | Any |
| POST | /api/v1/docs/extract | Extract fields from a document | Any |
| POST | /api/v1/docs/validate | Check extracted fields | Any |
| GET | /api/v1/docs/documents | List documents | Any |
| GET | /api/v1/docs/documents/search | Search documents | Any |
| GET | /api/v1/docs/documents/{document_id} | Get a document and its results | Any |
| GET | /api/v1/docs/documents/{document_id}/text | Get the text of a document | Any |
| DELETE | /api/v1/docs/documents/{document_id} | Delete a document | Any |
| POST | /api/v1/docs/documents/{document_id}/export-to-chat | Send the text to a Chat knowledge base | admin |
| POST | /api/v1/docs/process-and-ingest | Process a document and send it to Chat in one step | admin |
| GET | /api/v1/docs/stats | Processing statistics | Any |
| GET | /api/v1/docs/health | Health check | None |
Process a document
curl https://docs.example.gov/api/v1/docs/process \
-H "Authorization: Bearer $TOKEN" \
-F "file=@trade-licence.pdf"
The response has the document identifier, the text, the language, a confidence value, the values found and the passages. Values found include dates, Hijri dates, document numbers, reference numbers, national IDs, phone numbers, email addresses and amounts.
Errors
| Status | Cause |
|---|---|
| 400 | No file name, or a file type that is not supported |
| 400 | Run the earlier step first |
| 403 | Your role cannot send documents to Chat |
| 404 | The document does not exist |
| 413 | The file is larger than 50 MB |
| 503 | The connection to Chat is not set up |