Invoices
Set the Word invoice template
POST
/a/Invoices_templateWordSet
Sanitize and save the tenant’s Word/HTML invoice template.
When to use this endpoint
Use this when an administrator saves the invoice template editor.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to that tenant.
The authenticated user must satisfy Core_isClientAdmin().
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template | String | Yes | Complete template markup. The handler rewrites several dangerous tag/event patterns before storing it. |
Example request
$result = FM_api('Invoices_templateWordSet', [
'template' => '<html><body>{{INVOICE_NUMBER}}</body></html>',
]);
Example response
{
"ok": 1
}
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":"missing or invalid parameter: template"} | Template is absent. |
{"error":"you are not an admin"} | Caller is not a tenant administrator. |
{"error":"Could not save template as it is empty or not fully uploaded"} | The submitted/sanitized value is false or empty. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Case-insensitive opening/closing
script,iframe, andmetatags are renamed, and inlineon…=attributes are rewritten. The loop repeats until none of those patterns remains. - This is legacy pattern-based sanitization, not a general HTML allow-list. The stored markup may differ from the submitted value.
Side effects
- Replaces the tenant setting
invoice-template-word.
See it in Fieldmotion
CRM1
The invoice Word-template settings page saves editor contents here.
CRM2
No direct CRM2 caller was found.
Related endpoints
Invoices_templateWordGetreloads the stored template.