Skip to content

🌐 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 ​

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

Changelog ​

  • v1.2.0 on Jul 6, 2026

    • 5f9d0b7 β€” refactor(domains): replace options object with positional params
    • 7c35915 β€” feat: add custom tracking domains and update send options
  • v1.1.0 on Jun 12, 2026

    • 5a34b8a β€” fix: encode path params in all api requests
    • b2cf377 β€” refactor: restructure modules into module directories
  • v1.0.0 on May 26, 2026

    • f49c49f β€” feat(errors): introduce error type keys
  • v0.8.0 on May 27, 2026

    • 2d13d37 β€” refactor(domains-check)!: accept domain as first argument
    • daa8864 β€” fix: validate domain presence in domain methods
    • ab66dc1 β€” refactor: split internal utils into focused modules
    • bd4c25f β€” refactor!: rename webhooks enroll and dkim update methods

Released under the MIT License.