When to use this endpoint

Use this for the Credit Notes download/preview workflow after saving the note and selecting its report form.

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-compatibleYesActive credit-note ID.
htmlInteger-compatibleNoSet to 1 for HTML. HTML always bypasses report cache.
skip_cacheInteger-compatibleNoSet to 1 to request a fresh PDF render.

Example request

$document = FM_api('CreditNote_getPdf', ['id' => 311, 'html' => 1]);

Example response

{
  "ok": 1,
  "html": "<!doctype html>...",
  "filename": "CN-1042"
}

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":"credit note does not exist"}The ID is absent or soft-deleted.
{"error":"REPORTSERVER_URL not defined"}The report service is not configured.

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 report request uses kind credit_note and the authenticated tenant ID. PDF responses normally contain base64 data; HTML responses contain rendered HTML.
  • The report form suppresses invoice-only payment widgets for credit-note output. The endpoint adds filename to the report service response, including an error response.

See it in Fieldmotion

CRM1

No CRM1 credit-note download flow was found.

CRM2

Open a credit note and choose Download. CRM2 calls CreditNote_getPdf and downloads filename + ".pdf".

Related endpoints