API Reference

Integrate document extraction and review workflows into your applications.

Authentication

All API requests require an API key passed in the X-API-Key header. Generate keys from the API settings page in your dashboard.

curl https://api.casmoai.com/v1/extract \
  -H "X-API-Key: cai_your_api_key_here" \
  -F "file=@document.pdf" \
  -F "mode=response"

Base URL

https://api.casmoai.com

Response Modes

Both endpoints support two modes via the mode form field:

response (default)

Waits for processing to complete and returns the result in the HTTP response body. Webhooks are still fired if configured.

callback

Returns immediately with a job ID. The result is delivered asynchronously via your registered webhooks.

Endpoints

Webhooks

Configure webhooks in the API settings page to receive event notifications. Webhooks are fired whenever a matching event occurs, regardless of the request mode.

Available Events

EventDescription
extraction.completedFired when document extraction finishes (success or failure)
review.completedFired when a review against a workflow finishes

Webhook Payload

{
  "event": "extraction.completed",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "data": {
    "job_id": "temp_1_1234567890",
    "filename": "invoice.pdf",
    "result": { ... }
  }
}

Signature Verification

Each webhook request includes an X-Webhook-Signature header containing an HMAC-SHA256 hex digest of the request body, signed with your webhook secret.

import hmac
import hashlib

def verify_signature(body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode(), body, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)

Error Codes

StatusDescription
400Bad request — invalid file type, missing parameters, or invalid mode
401Unauthorized — missing or invalid API key
404Not found — workflow does not exist or does not belong to you
500Server error — document parsing or processing failed
504Timeout — document processing took too long