Invoices
Set credit-note status
/a/CreditNote_setStatus
Set a credit note to Draft, Issued, or Cancelled and write status activity history.
When to use this endpoint
Use this narrow route when only status should change. The current CRM2 list instead submits status-only updates through CreditNote_updateData.
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. |
val / status | Integer-compatible | Yes | val takes precedence. Accepted values: -1 Draft, 1 Issued, 3 Cancelled. |
Example request
$result = FM_api('CreditNote_setStatus', ['id' => 311, 'val' => 1]);
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":"missing or invalid parameter: status"} | The normalized status is outside -1, 1, and 3. |
{"error":"no such credit note"} | The ID is absent or soft-deleted; no status history is added. |
{"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
- No transition matrix is enforced: any accepted status may replace any other, including cancelling a credit note with allocations.
- An unchanged status still writes edit metadata and history. The note is locked and the status change commits within a transaction.
Side effects
- Updates status/edit metadata on an active match, invalidates the credit-note cache, and writes activity history. It does not send mail, change allocations, or fire a generic edit event.
See it in Fieldmotion
CRM1
No CRM1 caller was found.
CRM2
No direct production CRM2 caller was found. Inline status edits on Credit Notes currently use CreditNote_updateData.
Related endpoints
CreditNote_getreturns a credit note together with its allocations.CreditNotes_getDataTablesupplies the CRM2 list.