Download a PDF
Fetch a generated PDF from its URL with your API key.
The url of a generated document is an endpoint of the Tuix PDF Service, not a
public link. Fetching it needs the same API key you used to render, sent in the
same x-api-key header.
Endpoint
You normally never build this URL yourself: it comes back ready to use in
generatedDocuments[].url. Store that value and request it as it is.
Headers
| Header | Required | Value |
|---|---|---|
x-api-key | Yes | The same API key you render with. See API Keys. |
Accept | Yes | application/pdf. Any other value returns the file base64 encoded. |
Accept is not optional. A request without it is rejected with 400, and a
request with a different value still answers 200, but with a base64 string
instead of the PDF bytes.
Example
Response
200 OK with the bytes of the PDF and Content-Type: application/pdf. The body
is the file itself, there is no JSON envelope around it.
Status codes
| Status | Meaning |
|---|---|
200 | The file is returned. |
400 | Malformed applicationId or fileId, or no Accept header. |
401 | No API key sent. |
403 | Unknown or deleted API key. |
404 | No document with that fileId in that application. |
500 | The file could not be read. |
Serving the file to a browser?
The URL is not shareable: a browser opening it sends neither the API key nor the
Accept header, so it gets an error rather than the file. And an API key must
never reach a browser, it grants full access to the API.
Download the file in your backend and serve it from there:
Your endpoint decides what happens next: stream the bytes back, store the file, attach it to an email, or hand out a link of your own with your own access rules.