v24

latestOpenAPI 3.0.3raw.githubusercontent.com2026-08-014382230.2 KB

Create a template

Creates a new template. Each template must have a channel (email or web) with corresponding channel-specific content.

post/api/templates.create

Request body

workspace_idstring required

The ID of the workspace

idstring required

Unique identifier for the template (alphanumeric, underscores, and hyphens only)

namestring required

Name of the template

channel'email' | 'web' required

Communication channel

category'marketing' | 'transactional' | 'welcome' | 'opt_in' | 'unsubscribe' | 'bounce' | 'blocklist' | 'blog' | 'other' required

Template category

template_macro_idstring nullable

ID of the template macro (layout) to use

test_dataobject

Test data for template preview

settingsobject

Channel-specific settings

Example request

{
  "workspace_id": "ws_1234567890",
  "id": "welcome_email",
  "name": "Welcome Email",
  "channel": "email",
  "email": {
    "sender_id": "sender_123",
    "reply_to": "support@example.com",
    "subject": "Welcome, {{user_name}}!",
    "subject_preview": "Get started with your account",
    "visual_editor_tree": {
      "type": "mjml",
      "children": []
    }
  },
  "category": "transactional"
}

Response

Template created successfully

Example response

{
  "template": {
    "id": "welcome_email",
    "name": "Welcome Email",
    "version": 1,
    "channel": "email",
    "email": {
      "sender_id": "sender_123",
      "reply_to": "support@example.com",
      "subject": "Welcome, {{user_name}}!",
      "subject_preview": "Get started with your account",
      "visual_editor_tree": {
        "type": "mjml",
        "children": []
      }
    },
    "category": "transactional",
    "test_data": {
      "user_name": "John Doe",
      "action_url": "https://example.com/action"
    }
  }
}