This guide walks through the end-to-end flow of processing a bill via the Dolfin API. You’ll upload a bill document, optionally correct any fields the OCR scanner got wrong, submit the bill for review, and either approve or reject it.Documentation Index
Fetch the complete documentation index at: https://docs.dolfinai.co/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Dolfin API key
- An organisation already provisioned (see Client Integration)
- A valid session token or API key for authentication
- A bill PDF or image file to upload
All requests below require the
x-dolfin-api-key and x-dolfin-organisation-id headers. See Authentication for details.Overview
Patch extracted fields (optional)
Fix any fields the OCR scanner got wrong while the bill is in
PendingReview.Bill lifecycle
A bill moves through these states:Step 1: Upload a Bill
Upload the bill document asmultipart/form-data. OCR runs asynchronously, so the response returns immediately with the new bill’s id and initial state.
202 Accepted):
Save the bill
id — you’ll use it in every subsequent call. The bill starts in OcrProcessing and automatically moves to PendingReview once the scanner finishes. Poll GET /bills/{id} to check, or subscribe to the /hubs/bills SignalR hub for realtime updates.Poll for OCR completion
PendingReview, the OCR results are populated on the bill:
If the state becomes
OcrFailed, the document couldn’t be parsed. Call POST /bills/{id}/retry-ocr to try again.Step 2: Patch Extracted Fields (Optional)
OCR isn’t perfect. If the scanner got any fields wrong — the supplier name, invoice number, amounts, line items, bank details — patch them while the bill is inPendingReview.
PendingReview; attempts against any other state return 409 Conflict.
To link the bill to an existing supplier record, set
supplierId to the supplier’s UUID. Otherwise the free-text supplierName, supplierEmail, etc. are kept as-is and used for supplier resolution when you submit for review (see Step 3).Step 3: Submit for Review
Once the extracted data is correct, submit the bill for approval. This transitions the state fromPendingReview to NeedsApproval.
Supplier resolution
When you submit a bill for review, Dolfin resolves the bill’s supplier in this order:- If you set
supplierIdexplicitly (via patch), that supplier is used. - Otherwise, Dolfin looks for an existing supplier on the organisation whose tax ID or email matches the OCR-extracted value and links to it.
- If no match is found, a new supplier is created from the OCR data. This requires at minimum
supplierNameandsupplierEmail— fill these viaPATCH /bills/{id}in Step 2 if OCR didn’t capture them. Any other extracted details (phone, address, website, tax ID, bank details) are copied onto the new supplier too.
400 Bad Request.
Step 4: Approve or Reject
With the bill inNeedsApproval, an approver takes the final call.
Approve
POST /bills/{id}/schedule-payment.
Reject
If something’s off, reject the bill with an optionalreason.
A rejected bill can be re-opened for editing with
POST /bills/{id}/reopen, which returns it to PendingReview.Summary
| Step | Endpoint | What it does |
|---|---|---|
| 1 | POST /bills | Upload a bill document; OCR runs asynchronously |
| 2 | PATCH /bills/{id} | Correct any fields OCR got wrong (optional) |
| 3 | POST /bills/{id}/submit-review | Transition from PendingReview to NeedsApproval |
| 4a | POST /bills/{id}/approve | Approve the bill for payment |
| 4b | POST /bills/{id}/reject | Reject with an optional reason |
Next Steps
API Reference
Explore the full Bills API, including payment scheduling and file URLs.
Client Integration
Set up organisation provisioning and user authentication.