Templates API

Create, list, update, and delete reusable message templates with merge tags.

GET /v1/templates

List all templates for your organization.

ParameterTypeDescription
channelstringFilter by channel
categorystringFilter by category
activebooleanFilter by active status
cURL
curl https://api.yoursend.dev/v1/templates?channel=email \
  -H "Authorization: Bearer ys_live_..."

GET /v1/templates/:id

Retrieve a single template by its ID.

cURL
curl https://api.yoursend.dev/v1/templates/tpl_abc123 \
  -H "Authorization: Bearer ys_live_..."

POST /v1/templates

Create a new template.

FieldTypeRequiredDescription
namestringYesTemplate name
channelstringYesemail, sms, voice, whatsapp
categorystringNoe.g. otp, reminder, receipt, transactional
subjectstringNoEmail subject line (supports merge tags)
html_bodystringNoHTML email body
text_bodystringNoPlain text email body
message_bodystringNoSMS/Voice/WhatsApp body
merge_tagsstring[]NoList of merge tag names used in the template
cURL
curl -X POST https://api.yoursend.dev/v1/templates \
  -H "Authorization: Bearer ys_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome Email",
    "channel": "email",
    "category": "transactional",
    "subject": "Welcome to {{app_name}}!",
    "html_body": "<h1>Hello {{name}}</h1><p>Welcome aboard.</p>",
    "text_body": "Hello {{name}}, welcome aboard.",
    "merge_tags": ["name", "app_name"]
  }'

PUT /v1/templates/:id

Update an existing template. Only pass the fields you want to change.

cURL
curl -X PUT https://api.yoursend.dev/v1/templates/tpl_abc123 \
  -H "Authorization: Bearer ys_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "subject": "Updated Subject", "is_active": true }'

DELETE /v1/templates/:id

Permanently delete a template.

cURL
curl -X DELETE https://api.yoursend.dev/v1/templates/tpl_abc123 \
  -H "Authorization: Bearer ys_live_..."
Response
{ "deleted": true }