Skip to content

API Quickstart

This walkthrough creates a mailbox, uploads a document for extraction, waits for processing, and reads the extracted rows — all with curl. You need a client ID and secret first.

Terminal window
TOKEN=$(curl -s -X POST https://app.docstosheets.com/connect/token \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" \
| jq -r .access_token)

A mailbox defines the extraction columns (“config”) applied to every document it receives.

Terminal window
curl -s -X POST https://app.docstosheets.com/api/mailboxes \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"config": {
"fields": [
{ "key": "invoiceNumber", "type": "text", "required": true },
{ "key": "vendor", "type": "text", "required": false },
{ "key": "total", "type": "currency", "required": false }
],
"groups": []
}
}'

The response includes the mailbox id (used below) and its inbound email address.

Uploads are multipart/form-data; PDFs and common image formats are supported (10 MB request limit).

Terminal window
curl -s -X POST "https://app.docstosheets.com/api/mailboxes/$MAILBOX_ID/uploads" \
-H "Authorization: Bearer $TOKEN" \
-F "clientReferenceId=my-batch-42"

The response lists the created documents with their id and initial status.

Extraction runs asynchronously. Poll the document list until the status is extracted (or failed):

Terminal window
curl -s "https://app.docstosheets.com/api/documents?mailboxId=$MAILBOX_ID&page=1&pageSize=20" \
-H "Authorization: Bearer $TOKEN"

Processing typically takes a few seconds to a minute per document. Poll at a modest interval (for example every 5–10 seconds).

Rows are the flat, spreadsheet-shaped projection of the extracted data:

Terminal window
curl -s "https://app.docstosheets.com/api/mailboxes/$MAILBOX_ID/rows" \
-H "Authorization: Bearer $TOKEN"

To inspect or correct individual extractions, use the Extractions endpoints instead.

  • Browse the full API Reference for every endpoint, parameter, and response schema.
  • Documents can also arrive by email — each mailbox has an inbound address (see Email Mailboxes & Ingestion); the API then serves the extracted results regardless of how documents arrived.