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

ParameterTypeRequiredDescription
idPositive integerYesActive invoice ID.
htmlInteger-compatibleNoSet to 1 for rendered HTML; otherwise the report service normally returns base64 PDF data.
portalPresence flagNoUses 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

ResponseCondition
{"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 base64 for PDF or html for preview. The endpoint then adds filename.

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