Invoices
Delete a credit note
/a/CreditNote_delete
Soft-delete a credit note only when it has no allocated or refunded value.
When to use this endpoint
Use this from the Credit Notes list or editor after confirming the credit note has no allocations.
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 |
|---|---|---|---|
id | Positive integer-compatible | Yes | Credit note ID. |
Example request
$result = FM_api('CreditNote_delete', ['id' => 311]);
Example response
{
"ok": 1,
"id": 311
}
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":"Credit Note has allocations and cannot be deleted"} | The sum of invoice allocations and refunds is greater than zero. |
{"error":"no such credit note"} | The ID is absent or already soft-deleted. |
{"error":"Credit Note deletion could not be recorded"} | The deletion audit could not be written; the note remains active. |
{"error":"Could not start Credit Note change. Please retry."} | The database transaction could not begin. |
{"error":"Credit Note change could not be saved. Please reload before retrying."} | A database write or commit failed; the transaction is rolled back. For enablement, earlier completed invoice migrations remain committed. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Deletion sets
deleted=1and a Unixddate; it is not permanent despite the current CRM2 confirmation wording. - A missing or already deleted ID returns an error without a new deletion/history entry.
- Related sync mappings, job relations, mail, and other rows are not removed.
Side effects
- Locks the active credit note, checks allocations, and commits the tenant deletion-stream record together with soft deletion. Advances edit metadata, invalidates the credit-note cache, and writes credit-note activity history.
See it in Fieldmotion
CRM1
No CRM1 credit-note deletion flow was found.
CRM2
Delete a row on Credit Notes or use Delete in the editor and filter for CreditNote_delete. CRM2 checks pageCreditNotes permissions in the UI only.
Related endpoints
CreditNote_getreturns a credit note together with its allocations.CreditNotes_getDataTablesupplies the CRM2 list.