Create Email Template (Experimental)
Creates an email template and returns it in a data envelope.
The request body is flat, where POST /api/email_templates expects the attributes wrapped in email_template. That wrapper is still accepted here, so you can switch the path first and flatten the body afterwards.
API token in Api-Token header
Email template created successfully.
Returns unauthorized error message. Check your credentials.
Returns forbidden error message. Check your permissions.
Validation errors, or the account has reached its plan's template limit.
Too many requests. Two limits apply: 150 requests per minute per account on this endpoint,
counted in separate allowances for listing and for creating, and the global 150 requests
per 10 seconds per API token. The response body tells them apart, and only the global
throttle sets the x-ratelimit-* headers.
curl -X POST "https://mailtrap.io/api/templates" \
-H "Api-Token: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email",
"subject": "Welcome to {{company_name}}!",
"category": "onboarding",
"body_html": "<h1>Welcome {{user_name}}!</h1>",
"body_text": "Welcome {{user_name}}!"
}'
{
"data": {
"id": 26730,
"uuid": "018dd5e3-f6d2-7c00-8f9b-e5c3f2d8a132",
"name": "My Email Template",
"subject": "Promotional Email",
"category": "Promotional",
"body_html": "<div>Template Body</div>",
"body_text": "Template Body",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z"
}
}Last updated
Was this helpful?

