Skip to content

Preview a template

POST
/event-types/{name}/template/preview
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.

name
required
string
Media typeapplication/json
object
version

A saved version to render instead of the current one. Send this or draft, not both.

integer
>= 1
locale

The translation to render, such as pt-BR.

string
<= 35 characters /^[A-Za-z]{2,3}(-[A-Za-z]{4})?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*$/
timezone

The time zone dates render in. Defaults to UTC.

string
draft

An unsaved template to render, with the fields of a save. Send this or version, not both.

object
subject
required
string
from_local_part
required
string
display_name
string | null
reply_to
string | null
locale
string
composition
required
object
editorVersion
required
integer
Allowed value: 3
target
required
string
Allowed value: email
document
required
object
settings
object
key
additional properties
theme
object
key
additional properties
blocks
required
Array<object>
object
id
required
string
type
required
string
attrs
required
object
key
additional properties
children
Array<object>
object
key
additional properties
columns
Array<object>
object
key
additional properties
translations
object
key
additional properties
object
key
additional properties
object
text
required
string
source
string | null
payload

The event’s fields to render with, checked against its schema. Leave it out to render with sample values.

object | null
contact

The contact to render for, as the contacts API has them.

object
email
string | null
attributes
object | null
Media typeapplication/json
object
data
required
object
subject
required
string
html
required
string
text
required
string
from_local_part
required
string
display_name
required
string
reply_to
required
string | null
fallen_back
required
Array
Examplegenerated
{
"data": {
"subject": "example",
"html": "example",
"text": "example",
"from_local_part": "example",
"display_name": "example",
"reply_to": "example",
"fallen_back": [
"example"
]
}
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

The API key is missing, malformed, revoked or expired.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: unauthenticated
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "unauthenticated"
}
Request-Id
required
string format: uuid

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.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: not_found
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "not_found"
}
Request-Id
required
string format: uuid

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.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: validation_failed
errors
required

Each field that failed validation, by its path in the request, with its messages.

object
key
additional properties
Array<string>
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "validation_failed"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

Too many requests. Wait for the seconds in Retry-After.

Media typeapplication/json
object
message
required

What went wrong, for a person to read. It may change, so branch on code.

string
code
required

What went wrong, for your code to branch on. A new code is not a breaking change.

string
Allowed values: rate_limited
doc_url
required

The entry on our errors page that explains this code.

string format: uri
request_id
required

This request’s id, the same as its Request-Id header. Quote it when you ask us about the request.

string format: uuid
Example
{
"code": "rate_limited"
}
Request-Id
required
string format: uuid

This request’s id. Quote it when you ask us about the request.

Retry-After
integer

Seconds to wait before trying again.