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

ParameterTypeRequiredDescription
idPositive integerYesActive invoice ID.

Example request

$name = FM_api('Invoice_getFilename', ['id' => 981]);

Example response

{
  "value": "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":"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-filename setting returns invoice without 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_id found 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