Save an event type's default template
const url = 'https://api.sendtruss.com/v1/event-types/example/template';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"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"}}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
The version you started from. If someone has saved a newer one since, the save is refused with version_conflict.
Save even though some translations were written for source text that has changed since.
The subject line. It can carry merge tags such as {{ event.reference }}.
The part before the @ of the address the email comes from; your verified domain is the part after.
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
object
object
object
object
object
object
object
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
object
object
Responses
Section titled “Responses”Examplegenerated
exampleHeaders
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.
Refused because of the resource’s current state. The code says why.
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 message again, under base_version.
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": "version_conflict"}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 at fault, 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.