Invoices
Render an invoice document
POST
/a/Invoice_getPdf
Render an invoice through the report service and return PDF data or HTML together with a download filename.
When to use this endpoint
Use this for invoice preview, download, printing, or email attachment preparation.
Authentication and permissions
Accepts the authenticated tenant from a CRM/API session or the legacy customer-portal tenant session. The legacy access-mask restriction still applies.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Active invoice ID. |
html | Integer-compatible | No | Set to 1 for rendered HTML; otherwise the report service normally returns base64 PDF data. |
portal | Presence flag | No | Uses the fixed filename invoice-{id} instead of expanding the tenant filename template. |
Example request
$document = FM_api('Invoice_getPdf', ['id' => 981, 'html' => 1]);
Example response
{
"html": "<!doctype html>...",
"filename": "INV-981-Example Ltd"
}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"invoice does not exist"} | The invoice is absent or deleted. |
{"error":"REPORTSERVER_URL not defined"} | The report service is not configured. |
{"error":"report generate route unavailable"} | The report service returns no usable JSON response. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- HTML mode forces a fresh report render. PDF mode may use the report cache, whose freshness depends on invoice, form, and related edit timestamps.
- The response body is supplied by the report service and can include
base64for PDF orhtmlfor preview. The endpoint then addsfilename.
See it in Fieldmotion
CRM1
Invoice, Job Invoice, Customer Invoices, Asset Invoices, bulk PDF, and mail workflows request this route.
CRM2
Invoice lists, Job Invoice, Job Costs, multi-edit PDF, and Send Email use this route. Filter Network requests for Invoice_getPdf.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.