Invoices
Create a basic invoice
/a/Invoice_new
Create a basic draft invoice directly, applying customer defaults and the tenant numbering and due-date policies.
When to use this endpoint
Use this legacy-compatible creator for straightforward invoice generation. CRM2 configurable forms normally use Invoice_createData.
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 |
|---|---|---|---|
customer_id / customer_type | Integers | No | Target ID and type; type 1 stores the asset as target and resolves its owner as the invoice customer. |
form_id / quote_id | Integers | No | Invoice form and related quote. Missing form uses the first form of type 7. |
total_gross / total_net | Numeric-compatible | No | Initial totals; both default to zero. No line items are created. |
inv_date / num / notes / order_no | Strings | No | Invoice date, optional explicit number, notes, and order number. |
nominal / tax_code_id / status | Mixed | No | Header accounting defaults and notification context. Stored status is always Draft; status only influences initial overdue scheduling. |
Example request
$created = FM_api('Invoice_new', [
'customer_id' => 1042,
'customer_type' => 0,
'form_id' => 17,
]);
Example response
{
"ok": 1,
"id": 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. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The call succeeds even with no parameters and creates a zero-value unassigned draft.
- A supplied
order_nois preserved as text, including apostrophes. - The stored status is
-1. Customer default nominal/tax values are read, but the customer nominal is not used whennominalis omitted.
Side effects
- Creates the invoice and historical target snapshot, marks a customer as having invoices, writes a “job / invoice generate” activity log, and may schedule an overdue notification using calculated terms.
See it in Fieldmotion
CRM1
The main Invoices page uses this route for its legacy create flow.
CRM2
No direct production CRM2 caller was found; CRM2’s configurable create dialog uses Invoice_createData.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.