Users Get a list of account users Retrieve information about account users with this GET request:
GET https://api.mailersend.com/v1/users
Request parameters Query parameter Type Required Limitations Details limitintno Min: 10, Max: 100 Default: 25 pageintno Min: 1
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. user. list ( )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. page( 1 )
. limit( 25 )
. build_users_list( ) )
response = ms. users. list_users( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
options := & mailersend. ListUserOptions{
Page: 1 ,
Limit: 25 ,
}
_ , _ , err := ms. User. List ( ctx, options)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. users. User ;
import com. mailersend. sdk. users. UsersList ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void ListUsers ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
UsersList list = ms. users ( ) . getUsers ( 1 , 25 ) ;
for ( User user : list. users) {
System . out. println ( user. id) ;
System . out. println ( user. email) ;
}
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
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" ,
"type" : "gh" ,
"created_at" : "2024-02-23T15:40:51.000000Z"
}
]
}
]
}
Error Response Code: 404 Not Found
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_idstringyes
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. user. single ( "user-id" )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. user_id( "user-id" )
. build_user_get( ) )
response = ms. users. get_user( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
userID := "user-id"
_ , _ , err := ms. User. Get ( ctx, userID)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. users. User ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void GetUser ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
User user = ms. users ( ) . getUser ( "user-id" ) ;
System . out. println ( user. id) ;
System . out. println ( user. email) ;
System . out. println ( user. name) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
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" ,
"type" : "gh" ,
"created_at" : "2024-02-23T15:40:51.000000Z"
}
]
}
}
Error Response Code: 404 Not Found
Invite 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/users
Request Parameters JSON parameters are provided in dot notation
JSON Parameter Type Required Limitations Details emailstringyes Max 320 characters, uniquerolestringyes Must be the name of a role View roles permissionsstring[]yes* Must be list of permission names *Only required if role is a Custom User. View permissions templatesstring[]no Must be list of template IDs domainsstring[]no Must be list of domain IDs requires_periodic_password_changebooleanno
PHP NodeJS Python Go Java Ruby use MailerSend\ MailerSend ;
use MailerSend\ Helpers\ Builder\ UserParams ;
use MailerSend\ Common\ Roles ;
use MailerSend\ Common\ Permissions ;
$mailersend = new MailerSend ( [ 'api_key' => 'key' ] ) ;
$mailersend -> user -> create (
( new UserParams ( 'newuser@example.com' , Roles :: ADMIN ) )
) ;
$mailersend -> user -> create (
( new UserParams ( 'designer@example.com' , Roles :: CUSTOM_USER ) )
-> setDomains ( [ 'domain-id' ] )
-> setTemplates ( [ 'template-id' ] )
-> setPermissions ( [ Permissions :: READ_OWN_TEMPLATES ] )
-> setRequiresPeriodicPasswordChange ( true )
) ;
More examplesopen in new window
import 'dotenv/config' ;
import { MailerSend, User } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
const user = new User ( )
. setEmail ( "newuser@example.com" )
. setRole ( "admin" ) ;
mailerSend. user. create ( user)
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
const customUser = new User ( )
. setEmail ( "designer@example.com" )
. setRole ( "designer" )
. addPermission ( "read-all-templates" )
. addPermission ( "manage-template" )
. addTemplate ( "template-id" )
. addDomain ( "domain-id" )
. setRequiresPeriodicPasswordChange ( true ) ;
mailerSend. user. create ( customUser)
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. email( "newuser@example.com" )
. admin_role( )
. build_user_invite( ) )
response = ms. users. invite_user( request)
request = ( UsersBuilder( )
. email( "designer@example.com" )
. designer_role( )
. add_permission( "read-all-templates" )
. add_permission( "manage-template" )
. add_template( "template-id" )
. add_domain( "domain-id" )
. requires_periodic_password_change( True )
. build_user_invite( ) )
response = ms. users. invite_user( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
options := & mailersend. CreateUserOptions{
Email: "newuser@example.com" ,
Role: mailersend. String ( "admin" ) ,
}
_ , _ , err := ms. User. Create ( ctx, options)
if err != nil {
log. Fatal ( err)
}
customOptions := & mailersend. CreateUserOptions{
Email: "designer@example.com" ,
Role: mailersend. String ( "designer" ) ,
Permissions: [ ] string { "read-all-templates" , "manage-template" } ,
TemplateIDs: [ ] string { "template-id" } ,
DomainIDs: [ ] string { "domain-id" } ,
RequiresPeriodicPasswordChange: mailersend. Bool ( true ) ,
}
_ , _ , err = ms. User. Create ( ctx, customOptions)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. users. User ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void InviteUser ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
User user = ms. users ( ) . builder ( )
. email ( "newuser@example.com" )
. role ( "admin" )
. createUser ( ) ;
System . out. println ( user. id) ;
User customUser = ms. users ( ) . builder ( )
. email ( "designer@example.com" )
. role ( "designer" )
. addPermission ( "read-all-templates" )
. addPermission ( "manage-template" )
. addTemplate ( "template-id" )
. addDomain ( "domain-id" )
. requiresPeriodicPasswordChange ( true )
. createUser ( ) ;
System . out. println ( customUser. id) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
require "mailersend-ruby"
ms_user = Mailersend:: User . new
ms_user. create( email : "newuser@example.com" , role : "admin" )
ms_user. create(
email : "designer@example.com" ,
role : "designer" ,
permissions : [ "read-all-templates" , "manage-template" ] ,
templates : [ "template-id" ] ,
domains : [ "domain-id" ] ,
requires_periodic_password_change : true
)
More examplesopen in new window
Responses Response Key Type Details data object User invite object created.
Valid Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data" : {
"id" : "n3k6d1jrveq50x4v" ,
"email" : "user@example.com" ,
"data" : null ,
"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 Entity
See - Validation errors
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_idstringyes
JSON parameters are provided in dot notation
JSON Parameter Type Required Limitations Details rolestringyes Must be the name of a role View roles permissionsstring[]yes* Must be list of permission names *Only required if role is a Custom User. View permissions templatesstring[]no Must be list of template IDs domainsstring[]no Must be list of domain IDs requires_periodic_password_changebooleanno
PHP NodeJS Python Go Java Ruby 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 )
) ;
More examplesopen in new window
import 'dotenv/config' ;
import { MailerSend, User } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
const user = new User ( )
. setRole ( "manager" )
. addPermission ( "read-analytics" )
. addPermission ( "read-activity" )
. addDomain ( "domain-id" ) ;
mailerSend. user. update ( "user-id" , user)
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. user_id( "user-id" )
. manager_role( )
. add_permission( "read-analytics" )
. add_permission( "read-activity" )
. add_domain( "domain-id" )
. build_user_update( ) )
response = ms. users. update_user( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
userID := "user-id"
options := & mailersend. UpdateUserOptions{
Role: mailersend. String ( "manager" ) ,
Permissions: [ ] string { "read-analytics" , "read-activity" } ,
DomainIDs: [ ] string { "domain-id" } ,
}
_ , _ , err := ms. User. Update ( ctx, userID, options)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. users. User ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void UpdateUser ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
User user = ms. users ( ) . builder ( )
. role ( "manager" )
. addPermission ( "read-analytics" )
. addPermission ( "read-activity" )
. addDomain ( "domain-id" )
. updateUser ( "user-id" ) ;
System . out. println ( user. id) ;
System . out. println ( user. email) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
require "mailersend-ruby"
ms_user = Mailersend:: User . new
ms_user. update(
"user-id" ,
role : "manager" ,
permissions : [ "read-analytics" , "read-activity" ] ,
domains : [ "domain-id" ]
)
More examplesopen in new window
Responses Response Key Type Details data object User object updated.
Valid Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data" : {
"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"
}
}
Invalid Response Code: 422 Unprocessable Entity
See - Validation errors
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_idstringyes
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. user. delete ( "user-id" )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. user_id( "user-id" )
. build_user_delete( ) )
response = ms. users. delete_user( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
userID := "user-id"
_ , _ , err := ms. User. Delete ( ctx, userID)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void DeleteUser ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
ms. users ( ) . deleteUser ( "user-id" ) ;
System . out. println ( "User deleted successfully" ) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
Responses Valid Response Code: 204 No Content
Error Response Code: 404 Not Found
Get a list of invites Retrieve information about account invited users with this GET request:
GET https://api.mailersend.com/v1/invites
Request parameters Query parameter Type Required Limitations Details limitintno Min: 10, Max: 100 Default: 25 pageintno Min: 1
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. invite. list ( )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. page( 1 )
. limit( 25 )
. build_invites_list( ) )
response = ms. users. list_invites( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
options := & mailersend. ListInviteOptions{
Page: 1 ,
Limit: 25 ,
}
_ , _ , err := ms. Invite. List ( ctx, options)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. invites. Invite ;
import com. mailersend. sdk. invites. InvitesList ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void ListInvites ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
InvitesList list = ms. invites ( ) . getInvites ( 1 , 25 ) ;
for ( Invite invite : list. invites) {
System . out. println ( invite. id) ;
System . out. println ( invite. email) ;
}
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
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"
}
]
}
Error Response Code: 404 Not Found
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_idstringyes
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. invite. single ( "invite-id" )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. invite_id( "invite-id" )
. build_invite_get( ) )
response = ms. users. get_invite( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
inviteID := "invite-id"
_ , _ , err := ms. Invite. Get ( ctx, inviteID)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. invites. Invite ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void GetInvite ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
Invite invite = ms. invites ( ) . getInvite ( "invite-id" ) ;
System . out. println ( invite. id) ;
System . out. println ( invite. email) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
Responses Valid Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data" : {
"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}/resend
Request parameters URL parameter Type Required Limitations Details invite_idstringyes
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. invite. resend ( "invite-id" )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. invite_id( "invite-id" )
. build_invite_resend( ) )
response = ms. users. resend_invite( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
inviteID := "invite-id"
_ , _ , err := ms. Invite. Resend ( ctx, inviteID)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void ResendInvite ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
ms. invites ( ) . resendInvite ( "invite-id" ) ;
System . out. println ( "Invite resent successfully" ) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
Responses Valid Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data" : {
"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 Found
Cancel 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_idstringyes
PHP NodeJS Python Go Java Ruby import 'dotenv/config' ;
import { MailerSend } from "mailersend" ;
const mailerSend = new MailerSend ( {
apiKey : process. env. API_KEY ,
} ) ;
mailerSend. invite. cancel ( "invite-id" )
. then ( ( response ) => console. log ( response. body) )
. catch ( ( error ) => console. log ( error. body) ) ;
More examplesopen in new window
from mailersend import MailerSendClient, UsersBuilder
ms = MailerSendClient( )
request = ( UsersBuilder( )
. invite_id( "invite-id" )
. build_invite_cancel( ) )
response = ms. users. cancel_invite( request)
More examplesopen in new window
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main ( ) {
ms := mailersend. NewMailersend ( APIKey)
ctx := context. Background ( )
ctx, cancel := context. WithTimeout ( ctx, 5 * time. Second)
defer cancel ( )
inviteID := "invite-id"
_ , _ , err := ms. Invite. Cancel ( ctx, inviteID)
if err != nil {
log. Fatal ( err)
}
}
More examplesopen in new window
import com. mailersend. sdk. MailerSend ;
import com. mailersend. sdk. exceptions. MailerSendException ;
public void CancelInvite ( ) {
MailerSend ms = new MailerSend ( ) ;
ms. setToken ( "api token" ) ;
try {
ms. invites ( ) . cancelInvite ( "invite-id" ) ;
System . out. println ( "Invite cancelled successfully" ) ;
} catch ( MailerSendException e) {
e. printStackTrace ( ) ;
}
}
More examplesopen in new window
Responses Valid Error Response Code: 404 Not Found
Roles Name Description Admin Administrator has full access and can perform all actions in the account. Manager Has full access, access API and 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.
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 update-plan Manage plans Plan and Billing manage-account Edit account settings Plan and Billing read-invoice View invoices 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