Invoices
Build an invoice filename
POST
/a/Invoice_getFilename
Expand the tenant invoice-filename template for one active invoice.
When to use this endpoint
Use this before naming a downloaded or attached invoice document. Invoice_getPdf calls it automatically outside portal mode.
Authentication and permissions
The route intentionally has no direct login guard because the share compatibility flow calls it, but it still requires a valid tenant ID in session context. An ID alone cannot choose another tenant.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Active invoice ID. |
Example request
$name = FM_api('Invoice_getFilename', ['id' => 981]);
Example response
{
"value": "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":"not logged in"} | No tenant context is available. |
{"error":"invoice does not exist"} | A non-empty filename template needs data from an absent or deleted invoice. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- An empty
invoice-filenamesetting returnsinvoicewithout looking up the ID. - Supported tokens are
{{ID}},{{NUMBER}},{{DATE}},{{DUE_DATE}},{{CUSTOMER}},{{CUSTOMER_JOB_REF}},{{CUSTOMER_STREET_ADDRESS1}}, and{{ASSET_NAME}}. - Customer text comes from the persisted historical snapshot when available. The helper may repair a missing snapshot; the job-reference token reads the greatest positive
job_idfound in the invoice rows.
Side effects
- May persist a rebuilt customer/asset snapshot when legacy invoice data lacks one.
See it in Fieldmotion
CRM1
No direct production CRM1 caller was found for this route.
CRM2
No direct production CRM2 caller was found for this route.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.