Invoices
Query the CRM2 credit-note table
/a/CreditNotes_getDataTable
Return one date-descending page of active credit notes for the CRM2 Credit Notes table.
When to use this endpoint
Use this for the Credit Notes list. It is a focused table feed, not a general mapped-field query.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to the authenticated tenant.
The tenant setting accounting_credit_notes must equal 1. Otherwise the handler returns {"error":"Credit Notes are not enabled for this account"}.
Users whose legacy crm_access mask contains bit 64 are denied. The handler does not enforce the CRM2 pageCreditNotes role permission, ownership, or department scope.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
search / search[value] | String / DataTables object | No | Case/collation behavior follows the database. Matches partial credit-note number, notes, customer name, or credited invoice number. |
start | Integer-compatible | No | Zero-based offset; negative values become 0. Defaults to 0. |
length | Integer-compatible | No | Page size from 1 to 500. Omitted, zero, negative, or above 500 becomes 100. |
Example request
$page = FM_api('CreditNotes_getDataTable', [
'start' => 0,
'length' => 50,
'search' => ['value' => 'CN-1042'],
]);
Example response
{
"ok": 1,
"data": [{"id":"311","cdate":"2026-10-02","customer_id":"1042","customer_type":"0","total":"40","remaining":"15","num":"CN-1042","status":"1","credited_invoice_id":"981","reason":"Returned materials","customer_name":"Example Ltd","credited_invoice_num":"INV-981"}],
"recordsTotal": 1,
"recordsFiltered": 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. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Only active credit notes are returned, ordered by document date descending then ID descending. Client-supplied sort, column filters, status filters, and date filters are ignored.
recordsTotalcounts all active credit notes;recordsFilteredcounts those matching search before pagination. Both counts remain independent of the page offset and length.- Customer name is populated only for customer type 0.
See it in Fieldmotion
CRM1
No CRM1 credit-note list was found.
CRM2
Open Credit Notes. The shared display widget derives CreditNotes_getDataTable from its API prefixes; searching and paging redraw this feed.
Related endpoints
CreditNote_getloads a selected row for editing.CreditNotes_getSyncProvidersByIdsdecorates the visible page with accounting-provider markers.