Skip to content

Save an event type's default template

PUT
/event-types/{name}/template
curl --request PUT \
--url https://api.sendtruss.com/v1/event-types/example/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "display_name": "example", "reply_to": "example", "locale": "example", "base_version": 1, "accept_outdated": true, "subject": "example", "from_local_part": "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" } } } }'

Writes the next version, live in every workspace at once: 201 for the first version, 200 after. A save identical to the current version writes nothing and answers with it, so you can push your templates on every deploy. Send base_version to have the save refused if someone saved a newer version since you read it.

name
required
string
Media typeapplication/json
object
display_name
string | null
<= 255 characters
reply_to
string | null
<= 320 characters
locale
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}))*$/
base_version

The version you started from. If someone has saved a newer one since, the save is refused with version_conflict.

integer | null
>= 1
accept_outdated

Save even though some translations were written for source text that has changed since.

boolean
subject
required

The subject line. It can carry merge tags such as {{ event.reference }}.

string
from_local_part
required

The part before the @ of the address the email comes from; your verified domain is the part after.

string
composition
required

The email’s content in composition format version 3: its blocks in order, each with its id, type and attributes. The console’s template editor writes the same format, so building the email there and reading it back is the quickest way to see one.

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

Translations by locale. Each maps a localizable text’s field id to its translated text and the source text it was translated from, which tells us when the source has changed since.

object
key
additional properties
object
key
additional properties
object
text
required
string
source
string | null
Media typeapplication/json
string
Examplegenerated
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.

Refused because of the resource’s current state. The code says why.

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: version_conflict
errors
required

The message again, under base_version.

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": "version_conflict"
}
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 translations_outdated
errors
required

Each field at fault, 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.