API Generate document

Generates PDF or any other target from report.

POST /v1/generate HTTP/1.1

Payload attributes:

Attribute Type Required Description
reportId string No ID to load report from database.
report object No Report object. See type Report in Git repo.
 
data unknown No Data object for generating report.
dataUrl string No URL to data object for generating report. It must return JSON or JavaScript.
dataJavaScript string No JavaScript async code to generate data. Must include return statement. Used with Function() constructor.
 
target string No What file to generate? Possible values: pdf (default), html, csv. Ignored when specifying html or url key.
 
url string No URL of a website to convert to pdf.
html string No HTML to convert to pdf.
properties object No Applied only when specifying html or url key. Paper size and other info required for PDF. See type GenerateResultProperties in Git repo.

If successful, returns status code 200 OK. Payload contains PDF (or other result type).

It may set the following additional response headers:

Header key Description
Content-Type MIME type based on target property
Content-Disposition Contains file name generated from report.
X-Job Request ID for debugging

Additional response status codes

Code Description
403 Forbidden Report not found or no permission to access it
408 Request Timeout Error while generating: problem with source data, error inside report, timeout, too big response, out-of-memory ...
413 Content Too Large Request payload too large. It can occur when embedded images are too large.
429 Too Many Requests Too many requests (rate limit).
503 Service Unavailable Server is unable to accept request because there are too many requests waiting in the queue.

Example request:

curl --request POST \ --header "Authorization: Bearer <your-token>" \ --header "Content-Type: application/json" \ --data '{ "reportId": "018cb9ec-6d6e-7708-8e8b-da56bb451728" }' \ --url "https://api.pantherpdf.com/v1/generate"

Example response (headers + payload):

HTTP/1.1 200 OK Access-Control-Allow-Origin: * Connection: close Content-Disposition: attachment; filename="invoice.pdf" Content-Length: 93204 Content-Type: application/pdf X-Job: 018cba2e-9d7d-7db0-9af8-8da6813699d4 %PDF-1.4 <PDF binary data>