Templates API
Create, list, update, and delete reusable message templates with merge tags.
GET /v1/templates
List all templates for your organization.
| Parameter | Type | Description |
|---|---|---|
channel | string | Filter by channel |
category | string | Filter by category |
active | boolean | Filter 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.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
channel | string | Yes | email, sms, voice, whatsapp |
category | string | No | e.g. otp, reminder, receipt, transactional |
subject | string | No | Email subject line (supports merge tags) |
html_body | string | No | HTML email body |
text_body | string | No | Plain text email body |
message_body | string | No | SMS/Voice/WhatsApp body |
merge_tags | string[] | No | List 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 }