Skip to main content

PDF Rendering

2 API calls in this section.

Generate PDF from an assigned template​

Platform & Access / PDF Rendering
POST/pdf-render/generate

Generates a PDF from an active stored template assignment. This generic HTTP service is restricted to the trusted internal PDF service credential or an active global system administrator (users.is_system_admin=true, or a database-verified system_admin role with roles.scope=system and user_roles.tenant_id=null). Tenant admins, staff, customers and drivers must use their existing domain APIs for labels, receipts and barcode printing; tenant membership alone never grants this generic endpoint access. The permission check runs before request-body parsing, template/currency-settings reads, renderer calls and storage writes. Role lookup errors deny access. POST /pdf-render is an alias with the same policy. Required body: assignment_key and data appropriate to the assigned template. Optional: tenant_id, render_pages for batches, render_config, storage_path, correlation_id. Only these trusted callers may select the tenant or storage path, including replacement of an existing object. Success 200 returns success, url, bucket, path, assignment, template, currency, and renderer {renderMs,sizeBytes}. 400 includes invalid_json_body or assignment_key_required; 401 returns a stable code (missing_authorization, invalid_or_expired_token or user_not_found) and localized message; 403 returns code:system_admin_required with a localized message; 404 includes pdf_template_assignment_not_found. Internal shipment-label and institution-barcode generation call the trusted assignment function directly and keep their domain-owned tenant, paths and overwrite/version rules. Frontend contract: no generic-render call is needed for tenant/customer/driver workflows; existing domain endpoints and response fields are unchanged. Internal credentials must stay on the backend.

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Content-Typestring

Example: application/json

Accept-Languagestring

Preferred language: en, ar, fa, or ku.

Example: en

Body parameters

ParameterTypeDescription
assignment_keystring—
tenant_idstring—
dataobject—
Staging
Request
curl
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/pdf-render/generate" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3  --header "Content-Type: application/json" \4  --header "Accept-Language: en" \5  --data-raw '{6  "assignment_key": "shipment_label",7  "tenant_id": "{{tenant_id}}",8  "data": {}9}'

Replace {{placeholders}} with your own values before sending.

Response examples

403Forbidden
Response body
json
1{2  "success": false,3  "code": "system_admin_required",4  "message": "System admin required"5}

Test an HTML PDF template (system administrator)​

Platform & Access / PDF Rendering
POST/pdf-render/generate

Renders caller-supplied HTML as a Handlebars template. Like normal assigned-template rendering, requires an active user whose users.is_system_admin is true or who has a database-verified global system_admin role (roles.scope=system and user_roles.tenant_id=null), or the trusted internal PDF service credential. Tenant-scoped role assignments and token metadata do not grant generic-render access. Role lookup failures deny access. Both boolean true and string "true" activate test mode; omitting test or setting it to false does not bypass authorization. Non-administrators receive HTTP 403 before request-body parsing, template compilation, renderer calls or storage writes. The response has success:false, code:system_admin_required, and a localized message. An empty HTML string returns 400 html_required_for_test_render after permission checks. Optional: template_id, template_key, template_name, tenant_id and render_config. Success 200 uses the same PDF response as normal rendering; assignment is null for raw tests. Frontend contract: the existing system-admin PDF editor keeps its request unchanged; display message on 401/403 and use code for branching. Internal credentials must stay on the backend.

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Content-Typestring

Example: application/json

Accept-Languagestring

Preferred language: en, ar, fa, or ku.

Example: en

Body parameters

ParameterTypeDescription
testboolean—
assignment_keystring—
htmlstring—
dataobject—
data.titlestring—
tenant_idstring—
Staging
Request
curl
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/pdf-render/generate" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3  --header "Content-Type: application/json" \4  --header "Accept-Language: en" \5  --data-raw '{6  "test": true,7  "assignment_key": "html-template-test",8  "html": "<html><body><h1>{{title}}</h1></body></html>",9  "data": {10    "title": "PDF template preview"11  },12  "tenant_id": "{{tenant_id}}"13}'

Replace {{placeholders}} with your own values before sending.

Response examples

403Forbidden
Response body
json
1{2  "success": false,3  "code": "system_admin_required",4  "message": "System admin required"5}