Sender Identities
Get a list of sender identities
Retrieve information about sender identities with this GET request:
GET https://api.mailersend.com/v1/identities
Request parameters
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
domain_id | string | no | ||
page | int | no | ||
limit | int | no | Min: 10, Max: 100 | Default: 25 |
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.identities.Identity;
import com.mailersend.sdk.identities.IdentitiesList;
import com.mailersend.sdk.exceptions.MailerSendException;
public void ListIdentities() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
IdentitiesList list = ms.identities().getIdentities("domain-id", 1, 25);
for (Identity identity : list.identities) {
System.out.println(identity.id);
System.out.println(identity.email);
}
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
ms_sender_identity.list
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 Found
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.identities.Identity;
import com.mailersend.sdk.exceptions.MailerSendException;
public void GetIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
Identity identity = ms.identities().getIdentity("identity-id");
System.out.println(identity.id);
System.out.println(identity.email);
System.out.println(identity.name);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
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 Found
Get 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');
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 Found
Add 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/identities
Request 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, Inbound, InboundFilterType } 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: mailersend.String("support@yourdomain.com"),
ReplyToName: mailersend.String("Support Team"),
AddNote: mailersend.Bool(true),
}
_, _, err := ms.Identity.Create(ctx, options)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.identities.Identity;
import com.mailersend.sdk.exceptions.MailerSendException;
public void CreateIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
Identity identity = ms.identities().builder()
.domainId("domain-id")
.name("John Doe")
.email("john@yourdomain.com")
.replyToEmail("support@yourdomain.com")
.replyToName("Support Team")
.addNote(true)
.createIdentity();
System.out.println(identity.id);
System.out.println(identity.email);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
ms_sender_identity.add(domain_id: 'idofdomain12412', name: 'yourname', email: 'youremail')
Request Parameters
JSON parameters are provided in dot notation
| JSON Parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
domain_id | string | yes | ||
name | string | yes | Max 191 characters. | |
email | string | yes | Max 191 characters, unique | |
reply_to_email | string | no | ||
reply_to_name | string | no | ||
add_note | boolean | no | ||
personal_note | string | no | Max 250 characters. |
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": true,
"personal_note": "Hi Pedro, please confirm this email by clicking on the link below.",
"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 Entity
See - Validation errors
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",
"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->update(
'identityId',
(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, Inbound, InboundFilterType } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const data = {
domain_id: 'string',
email: 'email@yourdomain.com',
name: 'name',
personal_note: 'Personal note',
reply_to_name: 'Reply Name',
reply_to_email: 'repy@yourdomain.com',
add_note: true,
};
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)
.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: mailersend.String("Jane Doe"),
ReplyToEmail: mailersend.String("support@yourdomain.com"),
ReplyToName: mailersend.String("Support Team"),
AddNote: mailersend.Bool(true),
}
_, _, err := ms.Identity.Update(ctx, identityID, options)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.identities.Identity;
import com.mailersend.sdk.exceptions.MailerSendException;
public void UpdateIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
Identity identity = ms.identities().builder()
.name("Jane Doe")
.replyToEmail("support@yourdomain.com")
.replyToName("Support Team")
.addNote(true)
.updateIdentity("identity-id");
System.out.println(identity.id);
System.out.println(identity.name);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
ms_sender_identity.update(identity_id: 'idofidentity123', reply_to_email: 'replyemail', reply_to_name: 'replyname')
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 191 characters. | |
reply_to_name | string | no | ||
add_note | boolean | no | ||
personal_note | string | no |
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": true,
"personal_note": "Hi Pedro, please confirm this email by clicking on the link below.",
"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 Entity
See - Validation errors
Update 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",
"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->updateByEmail(
'email',
(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 } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const data = {
name: 'Doe Jane',
reply_to_email: 'support@yourdomain.com',
reply_to_name: 'Support Team',
add_note: true,
};
mailerSend.email.identity.updateByEmail('support@yourdomain.com', 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)
.build_update_by_email_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()
email := "support@yourdomain.com"
options := &mailersend.UpdateIdentityOptions{
Name: mailersend.String("Doe Jane"),
ReplyToEmail: mailersend.String("support@yourdomain.com"),
ReplyToName: mailersend.String("Support Team"),
AddNote: mailersend.Bool(true),
}
_, _, err := ms.Identity.UpdateByEmail(ctx, email, options)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.identities.Identity;
import com.mailersend.sdk.exceptions.MailerSendException;
public void UpdateIdentityByEmail() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
Identity identity = ms.identities().builder()
.email("support@yourdomain.com")
.name("Doe Jane")
.replyToEmail("support@yourdomain.com")
.replyToName("Support Team")
.addNote(true)
.updateIdentityByEmail();
System.out.println(identity.id);
System.out.println(identity.name);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
ms_sender_identity.update_by_email(email: 'support@yourdomain.com', name: 'Doe Jane', reply_to_email: 'support@yourdomain.com', reply_to_name: 'Support Team', add_note: true)
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 191 characters. | |
reply_to_name | string | no | ||
add_note | boolean | no | ||
personal_note | string | no |
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": true,
"personal_note": "Hi Pedro, please confirm this email by clicking on the link below.",
"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 Entity
See - Validation errors
Delete 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 DeleteIdentity() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
ms.identities().deleteIdentity("identity-id");
System.out.println("Identity deleted successfully");
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
ms_sender_identity = Mailersend::SenderIdentity.new
ms_sender_identity.delete(identity_id: 'idofidentity123')
Responses
Valid
Response Code: 200 OK
Error
Response Code: 404 Not Found
Delete 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');
File not foundfrom 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 DeleteIdentityByEmail() {
MailerSend ms = new MailerSend();
ms.setToken("api token");
try {
ms.identities().deleteIdentityByEmail("support@yourdomain.com");
System.out.println("Identity deleted successfully");
} catch (MailerSendException e) {
e.printStackTrace();
}
}
File not foundResponses
Valid
Response Code: 200 OK
Error
Response Code: 404 Not Found