Sender Identities
Easily manage email sender identities with MailerSend's API. Add, update, delete and retrieve a list of sender identities.
Get a list of sender identities
Retrieve information about sender identities with this GET request:
GET https://api.mailersend.com/v1/identitiesRequest parameters
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
domain_id | string | no | ||
page | int | no | Min: 1 | |
limit | int | no | Min: 10, Max: 100 | Default: 25 |
query | string | no | Filter by email address. | |
order_by | string | no | email, created_at, verified_at | Default: created_at |
order | string | no | asc, desc | Default: asc |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->getAll($domainId = 'domainId', $page = 1, $limit = 10);import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.list()
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.domain_id("domain-id")
.build_list_request())
response = ms.identities.list_identities(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
domainID := "domain-id"
options := &mailersend.ListIdentityOptions{
DomainID: domainID,
Page: 1,
Limit: 25,
}
_, _, err := ms.Identity.List(ctx, options)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentitiesList;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void getSenderIdentities() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentitiesList list = ms.senderIdentities()
.page(1)
.limit(25)
.getIdentities();
for (SenderIdentity identity : list.identities) {
System.out.println(identity.id);
System.out.println(identity.email);
System.out.println(identity.name);
System.out.println(identity.isVerified);
}
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.listResponses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": [
{
"id": "7nxe3yjmeq28vp0k",
"email": "john@test.com",
"name": "John Doe",
"reply_to_email": null,
"reply_to_name": null,
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
],
"links": {
"first": "https://api.mailersend.com/v1/identities?page=1",
"last": "https://api.mailersend.com/v1/identities?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/identities?page=1",
"label": "1",
"page": 1,
"active": true
},
{
"url": null,
"label": "Next »",
"page": null,
"active": false
}
],
"path": "https://api.mailersend.com/v1/identities",
"per_page": 25,
"to": 1,
"total": 1
}
}Error
Response Code: 422 Unprocessable EntitySee - Validation errors
Get a single sender identity
If you want to retrieve a single sender identity, use this GET request:
GET https://api.mailersend.com/v1/identities/{identity_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
identity_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->find('identityId');import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.single("identity_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.identity_id("identity-id")
.build_get_request())
response = ms.identities.get_identity(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
identityID := "identity-id"
_, _, err := ms.Identity.Get(ctx, identityID)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void getSenderIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().getIdentity("your-identity-id");
System.out.println(identity.id);
System.out.println(identity.email);
System.out.println(identity.name);
System.out.println(identity.isVerified);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.single(identity_id: 'idofidentity123')Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "john@test.com",
"name": "John Doe",
"reply_to_email": null,
"reply_to_name": null,
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Error
Response Code: 404 Not FoundGet a single sender identity by email
If you want to retrieve a single sender identity by email, use this GET request:
GET https://api.mailersend.com/v1/identities/email/{email}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
email | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->findByEmail('email');import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.singleByEmail('email_address')
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.email("support@yourdomain.com")
.build_get_by_email_request())
response = ms.identities.get_identity_by_email(request)package main
import (
"context"
"os"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
_, _, err := ms.Identity.GetByEmail(ctx, "identity-email")
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void getSenderIdentityByEmail() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().getIdentityByEmail("sender@yourdomain.com");
System.out.println(identity.id);
System.out.println(identity.email);
System.out.println(identity.name);
System.out.println(identity.isVerified);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.single_by_email(email: 'example@email.com')Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "john@test.com",
"name": "John Doe",
"reply_to_email": null,
"reply_to_name": null,
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Error
Response Code: 404 Not FoundAdd a sender identity
If you want to add a new sender identity from which you can send emails without having to verify a domain, use this POST request:
POST https://api.mailersend.com/v1/identitiesRequest body
{
"domain_id": "7nxe3yjmeq28vp0k",
"email": "pedro@test.com",
"name": "Pedro Doe",
"personal_note": "Hi Pedro, please confirm this email by clicking on the link below.",
"reply_to_name": "Test Doe",
"reply_to_email": "test@test.com",
"add_note": true
}use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SenderIdentity;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->create(
(new SenderIdentity('domainId', 'name', 'email'))
->setReplyToName("John Doe")
->setReplyToEmail("john@test.com")
->setAddNote(true)
->setPersonalNote("Hi John, please use this token")
);import 'dotenv/config';
import { MailerSend, Identity } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const identity = new Identity()
.setDomainId('domain_id')
.setEmail('identity@yourdomain.com')
.setName('Name')
.setReplyToEmail('reply_identity@yourdomain.com')
.setReplyToName('Reply Name')
.setAddNote(false);
mailerSend.email.identity.create(identity)
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.domain_id("domain-id")
.name("John Doe")
.email("john@yourdomain.com")
.reply_to_email("support@yourdomain.com")
.reply_to_name("Support Team")
.add_note(True)
.build_create_request())
response = ms.identities.create_identity(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
options := &mailersend.CreateIdentityOptions{
DomainID: "domain-id",
Name: "John Doe",
Email: "john@yourdomain.com",
ReplyToEmail: "support@yourdomain.com",
ReplyToName: "Support Team",
AddNote: true,
}
_, _, err := ms.Identity.Create(ctx, options)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void createSenderIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().builder()
.domainId("your-domain-id")
.email("sender@yourdomain.com")
.name("Sender Name")
.replyToEmail("reply@yourdomain.com")
.replyToName("Reply Name")
.addNote(true)
.personalNote("Please verify this sender identity.")
.createIdentity();
System.out.println(identity.id);
System.out.println(identity.email);
System.out.println(identity.isVerified);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.add(domain_id: 'idofdomain12412', name: 'yourname', email: 'sender@yourdomain.com')Request Parameters
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
domain_id | string | yes | ||
name | string | no | Max 191 characters. | |
email | string | yes | Max 320 characters, unique per domain. Domains marked as unavailable or with a DMARC p=reject policy are rejected. | |
reply_to_email | string | no | Max 320 characters. Domains marked as unavailable are rejected. | Required when reply_to_name is set. |
reply_to_name | string | no | Max 191 characters. | |
add_note | boolean | no | ||
personal_note | string | no | Max 250 characters. HTML is stripped. Can't contain links, domain names or email addresses. |
Responses
| Response Key | Type | Details |
|---|---|---|
| data | object | Identity object created. |
Valid
Response Code: 201 CREATED
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "pedro@test.com",
"name": "Pedro Doe",
"reply_to_email": "test@test.com",
"reply_to_name": "Test Doe",
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Invalid
Response Code: 422 Unprocessable EntitySee - Validation errors
Identity limit error
Response Code: 403 Forbidden
Response Headers:
content-type: application/json{
"message": "You've reached the maximum sender identity limit. Upgrade to add more identities."
}Update a sender identity
If you want to update the information of an existing sender identity, use this PUT request:
PUT https://api.mailersend.com/v1/identities/{identity_id}Request body
{
"name": "Pedro Doe",
"reply_to_name": "Test Doe",
"reply_to_email": "test@test.com"
}use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SenderIdentity;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->update(
'identityId',
(new SenderIdentity('domainId', 'name', 'email'))
->setReplyToName("John Doe")
->setReplyToEmail("john@test.com")
);import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const data = {
name: 'name',
reply_to_name: 'Reply Name',
reply_to_email: 'reply@yourdomain.com',
};
mailerSend.email.identity.update('identity_id', data)
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.identity_id("identity-id")
.name("Jane Doe")
.reply_to_email("support@yourdomain.com")
.reply_to_name("Support Team")
.add_note(True)
.personal_note("Please verify this sender identity.")
.build_update_request())
response = ms.identities.update_identity(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
identityID := "identity-id"
options := &mailersend.UpdateIdentityOptions{
Name: "Jane Doe",
ReplyToEmail: "support@yourdomain.com",
ReplyToName: "Support Team",
AddNote: true,
PersonalNote: "Please verify this sender identity.",
}
_, _, err := ms.Identity.Update(ctx, identityID, options)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void updateSenderIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().builder()
.name("Updated Sender Name")
.replyToEmail("newreply@yourdomain.com")
.replyToName("New Reply Name")
.updateIdentity("your-identity-id");
System.out.println(identity.id);
System.out.println(identity.name);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.update(identity_id: 'idofidentity123', reply_to_email: 'reply@yourdomain.com', reply_to_name: 'replyname', add_note: true, personal_note: 'Please verify this sender identity.')Request Parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
identity_id | string | yes |
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
name | string | no | Max 191 characters. | |
reply_to_email | string | no | Max 320 characters. Domains marked as unavailable are rejected. | Required when reply_to_name is set. |
reply_to_name | string | no | Max 191 characters. | |
add_note | boolean | no | Whether to add personal_note to the verification email. | |
personal_note | string | no | Max 250 characters. HTML is stripped. Can't contain links, domain names or email addresses. |
Responses
| Response Key | Type | Details |
|---|---|---|
| data | object | Identity object updated. |
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "pedro@test.com",
"name": "Pedro Doe",
"reply_to_email": "test@test.com",
"reply_to_name": "Test Doe",
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Invalid
Response Code: 422 Unprocessable EntitySee - Validation errors
Premium feature error
Response Code: 403 Forbidden
Response Headers:
content-type: application/json{
"message": "Sender identity is a premium feature. Please Upgrade your plan to update sender identity."
}Error
Response Code: 404 Not FoundUpdate a sender identity by email
If you want to update the information of an existing sender identity by email, use this PUT request:
PUT https://api.mailersend.com/v1/identities/email/{email}Request body
{
"name": "Pedro Doe",
"reply_to_name": "Test Doe",
"reply_to_email": "test@test.com"
}use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SenderIdentity;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->updateByEmail(
'email',
(new SenderIdentity('domainId', 'name', 'email'))
->setReplyToName("John Doe")
->setReplyToEmail("john@test.com")
);import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const data = {
name: 'name',
reply_to_name: 'Reply Name',
reply_to_email: 'reply@yourdomain.com',
};
mailerSend.email.identity.updateByEmail('email_address', data)
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.email("support@yourdomain.com")
.name("Doe Jane")
.reply_to_email("support@yourdomain.com")
.reply_to_name("Support Team")
.add_note(True)
.personal_note("Please verify this sender identity.")
.build_update_by_email_request())
response = ms.identities.update_identity_by_email(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
email := "support@yourdomain.com"
options := &mailersend.UpdateIdentityOptions{
Name: "Doe Jane",
ReplyToEmail: "support@yourdomain.com",
ReplyToName: "Support Team",
AddNote: true,
PersonalNote: "Please verify this sender identity.",
}
_, _, err := ms.Identity.UpdateByEmail(ctx, email, options)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void updateSenderIdentityByEmail() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().builder()
.name("Updated Sender Name")
.replyToEmail("newreply@yourdomain.com")
.replyToName("New Reply Name")
.updateIdentityByEmail("sender@yourdomain.com");
System.out.println(identity.id);
System.out.println(identity.name);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.update_by_email(email: 'example@email.com', reply_to_email: 'reply@yourdomain.com', reply_to_name: 'replyname', add_note: true, personal_note: 'Please verify this sender identity.')Request Parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
email | string | yes |
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
name | string | no | Max 191 characters. | |
reply_to_email | string | no | Max 320 characters. Domains marked as unavailable are rejected. | Required when reply_to_name is set. |
reply_to_name | string | no | Max 191 characters. | |
add_note | boolean | no | Whether to add personal_note to the verification email. | |
personal_note | string | no | Max 250 characters. HTML is stripped. Can't contain links, domain names or email addresses. |
Responses
| Response Key | Type | Details |
|---|---|---|
| data | object | Identity object updated. |
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "pedro@test.com",
"name": "Pedro Doe",
"reply_to_email": "test@test.com",
"reply_to_name": "Test Doe",
"is_verified": false,
"resends": 0,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Invalid
Response Code: 422 Unprocessable EntitySee - Validation errors
Error
Response Code: 404 Not FoundDelete a sender identity
If you want to delete a sender identity, use this DELETE request:
DELETE https://api.mailersend.com/v1/identities/{identity_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
identity_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->delete('identityId');import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.delete("identity_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.identity_id("identity-id")
.build_delete_request())
response = ms.identities.delete_identity(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
identityID := "identity-id"
_, err := ms.Identity.Delete(ctx, identityID)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
public void deleteSenderIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
boolean deleted = ms.senderIdentities().deleteIdentity("your-identity-id");
System.out.println("Identity deleted: " + deleted);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.delete(identity_id: 'idofidentity123')Responses
Valid
Response Code: 204 No ContentError
Response Code: 404 Not FoundDelete a sender identity by email
If you want to delete a sender identity by email, use this DELETE request:
DELETE https://api.mailersend.com/v1/identities/email/{email}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
email | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->deleteByEmail('email');import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.deleteByEmail('email_address')
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));from mailersend import MailerSendClient, IdentityBuilder
ms = MailerSendClient()
request = (IdentityBuilder()
.email("support@yourdomain.com")
.build_delete_by_email_request())
response = ms.identities.delete_identity_by_email(request)package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
email := "support@yourdomain.com"
_, err := ms.Identity.DeleteByEmail(ctx, email)
if err != nil {
log.Fatal(err)
}
}import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
public void deleteSenderIdentityByEmail() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
boolean deleted = ms.senderIdentities().deleteIdentityByEmail("sender@yourdomain.com");
System.out.println("Identity deleted: " + deleted);
} catch (MailerSendException e) {
e.printStackTrace();
}
}require "mailersend-ruby"
ms_client = Mailersend::Client.new('your_mailersend_token')
ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.delete_by_email(email: 'example@email.com')Responses
Valid
Response Code: 202 AcceptedError
Response Code: 404 Not FoundResend a sender identity verification
If you want to resend the verification email for a sender identity, use this POST request:
POST https://api.mailersend.com/v1/identities/{identity_id}/resendRequest parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
identity_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$mailersend->senderIdentity->resend('identityId');import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.email.identity.resend("identity_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.senderidentities.SenderIdentity;
public void resendSenderIdentityConfirmation() {
MailerSend ms = new MailerSend();
ms.setToken("Your API token");
try {
SenderIdentity identity = ms.senderIdentities().resendConfirmation("your-identity-id");
System.out.println("Confirmation resent. Resend count: " + identity.resends);
} catch (MailerSendException e) {
e.printStackTrace();
}
}Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "7nxe3yjmeq28vp0k",
"email": "john@test.com",
"name": "John Doe",
"reply_to_email": null,
"reply_to_name": null,
"is_verified": false,
"resends": 1,
"add_note": false,
"personal_note": null,
"domain": {
"id": "7nxe3yjmeq28vp0k",
"name": "test.com",
"created_at": "2022-11-29T10:43:22.000000Z",
"updated_at": "2022-11-29T10:43:32.000000Z"
}
}
}Error
Response Code: 404 Not FoundIdentity limit error
Response Code: 403 Forbidden
Response Headers:
content-type: application/json{
"message": "You've reached the maximum sender identity limit. Upgrade to add more identities."
}Resend limit error
Response Code: 429 Too Many Requests
Response Headers:
content-type: application/json{
"message": "Limit of max 3 emails was reached. Contact support if you need additional help."
}Domains
Discover how to easily manage your email domains using MailerSend's Domains API endpoint. Get a list of domains or retrieve a single domain in just a few clicks.
Inbound routing
Easily manage inbound emails with MailerSend's Inbound Routing API endpoint. Retrieve, add, update and delete inbound routes.