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

ParameterTypeRequiredDescription
customer_id / customer_typeIntegersNoTarget ID and type; type 1 stores the asset as target and resolves its owner as the invoice customer.
form_id / quote_idIntegersNoInvoice form and related quote. Missing form uses the first form of type 7.
total_gross / total_netNumeric-compatibleNoInitial totals; both default to zero. No line items are created.
inv_date / num / notes / order_noStringsNoInvoice date, optional explicit number, notes, and order number.
nominal / tax_code_id / statusMixedNoHeader 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

ResponseCondition
{"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_no is preserved as text, including apostrophes.
  • The stored status is -1. Customer default nominal/tax values are read, but the customer nominal is not used when nominal is 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