Node.js
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, TRACKING_HOSTNAME } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!TRACKING_HOSTNAME) throw new Error("Set TRACKING_HOSTNAME (e.g. click.example.com)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
// Disable a custom tracking domain (identified by hostname and scope) without deleting it.
const { data, error } = await mailchannels.domains.customTracking.update(TRACKING_HOSTNAME, "click", {
status: "disabled",
});
if (error) {
console.error("Update custom tracking domain failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
hostname = os.environ.get("TRACKING_HOSTNAME")
if not hostname:
sys.exit("Set TRACKING_HOSTNAME (e.g. click.example.com)")
# Disable a custom tracking domain (identified by hostname and scope) without deleting it.
response = mailchannels.CustomTrackingDomains.update(hostname, "click", status="disabled")
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
use MailChannels\Enum\CustomTrackingScope;
use MailChannels\Enum\CustomTrackingStatus;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$hostname = getenv('TRACKING_HOSTNAME') or exit("Error: TRACKING_HOSTNAME is not set\n");
$client = new Client(apiKey: $api_key);
// Disable a custom tracking domain (identified by hostname and scope) without deleting it.
$response = $client->customTrackingDomains->update(
$hostname,
CustomTrackingScope::Click,
status: CustomTrackingStatus::Disabled,
);
print_r($response->toArray());curl --request PATCH \
--url https://api.mailchannels.net/tx/v1/custom-tracking-domains/{hostname}/{scope} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"name": "<string>"
}
'{
"created_at": "2023-11-07T05:31:56Z",
"hostname": "<string>",
"name": "<string>",
"scope": "click",
"status": "active"
}{
"instructions": "<string>",
"token": "550e8400-e29b-41d4-a716-446655440000",
"txt_record_name": "_mailchannels-verify.click.example.com",
"txt_record_value": "550e8400-e29b-41d4-a716-446655440000"
}{
"errors": [
"<string>"
]
}{
"instructions": "<string>",
"token": "550e8400-e29b-41d4-a716-446655440000",
"txt_record_name": "_mailchannels-verify.click.example.com",
"txt_record_value": "550e8400-e29b-41d4-a716-446655440000"
}Update Custom Tracking Domain
Update an existing custom tracking domain by its hostname and scope. Supports updating the custom tracking domain’s name or toggling its active status.
PATCH
/
custom-tracking-domains
/
{hostname}
/
{scope}
Node.js
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, TRACKING_HOSTNAME } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!TRACKING_HOSTNAME) throw new Error("Set TRACKING_HOSTNAME (e.g. click.example.com)");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
// Disable a custom tracking domain (identified by hostname and scope) without deleting it.
const { data, error } = await mailchannels.domains.customTracking.update(TRACKING_HOSTNAME, "click", {
status: "disabled",
});
if (error) {
console.error("Update custom tracking domain failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
hostname = os.environ.get("TRACKING_HOSTNAME")
if not hostname:
sys.exit("Set TRACKING_HOSTNAME (e.g. click.example.com)")
# Disable a custom tracking domain (identified by hostname and scope) without deleting it.
response = mailchannels.CustomTrackingDomains.update(hostname, "click", status="disabled")
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
use MailChannels\Enum\CustomTrackingScope;
use MailChannels\Enum\CustomTrackingStatus;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$hostname = getenv('TRACKING_HOSTNAME') or exit("Error: TRACKING_HOSTNAME is not set\n");
$client = new Client(apiKey: $api_key);
// Disable a custom tracking domain (identified by hostname and scope) without deleting it.
$response = $client->customTrackingDomains->update(
$hostname,
CustomTrackingScope::Click,
status: CustomTrackingStatus::Disabled,
);
print_r($response->toArray());curl --request PATCH \
--url https://api.mailchannels.net/tx/v1/custom-tracking-domains/{hostname}/{scope} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"name": "<string>"
}
'{
"created_at": "2023-11-07T05:31:56Z",
"hostname": "<string>",
"name": "<string>",
"scope": "click",
"status": "active"
}{
"instructions": "<string>",
"token": "550e8400-e29b-41d4-a716-446655440000",
"txt_record_name": "_mailchannels-verify.click.example.com",
"txt_record_value": "550e8400-e29b-41d4-a716-446655440000"
}{
"errors": [
"<string>"
]
}{
"instructions": "<string>",
"token": "550e8400-e29b-41d4-a716-446655440000",
"txt_record_name": "_mailchannels-verify.click.example.com",
"txt_record_value": "550e8400-e29b-41d4-a716-446655440000"
}Headers
Path Parameters
Available options:
click, open, unsubscribe Body
application/json
Response
Custom tracking domain updated
ISO 8601 timestamp when the domain was registered
The registered domain hostname
The label for this custom tracking domain
The event type this domain handles
Available options:
click, open, unsubscribe Current status of the custom tracking domain
Available options:
active, disabled Was this page helpful?

