import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, DOMAIN, SELECTOR } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!DOMAIN) throw new Error("Set DOMAIN (the sending domain, e.g. example.com)");
if (!SELECTOR) throw new Error("Set SELECTOR (the DKIM key selector to update)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { success, error } = await mailchannels.domains.dkim.updateStatus(DOMAIN, {
selector: SELECTOR,
status: "retired",
});
if (!success) {
console.error("Update DKIM key status failed:", error);
process.exit(1);
}
console.log({ success });import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
domain = os.environ.get("DOMAIN")
selector = os.environ.get("SELECTOR")
if not domain:
sys.exit("Set DOMAIN (the sending domain, e.g. example.com)")
if not selector:
sys.exit("Set SELECTOR (the DKIM key selector to update)")
response = mailchannels.Dkim.update_status(domain, selector, status="retired")
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$domain = getenv('DOMAIN') or exit("Error: DOMAIN is not set\n");
$selector = getenv('SELECTOR') or exit("Error: SELECTOR is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->dkim->updateStatus($domain, $selector, 'retired');
echo "HTTP Status: " . $response->statusCode . "\n";curl --request PATCH \
--url https://api.mailchannels.net/tx/v1/domains/{domain}/dkim-keys/{selector} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '{}'{
"errors": [
"<string>"
]
}Update DKIM Key Status
Update fields of an existing DKIM key pair for the specified domain and selector, for the current customer. Currently, only the status field can be updated. revoked: Indicates that the key is compromised and should not be used. retired: Indicates that the key has been rotated and is no longer in use. rotated: Indicates that the key is going through the rotation process. Only active key pairs can be updated to this status, and no new key pair is created. The rotated key can be used to sign emails for 3 days after the status update, and will automatically change to ‘retired’ 2 weeks after update. For a smooth key transition, it is recommended to create and publish a new key pair before signing is disabled for the rotated key.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, DOMAIN, SELECTOR } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!DOMAIN) throw new Error("Set DOMAIN (the sending domain, e.g. example.com)");
if (!SELECTOR) throw new Error("Set SELECTOR (the DKIM key selector to update)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { success, error } = await mailchannels.domains.dkim.updateStatus(DOMAIN, {
selector: SELECTOR,
status: "retired",
});
if (!success) {
console.error("Update DKIM key status failed:", error);
process.exit(1);
}
console.log({ success });import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
domain = os.environ.get("DOMAIN")
selector = os.environ.get("SELECTOR")
if not domain:
sys.exit("Set DOMAIN (the sending domain, e.g. example.com)")
if not selector:
sys.exit("Set SELECTOR (the DKIM key selector to update)")
response = mailchannels.Dkim.update_status(domain, selector, status="retired")
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$domain = getenv('DOMAIN') or exit("Error: DOMAIN is not set\n");
$selector = getenv('SELECTOR') or exit("Error: SELECTOR is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->dkim->updateStatus($domain, $selector, 'retired');
echo "HTTP Status: " . $response->statusCode . "\n";curl --request PATCH \
--url https://api.mailchannels.net/tx/v1/domains/{domain}/dkim-keys/{selector} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '{}'{
"errors": [
"<string>"
]
}Was this page helpful?

