Get a paginated list of Email Templates (Experimental)
Returns a paginated list of the email templates in your account.
/api/templates is the conventions-compliant replacement for /api/email_templates: it wraps every response in a data envelope, takes a flat request body on writes, and paginates this list, where GET /api/email_templates returns every template as a single unpaginated array. /api/email_templates keeps its published shapes and is unaffected.
Pagination is page-token based: pass the token query parameter and follow the next_token and prev_token values returned in the pagination object to walk between pages.
A per_page above 100 is clamped to 100 rather than rejected. A token past the last page returns an empty data array rather than an error: the pagination object echoes the token you asked for, and prev_token points at the last page that has data. Follow the tokens returned by a previous response rather than constructing them by hand — a token whose offset ((token - 1) * per_page) overflows a 64-bit integer is rejected with 422.
API token in Api-Token header
Page number to retrieve (page-token pagination). Defaults to 1.
1Example: 1Number of templates per page. Defaults to 50, maximum 100. Larger values are clamped to 100.
50Example: 50OK.
Returns unauthorized error message. Check your credentials.
Returns forbidden error message. Check your permissions.
The token is too large to paginate with — its offset overflows a 64-bit integer.
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 GET "https://mailtrap.io/api/templates?per_page=50&token=1" \
-H "Api-Token: YOUR_API_KEY"
{
"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"
}
],
"pagination": {
"token": 1,
"prev_token": null,
"next_token": 2,
"first_url": "https://mailtrap.io/api/templates?per_page=50&token=1",
"prev_url": null,
"current_url": "https://mailtrap.io/api/templates?per_page=50&token=1",
"next_url": "https://mailtrap.io/api/templates?per_page=50&token=2"
}
}Last updated
Was this helpful?

