Content Negotiation
The PdfBroker.io API supports multiple request and response formats. Choose the format that best fits your application architecture.
Sending Requests
The API accepts requests in two formats:
JSON Format
The standard REST API approach for most requests. Set the Content-Type header to application/json.
curl -X POST https://api.pdfbroker.io/api/pdf/... \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "document": "base64-encoded-content" }'
Multipart/Form-Data
An alternative format useful when transmitting binary data, such as images embedded in XSL-FO documents. Set the Content-Type header to multipart/form-data.
curl -X POST https://api.pdfbroker.io/api/pdf/... \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "document=@template.fo" \
-F "resource1=@image.png"
Multipart Advantage
Encoding images as Base64 causes an increase of the request size by approximately 33% compared to the original format of the file. Using multipart/form-data allows direct binary transmission, reducing payload size significantly.
Receiving Responses
Control the response format by setting the Accept header:
| Accept Header | Response Format |
|---|---|
application/json |
Returns the PDF as a Base64-encoded JSON response. Requires decoding before use. |
application/pdf |
Returns the generated PDF file directly as binary data. |
JSON Response Example
{
"document": "JVBERi0xLjQKMSAw...",
"errorMessage": null
}
Binary PDF Response
When using Accept: application/pdf, the response body contains the raw PDF bytes. This is the most efficient option for saving or streaming the PDF directly.