When to use this endpoint

Use this from the allocation history inside a saved credit note.

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

ParameterTypeRequiredDescription
idPositive integer-compatibleYesAllocation-row ID, not the credit-note ID.

Example request

$result = FM_api('CreditNote_deleteAllocation', ['id' => 72]);

Example response

{
  "ok": 1,
  "id": 72,
  "remaining": 40
}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"no such allocation"}No allocation row has that ID, including a concurrent deletion.
{"error":"no such credit note"}The allocation’s parent credit note is absent or soft-deleted.
{"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

  • The allocation row is hard-deleted. Its note and audit fields cannot be restored through the API.
  • Remaining is recalculated from all surviving allocations and refunds and never falls below zero.

Side effects

  • Locks the parent credit note and any referenced invoice, permanently deletes the allocation, recalculates remaining, advances credit-note edit metadata, and writes activity history within a transaction. A failed balance write rolls back the deletion.
  • Deleting an invoice allocation changes calculated invoice owing but does not touch invoice paid or payment history.

See it in Fieldmotion

CRM1

No CRM1 allocation UI was found.

CRM2

Edit a credit note and delete an existing allocation row. The editor reloads the note after CreditNote_deleteAllocation.

Related endpoints