Skip to Content
MailerSend
Account

Tokens

Create and manage API tokens for MailerSend Email API. Securely authenticate and authorize access to your account with ease.

You need to add a sending domain token to authenticate your API requests. API tokens are generated for sending domains and can have different permissions to limit which areas of your account they may be used to access.

List tokens

List API token with this GET request:

GET  https://api.mailersend.com/v1/token

Request parameters

Query parameterTypeRequiredLimitationsDetails
pageintnoMin: 1
limitintnoMin: 10, Max: 100Default: 25

Request Body

use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\TokenParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->token->getAll();

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": [
    {
      "id": "481c8fdf59036be3f102b1ee6052e0f50a42051702dc5c820c1753d1752adc41ba5b1aaaaaaaaa",
      "name": "First token",
      "status": "unpause",
      "created_at": "2024-04-12T11:27:53.000000Z",
      "scopes": ["email_full"],
      "domain": {
        "id": "yjm4ej",
        "name": "example.org",
        "created_at": "2020-06-10T10:09:50.000000Z",
        "updated_at": "2020-06-10T10:09:50.000000Z"
      }
    },
    {
      "id": "481c8fdf59036be3f102b1ee6052e0f50a42051702dc5c820c1753d1752adc41ba5b12aaaaaaaaa",
      "name": "Second token",
      "status": "unpause",
      "created_at": "2024-04-17T08:40:13.000000Z",
      "scopes": ["domains_read", "analytics_full"],
      "domain": {
        "id": "yjm4ej",
        "name": "example.org",
        "created_at": "2020-06-10T10:09:50.000000Z",
        "updated_at": "2020-06-10T10:09:50.000000Z"
      }
    }
  ],
  "links": {
    "first": "https://api.mailersend.com/v1/token?page=1",
    "last": "https://api.mailersend.com/v1/token?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "page": null,
        "active": false
      },
      {
        "url": "https://api.mailersend.com/v1/token?page=1",
        "label": "1",
        "page": 1,
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "page": null,
        "active": false
      }
    ],
    "path": "https://api.mailersend.com/v1/token",
    "per_page": 25,
    "to": 2,
    "total": 2
  }
}

Show a token

View API token with this GET request:

GET  https://api.mailersend.com/v1/token/{token_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
token_idstringyes

Request Body

use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\TokenParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->token->find('token_id');

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "481c8fdf59036be3f102b1ee6052e0f50a42051702dc5c820c1753d1752adc41ba5b1aaaaaaaaa",
    "name": "First token",
    "status": "unpause",
    "created_at": "2024-04-12T11:27:53.000000Z",
    "scopes": ["email_full"],
    "domain": {
      "id": "yjm4ej",
      "name": "example.org",
      "created_at": "2020-06-10T10:09:50.000000Z",
      "updated_at": "2020-06-10T10:09:50.000000Z"
    }
  }
}

Error

Response Code: 404 Not Found

Create a token

Create an API token with this POST request:

POST  https://api.mailersend.com/v1/token

Request Body

{
    "name": "API Token",
    "domain_id": "Domain ID",
    "scopes" : ["email_full", "analytics_read"]
}

Request parameters

JSON parameters are provided in dot notation.

JSON parameterTypeRequiredLimitationsDetails
namestringyesMax: 50
domain_idstringnoMust be a verified domain ID
scopesarrayyes
Possible scopes
 [
     "email_full",
     "domains_read",
     "domains_full",
     "activity_read",
     "activity_full",
     "analytics_read",
     "analytics_full",
     "tokens_full",
     "webhooks_full",
     "templates_full",
     "suppressions_read",
     "suppressions_full",
     "sms_full",
     "sms_read",
     "email_verification_read",
     "email_verification_full",
     "inbounds_full",
     "recipients_read",
     "recipients_full",
     "sender_identity_read",
     "sender_identity_full",
     "users_read",
     "users_full",
     "smtp_users_read",
     "smtp_users_full",
     "dmarc_monitoring_read",
     "dmarc_monitoring_full",
     "blocklist_monitoring_read",
     "blocklist_monitoring_full",
     "whatsapp_read",
     "whatsapp_full"
   ]

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "b74c547a741e199d29c2bb38703fc4642c486841ab568b9fddc83be12329727022f6fb98291efd62",
    "accessToken": "[redacted]",
    "name": "Token",
    "created_at": "2020-06-10T10:10:14.000000Z",
    "scopes": [
      "email_full",
      "domains_read"
    ],
    "has_full": false,
    "has_only_sending": false,
    "domain": {
      "id": "dle1krod2jvn8gwm",
      "name": "testname.com",
      "dkim": null,
      "spf": null,
      "mx": null,
      "tracking": null,
      "is_verified": false,
      "is_dns_active": false,
      "is_trial_domain": false,
      "domain_settings": {
        "send_paused": false,
        "send_paused_by_downgrade": false,
        "track_clicks": true,
        "track_opens": true,
        "track_opens_pixel_on_top": false,
        "track_unsubscribe": false,
        "track_unsubscribe_html": "<p>Click here to <a href=\"{{unsubscribe}}\">unsubscribe</a></p>",
        "track_unsubscribe_html_enabled": false,
        "track_unsubscribe_plain": "Click here to unsubscribe: {{unsubscribe}}",
        "track_unsubscribe_plain_enabled": false,
        "track_content": false,
        "custom_tracking_enabled": false,
        "custom_tracking_subdomain": "email",
        "return_path_subdomain": "mta",
        "inbound_routing_enabled": false,
        "inbound_routing_subdomain": "inbound",
        "precedence_bulk": false,
        "ignore_duplicated_recipients": false
      },
      "can": {
        "manage": true
      },
      "totals": [],
      "is_being_verified": false,
      "is_custom_links_available": false,
      "needs_dkim_migration": false,
      "dkim_deprecation_date": "February 1, 2027"
    },
    "preview": "mlsn.4f2a9c",
    "expires_at": null
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Update a token

Update an API token with this PUT request:

PUT https://api.mailersend.com/v1/token/{token_id}/settings

Request parameters

URL parameterTypeRequiredLimitationsDetails
token_idstringyes

Request Body

{
    "status": "pause"
}

Request parameters

JSON parameters are provided in dot notation.

JSON parameterTypeRequiredLimitationsDetails
namestringrequired without statusMax: 50
statusstringnopause, unpause

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "481c8fdf59036be3f102b1ee6052e0f50a42051702dc5c820c1753d1752adc41ba5b1aaaaaaaaa",
    "name": "First token",
    "status": "unpause",
    "created_at": "2024-04-12T11:27:53.000000Z",
    "scopes": ["email_full"],
    "domain": {
      "id": "yjm4ej",
      "name": "example.org",
      "created_at": "2020-06-10T10:09:50.000000Z",
      "updated_at": "2020-06-10T10:09:50.000000Z"
    }
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Change token name

Change an API token name with this PUT request:

PUT https://api.mailersend.com/v1/token/{token_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
token_idstringyes

Request Body

{
    "name": "new name"
}

Request parameters

JSON parameters are provided in dot notation.

JSON parameterTypeRequiredLimitationsDetails
namestringrequired without statusmax length 50 chars
statusstringnopause, unpause

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "481c8fdf59036be3f102b1ee6052e0f50a42051702dc5c820c1753d1752adc41ba5b1aaaaaaaaa",
    "name": "First token",
    "status": "unpause",
    "created_at": "2024-04-12T11:27:53.000000Z",
    "scopes": ["email_full"],
    "domain": {
      "id": "yjm4ej",
      "name": "example.org",
      "created_at": "2020-06-10T10:09:50.000000Z",
      "updated_at": "2020-06-10T10:09:50.000000Z"
    }
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Delete a token

Delete an API token with this DELETE request:

DELETE  https://api.mailersend.com/v1/token/{token_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
token_idstringyes
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\TokenParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->token->delete('token_id');

More examples

Responses

Valid

Response Code: 200 OK
Response Body: [EMPTY]

Error

Response Code: 404 Not Found

On this page