Production API

Document Processing API

Upload documents, receive structured business data asynchronously, and recover results by document ID.

What the service provides

Secure document intake and validation
Asynchronous processing and status tracking
Structured line-item extraction
Per-upload callback URLs
Caller metadata returned with results
Result recovery when a callback is missed
Tenant-scoped API keys and permissions
A stable integration contract independent of the underlying processing engine

Authentication

Keep API keys in server-side secrets and send them as Bearer tokens.

Authorization: Bearer ds_live_your_secret_key
Never expose a key in browser code, source control, email, screenshots, support tickets, or application logs.

Upload a document

POST https://datascribe.app/api/client/upload

FieldRequiredDescription
fileYesPDF or supported image, up to 50 MB.
webhook_urlRecommendedPublic HTTP(S) callback URL for this upload. Query parameters are preserved.
metadataRecommendedA valid JSON string returned with processing events and results.
curl --fail-with-body -sS \
  -X POST 'https://datascribe.app/api/client/upload' \
  -H "Authorization: Bearer ${DATASCRIBE_API_KEY}" \
  -F "file=@${PDF_FILE};type=application/pdf" \
  -F "webhook_url=${CALLBACK_URL}" \
  -F 'metadata={"v":1,"import_id":"YOUR-IMPORT-ID","flow":"standard","source":"pdf"}'

Immediate response

{
  "success": true,
  "documentId": "DOCUMENT-UUID",
  "status": "pending",
  "message": "Document uploaded successfully. Processing has been queued."
}

This acknowledges the upload. It is not the final extraction result. Store the documentId immediately.

Callback events

The exact callback URL supplied with the upload is used for all events, including its query parameters.

document.received

The document was accepted.

document.processing

Extraction is in progress.

document.completed

The final structured result is available.

document.failed

Processing ended with an error.

{
  "event": "document.completed",
  "documentId": "DOCUMENT-UUID",
  "status": "completed",
  "timestamp": "2026-08-27T12:00:10.000Z",
  "metadata": { "v": 1, "import_id": "YOUR-IMPORT-ID", "flow": "standard", "source": "pdf" },
  "result": {
    "extraction": {
      "items": [
        { "rank": 1, "sku": "ITEM-001", "description": "Product description", "quantity": 10, "unitPrice": 4.25 }
      ]
    },
    "processingTime": 8.4,
    "totalItems": 1
  }
}

Extraction is probabilistic. Values may be null or require human validation when source documents are incomplete or difficult to read.

Recover a result

GET https://datascribe.app/api/client/documents/{documentId}

Use this endpoint whenever a final callback is missing. Callback delivery alone must not be the only recovery mechanism.

curl --fail-with-body -sS \
  "https://datascribe.app/api/client/documents/${DATASCRIBE_DOCUMENT_ID}" \
  -H "Authorization: Bearer ${DATASCRIBE_API_KEY}"
pending
Queued
processing
In progress
completed
Result available
failed
Processing failed

Error handling

StatusMeaningRecommended action
400Invalid request or metadataCorrect the request.
401Invalid or expired keyVerify the server-side secret.
403Insufficient scopeVerify key permissions.
404Unknown document for this tenantVerify the documentId.
413File too largeReduce or split the file.
422Unsupported formatUse a supported file type.
429Rate limit reachedRetry with exponential backoff.
500Temporary service errorRetry with backoff, then contact support.

Need help with an integration?

Contact us for custom extraction fields, workflow review, and production onboarding.

Contact support