import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, DOMAIN } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!DOMAIN) throw new Error("Set DOMAIN (the sending domain, e.g. example.com)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.domains.check(DOMAIN);
if (error) {
console.error("Check domain failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
domain = os.environ.get("DOMAIN")
if not domain:
sys.exit("Set DOMAIN (the sending domain, e.g. example.com)")
# Check that DKIM, SPF, and Domain Lockdown records are configured correctly
# and have propagated.
response = mailchannels.CheckDomain.check(domain)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$domain = getenv('DOMAIN') or exit("Error: DOMAIN is not set\n");
$client = new Client(apiKey: $api_key);
// Check that DKIM, SPF, and Domain Lockdown records are configured correctly
// and have propagated.
$response = $client->checkDomain->check($domain);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/check-domain \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"domain": "<string>",
"dkim_settings": [
{
"dkim_domain": "<string>",
"dkim_private_key": "<string>",
"dkim_selector": "<string>"
}
],
"envelope_from_domain": "<string>",
"sender_id": "<string>"
}
'{
"check_results": {
"dkim": [
{
"dkim_domain": "<string>",
"dkim_key_status": "<string>",
"dkim_selector": "<string>",
"reason": "<string>",
"verdict": "passed"
}
],
"domain_lockdown": {
"reason": "<string>",
"verdict": "passed"
},
"sender_domain": {
"a": {
"reason": "<string>",
"verdict": "passed"
},
"mx": {
"reason": "<string>",
"verdict": "passed"
},
"verdict": "passed"
},
"spf": {
"reason": "<string>",
"spfRecord": "<string>",
"spfRecordError": "<string>",
"verdict": "passed"
}
},
"references": [
"<string>"
]
}{
"errors": [
"<string>"
]
}DKIM, SPF & Domain Lockdown Check
Validates a domain’s email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This endpoint checks whether the domain is properly configured for secure email delivery.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, DOMAIN } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!DOMAIN) throw new Error("Set DOMAIN (the sending domain, e.g. example.com)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.domains.check(DOMAIN);
if (error) {
console.error("Check domain failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
domain = os.environ.get("DOMAIN")
if not domain:
sys.exit("Set DOMAIN (the sending domain, e.g. example.com)")
# Check that DKIM, SPF, and Domain Lockdown records are configured correctly
# and have propagated.
response = mailchannels.CheckDomain.check(domain)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$domain = getenv('DOMAIN') or exit("Error: DOMAIN is not set\n");
$client = new Client(apiKey: $api_key);
// Check that DKIM, SPF, and Domain Lockdown records are configured correctly
// and have propagated.
$response = $client->checkDomain->check($domain);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/check-domain \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"domain": "<string>",
"dkim_settings": [
{
"dkim_domain": "<string>",
"dkim_private_key": "<string>",
"dkim_selector": "<string>"
}
],
"envelope_from_domain": "<string>",
"sender_id": "<string>"
}
'{
"check_results": {
"dkim": [
{
"dkim_domain": "<string>",
"dkim_key_status": "<string>",
"dkim_selector": "<string>",
"reason": "<string>",
"verdict": "passed"
}
],
"domain_lockdown": {
"reason": "<string>",
"verdict": "passed"
},
"sender_domain": {
"a": {
"reason": "<string>",
"verdict": "passed"
},
"mx": {
"reason": "<string>",
"verdict": "passed"
},
"verdict": "passed"
},
"spf": {
"reason": "<string>",
"spfRecord": "<string>",
"spfRecordError": "<string>",
"verdict": "passed"
}
},
"references": [
"<string>"
]
}{
"errors": [
"<string>"
]
}Headers
Body
Domain used for sending emails. If dkim_settings are not provided, or dkim_settings are provided with no dkim_domain, the stored dkim settings for this domain will be used.
Each item may include DKIM domain, selector and private key. Up to 10 items are allowed. The absence or presence of these fields affects how DKIM settings are validated:
- If dkim_domain, dkim_selector, and dkim_private_key are all present, verify using the provided domain, selector, and key.
- If dkim_domain and dkim_selector are present, use the stored private key for the given domain and selector.
- If only dkim_domain is present, use all stored keys for the given domain.
- If none are present, use all stored keys for the domain provided in the
domainfield of the request. - If dkim_private_key is present, dkim_selector must be present.
- If dkim_selector is present and dkim_domain is not, the domain will be taken from the
domainfield of the request.
10Show child attributes
Show child attributes
Optional envelope-from domain. During message delivery, SPF and Domain Lockdown verification are evaluated against the envelope sender domain. If your envelope-from domain differs from the domain used for sending messages, provide it here to ensure both checks are run against the correct domain. Otherwise, SPF or Domain Lockdown failures may cause message delivery to fail.
Used exclusively for Domain Lockdown verification.
If you're not using senderid to associate your domain with your account, you can disregard this field.
The corresponding value is included in the X-MailChannels-SenderId header of emails sent via MailChannels.
Was this page helpful?

