Documents
A document is one file in your organization (an invoice, credit note, purchase order, receipt…), with its type, number, extracted data and every time it was received. The same bytes are stored once: uploading a file the organization already has returns the existing document and records the new arrival.
The document object
{
"id": "Xb3kT9qLm2Pa",
"doc_type": "invoice",
"doc_subtype": "purchase_invoice",
"extraction_status": "complete",
"extraction_error": null,
"hold_posting": false,
"object_number": "INV-001",
"file_name": "INV-001.pdf",
"mime_type": "application/pdf",
"file_size": 48213,
"sha256": "9f2c…",
"extracted_data": { "vendor_name": "Acme Supplies", "total": 11800 },
"classification": { "station": "AP1", "confidence": 0.97, "work_record_id": "wr_123" },
"extraction": { "station": "AP8", "confidence": 0.93, "work_record_id": "wr_123" },
"parent_document_id": null,
"parent_document": null,
"parts": [],
"created_at": "2026-11-16T10:00:00.000Z",
"updated_at": "2026-11-16T10:05:00.000Z",
"arrivals": [
{
"id": "a8Kp2Lm9Qx1Z",
"channel": "email",
"channel_ref": "<[email protected]>",
"sender": "[email protected]",
"received_at": "2026-11-15T10:00:00.000Z",
"file_name": "INV-001.pdf",
"work_record_id": null,
"details": { "subject": "Invoice 001" },
"created_at": "2026-11-16T10:00:00.000Z"
}
]
}
| Field | Values |
|---|---|
doc_type | What the document is: invoice, proforma_invoice, credit_note, debit_note, quotation, purchase_order, receipt, payment_advice, statement, report, gst_certificate, contract, other; or bundle (a file holding several documents), junk (not a finance document), unclassified (on upload) |
doc_subtype | The finer kind, only for an invoice: purchase_invoice (billed to your organization) or sales_invoice (issued by it); otherwise null |
extraction_status | received → classified → extracted → complete (nothing left to extract) |
extraction_error | Why extraction stopped, as { "reason", "station", "work_record_id", "at" }, or null. It's fixed where the document is processed, not here |
hold_posting | true when the document must not be posted; set by the processing line or a person |
extracted_data | Any JSON object; its shape depends on the document type |
arrivals[].channel | email, whatsapp, drive, upload, api |
arrivals, parent_document and parts are included when you get one document or upload one, not in lists.
parent_document: the bundle this document was split from, as{ "id", "file_name" }, ornull.parts: the documents split from this one (those whoseparent_document_idis this id), by first page. Each is{ "id", "file_name", "doc_type", "extraction_status", "object_number", "page_range" }:page_rangecomes from the part's split arrival (details.split_fromset to this id,details.page_range). A part that was split again hasdoc_typebundle.
Upload a document
POST /api/v1/documents, multipart/form-data:
| Field | Required | Notes |
|---|---|---|
file | yes | Up to 12 MB |
channel | yes | How it arrived |
channel_ref | no | The channel's own id: email Message-ID, WhatsApp message id, Drive file id |
sender | no | Email address, phone number or user |
received_at | no | When the channel received it, e.g. 2026-11-15T10:00:00Z |
work_record_id | no | The orchestrator run that uploaded it |
details | no | A JSON object as a string, e.g. {"subject":"Invoice 001"} |
curl -X POST https://documents.finopsbricks.com/api/v1/documents \
-H "api-key: YOUR_KEY" -H "api-secret: YOUR_SECRET" \
-F "[email protected]" \
-F "channel=email" \
-F "[email protected]" \
-F "received_at=2026-11-15T10:00:00Z"
Returns 201 with the new document, or 200 when the organization already has these bytes:
{ "data": { "id": "Xb3kT9qLm2Pa", "extraction_status": "received", "arrivals": [ … ] }, "duplicate_file": true }
To skip sending a file you may already have, look it up first by its SHA-256:
GET /api/v1/documents?sha256=<hex>.
List documents
GET /api/v1/documents
| Parameter | Notes |
|---|---|
doc_type, doc_subtype, extraction_status, object_number, sha256 | Exact match |
hold_posting, has_extraction_error | true or false |
created_at_from, created_at_to | ISO 8601 instants, inclusive |
sort_by | created_at (default) or updated_at |
sort_order | DESC (default) or ASC |
page, limit | See Pagination |
curl "https://documents.finopsbricks.com/api/v1/documents?extraction_status=complete&doc_subtype=purchase_invoice&hold_posting=false" \
-H "api-key: YOUR_KEY" -H "api-secret: YOUR_SECRET"
Get a document
GET /api/v1/documents/:id returns the document with its arrivals.
Download the file
GET /api/v1/documents/:id/file returns the stored bytes with their original content type.
curl -o INV-001.pdf https://documents.finopsbricks.com/api/v1/documents/Xb3kT9qLm2Pa/file \
-H "api-key: YOUR_KEY" -H "api-secret: YOUR_SECRET"
Update a document
PUT /api/v1/documents/:id with a JSON body. Only the fields you send change.
| Field | Notes |
|---|---|
doc_type | One of the types above |
doc_subtype | One the doc_type has, or null |
extraction_status | Moves forward only |
extraction_error | { "reason": "…", "station": "…", "work_record_id": "…", "at": "…" } (reason required), or null to clear it |
hold_posting | true or false |
object_number | The document's own number as printed |
extracted_data, classification, extraction | JSON objects, or null |
parent_document_id | Another document in your organization, when this one was split out of it |
curl -X PUT https://documents.finopsbricks.com/api/v1/documents/Xb3kT9qLm2Pa \
-H "api-key: YOUR_KEY" -H "api-secret: YOUR_SECRET" \
-H "content-type: application/json" \
-d '{"doc_type":"invoice","doc_subtype":"purchase_invoice","extraction_status":"complete","object_number":"INV-001","extracted_data":{"total":11800}}'