Invoices
Export credit notes
/a/CreditNotes_getExportData
Return selected active credit-note fields in positional export columns for the CRM2 CSV exporter.
When to use this endpoint
Use this after the caller already has the selected/visible credit-note IDs and export field map. Unlike many legacy exporters, this endpoint has no ID-discovery phase.
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 |
|---|---|---|---|
_ids | JSON array string | Yes | Selected credit-note IDs. Values are integer-normalized and non-positive values are removed. An empty array returns an empty array. |
fields | JSON array string | No | Requested field names. Omission/empty selects ID as f0; malformed JSON returns an error. Supported fields are the persisted document columns plus customer_name, credited_invoice_num, and aggregate allocated. |
Example request
$rows = FM_api('CreditNotes_getExportData', [
'_ids' => json_encode([311]),
'fields' => json_encode(['num', 'customer_name', 'total', 'remaining', 'allocated']),
]);
Example response
[
{"f0":"CN-1042","f1":"Example Ltd","f2":"40","f3":"15","f4":"25"}
]
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":"invalid parameter: _ids"} | _ids is not a JSON array. |
{"error":"invalid parameter: fields"} | fields is present but not a JSON array. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Output keys are
f0,f1, and so on in requested-field order. Unknown field names produce a blank column at their position. - Results exclude missing/deleted IDs, are unpaginated, and have no guaranteed order. Duplicate IDs do not duplicate rows.
allocatedsums both invoice allocations and refunds.
See it in Fieldmotion
CRM1
No CRM1 credit-note exporter was found.
CRM2
On Credit Notes choose Export. CRM2 supplies visible IDs and batches them through CreditNotes_getExportData.
Related endpoints
CreditNotes_getDataTablesupplies the visible IDs used by the export dialog.