Invoices
Set an invoice due date
POST
/a/Invoice_setDueDate
Set an unpaid invoice due date and rebuild its overdue-notification schedule.
When to use this endpoint
Use this for an explicit due-date override after invoice creation.
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. |
val | Date/time string | Yes | Parsed with PHP strtotime in the server timezone and stored as a Unix timestamp. |
Example request
$result = FM_api('Invoice_setDueDate', ['id' => 981, 'val' => '2026-11-01']);
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":"invalid date"} | The value cannot be parsed. |
{"error":"invoice does not exist"} | The invoice is absent or deleted. |
{"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
- Scheduling first removes any existing overdue notification. A replacement is created only when status is Invoiced, the date is future, and the tenant invoice-overdue notification is enabled. Scheduling errors do not change the endpoint response.
Side effects
- Updates due date and edit metadata, fires
Invoice_edit, and deletes/recreates the type-13 scheduled notification when eligible.
See it in Fieldmotion
CRM1
The main invoice editor’s due-date input submits 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.