Skip to content

Documents API

The Documents API provides endpoints for uploading files, managing document lifecycle, controlling the ingestion queue, and inspecting the resulting knowledge graph entries.

Document Management

MethodEndpointDescription
POST/api/v1/documents/uploadUpload one or more files for ingestion
GET/api/v1/documents/List all documents
GET/api/v1/documents/ingestion-statusIngestion status across all documents
GET/api/v1/documents/graphKnowledge graph entries for ingested documents
GET/api/v1/documents/{doc_id}/previewPreview a document (PDF, text, or structured)
GET/api/v1/documents/{doc_id}/downloadDownload the original file
PATCH/api/v1/documents/{doc_id}/statusUpdate document status
POST/api/v1/documents/{doc_id}/approveApprove a document for ingestion
POST/api/v1/documents/{doc_id}/ingestTrigger ingestion for a specific document
DELETE/api/v1/documents/{doc_id}Delete a document

Document Linking

MethodEndpointDescription
POST/api/v1/documents/{doc_id}/linkCreate a relationship link from this document
DELETE/api/v1/documents/{doc_id}/link/{rel_id}Remove a relationship link

Ingestion Queue

MethodEndpointDescription
POST/api/v1/documents/queue/enqueueAdd documents to the ingestion queue
POST/api/v1/documents/queue/pausePause the ingestion queue
POST/api/v1/documents/queue/resumeResume the ingestion queue
GET/api/v1/documents/queue/statusCurrent queue status and progress
GET/api/v1/documents/queue/streamSSE stream for real-time queue updates
DELETE/api/v1/documents/queue/{doc_id}Remove a document from the queue

Examples

Upload Documents

Upload one or more files using multipart/form-data.

Terminal window
curl -X POST https://yourorg.squadai.uk/api/v1/documents/upload \
-H "Authorization: Bearer $TOKEN" \
-F "files=@fault-schedule-2026.pdf" \
-F "files=@reactor-specs.docx"

Response 200

{
"success": true,
"files_uploaded": 2,
"files": [
{"key": "documents/fault-schedule-2026.pdf", "url": "https://storage.squadai.uk/documents/fault-schedule-2026.pdf"},
{"key": "documents/reactor-specs.docx", "url": "https://storage.squadai.uk/documents/reactor-specs.docx"}
]
}

List Documents

Terminal window
curl https://yourorg.squadai.uk/api/v1/documents/ \
-H "Authorization: Bearer $TOKEN"

Response 200

{
"documents": [
{
"id": "doc-001",
"filename": "fault-schedule-2026.pdf",
"status": "ingested",
"uploaded_at": "2026-03-17T09:00:00Z",
"size_bytes": 245760
},
{
"id": "doc-002",
"filename": "reactor-specs.docx",
"status": "pending",
"uploaded_at": "2026-03-17T09:00:01Z",
"size_bytes": 102400
}
]
}

Ingestion Status

Terminal window
curl https://yourorg.squadai.uk/api/v1/documents/ingestion-status \
-H "Authorization: Bearer $TOKEN"

Response 200

{
"total": 12,
"ingested": 8,
"pending": 2,
"failed": 1,
"in_progress": 1
}

Update Document Status

Terminal window
curl -X PATCH https://yourorg.squadai.uk/api/v1/documents/doc-001/status \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "approved"}'

Response 200

{
"id": "doc-001",
"status": "approved",
"updated_at": "2026-03-17T10:15:00Z"
}

Enqueue for Ingestion

Terminal window
curl -X POST https://yourorg.squadai.uk/api/v1/documents/queue/enqueue \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"document_ids": ["doc-001", "doc-002"]}'

Response 200

{
"queued": 2,
"document_ids": ["doc-001", "doc-002"]
}

Queue Status

Terminal window
curl https://yourorg.squadai.uk/api/v1/documents/queue/status \
-H "Authorization: Bearer $TOKEN"

Response 200

{
"status": "running",
"total": 4,
"completed": 2,
"in_progress": 1,
"pending": 1
}

Queue Stream (SSE)

Connect to the real-time ingestion progress stream.

Terminal window
curl -N https://yourorg.squadai.uk/api/v1/documents/queue/stream \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: text/event-stream"

Event stream

{"timestamp": "2026-03-17T10:20:00Z", "event": "ingestion_started", "data": {"doc_id": "doc-001", "filename": "fault-schedule-2026.pdf"}}
{"timestamp": "2026-03-17T10:20:15Z", "event": "ingestion_progress", "data": {"doc_id": "doc-001", "stage": "parsing", "progress": 0.45}}
{"timestamp": "2026-03-17T10:20:30Z", "event": "ingestion_completed", "data": {"doc_id": "doc-001", "nodes_created": 142}}