API Documentation

Integrate CorpusFabric into your applications with our REST API.

Authentication

All API requests require an API key passed in the X-API-Key header.

curl -H "X-API-Key: cf_your_api_key" \
https://corpusfabric.com/api/workspaces/YOUR_ID/documents

Generate API keys from Settings → API Keys in your dashboard.

Endpoints

POST
/api/workspaces/{id}/query

RAG query with streaming response

API Key
GET
/api/workspaces/{id}/documents

List documents

API Key
POST
/api/workspaces/{id}/documents/upload-url

Get presigned upload URL

API Key
POST
/api/workspaces/{id}/documents/{docId}/trigger-index

Trigger document indexing

API Key
DELETE
/api/workspaces/{id}/documents/{docId}

Delete a document

API Key
GET
/api/workspaces/{id}/folders

List folders

API Key
POST
/api/workspaces/{id}/folders

Create a folder

API Key
POST
/api/workspaces/{id}/crawl

Start a web crawl

API Key
GET
/api/workspaces/{id}/analytics/summary

Get analytics summary

API Key
GET
/api/widget/{id}/query

Public widget query (no auth)

None

Streaming Responses

The query endpoint returns Server-Sent Events (SSE). Each event is a JSON object with a type field:

data: {"type": "token", "content": "The answer..."}

data: {"type": "citations", "citations": [...]}

data: {"type": "follow_ups", "questions": [...]}

data: {"type": "done"}

Webhooks

Configure webhooks in Settings → Webhooks to receive real-time notifications.

doc.indexed — Document finished indexing
crawl.complete — Web crawl finished
query.received — New query received

Requests include an X-Webhook-Signature header (HMAC-SHA256) for verification.