Merge renders
Merges multiple renders into a single PDF.
You can also include external PDF URLs to merge with your renders.
A merge uses 1 API credit.
By default, the merged PDF will be returned directly in the response.
But if you pass the host
parameter, the merged PDF will be uploaded to our servers and you will receive a URL in the response.
Parameters
ids array
REQUIRED
The render ids of the renders that will be merged.
urls array
Optional array of PDF URLs to merge with the renders. The external PDFs will be downloaded and merged after the renders in the order provided.
host boolean
If true
, the merged PDF will be hosted in our servers and you will receive a URL in the response. Defaults to false
.
Sample Requests
POST /v1/render/merge
Merge renders only
fetch("https://api.templated.io/v1/render/merge", { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` }, body: JSON.stringify({ "ids": [ "render_id_1", "render_id_2", "render_id_3" ], "host": true })}).then(response => response.json()).then(data => { // Handling the response const url = data.url; const link = document.createElement('a'); link.href = url; link.download = 'merged_renders.pdf';
// Trigger the download document.body.appendChild(link); link.click();});
Merge renders with external PDFs
fetch("https://api.templated.io/v1/render/merge", { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` }, body: JSON.stringify({ "ids": [ "render_id_1", "render_id_2" ], "urls": [ "https://example.com/document1.pdf", "https://example.com/document2.pdf" ], "host": true })}).then(response => response.json()).then(data => { console.log('Merged PDF URL:', data.url);});
Response
The response format depends on the host
parameter:
When host: true
(hosted response)
Returns a JSON object with the URL of the hosted merged PDF:
{ "url": "https://assets.templated.io/renders/merged/merged-abc123.pdf"}
When host: false
(direct download)
Returns the merged PDF file directly in the response body with the following headers:
- Content-Type:
application/pdf
- Content-Disposition:
attachment; filename="merged_renders.pdf"
The PDF file can be downloaded and saved directly from the response.
Merge Order
The final PDF will contain pages in this order:
- Renders: In the order specified by the
ids
array - External PDFs: In the order specified by the
urls
array (if provided)
For example, if you provide ids: ["render1", "render2"]
and urls: ["doc1.pdf", "doc2.pdf"]
, the final PDF will contain: render1 → render2 → doc1.pdf → doc2.pdf