For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

get
Authorizations
Api-TokenstringRequired

API token in Api-Token header

Query parameters
tokeninteger · int64 · min: 1Optional

Page number to retrieve (page-token pagination). Defaults to 1.

Default: 1Example: 1
per_pageinteger · min: 1Optional

Number of templates per page. Defaults to 50, maximum 100. Larger values are clamped to 100.

Default: 50Example: 50
Responses
200

OK.

application/json
get/api/templates
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?