Manage Templates
Create, list, update, and delete message templates.
Manage reusable message templates via the API.
Scope: templates:write (create/update/delete), templates:read (list/get)
Rate limit: 1,000/hr
Create a template
POST /api/v1/templates
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique template name (used as a slug) |
subject | string | No | Subject line template (supports variables) |
body | string | Yes | HTML body with Handlebars variables |
description | string | No | Internal description |
curl -X POST https://api.platformxe.com/api/v1/templates \
-H "Content-Type: application/json" \
-H "x-api-key: pxk_live_your_api_key_here" \
-d '{
"name": "welcome-email",
"subject": "Welcome to {{appName}}, {{firstName}}!",
"body": "<h1>Welcome, {{firstName}}!</h1><p>Get started with {{appName}}.</p>",
"description": "Sent after user registration"
}'
await px.createTemplate({
name: 'welcome-email',
subject: 'Welcome to {{appName}}, {{firstName}}!',
body: '<h1>Welcome, {{firstName}}!</h1><p>Get started with {{appName}}.</p>',
description: 'Sent after user registration',
});
List templates
GET /api/v1/templates
curl https://api.platformxe.com/api/v1/templates \
-H "x-api-key: pxk_live_your_api_key_here"
const templates = await px.listTemplates();
Get a template
GET /api/v1/templates/:id
curl https://api.platformxe.com/api/v1/templates/tpl_abc123 \
-H "x-api-key: pxk_live_your_api_key_here"
Update a template
PATCH /api/v1/templates/:id
curl -X PATCH https://api.platformxe.com/api/v1/templates/tpl_abc123 \
-H "Content-Type: application/json" \
-H "x-api-key: pxk_live_your_api_key_here" \
-d '{
"body": "<h1>Welcome aboard, {{firstName}}!</h1><p>Your account is ready.</p>"
}'
Delete a template
DELETE /api/v1/templates/:id
curl -X DELETE https://api.platformxe.com/api/v1/templates/tpl_abc123 \
-H "x-api-key: pxk_live_your_api_key_here"
Deleting a template is permanent. Any code referencing the template ID will receive a NOT_FOUND error. Consider disabling templates instead by adding a deprecated flag in the description.
Error responses
| Code | Description |
|---|---|
BAD_REQUEST | Missing template name or body |
CONFLICT | Template with that name already exists |
FORBIDDEN | API key missing required scope |
NOT_FOUND | Template does not exist |