MailerSend
Email API

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/identities

Request parameters

Query parameterTypeRequiredLimitationsDetails
domain_idstringno
pageintnoMin: 1
limitintnoMin: 10, Max: 100Default: 25
querystringnoFilter by email address.
order_bystringnoemail, created_at, verified_atDefault: created_at
orderstringnoasc, descDefault: asc
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->getAll($domainId = 'domainId', $page = 1, $limit = 10);

More examples

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));

More examples

from mailersend import MailerSendClient, IdentityBuilder

ms = MailerSendClient()

request = (IdentityBuilder()
          .domain_id("domain-id")
          .build_list_request())

response = ms.identities.list_identities(request)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

require "mailersend-ruby"

ms_client = Mailersend::Client.new('your_mailersend_token')

ms_sender_identity = Mailersend::SenderIdentity.new(ms_client)
ms_sender_identity.list

More examples

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"
      }
    }
  ],
  "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 Entity

See - 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 parameterTypeRequiredLimitationsDetails
identity_idstringyes
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->find('identityId');

More examples

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));

More examples

from mailersend import MailerSendClient, IdentityBuilder

ms = MailerSendClient()

request = (IdentityBuilder()
          .identity_id("identity-id")
          .build_get_request())

response = ms.identities.get_identity(request)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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')

More examples

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 parameterTypeRequiredLimitationsDetails
emailstringyes
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->findByEmail('email');

More examples

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));

More examples

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)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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')

More examples

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")
);

More examples

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));

More examples

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)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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')

More examples

Request Parameters

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
domain_idstringyes
namestringnoMax 191 characters.
emailstringyesMax 320 characters, unique per domain. Domains marked as unavailable or with a DMARC p=reject policy are rejected.
reply_to_emailstringnoMax 320 characters. Domains marked as unavailable are rejected.Required when reply_to_name is set.
reply_to_namestringnoMax 191 characters.
add_notebooleanno
personal_notestringnoMax 250 characters. HTML is stripped. Can't contain links, domain names or email addresses.

Responses

Response KeyTypeDetails
dataobjectIdentity 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 Entity

See - 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")
);

More examples

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));

More examples

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)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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.')

More examples

Request Parameters

URL parameterTypeRequiredLimitationsDetails
identity_idstringyes

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
namestringnoMax 191 characters.
reply_to_emailstringnoMax 320 characters. Domains marked as unavailable are rejected.Required when reply_to_name is set.
reply_to_namestringnoMax 191 characters.
add_notebooleannoWhether to add personal_note to the verification email.
personal_notestringnoMax 250 characters. HTML is stripped. Can't contain links, domain names or email addresses.

Responses

Response KeyTypeDetails
dataobjectIdentity 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 Entity

See - 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 Found

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",
  "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")
);

More examples

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));

More examples

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)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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.')

More examples

Request Parameters

URL parameterTypeRequiredLimitationsDetails
emailstringyes

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
namestringnoMax 191 characters.
reply_to_emailstringnoMax 320 characters. Domains marked as unavailable are rejected.Required when reply_to_name is set.
reply_to_namestringnoMax 191 characters.
add_notebooleannoWhether to add personal_note to the verification email.
personal_notestringnoMax 250 characters. HTML is stripped. Can't contain links, domain names or email addresses.

Responses

Response KeyTypeDetails
dataobjectIdentity 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 Entity

See - Validation errors

Error

Response Code: 404 Not Found

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 parameterTypeRequiredLimitationsDetails
identity_idstringyes
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->delete('identityId');

More examples

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));

More examples

from mailersend import MailerSendClient, IdentityBuilder

ms = MailerSendClient()

request = (IdentityBuilder()
          .identity_id("identity-id")
          .build_delete_request())

response = ms.identities.delete_identity(request)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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')

More examples

Responses

Valid

Response Code: 204 No Content

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 parameterTypeRequiredLimitationsDetails
emailstringyes
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->deleteByEmail('email');

More examples

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));

More examples

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)

More examples

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)
	}
}

More examples

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();
    }
}

More examples

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')

More examples

Responses

Valid

Response Code: 202 Accepted

Error

Response Code: 404 Not Found

Resend 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}/resend

Request parameters

URL parameterTypeRequiredLimitationsDetails
identity_idstringyes
use MailerSend\MailerSend;

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

$mailersend->senderIdentity->resend('identityId');

More examples

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));

More examples

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();
    }
}

More examples

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 Found

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."
}

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."
}

On this page