POST /api/v1/templates
Creates a template. Answers 201.
The response adds one field to the template: unsupportedTags.
json
{
"success": true,
"data": {
"id": "…",
"name": "August newsletter",
"defaultSubject": "What shipped in August",
"content": "…",
"unsupportedTags": ["*|DATE:d F Y|*"],
"createdAt": "…",
"updatedAt": "…"
}
}Mailchimp merge tags are converted on the way in.
*|UNSUB|* becomes {{unsubscribeUrl}},
*|FNAME|* becomes {{firstName}}, *|CURRENT_YEAR|* becomes {{currentYear}}, and so on. A tag
with no equivalent is left exactly where it
is and listed in unsupportedTags — you find out while you write, not when the email lands in an
inbox with a raw *|DATE:d F Y|* in it.Authorization
| Role in the organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused — 403 |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | 1 to 100 characters |
defaultSubject | string | yes | 1 to 200 characters, used by campaigns that do not override it |
content | string | yes | The HTML of the email |
Example
bash
curl -X POST -H "x-api-key: $AGENTMAIL_API_KEY" -H "content-type: application/json" \
-d '{
"name": "August newsletter",
"defaultSubject": "What shipped in August",
"content": "<html><body><p>Hi {{firstName}}</p><a href=\"{{unsubscribeUrl}}\">Unsubscribe</a></body></html>"
}' \
"https://www.agentsmail.io/api/v1/templates"Response
201 Created— the created resource.401 Unauthorized— missing or invalid key, or its owner left the organization.403 Forbidden— the key's owner is amemberof the organization, not anadmin.429 Too Many Requests— over 120 requests in a minute for this key.
Response fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the operation was successful |
data.id | string | Unique identifier for the template |
data.name | string | Name of the template |
data.defaultSubject | string | Subject a campaign inherits, and may override |
data.content | string | The complete HTML document |
data.createdAt | string | ISO creation date |
data.updatedAt | string | ISO date of the last change |
data.unsupportedTags | array | Mailchimp tags left untouched in your HTML — read it |
Example response
json
{
"success": true,
"data": {
"id": "4d19c0a2",
"name": "Newsletter",
"defaultSubject": "August news",
"content": "<html>…</html>",
"createdAt": "2026-08-23T10:22:05.000Z",
"updatedAt": "2026-08-23T10:22:05.000Z",
"unsupportedTags": []
}
}