Templates API
List, create, update and delete HTML email templates.
How templates work
A template is a reusable email design stored as full HTML. Templates created through the API appear under Templates in the app, can be edited in the HTML editor, and can be used as the starting point for campaigns and automation emails. Merge tags such as {{firstName}} and {{coupon_code}}, and product blocks using template syntax like {% for item in line_items %}, are rendered per recipient at send time. Dynamic product feeds use the same syntax with feed.<slug> as the collection, for example {% for item in feed.recently_viewed limit:4 %} wrapped in {% if feed.recently_viewed %}. Built-in slugs are recently_viewed, cart, recommended, best_sellers and new_arrivals; custom feeds are defined under Integrations, Product feeds in the app. Items expose name, url, image, price, compare_at_price, currency, vendor, category and product_id (plus quantity and line_total for cart). For multilingual catalogs each item is rendered in the recipient's language (subscriber language field, then the language they browsed in, then the store default); add a lang modifier to fix it, for example {% for item in feed.best_sellers limit:4 lang:en %}.
Use the optional category field to organize designs, for example welcome, newsletter or custom (the default).
Use cases
- Push designs from your own design pipeline or repository into the platform.
- Keep one master template in sync across several accounts or environments.
- Fetch a template’s HTML to render previews in your own tools.
- Create seasonal variants of a base template programmatically.
Endpoints
List templates
/templates-apiReturns your email templates. HTML templates created through this API are editable in the HTML editor.
curl -X GET "https://api.mailingplatform.net/templates-api?category=welcome&limit=50" \ -H "Authorization: Bearer mp_live_..."
Get single template
/templates-api/{id}Retrieve one template by id, including its full HTML content.
| Name | Type | Description |
|---|---|---|
idrequired | string | Template id (path). |
curl -X GET "https://api.mailingplatform.net/templates-api/{id}" \
-H "Authorization: Bearer mp_live_..."Create template
/templates-apiCreate an HTML template. Required fields: name, html.
| Name | Type | Description |
|---|---|---|
namerequired | string | Template name. |
htmlrequired | string | HTML content. Merge tags such as {{firstName}} are supported. |
category | string | Optional category, for example welcome. |
description | string | Optional description. |
curl -X POST "https://api.mailingplatform.net/templates-api" \
-H "Authorization: Bearer mp_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome email",
"category": "welcome",
"description": "Optional",
"html": "<!DOCTYPE html><html><body>Hello {{firstName}}</body></html>"
}'Update template
/templates-api/{id}Update an existing template. Send only the fields you want to change. At least one of name, description, category, or html is required. Updating html replaces the template content and keeps it editable in the HTML editor.
curl -X PUT "https://api.mailingplatform.net/templates-api/{id}" \
-H "Authorization: Bearer mp_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome email",
"category": "welcome",
"description": "Updated description",
"html": "<!DOCTYPE html><html><body>Hello {{firstName}}</body></html>"
}'Delete template
/templates-api/{id}Permanently delete a template you own. Returns 404 if the template does not exist. The delete is rejected if an automation email still references the template.
curl -X DELETE "https://api.mailingplatform.net/templates-api/{id}" \
-H "Authorization: Bearer mp_live_..."