Update Custom Tracking Domain method 🌐 Domains
Update an existing custom tracking domain by its hostname and scope. Supports updating the custom tracking domain's name or toggling its active status.
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.customTracking.update('click.example.com', 'click', {
name: 'newclickname',
status: 'active'
})
if (error) {
throw new Error(error.message)
}
if (data.dnsSetupRequired) {
// DNS setup required fields available here
}
else {
// Domain fields available here
}ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.domains.customTracking.update('click.example.com', 'click', {
name: 'newclickname',
status: 'active'
})
if (error) {
throw new Error(error.message)
}
if (data.dnsSetupRequired) {
// DNS setup required fields available here
}
else {
// Domain fields available here
}Params
hostnamestringrequired: The hostname of the custom tracking domain to update.scopeDomainsCustomTrackingScoperequired: The scope of the custom tracking domain to update (click,open,unsubscribe).optionsDomainsCustomTrackingUpdateOptionsrequired: The options for updating the custom tracking domain.namestringoptional: New label for this custom tracking domain.IMPORTANT
Maximum length is
64characters. Must match the pattern^[a-z0-9-]+$.status"active" | "disabled"optional: New status. Re-activation requires DNS verification — add the TXT record and CNAME record described in the response body, then retry.
Response
dataDomainsCustomTrackingWithDnsSetupRequired | nullnullable: The updated domain or DNS verification info when pending.- When DNS setup is complete:
dnsSetupRequiredfalseguaranteed: Whether DNS setup is required for this domain.namestringguaranteed: The label for this custom tracking domain.hostnamestringguaranteed: The registered domain hostname.scopeDomainsCustomTrackingScopeguaranteed: The event type this domain handles (click,open,unsubscribe).status"active" | "disabled"guaranteed: Current status of the custom tracking domain.createdAtstringguaranteed: ISO 8601 timestamp when the domain was registered.
- When DNS setup is required:
dnsSetupRequiredtrueguaranteed: Whether DNS setup is required for this domain.tokenstringoptional: UUID v4 nonce; also the TXT record value to set. Present only when TXT ownership verification is pending.txtRecordNamestringoptional: Fully-qualified DNS TXT record name to add. Present only when TXT ownership verification is pending.txtRecordValuestringoptional: Value for the DNS TXT record. Present only when TXT ownership verification is pending.instructionsstringoptional: Human-readable guidance for the DNS records that must be in place before retrying.
- When DNS setup is complete:
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.responseRecord<string, unknown> | nullnullable: An object containing the response, if available. This field may benullif no response is available or if the error is not related to an HTTP request or if the response is not a JSON object.
Type declarations
Signature
ts
async function update (hostname: string, scope: DomainsCustomTrackingScope, options: DomainsCustomTrackingUpdateOptions): Promise<DomainsCustomTrackingUpdateResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
response: Record<string, unknown> | null;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};Custom Tracking Domain type declarations
ts
type DomainsCustomTrackingScope = "click" | "open" | "unsubscribe";ts
interface DomainsCustomTrackingDomain {
name: string;
hostname: string;
scope: DomainsCustomTrackingScope;
status: "active" | "disabled";
createdAt: string;
}Update Custom Tracking Domain type declarations
ts
interface DomainsCustomTrackingUpdateOptions {
name?: string;
status?: "active" | "disabled";
}ts
interface DomainsCustomTrackingDnsSetupRequired {
token?: string;
txtRecordName?: string;
txtRecordValue?: string;
instructions?: string;
}ts
type DomainsCustomTrackingWithDnsSetupRequired<T extends 202 | 201 | 200 | undefined = undefined> =
T extends undefined
? | DomainsCustomTrackingDomain & { dnsSetupRequired: false }
| DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: T extends 202
? DomainsCustomTrackingDnsSetupRequired & { dnsSetupRequired: true }
: DomainsCustomTrackingDomain & { dnsSetupRequired: false };ts
type DomainsCustomTrackingUpdateResponse = DataResponse<DomainsCustomTrackingWithDnsSetupRequired>;Source
Source • Playground • Docs • Tests