Preview a template
const url = 'https://api.sendtruss.com/v1/event-types/example/template/preview';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"version":1,"locale":"example","timezone":"example","draft":{"subject":"example","from_local_part":"example","display_name":"example","reply_to":"example","locale":"example","composition":{"editorVersion":3,"target":"email","document":{"settings":{"additionalProperty":"example"},"theme":{"additionalProperty":"example"},"blocks":[{"id":"example","type":"example","attrs":{"additionalProperty":"example"},"children":[{"additionalProperty":"example"}],"columns":[{"additionalProperty":"example"}]}]}},"translations":{"additionalProperty":{"additionalProperty":{"text":"example","source":"example"}}}},"payload":"example","contact":{"email":"example","attributes":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sendtruss.com/v1/event-types/example/template/preview \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "version": 1, "locale": "example", "timezone": "example", "draft": { "subject": "example", "from_local_part": "example", "display_name": "example", "reply_to": "example", "locale": "example", "composition": { "editorVersion": 3, "target": "email", "document": { "settings": { "additionalProperty": "example" }, "theme": { "additionalProperty": "example" }, "blocks": [ { "id": "example", "type": "example", "attrs": { "additionalProperty": "example" }, "children": [ { "additionalProperty": "example" } ], "columns": [ { "additionalProperty": "example" } ] } ] } }, "translations": { "additionalProperty": { "additionalProperty": { "text": "example", "source": "example" } } } }, "payload": "example", "contact": { "email": "example", "attributes": "example" } }'Renders the email a send would, without sending it: an unsaved draft,
a saved version, or the current version when you send neither. With
no payload or contact, sample values fill in. A payload you send is
checked against the schema, and an optional field it leaves out renders
its fallback, as in a send. The workspace name shows a sample name.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Body
Section titled “Request Body”object
A saved version to render instead of the current one. Send this or draft, not both.
The translation to render, such as pt-BR.
The time zone dates render in. Defaults to UTC.
An unsaved template to render, with the fields of a save. Send this or version, not both.
object
object
object
object
object
object
object
object
object
object
object
object
The event’s fields to render with, checked against its schema. Leave it out to render with sample values.
The contact to render for, as the contacts API has them.
object
Responses
Section titled “Responses”object
object
Examplegenerated
{ "data": { "subject": "example", "html": "example", "text": "example", "from_local_part": "example", "display_name": "example", "reply_to": "example", "fallen_back": [ "example" ] }}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
The API key is missing, malformed, revoked or expired.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "unauthenticated"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
Nothing is at this path for your key. Another platform’s or another workspace’s resource answers the same as one that doesn’t exist.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "not_found"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
The request is invalid. The code says why, and errors names each field at fault.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
Each field that failed validation, by its path in the request, with its messages.
object
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "validation_failed"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
Too many requests. Wait for the seconds in Retry-After.
object
What went wrong, for a person to read. It may change, so branch on code.
What went wrong, for your code to branch on. A new code is not a breaking change.
The entry on our errors page that explains this code.
This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.
Example
{ "code": "rate_limited"}Headers
Section titled “Headers”This request’s id. Quote it when you ask us about the request.
Seconds to wait before trying again.