FlaresendDocs
Templates

Render a template

Preview what a template produces for some data, without sending anything.

POST/v1/templates/{name}/renderAPI key

Renders a template exactly as a send would, and returns the result. Nothing is stored or sent. Use it to preview a template or to check your data before sending.

The name is looked up like a send does: a template stored in the project first, then the built-in templates. The same checks apply too: required variables of a stored template, and the data schema of a built-in one.

Path parameters

namestringpathrequired

The template name.

Body parameters

The body is optional. Leaving it out is the same as sending { "data": {} }.

dataobjectdefault: {}

The values for the template's variables.

Response

subjectstring

The rendered subject.

htmlstring

The rendered HTML.

textstring

The rendered plain text. For a stored template without a text body, this is made from the rendered HTML.

Errors

StatusCodeWhen
400invalid_bodyThe body is not valid JSON, or data is not an object.
400invalid_template_dataA required variable is missing, or data doesn't match a built-in template's schema. param is the field, for example data.loginUrl.
400invalid_templateThe stored template has a syntax error.
404template_not_foundNo stored or built-in template with this name.