Users
Easily manage users with MailerSend's API. Invite, update, delete and retrieve a list of users in your account.
Get a list of account users
Retrieve information about account users with this GET request:
GET https://api.mailersend.com/v1/usersRequest parameters
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
limit | int | no | Min: 10, Max: 100 | Default: 25 |
page | int | no | Min: 1 |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->user->getAll();Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": [
{
"id": "83gwk2j7zqz1nxyd",
"avatar": null,
"email": "user@example.com",
"last_name": "User",
"name": "User",
"2fa": false,
"created_at": "2024-01-18T06:59:00.000000Z",
"updated_at": "2024-01-18T07:01:26.000000Z",
"role": "Custom User",
"permissions": ["read-suppressions", "read-invoice", "read-own-templates"],
"domains": [
{
"id": "0z76k5jg0o3yeg2d",
"name": "example-domain.com",
"created_at": "2024-02-20T08:13:17.000000Z",
"updated_at": "2024-02-20T08:13:22.000000Z"
},
{
"id": "9dnxr7qvdqg6pm0e",
"name": "another-domain.com",
"created_at": "2024-02-20T08:47:06.000000Z",
"updated_at": "2024-02-20T08:47:11.000000Z"
}
],
"templates": [
{
"id": "n3k6d1jreo50x4ve",
"name": "Template",
"description": null,
"type": "gh",
"created_at": "2024-02-23T15:40:51.000000Z"
}
]
}
],
"links": {
"first": "https://api.mailersend.com/v1/users?page=1",
"last": "https://api.mailersend.com/v1/users?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/users?page=1",
"label": "1",
"page": 1,
"active": true
},
{
"url": null,
"label": "Next »",
"page": null,
"active": false
}
],
"path": "https://api.mailersend.com/v1/users",
"per_page": 25,
"to": 1,
"total": 1
}
}Error
Response Code: 422 Unprocessable EntitySee - Validation errors
Get a single account user
If you want to retrieve a single account user, use this GET request:
GET https://api.mailersend.com/v1/users/{user_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
user_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->user->find('userId');Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "83gwk2j7zqz1nxyd",
"avatar": null,
"email": "user@example.com",
"last_name": "User",
"name": "User",
"2fa": false,
"created_at": "2024-01-18T06:59:00.000000Z",
"updated_at": "2024-01-18T07:01:26.000000Z",
"role": "Custom User",
"permissions": ["read-suppressions", "read-invoice", "read-own-templates"],
"domains": [
{
"id": "0z76k5jg0o3yeg2d",
"name": "example-domain.com",
"created_at": "2024-02-20T08:13:17.000000Z",
"updated_at": "2024-02-20T08:13:22.000000Z"
},
{
"id": "9dnxr7qvdqg6pm0e",
"name": "another-domain.com",
"created_at": "2024-02-20T08:47:06.000000Z",
"updated_at": "2024-02-20T08:47:11.000000Z"
}
],
"templates": [
{
"id": "n3k6d1jreo50x4ve",
"name": "Template",
"description": null,
"type": "gh",
"created_at": "2024-02-23T15:40:51.000000Z"
}
]
}
}Error
Response Code: 404 Not FoundInvite a user to account
If you want to add a new user to your account, use this POST request:
POST https://api.mailersend.com/v1/usersRequest Parameters
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
email | string | yes | Max 320 characters, unique | |
role | string | yes | Must be the name of a role, case-sensitive | View roles. When the account has as many users as its plan allows, only Accountant is accepted, and only while the free Accountant seat is unused. |
permissions | string[] | yes* | Must be list of permission names | *Only required if role is a Custom User. Ignored for other roles. View permissions |
templates | string[] | no | Must be list of template IDs | Requires read-own-templates in permissions. Ignored unless role is a Custom User. |
domains | string[] | no | Must be list of domain IDs | |
requires_periodic_password_change | boolean | no |
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\UserParams;
use MailerSend\Common\Roles;
use MailerSend\Common\Permissions;
$mailersend = new MailerSend(['api_key' => 'key']);
// Basic invite with admin role
$mailersend->user->create(
(new UserParams('newuser@example.com', Roles::ADMIN))
);
// Custom invite with specific permissions and access
$mailersend->user->create(
(new UserParams('designer@example.com', Roles::CUSTOM_USER))
->setDomains(['domain-id'])
->setTemplates(['template-id'])
->setPermissions([Permissions::READ_OWN_TEMPLATES])
->setRequiresPeriodicPasswordChange(true)
);Responses
| Response Key | Type | Details |
|---|---|---|
id | string | ID of the invite. |
email | string | Email address the invite was sent to. |
data.domains | string[] | IDs of the domains the user gets access to. |
data.templates | string[] | IDs of the templates the user gets access to. |
permissions | string[] | Permissions the user gets. |
role | string | Role the user gets. |
requires_periodic_password_change | boolean | Whether the user has to change their password periodically. |
created_at | datetime | |
updated_at | datetime |
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"id": "n3k6d1jrveq50x4v",
"email": "user@example.com",
"data": {
"domains": [],
"templates": []
},
"permissions": ["manage-api-token", "read-filemanager"],
"role": "Custom User",
"requires_periodic_password_change": false,
"created_at": "2024-01-24T06:40:19.000000Z",
"updated_at": "2024-01-24T06:40:19.000000Z"
}Invalid
Response Code: 422 Unprocessable EntitySee - Validation errors
Users limit error
Response Code: 403 Forbidden
Response Headers:
content-type: application/json{
"message": "You've reached the maximum users limit. Upgrade to add more users."
}Update account user
If you want to update the information of an existing account user, use this PUT request:
PUT https://api.mailersend.com/v1/users/{user_id}Request Parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
user_id | string | yes |
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
role | string | yes | Must be the name of a role, case-sensitive | View roles |
permissions | string[] | yes* | Must be list of permission names | *Only required if role is a Custom User. Ignored for other roles. View permissions |
templates | string[] | no | Must be list of template IDs | Requires read-own-templates in permissions. Reset unless role is a Custom User. |
domains | string[] | no | Must be list of domain IDs | |
requires_periodic_password_change | boolean | no |
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\UserParams;
use MailerSend\Common\Roles;
use MailerSend\Common\Permissions;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->user->update(
'userId',
(new UserParams())
->setRole(Roles::CUSTOM_USER)
->setDomains(['domain-id'])
->setPermissions([Permissions::READ_OWN_TEMPLATES])
->setRequiresPeriodicPasswordChange(true)
);Responses
| Response Key | Type | Details |
|---|---|---|
id | string | ID of the user. |
avatar | string|null | URL of the user's avatar. |
email | string | |
name | string | |
last_name | string | |
2fa | boolean | Whether two-factor authentication is on. |
role | string | |
permissions | string[] | |
domains | object[] | Domains the user has access to. |
templates | object[] | Templates the user has access to. |
created_at | datetime | |
updated_at | datetime |
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"id": "4k386zo42j07xv52",
"avatar": null,
"email": "user@example.com",
"last_name": "User",
"name": "User",
"2fa": false,
"created_at": "2024-01-22T09:35:04.000000Z",
"updated_at": "2024-01-22T23:40:44.000000Z",
"role": "Manager",
"permissions": [],
"domains": [
{
"id": "0z76k5jg0o3yeg2d",
"name": "example-domain.com",
"created_at": "2024-02-20T08:13:17.000000Z",
"updated_at": "2024-02-20T08:13:22.000000Z"
},
{
"id": "9dnxr7qvdqg6pm0e",
"name": "another-domain.com",
"created_at": "2024-02-20T08:47:06.000000Z",
"updated_at": "2024-02-20T08:47:11.000000Z"
}
],
"templates": [
{
"id": "n3k6d1jreo50x4ve",
"name": "Template",
"description": null,
"type": "gh",
"created_at": "2024-02-23T15:40:51.000000Z"
}
]
}Invalid
Response Code: 422 Unprocessable EntitySee - Validation errors
Users limit error
Response Code: 403 Forbidden
Response Headers:
content-type: application/json{
"message": "You've reached the maximum users limit. Upgrade to add more users."
}Delete a user from account
If you want to delete a user from account, use this DELETE request:
DELETE https://api.mailersend.com/v1/users/{user_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
user_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->user->delete('userId');Responses
Valid
Response Code: 204 No ContentError
Response Code: 404 Not FoundGet a list of invites
Retrieve information about account invited users with this GET request:
GET https://api.mailersend.com/v1/invitesRequest parameters
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
limit | int | no | Min: 10, Max: 100 | Default: 25 |
page | int | no | Min: 1 |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->invite->getAll();Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": [
{
"id": "dle1krod2jvn8gwm",
"email": "user@example.com",
"data": {
"domains": ["n3k6d1jrveq50x4v"],
"templates": ["0z76k5jg0o3yeg2d"]
},
"role": "Custom User",
"permissions": ["read-own-templates"],
"requires_periodic_password_change": true,
"created_at": "2024-04-25T17:09:23.000000Z",
"updated_at": "2024-04-25T17:09:23.000000Z"
}
],
"links": {
"first": "https://api.mailersend.com/v1/invites?page=1",
"last": "https://api.mailersend.com/v1/invites?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/invites?page=1",
"label": "1",
"page": 1,
"active": true
},
{
"url": null,
"label": "Next »",
"page": null,
"active": false
}
],
"path": "https://api.mailersend.com/v1/invites",
"per_page": 25,
"to": 1,
"total": 1
}
}Error
Response Code: 422 Unprocessable EntitySee - Validation errors
Get a single invite
If you want to retrieve a single invite, use this GET request:
GET https://api.mailersend.com/v1/invites/{invite_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
invite_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->invite->find('inviteId');Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"id": "dle1krod2jvn8gwm",
"email": "test7@user.com",
"data": {
"domains": ["n3k6d1jrveq50x4v"],
"templates": ["0z76k5jg0o3yeg2d"]
},
"role": "Custom User",
"permissions": ["read-own-templates"],
"requires_periodic_password_change": true,
"created_at": "2024-04-25T17:09:23.000000Z",
"updated_at": "2024-04-25T17:09:23.000000Z"
}Resend an invite
If you want to resend a user invite, use this POST request:
POST https://api.mailersend.com/v1/invites/{invite_id}/resendRequest parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
invite_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->invite->resend('inviteId');Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"id": "dle1krod2jvn8gwm",
"email": "test7@user.com",
"data": {
"domains": ["n3k6d1jrveq50x4v"],
"templates": ["0z76k5jg0o3yeg2d"]
},
"role": "Custom User",
"permissions": ["read-own-templates"],
"requires_periodic_password_change": true,
"created_at": "2024-04-25T17:09:23.000000Z",
"updated_at": "2024-04-25T17:09:23.000000Z"
}Error
Response Code: 404 Not FoundCancel an invite
If you want to cancel a user invite from account, use this DELETE request:
DELETE https://api.mailersend.com/v1/invites/{invite_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
invite_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->invite->cancel('inviteId');Responses
Valid
Response Code: 204 OKError
Response Code: 404 Not FoundRoles
| Name | Description |
|---|---|
| Admin | Administrator has full access and can perform all actions in the account. |
| Manager | Managers have full access, but can not access API or access billing. |
| Designer | Designers can only view and create templates. |
| Accountant | Can only manage payments and access invoices. |
| Custom User | Select the sections of your account that the user should have access to. |
Plans such as Free include one free seat that only an Accountant can use. Other roles count towards the plan's user limit. See resources.free_accountant_seat in Get account.
Permissions
| Name | Description | Group |
|---|---|---|
| read-all-templates | View all templates | Templates |
| read-own-templates | View specific templates | Templates |
| manage-template | Manage templates | Templates |
| read-filemanager | View the file manager | Templates |
| manage-domain | Manage domain | Domains |
| manage-inbound | Manage inbound routes | Domains |
| manage-webhook | Manage webhooks | Domains |
| control-sendings | Control sendings | Domains |
| control-tracking-options | Control tracking option | Domains |
| access-smtp-credentials | Access SMTP credentials | Domains |
| view-smtp-users | View SMTP users | Domains |
| manage-smtp-users | Manage SMTP users | Domains |
| read-recipient | View recipients | Recipient |
| read-activity | View email activity | Activity |
| read-email | View email content | Activity |
| read-analytics | View email analytics | Analytics |
| read-sender-identities | View sender identities | Sender identities |
| manage-sender-identities | Manage sender identities | Sender identities |
| read-email-verification | View email verifications lists | Email verification |
| manage-email-verification | Manage email verification lists | Email verification |
| manage-sms | Manage numbers | SMS |
| read-sms | View SMS activity | SMS |
| manage-verified-recipients | Manage verified recipients | SMS |
| view-sms-webhooks | View number webhooks | SMS |
| manage-sms-webhooks | Manage number webhooks | SMS |
| view-sms-inbound | View number inbound routes | SMS |
| manage-sms-inbound | Manage number inbound routes | SMS |
| view-whatsapp | View WhatsApp | |
| manage-whatsapp | Manage WhatsApp | |
| read-dmarc-monitoring | View DMARC monitoring lists | Monitoring |
| manage-dmarc-monitoring | Manage DMARC monitoring lists | Monitoring |
| read-blocklist-monitoring | View blocklist monitoring | Monitoring |
| manage-blocklist-monitoring | Manage blocklist monitoring | Monitoring |
| read-billing | View plan and billing information | Plan and Billing |
| update-plan | Manage plans | Plan and Billing |
| read-invoice | View invoices | Plan and Billing |
| manage-account | Edit account settings | Account settings |
| manage-api-token | Manage API tokens | Account settings |
| read-suppressions | View suppressions lists | Account settings |
| manage-suppressions | Manage suppressions | Account settings |
| read-ip-addresses | View IP allowlist | Account settings |
| manage-ip-addresses | Manage IP allowlist | Account settings |
| read-error-log | View error log | Account settings |