Skip to content

Create DKIM Key method 🌐 Domains

Create a DKIM key pair for a specified domain and selector using the specified algorithm and key length, for the current customer.

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.dkim.create('example.com', {
  selector: 'mailchannels'
})
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { data, error } = await mailchannels.domains.dkim.create('example.com', {
  selector: 'mailchannels'
})

Params

  • domain string required: The domain to create the DKIM key for.
  • options DomainsDkimCreateOptions required: Create DKIM key options.
    • algorithm "rsa" optional: Algorithm used for the new key pair Currently, only RSA is supported. Defaults to rsa.
    • length 1024 | 2048 | 3072 | 4096 optional: Key length in bits. For RSA, must be a multiple of 1024.

      TIP

      Defaults to 2048. Common values: 1024 or 2048.

    • selector string required: Selector for the new key pair. Must be a maximum of 63 characters.

Response

  • data DomainsDkimKey | null nullable: The created DKIM key information.
    • algorithm string guaranteed: Algorithm used for the key pair.
    • createdAt string optional: Timestamp when the key pair was created.
    • dnsRecords object[] guaranteed: Suggested DNS records for the DKIM key.
      • name string guaranteed
      • type string guaranteed
      • value string guaranteed
    • domain string guaranteed: Domain associated with the key pair.
    • gracePeriodExpiresAt string optional: UTC timestamp after which you can no longer use the rotated key for signing.
    • length 1024 | 2048 | 3072 | 4096 guaranteed: Key length in bits.
    • publicKey string guaranteed
    • retiresAt string optional: UTC timestamp when a rotated key pair is retired.
    • selector string guaranteed: Selector assigned to the key pair.
    • status "active" | "revoked" | "retired" | "rotated" guaranteed: Status of the key.
    • statusModifiedAt string optional: Timestamp when the key was last modified.
  • error ErrorResponse | null nullable: Error information if the operation failed.
    • message string guaranteed: A human-readable description of the error.
    • statusCode number | null nullable: The HTTP status code from the API, or null if the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.
    • type string guaranteed: 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 create (domain: string, options: DomainsDkimCreateOptions): Promise<DomainsDkimCreateResponse>

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

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

Source

SourcePlaygroundDocsTests

Released under the MIT License.