Check Domain method 🌐 Domains
DKIM, SPF & Domain Lockdown Check
Validates a domain's email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This method checks whether the domain is properly configured for secure email delivery.
Usage
ts
import { MailChannelsClient, Domains } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const domains = new Domains(mailchannels)
const { data, error } = await domains.check('example.com', {
dkim: {
domain: 'example.com',
selector: 'your-dkim-selector',
privateKey: 'your-dkim-private-key'
},
senderId: 'your-sender-id'
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.domains.check('example.com', {
dkim: {
domain: 'example.com',
selector: 'your-dkim-selector',
privateKey: 'your-dkim-private-key'
},
senderId: 'your-sender-id'
})Params
domainstringrequired: Domain used for sending emails. Ifdkimsettings are not provided, ordkimsettings are provided with nodomain, the stored dkim settings for this domain will be used.optionsDomainsCheckOptionsoptional: Check domain options.dkimDomainsCheck[] | DomainsCheckoptional: The DKIM settings for the domain.domainstringoptional: The DKIM domain to sign the email with.privateKeystringoptional: The DKIM private key to sign the email with. Encoded in Base64.selectorstringoptional: The DKIM selector to use.
TIP
The absence or presence of these fields affects how DKIM settings are validated:
- If
domain,selector, andprivateKeyare all present, verify using the provided domain, selector, and key. - If
domainandselectorare present, use the stored private key for the given domain and selector. - If only
domainis present, use all stored keys for the given domain. - If none are present, use all stored keys for the
domainprovided in the domain field of the request. - If
privateKeyis present,selectormust be present. - If
selectoris present anddomainis not, the domain will be taken from the domain field of the request.
senderIdstringoptional: Used exclusively for Domain Lockdown verification. If you're not using senderid to associate your domain with your account, you can disregard this field.INFO
Your
senderIdis theX-MailChannels-Sender-Idheader value in emails sent via MailChannels.
Response
dataobject | nullnullable: The results of the domain checks.dkimobject[]guaranteeddomainstringguaranteedkeyStatus"active" | "revoked" | "retired" | "provided" | "rotated"guaranteed: The human readable status of the DKIM key used for verification.selectorstringguaranteedreasonstringoptional: A human-readable explanation of DKIM check.verdict"passed" | "failed"guaranteed
domainLockdownobjectguaranteedreasonstringoptional: A human-readable explanation of Domain Lockdown check.verdict"passed" | "failed"guaranteed
senderDomainobjectguaranteed: These results are here to help avoid SDNF (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain.aobjectguaranteedreasonstringoptional: A human-readable explanation of A record check.verdict"passed" | "failed"guaranteed
mxobjectguaranteedreasonstringoptional: A human-readable explanation of MX record check.verdict"passed" | "failed"guaranteed
spfobjectguaranteedreasonstringoptional: A human-readable explanation of SPF check.spfRecordstringoptional: The SPF record that was used for the check.spfRecordErrorstringoptional: Error message if the SPF record lookup failed.verdict"passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown"guaranteed
referencesstring[]optional
errorErrorResponse | nullnullable: Error information if the operation failed.messagestringguaranteed: A human-readable description of the error.statusCodenumber | nullnullable: The HTTP status code from the API, ornullif the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.typestringguaranteed: A string identifier for the type of error. This field is intended for diagnostic use only and should not be relied upon.
Type declarations
Signature
ts
async function check (domain: string, options?: DomainsCheckOptions): Promise<DomainsCheckResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};DKIM key type declarations
ts
type DomainsDkimKeyStatus = "active" | "retired" | "revoked" | "rotated";ts
interface DomainsDkimKey {
algorithm: string;
createdAt?: string;
dnsRecords: {
name: string;
type: string;
value: string;
}[];
domain: string;
gracePeriodExpiresAt?: string;
length: 1024 | 2048 | 3072 | 4096;
publicKey: string;
retiresAt?: string;
selector: string;
status: DomainsDkimKeyStatus;
statusModifiedAt?: string;
}Check Domain type declarations
ts
interface DomainsCheck {
domain?: string;
privateKey?: string;
selector?: string;
}ts
interface DomainsCheckOptions {
dkim?: DomainsCheck[] | DomainsCheck;
senderId?: string;
}ts
type DomainsCheckVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";ts
type DomainsCheckResponse = DataResponse<{
dkim: {
domain: string;
keyStatus?: DomainsDkimKey["status"] | "provided";
selector: string;
reason?: string;
verdict: Extract<DomainsCheckVerdict, "passed" | "failed">;
}[];
domainLockdown: {
reason?: string;
verdict: Extract<DomainsCheckVerdict, "passed" | "failed">;
};
senderDomain: {
a: {
reason?: string;
verdict: Extract<DomainsCheckVerdict, "passed" | "failed">;
};
mx: {
reason?: string;
verdict: Extract<DomainsCheckVerdict, "passed" | "failed">;
};
verdict: Extract<DomainsCheckVerdict, "passed" | "failed">;
};
spf: {
reason?: string;
spfRecord?: string;
spfRecordError?: string;
verdict: DomainsCheckVerdict;
};
references?: string[];
}>;Source
Source • Playground • Docs • Tests