# Documents

The issued documents: status, PDF and data.

## GET /v1/documents

**Bulk settlement status by your own identifiers**

Which of the invoices you pushed are still open. Derived from allocations and never stored, so it is always current — do not cache it as a boolean, it is wrong the moment a receipt is allocated. Refs that match nothing come back under not_found, so a syncing caller sees what never landed instead of inferring it from a short list.

Each row splits the settling side, because 'settled' is not one fact: paid_amount is receipts, credited_amount is credit notes, and state is derived from the two — OPEN, PART_PAID, PAID, PART_CREDITED, CREDITED, PAID_AND_CREDITED or VOIDED. An invoice paid and an invoice cancelled-and-credited both show settlement_status SETTLED, and an app that renders them the same way is lying to the customer. credit_note_nos lists the credit notes against the document, marked_for_refund says the customer asked for the money back, and last_movement_at is when an allocation last touched it. Everything is derived from the allocation rows, so it cannot disagree with the ledger — learn that something moved from GET /v1/changes (ALLOCATED) and re-read rather than caching a flag.

Parameters:

- `externalRefs` (query, required): Comma-separated, up to 1000.
- `sourceSystem` (query): Your system's name, the same on every call (for example shop). Identifies your references.

Answers:

- `200` document_id, doc_no, doc_type, total_incl_tax, allocated, outstanding, settlement_status, status, reference — plus not_found

## GET /v1/documents/{externalRef}/pdf

**The issued document as a PDF**

The tax invoice or credit note on the ReconSmith letterhead, exactly as posted: our invoice number, the date and due date, our company details and VAT number as the letterhead stood on that date, the customer's name, address and VAT number, every line, the totals, and the reference (your order or work-order number).

Fetch it once when the invoice is posted and store it; fetch again if a credit note is raised against it. Your app then serves its stored copy, so a customer can still get their invoice when ReconSmith is slow or unreachable.

Drawn by one renderer from the template's render_spec, and reissued on the branding of the document's own date — a copy fetched next year matches the one that was sent. The service does not draw PDFs itself: a second implementation would mean two versions of the same tax invoice, with no way to say which one the customer received.

Only a POSTED document has an issued PDF; anything else is a 409.

Parameters:

- `externalRef` (path, required): Your identifier for the document — the order number you invoiced under.
- `sourceSystem` (query): Your system's name, the same on every call (for example shop). Identifies your references.

Answers:

- `200` application/pdf, named for our document number, e.g. "Tax invoice INV-00041.pdf"
- `404` Unknown document
- `409` The document is not POSTED, so no PDF was ever issued
- `502` The renderer is unreachable or refused
- `503` No renderer is configured

## GET /v1/documents/{externalRef}/content

**The issued document as JSON or XML**

The same document as data: our invoice number, date and due date; our company details and VAT number from the letterhead for that date; the customer's name, address and VAT number; every line with description, quantity, unit price, amount excluding VAT and VAT; the totals, a tax summary by rate, and the reference.

Built from the ledger rather than from what the caller pushed, so if your copy and ours ever disagree, ours is right by construction. Not needed when you store the PDF, but it is what you want to render the invoice natively in an app or to keep an archival XML copy. Bank account number is masked to the last four: the full number belongs on the PDF the supplier issues, not in a payload that gets cached.

format=xml, or an Accept header asking for XML, returns the XML rendering of the same facts.

Parameters:

- `externalRef` (path, required)
- `sourceSystem` (query): Your system's name, the same on every call (for example shop). Identifies your references.
- `format` (query)

Answers:

- `200` The document
- `404` Unknown document
