Integration guide · REST API
Render a PDF by sending JSON and data
The host application can keep each report definition and send it with the data for a render. Open Reports validates the JSON and returns the generated file bytes; it does not look up a stored template for this endpoint.
Inline definition request
Call POST /api/v1/render from a trusted backend and send report, format, and optional data and parameters.
const response = await fetch(`${OPEN_REPORTS_URL}/api/v1/render`, {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": OPEN_REPORTS_API_KEY,
},
body: JSON.stringify({
report: invoiceDefinition,
format: "pdf",
data: { invoice: authorizedInvoice },
}),
});
if (!response.ok) throw new Error(`Render failed: ${response.status}`);
const pdfBytes = Buffer.from(await response.arrayBuffer());
Do you need a template ID?
No, not for POST /api/v1/render when you include the full report definition in the request. The id inside that JSON is report metadata, not a lookup key.
A template ID is needed only for the separate optional saved-template endpoint POST /api/v1/templates/{templateId}/render. Use that when Open Reports should manage saved drafts and published versions.
Different customers and branding
The host can select the customer's report definition using its own authenticated tenant/report mapping. If customers share one layout, send their logo URL, header text, footer text, and business data as render data. For different layouts, send the definition selected by the host. Open Reports does not infer customer identity or authorize access to records.
Security and output
- Keep API keys in the host backend or secret store; do not expose privileged keys in browser code.
- Authorize the current user and retrieve only the data they may print.
- The REST response contains raw bytes such as
application/pdf. If another system requires Base64, encode those bytes in the host application.
See the API reference for cURL, Node, Python, Java, C#, and Go examples, errors, template endpoints, and asynchronous rendering.