Skip to content

๐ŸŒ Domains module Email API

This module allows you to check a domain's email authentication and manage DKIM keys for secure email delivery.

Methods โ€‹

Type declarations โ€‹

ts
class Domains {
  readonly dkim: DomainsDkim;
  constructor (protected mailchannels: MailChannelsClient);
  async check (domain: string, options?: DomainsCheckOptions): Promise<DomainsCheckResponse>;
}

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>;
}
All type declarations

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;
};
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;
}>;

Source โ€‹

Source โ€ข Playground โ€ข Docs โ€ข Tests

Changelog โ€‹

  • Unreleased 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.