PlatformXeDocs
Get API Key

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

FieldTypeRequiredDescription
namestringYesUnique template name (used as a slug)
subjectstringNoSubject line template (supports variables)
bodystringYesHTML body with Handlebars variables
descriptionstringNoInternal 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

CodeDescription
BAD_REQUESTMissing template name or body
CONFLICTTemplate with that name already exists
FORBIDDENAPI key missing required scope
NOT_FOUNDTemplate does not exist