> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailchannels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Custom Tracking Domain

> Permanently delete an existing custom tracking domain for the given hostname and scope. The domain can be re-registered if needed.
WARNING: Any tracking links or unsubscribe URLs in previously sent emails using this domain will stop working immediately.




## OpenAPI

````yaml /email-api/api-reference/openapi.yaml delete /custom-tracking-domains/{hostname}/{scope}
openapi: 3.0.0
info:
  contact:
    email: support@mailchannels.com
    name: MailChannels Corporation
  description: >
    This is the API reference for Email API. Here, you'll find more detailed
    information on every endpoint, including parameters, response formats, and
    error codes.
  title: Email API
  version: 1.7.1
servers:
  - url: https://api.mailchannels.net/tx/v1
security: []
tags:
  - name: Send
  - name: DKIM
  - name: Metrics
  - name: Sub-accounts
  - name: Suppression
  - name: Webhooks
  - name: Usage
  - name: Custom Tracking
paths:
  /custom-tracking-domains/{hostname}/{scope}:
    delete:
      tags:
        - Custom Tracking
      summary: Delete Custom Tracking Domain
      description: >
        Permanently delete an existing custom tracking domain for the given
        hostname and scope. The domain can be re-registered if needed.

        WARNING: Any tracking links or unsubscribe URLs in previously sent
        emails using this domain will stop working immediately.
      parameters:
        - in: path
          name: hostname
          required: true
          schema:
            type: string
        - in: path
          name: scope
          required: true
          schema:
            enum:
              - click
              - open
              - unsubscribe
            type: string
        - in: header
          name: X-Api-Key
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Custom tracking domain successfully deleted
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid hostname or scope value
        '500':
          description: Internal server error
      x-codeSamples:
        - label: Node.js
          lang: javascript
          source: >-
            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);


            // Permanently delete a custom tracking domain by hostname and
            scope.

            const { success, error } = await
            mailchannels.domains.customTracking.delete(TRACKING_HOSTNAME,
            "click");


            if (!success) {
              console.error("Delete custom tracking domain failed:", error);
              process.exit(1);
            }

            console.log("Custom tracking domain deleted");
        - label: Python
          lang: python
          source: >-
            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)")

            # Permanently delete a custom tracking domain by hostname and scope.

            response = mailchannels.CustomTrackingDomains.delete(hostname,
            "click")


            print(response)
        - label: PHP
          lang: php
          source: >-
            <?php


            require_once __DIR__ . '/vendor/autoload.php';


            use MailChannels\Client;

            use MailChannels\Enum\CustomTrackingScope;


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


            // Permanently delete a custom tracking domain by hostname and
            scope.

            $response = $client->customTrackingDomains->delete($hostname,
            CustomTrackingScope::Click);


            echo "HTTP Status: " . $response->statusCode . "\n";
components:
  schemas:
    ErrorResponse:
      properties:
        errors:
          description: >
            This is an array error objects that provide machine and human
            readable descriptions of the errors.
          items:
            type: string
          type: array
      type: object

````