Invoices
Set an invoice quote ID
POST
/a/Invoice_setQuoteId
Set or clear the direct quote_id field on an unpaid invoice.
When to use this endpoint
Use this for the legacy invoice header relationship. Job-mediated quote relationships are stored separately in relation rows.
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. |
quote_id | Integer | Yes | Positive active quote ID, or zero to clear. |
Example request
$result = FM_api('Invoice_setQuoteId', ['id' => 981, 'quote_id' => 611]);
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":"quote does not exist"} | A positive quote ID 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
- An unchanged value returns
warning: no change needed. This does not create or remove job/quotemanymanylinks.
Side effects
- Updates
quote_id,last_edited, andedited_uuid; it does not fireInvoice_edit.
See it in Fieldmotion
CRM1
The main invoice editor exposes this relationship 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.