Create a template

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 organizationThis endpoint
OWNERAllowed
ADMINAllowed
MEMBERRefused — 403
A key carries the role its creator holds in this organization — never a role on AgentsMail itself. See API keys.

Request body

FieldTypeRequiredDescription
namestringyes1 to 100 characters
defaultSubjectstringyes1 to 200 characters, used by campaigns that do not override it
contentstringyesThe 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 a member of the organization, not an admin.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Response fields

FieldTypeDescription
successbooleanIndicates if the operation was successful
data.idstringUnique identifier for the template
data.namestringName of the template
data.defaultSubjectstringSubject a campaign inherits, and may override
data.contentstringThe complete HTML document
data.createdAtstringISO creation date
data.updatedAtstringISO date of the last change
data.unsupportedTagsarrayMailchimp 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": []
  }
}