Invoices
Set an invoice nominal code
POST
/a/Invoice_setNominal
Replace the nominal accounting code on an unpaid invoice header.
When to use this endpoint
Use this legacy header setter only when the caller already has the accounting code. CRM2 mapped saves should submit the canonical nominal ID/code pair.
Authentication and permissions
The request must use a logged-in CRM session or valid signed API credentials and is scoped to that tenant.
Users whose legacy crm_access mask contains bit 64 receive {"error":"no permission to access api"}. No record-owner check is made.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Active invoice ID. |
nominal_code | Non-empty string | Yes | Trimmed accounting code written without checking account existence or tax-code compatibility. |
Example request
$result = FM_api('Invoice_setNominal', ['id' => 981, 'nominal_code' => '4000']);
Example response
{
"ok": 1,
"nominal_code": "4000"
}
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":"cannot edit invoices that are marked Paid"} | The invoice is Paid. |
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 unchanged code returns the same success shape. The paired
meta.nominalIDis not updated, so this route can leave the canonical ID/code pair inconsistent.
Side effects
- Updates the code and edit metadata and fires
Invoice_edit.
See it in Fieldmotion
CRM1
The main invoice editor calls this route from the nominal-code control.
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.