Documentation

Update Template

Update an existing email template. Changing mjml recompiles the stored HTML.

A test key cannot update a production template (403). A production key only updates production templates โ€” test templates are not found. To copy a test template into production, promote it.

PATCH /templates/:template_id
Example: /templates/welcome

Path Parameters

template_id string required

The template TypeID or user_id.

Body Parameters

name string

A name for the template. Unique per domain and mode.

user_id string

A stable identifier you supply, unique per domain and mode.

mjml string

MJML source. Compiled to HTML in the email. Required unless content is provided.

content string

HTML (or plain text). Required unless mjml is provided. Do not send with mjml.

from string

Default From address used when sending if the send request omits from.

to array

Default recipients used when sending if the send request omits to.

subject string

Default subject used when sending if the send request omits subject. Placeholders such as {{name}} are filled from data at send time.

Note

mjml, content, and subject can have dynamic content using our template language

Example

curl -X PATCH https://api.mailcast.io/v1/templates/:template_id \
     -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d $'{
  "name": "welcome-updated",
  "mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Hi {{name}}</mj-text></mj-column></mj-section></mj-body></mjml>",
  "subject": "Hi {{name}}"
}'
Response 200
{
  "template_id": "template_01k3tgwp77fcdtsekk1v9qf4rr",
  "user_id": "welcome",
  "name": "welcome-updated",
  "mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Hi {{name}}</mj-text></mj-column></mj-section></mj-body></mjml>",
  "from": "hello@example.com",
  "to": null,
  "subject": "Hi {{name}}",
  "test_only": false,
  "created_at": "2025-08-29T12:00:00Z",
  "updated_at": "2025-08-29T13:30:00Z"
}