Templates and assets tools
Write email and SMS templates, preview them exactly as they will send, host the images they use and send yourself a test.
- upsert_template
- list_templates
- preview_template
- delete_template
- upload_asset
- list_assets
- delete_asset
- send_test_email
- send_test_sms
upsert_template
Create/update a template by key. Returns non-blocking CSS compatibility warnings alongside the saved template. Full replace: omitting header_html clears it; empty or whitespace-only header_html stores null. `channel` defaults to 'email'. EMAIL templates require `subject` + a body (`html`, preferred, or `mjml` compiled server-side). SMS templates (`channel:'sms'`) require `text` (the message body, plain text with {{tokens}}); subject/html/header_html/mjml/preheader are ignored. {{tokens}} are substituted at send time; SMS appends a 'Reply STOP to opt out' suffix automatically. Only the channel's required fields are validated (missing them ⇒ 422); fields not used by the channel are ignored.
keystringrequirednamestringrequiredchannelenum- email | sms
Sending channel; defaults to 'email'. 'sms' ⇒ provide `text`; subject/html/header_html/mjml are ignored. subjectstring- Email only — required for channel 'email'.
preheaderstringheader_htmlstring- Email only — inert header fragment in an unpadded row above the body.
htmlstring- Email only — inert body fragment (no <html>/<body>).
mjmlstring- Email only — compiled to html server-side.
textstring- SMS body (required for channel 'sms'); also the plain-text alt for email.
sample_tokensobject (any keys)required_tokensstring[]tagsstring[]- Interest tags (e.g. ['bed-bug']) stamped onto a contact's properties.tags when they CLICK this email.
teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
list_templates
List templates for the team.
teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
preview_template
Render a template (stored by key, or inline) with sample data — the browser HTML matches production output. Email previews also return gmail_html (a Gmail approximation) and non-blocking CSS compatibility warnings. SMS templates (or inline channel:'sms' + text) return { channel:'sms', text, segments }.
keystringchannelenum- email | sms
Channel for inline preview. Required when providing inline `text` without a stored key. subjectstringpreheaderstringheader_htmlstring- Email only — inert header fragment in an unpadded row above the body.
htmlstringtextstringsampleobjectsample.emailstringsample.namestringsample.propertiesobject (any keys)sample.eventobject- Fills {{event.*}} tokens, e.g. { properties: { advisor_first_name: 'Kevin' } }. Omit to render event tokens with their defaults.
sample.event.namestringsample.event.propertiesobject (any keys)teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
delete_template
Delete a template by id (get it from list_templates). Refused if any sequence step, A/B variant arm, or broadcast still references it (including soft-deleted steps, which preserve send history) — remove or replace those references first.
template_idstringrequiredteamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
upload_asset
Upload a public image to this team's media library. Provide EXACTLY ONE of `source_url` or `content_base64` (XOR); providing both or neither returns 422. Images only: structurally validated PNG, JPEG, GIF, or WebP. Base64 uploads are limited to 3 MiB decoded; source_url fetches are limited to 10 MiB. `filename` is optional display/path metadata and never determines the file type.
source_urlstring- Remote http(s) image URL. Provide this XOR content_base64.
content_base64string- Base64-encoded image bytes, up to 3 MiB decoded. Provide this XOR source_url.
filenamestring- Optional human-readable filename.
teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
list_assets
List public image assets for the team, newest first. Set include_usage to see template URL usage and social_usage post IDs retaining each image; retained social images cannot be deleted.
limitnumberinclude_usagebooleanteamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
delete_asset
Delete one team asset by id. Use list_assets with include_usage:true first: template usage is advisory; social_usage lists post IDs retaining the image. Social references block deletion with asset_in_use and post_ids until safe to release.
idstringrequiredteamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
send_test_email
Send a one-off test render of a template to an address (no enrollment).
tostringrequiredkeystringsubjectstringpreheaderstringheader_htmlstring- Email only — inert header fragment in an unpadded row above the body.
htmlstringtextstringsampleobjectsample.emailstringsample.namestringsample.propertiesobject (any keys)sample.eventobject- Fills {{event.*}} tokens, e.g. { properties: { advisor_first_name: 'Kevin' } }. Omit to render event tokens with their defaults.
sample.event.namestringsample.event.propertiesobject (any keys)teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.
send_test_sms
Send a one-off test SMS render to a phone number (no enrollment). Returns the rendered text, segment count, and estimated cost. Provide an SMS template `key` or inline `text`. If the team has no registered SMS sender yet, it renders + prices but does not send (reason: 'no_sender').
tostringrequired- E.164 recipient, e.g. +15551234567.
keystring- SMS template key. Provide this or `text`.
textstring- Inline SMS body ({{tokens}}). Provide this or `key`.
sampleobjectsample.emailstringsample.namestringsample.propertiesobject (any keys)sample.eventobject- Fills {{event.*}} tokens, e.g. { properties: { advisor_first_name: 'Kevin' } }. Omit to render event tokens with their defaults.
sample.event.namestringsample.event.propertiesobject (any keys)teamstringrequired- Brand/team to act on (slug or id) → X-Cadence-Team. Required — your account key authorizes every brand you own, so this picks which one.