Rotate DKIM Key method 🌐 Domains
Rotate an active DKIM key pair. Mark the original key as rotated, and create a new key pair with the required new key selector, reusing the same algorithm and key length. The rotated key remains valid for signing for a 3-day grace period, and is automatically changed to retired 2 weeks after rotation. Publish the new key to its DNS TXT record before rotated key expires for signing as emails sent with an unpublished key will fail DKIM validation by receiving providers. After the grace period, only the new key is valid for signing if published.
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.rotate('example.com', 'mailchannels', {
newKey: {
selector: 'new-selector'
}
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.domains.dkim.rotate('example.com', 'mailchannels', {
newKey: {
selector: 'new-selector'
}
})Params
domainstringrequired: The domain the DKIM key belongs to.selectorstringrequired: The selector of the DKIM key to rotate. Must be a maximum of 63 characters.optionsobjectrequired: The options to rotate the DKIM key.newKeyobjectrequired: New DKIM key options.selectorstringrequired: The selector for the new key pair. Must be a maximum of 63 characters.
Response
dataobject | nullnullable: The rotated and new DKIM key information.newDomainsDkimKeyguaranteedalgorithmstringguaranteed: Algorithm used for the key pair.createdAtstringoptional: Timestamp when the key pair was created.dnsRecordsobject[]guaranteed: Suggested DNS records for the DKIM key.namestringguaranteedtypestringguaranteedvaluestringguaranteed
domainstringguaranteed: Domain associated with the key pair.gracePeriodExpiresAtstringoptional: UTC timestamp after which you can no longer use the rotated key for signing.length1024 | 2048 | 3072 | 4096guaranteed: Key length in bits.publicKeystringguaranteedretiresAtstringoptional: UTC timestamp when a rotated key pair is retired.selectorstringguaranteed: Selector assigned to the key pair.status"active" | "revoked" | "retired" | "rotated"guaranteed: Status of the key.statusModifiedAtstringoptional: Timestamp when the key was last modified.
rotatedDomainsDkimKeyguaranteedalgorithmstringguaranteed: Algorithm used for the key pair.createdAtstringoptional: Timestamp when the key pair was created.dnsRecordsobject[]guaranteed: Suggested DNS records for the DKIM key.namestringguaranteedtypestringguaranteedvaluestringguaranteed
domainstringguaranteed: Domain associated with the key pair.gracePeriodExpiresAtstringoptional: UTC timestamp after which you can no longer use the rotated key for signing.length1024 | 2048 | 3072 | 4096guaranteed: Key length in bits.publicKeystringguaranteedretiresAtstringoptional: UTC timestamp when a rotated key pair is retired.selectorstringguaranteed: Selector assigned to the key pair.status"active" | "revoked" | "retired" | "rotated"guaranteed: Status of the key.statusModifiedAtstringoptional: Timestamp when the key was last modified.
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 rotate (domain: string, selector: string, options: DomainsDkimRotateOptions): Promise<DomainsDkimRotateResponse>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
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;
}Rotate DKIM Key type declarations
ts
interface DomainsDkimRotateOptions {
newKey: {
selector: string;
};
}ts
type DomainsDkimRotateResponse = DataResponse<{
new: DomainsDkimKey;
rotated: DomainsDkimKey;
}>;Source
Source • Playground • Docs • Tests