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

# Email Domains

> Manage custom email domains for enhanced deliverability and branding with Contiguity.

<Tabs>
  <Tab title="JavaScript" icon="js">
    ## Installing the SDK

    <Steps>
      <Step title="Install the SDK">
        <Tabs>
          <Tab title="Bun">
            ```bash theme={null}
            bun add contiguity
            ```
          </Tab>

          <Tab title="pnpm">
            ```bash theme={null}
            pnpm add contiguity
            ```
          </Tab>

          <Tab title="npm">
            ```bash theme={null}
            npm install contiguity
            ```
          </Tab>

          <Tab title="Yarn">
            ```bash theme={null}
            yarn add contiguity
            ```
          </Tab>
        </Tabs>
      </Step>

      <Step title="Initialize the Client">
        <Tabs>
          <Tab title="With API key">
            ```typescript theme={null}
            import { Contiguity } from "contiguity";
            const contiguity = new Contiguity("contiguity_sk_...your_key...");
            ```
          </Tab>

          <Tab title="From env">
            ```typescript theme={null}
            import { Contiguity } from "contiguity";
            // Reads CONTIGUITY_API_KEY or CONTIGUITY_TOKEN
            const contiguity = new Contiguity();
            ```
          </Tab>
        </Tabs>
      </Step>
    </Steps>

    ## Managing Email Domains

    Use your own custom domains to send emails, improving deliverability and maintaining brand consistency.

    ## List All Domains

    View all domains currently registered with your account.

    ```typescript theme={null}
    const res = await contiguity.domains.list();
    ```

    ### Response

    <ResponseField name="domains" type="object[]">
      Array of all domains registered with your account, including their verification status and configuration details.
    </ResponseField>

    <ResponseField name="metadata" type="object">
      Request metadata including ID, timestamp, and API version.
    </ResponseField>

    ## Get Domain Details

    Get detailed information about a specific domain, including verification status and DNS records.

    ```typescript theme={null}
    const res = await contiguity.domains.get({ 
      domain: "example.com" 
    });
    ```

    ### Response

    <ResponseField name="status" type="string">
      Current verification status of the domain (e.g., "verified", "pending", "failed").
    </ResponseField>

    <ResponseField name="records" type="object[]">
      Array of DNS records required for domain verification and email sending.
    </ResponseField>

    <ResponseField name="verifications" type="object">
      Detailed verification status for each DNS record type (DKIM, SPF, DMARC).
    </ResponseField>

    <ResponseField name="metadata" type="object">
      Request metadata including ID, timestamp, and API version.
    </ResponseField>

    ## Register a Domain

    Add a new domain to your account for sending emails.

    ```typescript theme={null}
    const res = await contiguity.domains.register({ 
      domain: "example.com", 
      region: "us-east-1", 
      custom_return_path: "mail" 
    });
    ```

    ### Response

    <ResponseField name="status" type="string">
      Registration status of the domain (e.g., "registered", "pending\_verification").
    </ResponseField>

    <ResponseField name="records" type="object[]">
      Array of DNS records that must be added to your domain's DNS settings for verification.

      <Expandable title="DNS Record Properties">
        <ResponseField name="type" type="string">
          Type of DNS record (e.g., "CNAME", "TXT", "MX").
        </ResponseField>

        <ResponseField name="name" type="string">
          DNS record name/host that should be added.
        </ResponseField>

        <ResponseField name="value" type="string">
          DNS record value that should be set.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="metadata" type="object">
      Request metadata including ID, timestamp, and API version.
    </ResponseField>

    You can also register a domain with minimal configuration:

    ```typescript theme={null}
    const res = await contiguity.domains.register({ 
      domain: "example.com"
    });
    ```

    ## Delete a Domain

    Remove a domain from your account when it's no longer needed.

    ```typescript theme={null}
    const res = await contiguity.domains.delete({ 
      domain: "example.com" 
    });
    ```

    ### Response

    <ResponseField name="success" type="boolean">
      Indicates whether the domain was successfully deleted.
    </ResponseField>

    <ResponseField name="message" type="string">
      Confirmation message about the deletion status.
    </ResponseField>

    <ResponseField name="metadata" type="object">
      Request metadata including ID, timestamp, and API version.
    </ResponseField>

    ## Parameters

    ### domains.list()

    No parameters required. Returns all registered domains.

    ### domains.get(params)

    <ParamField body="domain" type="string" required>
      The domain name to get details for (e.g., "example.com").
    </ParamField>

    ### domains.register(params)

    <ParamField body="domain" type="string" required>
      The domain name to register (e.g., "example.com"). Must be a valid domain you own.
    </ParamField>

    <ParamField body="region" type="string">
      AWS region for domain setup. Common options: `"us-east-1"`, `"us-west-2"`, `"eu-west-1"`. Defaults to `"us-east-1"` if not specified.
    </ParamField>

    <ParamField body="custom_return_path" type="string">
      Custom return path subdomain for bounce handling. If set to `"mail"`, bounce emails will be handled at `mail.yourdomain.com`.
    </ParamField>

    ### domains.delete(params)

    <ParamField body="domain" type="string" required>
      The domain name to delete from your account (e.g., "example.com").
    </ParamField>

    ## Using Custom Domains

    Once your domain is verified, you can use it to send emails with your brand:

    ```typescript theme={null}
    // Send email from your custom domain
    const res = await contiguity.email.send({
      to: "user@example.com",
      from: "Your App <hello@yourdomain.com>", // Use your verified domain
      subject: "Welcome to our platform!",
      html: "<h1>Welcome!</h1><p>Thanks for joining us.</p>",
      text: "Welcome! Thanks for joining us.",
      reply_to: "support@yourdomain.com"
    });
    ```

    ## Domain Verification

    After registering a domain, you'll need to:

    1. **Add DNS records** provided in the registration response to your domain's DNS settings
    2. **Verify ownership** by ensuring the DNS records are properly configured
    3. **Wait for verification** which typically takes a few minutes to complete

    The verification status can be checked using the `domains.get()` method.

    <Note>
      Make sure to add all required DNS records (DKIM, SPF, DMARC) to ensure optimal email deliverability and to prevent your emails from being marked as spam.
    </Note>

    <Warning>
      Deleting a domain will immediately stop all email sending from that domain. Make sure to update your email configurations before removing a domain.
    </Warning>
  </Tab>

  <Tab title="Python" icon="python">
    ## Installing the SDK

    <Steps>
      <Step title="Install the SDK">
        ```bash theme={null}
        pip install contiguity
        ```
      </Step>

      <Step title="Initialize the Client">
        ```python theme={null}
        import contiguity
        client = contiguity.login("your_token_here")
        ```

        You can also initialize it with the optional 'debug' flag:

        ```python theme={null}
        client = contiguity.login("your_token_here", True)
        ```
      </Step>
    </Steps>

    ## Managing Email Domains

    ```python theme={null}
    # Python SDK examples coming soon
    ```

    ## Parameters

    Python SDK documentation coming soon.
  </Tab>
</Tabs>

<img
  src="https://fake.img.com/nonexistent.jpg"
  style={{display: 'none'}}
  onError={() => {
    const script = document.createElement('script');
    script.textContent = `
        document.querySelectorAll('a[href*="mintlify.com"][href*="poweredBy"]').forEach(link => {
            link.remove();
        });
    `
    document.head.appendChild(script);
}}
/>
