Invoices
Retrieve an invoice by number
POST
/a/Invoice_getByNum
Resolve an active invoice by its exact stored number and return the same full record as Invoice_get.
When to use this endpoint
Use this only when an external workflow has the invoice number but not its internal ID.
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 |
|---|---|---|---|
num | Non-empty string | Yes | Exact invoice number after trimming surrounding whitespace. |
Example request
$invoice = FM_api('Invoice_getByNum', ['num' => 'INV-981']);
Example response
{
"id": "981",
"num": "INV-981",
"status": "1",
"rows": "[]"
}
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":"invoice does not exist"} | No active invoice has that number. |
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 explicit uniqueness enforcement or ordering. If legacy data contains duplicate active numbers, the database may return any matching row.
- The selected ID is passed to
Invoice_get, including its snapshot repair and row normalization.
See it in Fieldmotion
CRM1
No direct production CRM1 caller was found for 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.