Invoices
Render a credit-note document
/a/CreditNote_getPdf
Render an active credit note through the report service as PDF data or HTML and attach a safe filename.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer-compatible | Yes | Active credit-note ID. |
html | Integer-compatible | No | Set to 1 for HTML. HTML always bypasses report cache. |
skip_cache | Integer-compatible | No | Set 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
| 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 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_noteand 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
filenameto 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
CreditNote_getFilenameexposes filename generation separately.CreditNote_sendEmailqueues the mail after the Send Email widget prepares content.