π Domains module Email API
This module allows you to check a domain's email authentication, manage DKIM keys for secure email delivery, and manage custom tracking domains.
Methods β
- Check Domain
- Create DKIM Key
- List DKIM Keys
- Update DKIM Key Status
- Rotate DKIM Key
- Create Custom Tracking Domain
- List Custom Tracking Domains
- Delete Custom Tracking Domain
- Update Custom Tracking Domain
Type declarations β
ts
class Domains {
readonly dkim: DomainsDkim;
readonly customTracking: DomainsCustomTracking;
constructor (protected mailchannels: MailChannelsClient);
async check (domain: string, options?: DomainsCheckOptions): Promise<DomainsCheckResponse>;
}ts
class DomainsDkim {
constructor (private mailchannels: MailChannelsClient);
async create (domain: string, options: DomainsDkimCreateOptions): Promise<DomainsDkimCreateResponse>;
async list (domain: string, options?: DomainsDkimListOptions): Promise<DomainsDkimListResponse>;
async updateStatus (domain: string, options: DomainsDkimUpdateStatusOptions): Promise<SuccessResponse>;
async rotate (domain: string, selector: string, options: DomainsDkimRotateOptions): Promise<DomainsDkimRotateResponse>;
}ts
class DomainsCustomTracking {
constructor (private mailchannels: MailChannelsClient);
async list (options?: DomainsCustomTrackingListOptions): Promise<DomainsCustomTrackingListResponse>;
async create (name: string, hostname: string, scope: DomainsCustomTrackingScope): Promise<DomainsCustomTrackingCreateResponse>;
async update (hostname: string, scope: DomainsCustomTrackingScope, options: DomainsCustomTrackingUpdateOptions): Promise<DomainsCustomTrackingUpdateResponse>;
async delete (hostname: string, scope: DomainsCustomTrackingScope): Promise<SuccessResponse>;
}All type declarations
Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
response: Record<string, unknown> | null;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};ts
interface SuccessResponse {
success: boolean;
error: ErrorResponse | null;
}Domain check 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[];
}>;Create DKIM Key type declarations
ts
interface DomainsDkimCreateOptions {
algorithm?: "rsa";
length?: 1024 | 2048 | 3072 | 4096;
selector: string;
}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;
}ts
type DomainsDkimCreateResponse = DataResponse<DomainsDkimKey>;List DKIM Keys type declarations
ts
interface DomainsDkimListOptions {
selector?: string;
status?: DomainsDkimKey["status"];
offset?: number;
limit?: number;
includeDnsRecord?: boolean;
}ts
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;ts
type DomainsDkimListResponse = DataResponse<Optional<DomainsDkimKey, "dnsRecords">[]>;Update DKIM Key type declarations
ts
interface DomainsDkimUpdateStatusOptions {
selector: string;
status: Exclude<DomainsDkimKey["status"], "active">;
}Rotate DKIM Key type declarations
ts
interface DomainsDkimRotateOptions {
newKey: {
selector: string;
};
}ts
type DomainsDkimRotateResponse = DataResponse<{
new: DomainsDkimKey;
rotated: DomainsDkimKey;
}>;Custom Tracking Domain type declarations
ts
type DomainsCustomTrackingScope = "click" | "open" | "unsubscribe";ts
interface DomainsCustomTrackingDomain {
name: string;
hostname: string;
scope: DomainsCustomTrackingScope;
status: "active" | "disabled";
createdAt: string;
}ts
type DomainsCustomTrackingWithDnsSetupRequired<T extends 202 | 201 | 200 | undefined = undefined> =
T extends undefined
? | DomainsCustomTrackingDomain & { dnsSetupRequired: false }
| DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: T extends 202
? DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: DomainsCustomTrackingDomain & { dnsSetupRequired: false };Create Custom Tracking Domain type declarations
ts
interface DomainsCustomTrackingDnsSetupRequired {
token?: string;
txtRecordName?: string;
txtRecordValue?: string;
instructions?: string;
}ts
type DomainsCustomTrackingCreateResponse = DataResponse<DomainsCustomTrackingWithDnsSetupRequired>;List Custom Tracking Domains response type declarations
ts
interface DomainsCustomTrackingListOptions {
name?: string;
status?: "active" | "disabled";
scope?: DomainsCustomTrackingScope;
limit?: number;
offset?: number;
}ts
type DomainsCustomTrackingListResponse = DataResponse<{
customTrackingDomains: DomainsCustomTrackingDomain[];
total: number;
}>;Update Custom Tracking Domain type declarations
ts
interface DomainsCustomTrackingUpdateOptions {
name?: string;
status?: "active" | "disabled";
}ts
interface DomainsCustomTrackingDnsSetupRequired {
token?: string;
txtRecordName?: string;
txtRecordValue?: string;
instructions?: string;
}ts
type DomainsCustomTrackingWithDnsSetupRequired<T extends 202 | 201 | 200 | undefined = undefined> =
T extends undefined
? | DomainsCustomTrackingDomain & { dnsSetupRequired: false }
| DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: T extends 202
? DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: DomainsCustomTrackingDomain & { dnsSetupRequired: false };ts
type DomainsCustomTrackingUpdateResponse = DataResponse<DomainsCustomTrackingWithDnsSetupRequired>;Source β
Source β’ Playground β’ Docs β’ Tests