InterfacesAPI SpecSections
API Spec Designed
Base address: https://01scale.com/api/docflow/v1. Open an endpoint for its inputs, constraints, errors and samples.
POST/documentsStart a document
Starts the DocFlow process for one invoice: creates the document and its upload in the Upload service with DocFlow's limits. Signed in
Scope: docflow:write
Inputs
file_namebodystringrequired- The invoice's name.
- As Upload's.
mimebodystringrequired- Its type.
application/pdf,image/pngorimage/jpeg.sizebodyintegerrequired- Its size.
- 1 to 10 MB.
Idempotency-Keyheaderstringoptional- Makes a retry safe.
- 1 to 255 characters.
What it does
- Calls Upload
POST /fileswith the caller's token andaccept= PDF, PNG, JPEG, 10 MB, 10 pages. - Records the document as
pending_uploadwith the file's ID; returns Upload's upload link.
Responses
- 201Created.
documentandupload(Upload's link and headers). - 413
file_too_largePassed on from Upload. - 415
unsupported_file_typePassed on from Upload. - 422
validation_failedAn input is malformed. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
POST /api/docflow/v1/documents HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>
Content-Type: application/json
{
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size": 248913
}Sample response
{
"document": {
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "pending_upload",
"next_action": "upload",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": null,
"review_task_id": null,
"order_id": null,
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
},
"upload": {
"url": "https://01scale-uploads.s3.us-east-1.amazonaws.com/users/\u2026/original.pdf?X-Amz-Signature=\u2026",
"method": "PUT",
"headers": {
"Content-Type": "application/pdf",
"Content-Length": "248913"
},
"expires_at": "2026-11-17T09:19:07Z"
}
}POST/documents/{documentId}/upload-completeConfirm the upload and start extraction
Called by the upload component when the bytes are sent. Signed in
Scope: docflow:write
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
What it does
- Calls Upload
POST /files/{fileId}/complete. If the file is rejected, the document isrejectedwith Upload's reason. - If ready, calls Extraction
POST /jobswithreference: docflow:{documentId}and sets the documentextracting. It asks withhold: trueand a delegated token for the owner (act: service:docflow), so DocFlow holds the results until the order is paid (DOCFLOW-V1-E5-05). - Idempotent: a document already past this step is returned unchanged.
Responses
- 200The upload was checked.
documentwith statusextractingorrejected. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
upload_missingPassed on from Upload: the file has not arrived. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
POST /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/upload-complete HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"document": {
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "extracting",
"next_action": "extract",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": "0193b0d1-4b2c-7d10-9a8b-1c2d3e4f5a6b",
"review_task_id": null,
"order_id": null,
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
}
}GET/documentsList my documents
The caller's documents, newest first, with a status and the next action for each. Signed in
Scope: docflow:read
Inputs
statusquerystringoptional- Filter.
- A document status.
cursor, limitquerystring, integeroptional- Paging.
limit1 to 100.
What it does
- Read only.
next_actionisupload,extract,review,results,payordownload.
Responses
- 200Always.
data[]of documents andnext_cursor. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/documents HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"data": [
{
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "paid",
"next_action": "download",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": "0193b0d1-4b2c-7d10-9a8b-1c2d3e4f5a6b",
"review_task_id": "0193b0f2-3c4d-7e5f-8a6b-7c8d9e0f1a2b",
"order_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
}
],
"next_cursor": null
}GET/documents/{documentId}Get one document
A document, its status, and the IDs of its parts in each service. Signed in
Scope: docflow:read
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
What it does
- Read only.
Responses
- 200The document is the caller's.
document. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"document": {
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "paid",
"next_action": "download",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": "0193b0d1-4b2c-7d10-9a8b-1c2d3e4f5a6b",
"review_task_id": "0193b0f2-3c4d-7e5f-8a6b-7c8d9e0f1a2b",
"order_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
}
}POST/documents/{documentId}/retry-extractionRetry a failed extraction
Starts a new extraction job after the last one failed. Signed in
Scope: docflow:write
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
What it does
- Calls Extraction
POST /jobsfor the same file, again withhold: trueand a delegated token (DOCFLOW-V1-E5-05); stores the new job's ID; the document isextractingagain.
Responses
- 202A new job started.
document. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
not_failedThe last extraction did not fail. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
POST /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/retry-extraction HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"document": {
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "extracting",
"next_action": "extract",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": "0193b0d1-4b2c-7d10-9a8b-1c2d3e4f5a6b",
"review_task_id": null,
"order_id": null,
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
}
}POST/documents/{documentId}/complete-reviewFinish review
Re-checks the corrected values and completes the review. The results are built from Review's values whenever they are looked at; nothing is stored. Signed in
Scope: docflow:write
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
confirm_failed_checksbodybooleanoptional- The person confirmed values that still fail a check are as printed.
- Default false.
What it does
- Reads the review task, then calls Extraction
POST /validationswith its values and the job's ID. - If a check fails and
confirm_failed_checksis false, answers409with the failed checks; nothing changes. - Otherwise calls Review
POST /tasks/{taskId}/complete(withchecks_overridden) and sets the documentreviewed. - Safe to retry: completing an already completed task returns it unchanged, and a document already
reviewedorpaidis returned as it is.
Responses
- 200Review completed.
document(statusreviewed). - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
fields_unresolvedPassed on from Review. - 409
checks_failedfailed_checks[]lists them; sendconfirm_failed_checks: trueto keep the values. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
POST /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/complete-review HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>
Content-Type: application/json
{
"confirm_failed_checks": false
}Sample response
{
"document": {
"id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"status": "reviewed",
"next_action": "pay",
"file_id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"job_id": "0193b0d1-4b2c-7d10-9a8b-1c2d3e4f5a6b",
"review_task_id": "0193b0f2-3c4d-7e5f-8a6b-7c8d9e0f1a2b",
"order_id": null,
"created_at": "2026-11-17T09:14:07Z",
"updated_at": "2026-11-17T09:17:03Z"
}
}GET/documents/{documentId}/outputsResults status
Whether results can be shown, whether download is unlocked, and whether the current values pass every check. Signed in
Scope: docflow:read
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
What it does
- Read only.
lockedis true until the order is paid.checkscomes from ExtractionPOST /validationson Review's current values, so a later correction that breaks a rule is shown at once. last_changed_atis the latest correction in Review, after the review or after payment.
Responses
- 200The review is complete.
locked,formats,checks(passed,failed[]) andlast_changed_at. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
outputs_not_readyThe review is not complete. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/outputs HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"locked": false,
"formats": [
"json",
"csv"
],
"checks": {
"passed": true,
"failed": []
},
"last_changed_at": "2026-11-17T09:21:40Z"
}GET/documents/{documentId}/outputs/{format}/previewPreview the JSON or CSV
The results, shown on screen: a short preview before paying, the full results after. Signed in
Scope: docflow:read
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
formatpathstringrequired- Which output.
jsonorcsv.
What it does
- Builds it on demand: reads the final values from Review
GET /tasks/{taskId}?all=trueand the model, prompt version and page count from ExtractionGET /jobs/{jobId}, re-runs ExtractionPOST /validations(withjob_id) on the current values, then builds the format and validates the JSON againstschemas/invoice-v1.json. Nothing is stored (ARCHITECTURE.md §12.8), so it always reflects the latest corrections. - Until the order is paid, the preview holds four fields only (
vendor_name,invoice_number,invoice_date,total), and says how many fields and line items are held back; the CSV has those four columns. The limit is applied on the server, so the full results cannot be read before payment (Nikhil's decision, 22 Nov 2026, changingDOCFLOW-V1-E5-03AC1).
Responses
- 200The review is complete.
application/jsonortext/csvwithContent-Disposition: inline. Before payment the JSON addspreview: {limited: true, fields_hidden, line_items_hidden}and the CSV hasX-Preview-Limited: true. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
outputs_not_readyThe review is not complete. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/outputs/json/preview HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"data": {
"vendor_name": "Acme Supplies Ltd",
"invoice_number": "INV-0042",
"invoice_date": "2026-11-02",
"currency": "USD",
"subtotal": "1150.00",
"tax_total": "80.00",
"total": "1230.00",
"line_items": [
{
"description": "Paper, A4",
"quantity": "10",
"unit_price": "115.00",
"amount": "1150.00"
}
]
},
"metadata": {
"document_id": "0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"file_name": "acme-invoice-0042.pdf",
"pages": 2,
"model": "claude-opus-5-5",
"prompt_version": "extract-invoice/v1",
"extracted_at": "2026-11-17T09:14:41Z",
"reviewed_at": "2026-11-17T09:16:02Z",
"reviewed_by": "0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e",
"last_changed_at": "2026-11-17T09:21:40Z",
"fields_flagged": 3,
"fields_corrected": 1,
"fields": {
"total": {
"confidence": 0.3,
"corrected": true
},
"vendor_name": {
"confidence": 0.97,
"corrected": false
}
}
}
}GET/documents/{documentId}/outputs/{format}/downloadDownload the JSON or CSV
Locked until the order is paid, checked on the server every time. Signed in
Scope: docflow:read
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
formatpathstringrequired- Which output.
jsonorcsv.
What it does
- Reads the order from Payment; if it is not
paid, answers402. - Builds it on demand: reads the final values from Review
GET /tasks/{taskId}?all=trueand the model, prompt version and page count from ExtractionGET /jobs/{jobId}, re-runs ExtractionPOST /validations(withjob_id) on the current values, then builds the format and validates the JSON againstschemas/invoice-v1.json. Nothing is stored (ARCHITECTURE.md §12.8), so it always reflects the latest corrections. - Returns the file itself as an attachment named
{document}-result.{format}, and recordsdelivery.downloaded(DOCFLOW-V1-E7-02). A generated result is a few kilobytes, so it is returned directly: no stored copy, no storage link. Stored files, like the original upload, still move only by short-lived links.
Responses
- 200Paid. The file, with
Content-Disposition: attachment; filename="acme-invoice-0042-result.csv"andCache-Control: no-store. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 402
payment_requiredThe order is not paid. - 409
outputs_not_readyThe review is not complete. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/outputs/csv/download HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
HTTP/1.1 200 OK
Content-Type: text/csv; charset=utf-8
Content-Disposition: attachment; filename="acme-invoice-0042-result.csv"
Cache-Control: no-store
document_id,vendor_name,…POST/documents/{documentId}/checkoutStart payment
Sets the price and asks Payment for a checkout page. Signed in
Scope: docflow:write
Inputs
documentIdpathuuidrequired- The document.
- A document of the caller's.
What it does
- Requires status
reviewed. - Calls Payment
POST /ordersfrom DocFlow's server with a delegated token for the person (Payment accepts no other kind), the price, $5.00 (500 cents, from configuration),reference: docflow:{documentId}, and success and cancel addresses; stores the order's ID.
Responses
- 201Order ready.
order_idandcheckout_url. - 404
document_not_foundNo such document, or it belongs to another user. The same answer in both cases. - 409
already_paidGo straight to success. - 409
not_reviewedThe review is not complete. - 503
dependency_unavailableA platform service could not be reached. Nothing was changed; safe to retry. - 401
not_authenticatedNo valid access token.
Sample request
POST /api/docflow/v1/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/checkout HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"order_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_\u2026"
}GET/statsMy DocFlow totals
For the account page. Signed in
Scope: docflow:read
Inputs
None.
What it does
- Read only.
Responses
- 200Always.
documents_processed: documents that reachedreviewedorpaid. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/docflow/v1/stats HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"documents_processed": 4
}POST/webhooks/{service}Receive service events
Where platform services tell DocFlow that something finished, so the process moves on without the browser. Service
Scope: None: HMAC signature
Inputs
servicepathstringrequired- Who sent it.
extraction,review,payment,identityordelivery.X-01scale-Signatureheaderstringrequired- Proves the event came from the platform.
- HMAC-SHA256 of the raw body, compared in constant time.
event_id, type, databodyuuid, string, objectrequired- The event.
- Processed once per
event_id.
What it does
- No person is present, so each step uses a delegated token for the document's owner from Identity (
act: service:docflow; decision on #24). - Acts only on events about the document's current work: an extraction event whose
job_idis not the document'sjob_id, or a payment event whoseorder_idis not itsorder_id, is acknowledged and ignored. A late failure from a retried job, or the expiry of an earlier order, changes nothing. extraction.job.completed: reads the fields with ExtractionGET /jobs/{jobId}/fields, creates a Review task with ReviewPOST /tasksandhold: true(Idempotency-Keydocflow:{documentId}:{jobId};DOCFLOW-V1-E5-05) and sets the documentneeds_review; with nothing flagged it still creates the task, so every document is reviewed the same way.extraction.job.failed: setsextraction_failed.payment.order.paid: releases the held results, ExtractionPOST /jobs/{jobId}/releaseand ReviewPOST /tasks/{taskId}/release(each safe to repeat;DOCFLOW-V1-E5-05), then setspaidand asks DeliveryPOST /messagesfor theorder_paidemail, keyed by the event's ID. If a release fails, the event is retried; downloads already work, because DocFlow builds them as the holder.payment.order.expiredorfailed: clears the order so Pay starts a new one.identity.user.deleted: deletes that user's documents. There are no stored results to delete: Extraction and Review delete their own data.- Other types are acknowledged and ignored.
Responses
- 200Accepted, including a repeat. No body.
- 401
invalid_signatureThe signature is missing or wrong.
Sample request
POST /api/docflow/v1/webhooks/payment HTTP/1.1
X-01scale-Signature: sha256=8c1f...
Content-Type: application/json
{
"event_id": "0193b121-0000-7000-8000-00000000aaaa",
"type": "payment.order.paid",
"data": {
"order_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c"
}
}Sample response
HTTP/1.1 200 OKErrors
Every error has the same shape and a stable code to branch on.
{
"type": "https://01scale.com/errors/payment_required",
"title": "Payment required",
"status": 402,
"detail": "Pay to download these results.",
"code": "payment_required",
"request_id": "req_0193a61f9c2e"
}Handled without an endpoint
- Building the JSON (DOCFLOW-V1-E5-01)
dataholds the final values in the invoice v1 shape;metadataholds document_id, file_name, pages, model, prompt_version, extracted_at, reviewed_at, reviewed_by, fields_flagged, fields_corrected, and per fieldconfidenceandcorrected. Built on each request and validated againstschemas/invoice-v1.jsonbefore it is returned;metadata.last_changed_atis the latest correction in Review.- Building the CSV (DOCFLOW-V1-E5-02)
- Columns in this order:
document_id,vendor_name,vendor_address,vendor_tax_id,invoice_number,invoice_date,due_date,bill_to_name,bill_to_address,currency,subtotal,tax_total,total,payment_terms,line_number,line_description,line_quantity,line_unit_price,line_amount. RFC 4180 quoting, UTF-8 with a byte-order mark, CRLF line ends; cells starting with=,+,-,@, tab or carriage return are prefixed with'. - Success page (DOCFLOW-V1-E7-01)
- Polls Payment
GET /orders/{orderId}every 2 seconds for up to 30 seconds, then says 'We'll email you when it's ready'; shows the email's status from Delivery. - Which token each step uses (decisions on #24 and #21)
- Steps the person starts (upload, retry, complete review, checkout, preview, download) use their own token, except Payment and Delivery, which take only a delegated token. Steps after an event (create the review task, send the email) use a delegated token for the document's owner. So do starting an extraction and reading results for the preview, the downloads and the checks, because DocFlow holds the results until payment and only the holder reads them in full (
DOCFLOW-V1-E5-05). Every call goes throughhttps://01scale.com/api/…. - Pages
/documents,/documents/new(upload, with the file's preview once checked),/documents/{id}(extraction, with the preview beside the fields),/documents/{id}/review,/documents/{id}/results,/documents/{id}/pay,/documents/{id}/success. Each composes the services' components.
Constraints at the API level
- Every download checks on the server that the order is paid.
- The price is set by DocFlow's server, from configuration.
- DocFlow passes the person's own token to services when they are present, and a delegated token for them when not, so every service's ownership checks apply.
- Service events are verified and processed once.