Developer Documentation
Feedback

Render a template

Rendering a template

To render a template, create a POST request to the /template/render endpoint. Use the templateName property as part of your request body specify the template you'd like to render.

MethodURLCreditsDescription
POSThttps://api.tailrender.com/template/render1Render a template
GET/render/{renderId}0Get the result of a previously rendered file

Request body

NameTypedefaultDescription
templateNamestring*requiredDesired template to render
propsobjectnullProperties to pass to the render
webhookUrlstring''When specified, the API will deliver a POST request to this endpoint with the render result payload

Optionally, you can overwrite the properties saved on the template by passing those properties as part of the request body. The overwritten properties will not be saved on the template.

Passing properties

The template API supports passing properties to the render. Properties are passed to the template as a JSON object. Use the props field to pass properties to the render. The API uses Mustache under the hood to render the template. See the Mustache documentation for more information on how to use Mustache syntax. Additionally, any props passed to the render will appear on the render result object. This is useful when attempting to associate render webhooks received from the API.

Webhooks

Instead of synchronous generation, you can choose to have your render result delivered via webhook instead. To use webhook delivery, specify the webhook URL using the webhookUrl field. The API will respond with a 202 Accepted status code when your render request is received. When the render is complete, the API will deliver a POST request to the webhook URL with the render result payload. Three attempts will be made to deliver the webhook, each with a delay of 15 seconds between requests, before declaring the result undeliverable.

Example request

javascript
const body = {
templateName: "resume-template",
props: {
email: "jane.smith@gmail.com",
phone: "(555) 234-2344"
}
};
const response = await fetch('https://api.tailrender.com/template/render', {
method: 'POST',
headers: {
Authorization: "{{ YOUR_API_KEY }}",
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
const json = response.json();

Example response body

json
{
"id": "r5mT9aAuUhstaJYBNGcJ",
"templateName": "resume-template",
"status": "COMPLETED",
"result": {
"pdfUrl": "https://tailrender-api.s3.amazonaws.com/pdf/r5mT9aAuUhstaJYBNGcJ.pdf",
"url": "https://tailrender-api.s3.amazonaws.com/pdf/r5mT9aAuUhstaJYBNGcJ.pdf"
},
"props": {
"phone": "(555) 234-2344",
"email": "jane.smith@gmail.com"
}
}

Errors

You may receive an error while attempting to render your file. Errors while generating files are quite rare, however, if the error persists, please contact support.

A file generation error might look like the following:

json
{
"id": "lhXcGjxf63vq27odmqCb",
"status": "ERROR",
"error": "An unknown error occurred while attempting to generate this file."
}