Domains

Get information about your domain names, their account verification statuses, activity statistics, and history.

Get a list of domains

If you want to retrieve information about multiple domains, use this GET request:

GET https://api.mailersend.com/v1/domains

Request parameters

URL parameterTypeRequiredLimitationsDetails
pageintno
limitintnoMin: 10, Max: 100Default: 25
verifiedboolno
use MailerSend\MailerSend;

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

$mailersend->domain->getAll($page = 1, $limit = 10, $verified = true);

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainList({
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.get_domains()

More examplesopen in new window

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.ListDomainOptions{
		Page:  1,
		Limit: 25,
	}

	_, _, err := ms.Domain.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.Domain;
import com.mailersend.sdk.domains.DomainsList;
import com.mailersend.sdk.exceptions.MailerSendException;

public void DomainsList() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("token");
    
    try {
        
        DomainsList list = ms.domains().getDomains();
        
        for (Domain domain : list.domains) {
            
            System.out.println(domain.id);
            System.out.println(domain.name);
        }
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.list

More examplesopen in new window

Responses

Valid

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
	"data" : [
		{
      "id": "1jreeo",
      "name": "example.org",
      "dkim": true,
      "spf": true,
      "tracking": false,
      "is_verified": true,
      "is_cname_verified": false,
      "is_dns_active": true,
      "is_cname_active": false,
      "is_tracking_allowed": false,
      "has_not_queued_messages": false,
      "not_queued_messages_count": 0,
      "domain_settings": {
        "send_paused": false,
        "track_clicks": true,
        "track_opens": true,
        "track_unsubscribe": true,
        "track_unsubscribe_html": "<p>Click here to <a href=\"{$unsubscribe}\">unsubscribe<\/a><\/p>",
        "track_unsubscribe_plain": "Click here to unsubscribe: {$unsubscribe}",
        "track_content": true,
        "custom_tracking_enabled": false,
        "custom_tracking_subdomain": "email",
        "precedence_bulk": false
      },
      "created_at": "2020-06-10 10:09:48",
      "updated_at": "2020-06-10 10:09:48"
    }
	],
  "links": {
    "first": "http:\/\/www.mailersend.io\/api\/v1\/domains?page=1",
    "last": "http:\/\/www.mailersend.io\/api\/v1\/domains?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "http:\/\/www.mailersend.io\/api\/v1\/domains",
    "per_page": 25,
    "to": 1,
    "total": 1
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Get a single domain

If you want to retrieve information about a single domain name, use this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
use MailerSend\MailerSend;

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

$mailersend->domain->find('domain_id');

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domain({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.get_domain_by_id("domain-id")

More examplesopen in new window

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"

	_, _, err := ms.Domain.Get(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.Domain;
import com.mailersend.sdk.exceptions.MailerSendException;

public void SingleDomain() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        Domain domain = ms.domains().getDomain("domain id");
        
        System.out.println(domain.id);
        System.out.println(domain.name);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.single(domain_id: "idofdomain12412")

More examplesopen in new window

Responses

Valid

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
  "data": {
    "id": "yjm4ej",
    "name": "example.org",
    "dkim": true,
    "spf": true,
    "mx": false,
    "tracking": false,
    "is_verified": true,
    "is_cname_verified": false,
    "is_dns_active": true,
    "is_cname_active": false,
    "is_tracking_allowed": false,
    "has_not_queued_messages": false,
    "not_queued_messages_count": 0,
    "domain_settings": {
      "send_paused": false,
      "track_clicks": true,
      "track_opens": true,
      "track_unsubscribe": true,
      "track_unsubscribe_html": "<p>Click here to <a href=\"{$unsubscribe}\">unsubscribe<\/a><\/p>",
      "track_unsubscribe_plain": "Click here to unsubscribe: {$unsubscribe}",
      "track_content": true,
      "custom_tracking_enabled": false,
      "custom_tracking_subdomain": "email",
      "precedence_bulk": false
    },
    "created_at": "2020-06-10 10:09:50",
    "updated_at": "2020-06-10 10:09:50"
  }
}

Error

Response Code: 404 Not Found

Add a domain

If you want to add a new domain, use this POST request:

POST https://api.mailersend.com/v1/domains

Request body

{
    "name": "example.com",
    "return_path_subdomain": "rp_subdomain",
    "custom_tracking_subdomain": "ct_subdomain",
    "inbound_routing_subdomain": "ir_subdomain"
}
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\DomainParams;

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

$domainParams = (new DomainParams('domainName'))
                    ->setReturnPathSubdomain('returnPath')
                    ->setCustomTrackingSubdomain('customTracking')
                    ->getInboundRoutingSubdomain('inboundRouting');

$mailersend->domain->create($domainParams);

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addDomain({
    name: "example.com",
    return_path_subdomain: "rp_subdomain",
    custom_tracking_subdomain: "ct_subdomain",
    inbound_routing_subdomain: "ir_subdomain",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.add_domain("name", "example.com")

More examplesopen in new window

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.CreateDomainOptions{
		Name: "domain.test",
	}

	_, _, err := ms.Domain.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.Domain;
import com.mailersend.sdk.exceptions.MailerSendException;

public void AddDomain() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        Domain domain = ms.domains().addDomainBuilder().addDomain("domain to add");
        
        System.out.println(domain.id);
        System.out.println(domain.name);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

Request Parameters

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
namestringyesMust be unique and lowercase. Domain must be available and resolvable.
return_path_subdomainstringnoMust be alphanumeric.
custom_tracking_subdomainstringnoMust be alphanumeric.
inbound_routing_subdomainstringnoMust be alphanumeric.

Responses

Response KeyTypeDetails
dataobjectDomain object created.

Valid

Response Code: 201 CREATED
Response Headers:
	Content-Type: application/json
{
  "data": {
    "id": "dle1krod2jvn8gwm",
    "name": "testname.com",
    "dkim": null,
    "spf": null,
    "mx": null,
    "tracking": null,
    "is_verified": false,
    "is_dns_active": false,
    "domain_settings": {
      "send_paused": false,
      "track_clicks": true,
      "track_opens": true,
      "track_unsubscribe": false,
      "track_unsubscribe_html": "<p>Click here to <a href=\"{$unsubscribe}\">unsubscribe<\/a><\/p>",
      "track_unsubscribe_html_enabled": false,
      "track_unsubscribe_plain": "Click here to unsubscribe: {$unsubscribe}",
      "track_unsubscribe_plain_enabled": false,
      "track_content": false,
      "custom_tracking_enabled": false,
      "custom_tracking_subdomain": "email",
      "return_path_subdomain": "mta",
      "inbound_routing_enabled": false,
      "inbound_routing_subdomain": "inbound",
      "precedence_bulk": false
    },
    "can": {
      "manage": true
    },
    "totals": []
  }
}

Invalid

Response Code: 422 Unprocessable Entity

See - Validation errors

Delete a domain

If you want to delete a domain name, use this DELETE request:

DELETE https://api.mailersend.com/v1/domains/{domain_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
use MailerSend\MailerSend;

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

$mailersend->domain->delete('domain_id');

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteDomain({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.delete_domain("domain-id")

More examplesopen in new window

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"

	_, err := ms.Domain.Delete(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;

public void DeleteDomain() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        boolean domainDeleted = ms.domains().deleteDomain("domain id");
        
        System.out.println("Domain deleted: ".contains(String.valueOf(domainDeleted)));
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.delete(domain_id: "idofdomain12412")

More examplesopen in new window

Responses

Valid

Response Code: 204 OK

Error

Response Code: 404 Not Found

Get recipients for a domain

If you want to retrieve information (creation date, update date, deletion date) about the recipients for a domain name, use this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}/recipients

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
Query parameterTypeRequiredLimitationsDetails
pageintno
limitintnoMin: 10, Max: 100Default: 25
use MailerSend\MailerSend;

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

$mailersend->domain->recipients($domainId = 'domain_id', $page = 1, $limit = 10);

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainRecipients({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.get_recipients_for_domain("domain-id")

More examplesopen in new window

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.GetRecipientsOptions{
	 	DomainID: domainID,
	 	Page:     1,
	 	Limit:    25,
	}
	
	_, _, err := ms.Domain.GetRecipients(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.DomainRecipientsList;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.util.ApiRecipient;

public void ReceipientsPerDomain() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        DomainRecipientsList list = ms.domains().getDomainRecipients("domaion id");
        
        for (ApiRecipient recipient : list.recipients) {
            
            System.out.println(recipient.email);
        }
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.recipients(domain_id: "idofdomain12412")

More examplesopen in new window

Responses

Valid

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
  "data": [
    {
      "id": "5ee0b174b251345e407c92dc",
      "email": "dsanford@example.net",
      "created_at": "2020-06-10 10:09:56",
      "updated_at": "2020-06-10 10:09:56",
      "deleted_at": ""
    },
    {
      "id": "5ee0b174b251345e407c92dd",
      "email": "konopelski.nina@example.com",
      "created_at": "2020-06-10 10:09:56",
      "updated_at": "2020-06-10 10:09:56",
      "deleted_at": ""
    },
    {
      "id": "5ee0b174b251345e407c92de",
      "email": "hester.howe@example.net",
      "created_at": "2020-06-10 10:09:56",
      "updated_at": "2020-06-10 10:09:56",
      "deleted_at": ""
    }
  ],
  "links": {
    "first": "https:\/\/www.mailersend.io\/api\/v1\/domains\/7qvdnq\/recipients?page=1",
    "last": "https:\/\/www.mailersend.io\/api\/v1\/domains\/7qvdnq?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "http:\/\/www.mailersend.io\/api\/v1\/recipients",
    "per_page": 25,
    "to": 3,
    "total": 3
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Update domain settings

If you want to update the domain name settings, use this PUT request:

PUT https://api.mailersend.com/v1/domains/{domain_id}/settings

Request Body

{
    "send_paused": true,
    "track_clicks": true,
    "track_opens": true,
    "track_unsubscribe": true,
    "track_unsubscribe_html": "<p>Click here to <a href=\"{$unsubscribe}\">unsubscribe<\/a><\/p>",
    "track_unsubscribe_plain": "Click here to unsubscribe: {$unsubscribe}",
    "track_content": true,
    "custom_tracking_enabled": true,
    "custom_tracking_subdomain": "email",
    "precedence_bulk": false
}
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\DomainSettingsParams;

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

$domainSettingsParam = (new DomainSettingsParams())
                            ->setSendPaused(true)
                            ->setTrackClicks(true)
                            ->setTrackOpens(false)
                            ->setTrackUnsubscribe(false)
                            ->setTrackContent(true)
                            ->setTrackUnsubscribeHtml('html')
                            ->setTrackUnsubscribePlain('plain')
                            ->setCustomTrackingEnabled(true)
                            ->setCustomTrackingSubdomain(false);

$mailersend->domain->domainSettings($domainId = 'domain_id', $domainSettingsParam);

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainSettings({
  domain_id: 'xxx',
  send_paused: false
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.update_domain_setting("domain-id", "send_paused", True)

More examplesopen in new window

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.DomainSettingOptions{
		DomainID:    domainID,
		SendPaused:  mailersend.Bool(false),
		TrackClicks: mailersend.Bool(true),
	}
	
	_, _, err := ms.Domain.Update(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.Domain;
import com.mailersend.sdk.exceptions.MailerSendException;

public void UpdateDomainSettings() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        Domain domain = ms.domains().updateDomainSettingsBuilder()
            .customnTrackingEnabled(true)
            .sendPaused(false)
            .updateDomain("domain id");
        
        System.out.println(domain.domainSettings.customTrackingEnabled);
        System.out.println(domain.domainSettings.sendPaused);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.settings(domain_id: "idofdomain12412", track_clicks: true, track_unsubscribe: false)

More examplesopen in new window

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes

JSON parameters are provided in dot notation

JSON Body ParameterTypeRequiredLimitationsDetails
send_pausedboolNo
track_clicksboolno
track_opensboolno
track_unsubscribeboolno
track_contentboolno
track_unsubscribe_htmlstringno
track_unsubscribe_plainstringno
custom_tracking_enabledboolno
custom_tracking_subdomainstringno
precedence_bulkboolno

Responses

Valid

Response Code: 200 OK
{
  "data": {
    "id": "dq3wdj",
    "name": "example.org",
    "dkim": true,
    "spf": true,
    "tracking": false,
    "is_verified": true,
    "is_cname_verified": true,
    "is_dns_active": true,
    "is_cname_active": true,
    "is_tracking_allowed": true,
    "has_not_queued_messages": false,
    "not_queued_messages_count": 0,
    "domain_settings": {
      "send_paused": true,
      "track_clicks": true,
      "track_opens": true,
      "track_unsubscribe": true,
      "track_unsubscribe_html": "<p>Click here to <a href=\"{$unsubscribe}\">unsubscribe<\/a><\/p>",
      "track_unsubscribe_plain": "Click here to unsubscribe: {$unsubscribe}",
      "track_content": true,
      "custom_tracking_enabled": true,
      "custom_tracking_subdomain": "email",
      "precedence_bulk": false
    },
    "created_at": "2020-06-10 10:09:52",
    "updated_at": "2020-06-10 10:09:52"
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Get DNS Records

If you want to retrieve the domain's DNS records, use this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}/dns-records

Request Parameters

URL ParameterTypeRequiredLimitationsDetails
domain_idstringyes
use MailerSend\MailerSend;

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

$mailersend->domain->getDnsRecords('domain_id');

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getDNS({
    domain_id: "xxx",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.get_dns_records("domain-id")

More examplesopen in new window

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"

	_, _, err := ms.Domain.GetDNS(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.Domain;
import com.mailersend.sdk.domains.DomainDnsAttribute;
import com.mailersend.sdk.domains.DomainDnsRecords;
import com.mailersend.sdk.exceptions.MailerSendException;

public void DomainDnsRecords() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        DomainDnsRecords records = ms.domains().getDomainDnsRecords("domain id");
        
        printDomainDnsAttribute(records.spf);
        printDomainDnsAttribute(records.dkim);
        printDomainDnsAttribute(records.customTracking);
        printDomainDnsAttribute(records.returnPath);
        printDomainDnsAttribute(records.inboundRouting);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

private void printDomainDnsAttribute(DomainDnsAttribute attribute) {
    
    System.out.println(attribute.hostname);
    System.out.println(attribute.type);
    System.out.println(attribute.value);
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.dns(domain_id: "idofdomain12412")

More examplesopen in new window

Responses

Valid

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
  "data": {
    "id": "dle1krod2jvn8gwm",
    "spf": {
      "hostname": "testname.com",
      "type": "TXT",
      "value": "v=spf1 include:_spf.mailersend.net ip6:fd43:c0d1:c090::\/48 -all"
    },
    "dkim": {
      "hostname": "mlsend._domainkey.testname.com",
      "type": "TXT",
      "value": "v=DKIM1;t=s;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCv9y0EE38P8bpwNnvTRZvxnQkpe7hmv9clRGG8Vj+g3\/JTVh0Q\/4EOrgn29CO\/8ByRGzc9t\/IAQ0pevN0yXOKOLt8Gng67dzqp2hA1IKEBHPwRZjv30ROSjpknDcmnJSVK2KO3sI7lxzQo73fwuwm9WVbXUJpBJG8yQftwibkj+QIDAQAB"
    },
    "return_path": {
      "hostname": "mta.testname.com",
      "type": "CNAME",
      "value": "mailersend.net"
    },
    "custom_tracking": {
      "hostname": "email.testname.com",
      "type": "CNAME",
      "value": "links.mailersend.net"
    },
    "inbound_routing": {
      "hostname": "inbound.testname.com",
      "type": "MX",
      "value": "inbound.mailersend.net",
      "priority": "10"
    }
  }
}

Invalid

Response Code: 404 Not Found

Get verification status

If you want to retrieve the verification status for a domain, use this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}/verify

Request Parameters

URL ParameterTypeRequiredLimitationsDetails
domain_idstringyes
use MailerSend\MailerSend;

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

$mailersend->domain->verify('domain_id');

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.verifyDomain({
    domain_id: "xxx",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import domains

api_key = "API key here"

mailer = domains.NewDomain(api_key)

mailer.verify_domain("domain-id")

More examplesopen in new window

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"

	_, _, err := ms.Domain.Verify(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.domains.DomainVerificationStatus;
import com.mailersend.sdk.exceptions.MailerSendException;

public void VerifyDomain() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("api token");
    
    try {
        
        DomainVerificationStatus status = ms.domains().verifyDomain("domain id");
        
        System.out.println(status.message);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_domains = Mailersend::Domains.new
ms_domains.verify(domain_id: "idofdomain12412")

More examplesopen in new window

Responses

Valid

Domain verified:

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
  "message": "The domain is verified.",
  "data": {
    "dkim": true,
    "spf": true,
    "mx": true,
    "tracking": false,
    "cname": true,
    "rp_cname": true
  }
}

Domain not verified:

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
  "message": "The domain was not verified, please check your DNS records and try again.",
  "data": {
    "dkim": false,
    "spf": false,
    "mx": false,
    "tracking": false,
    "cname": false,
    "rp_cname": false
  }
}

Invalid

Response Code: 404 Not Found
Last Updated: