Invoices
Set an invoice number
POST
/a/Invoice_setNum
Replace an unpaid invoice number without reserving or checking uniqueness.
When to use this endpoint
Use this only where tenant settings allow manual invoice-number editing.
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 | Integer | Yes | Active invoice ID. |
num | String | Yes | Complete number; blank and duplicate values are accepted. |
Example request
$result = FM_api('Invoice_setNum', ['id' => 981, 'num' => 'INV-981']);
Example response
{
"ok": 1,
"num": "INV-981"
}
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
- There is no format, length, or uniqueness validation. An unchanged number returns the normal success shape.
Side effects
- Updates
numandlast_editedand firesInvoice_edit.
See it in Fieldmotion
CRM1
The main invoice page uses this route when invoice-number editing is enabled.
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.