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

# DNS Records API — Retrieve Required DNS Configuration

> Use GET /api/dns/{domain} to retrieve the exact MX, SPF, and DKIM records you must add at your registrar to activate email delivery for your UGMail domain.

After registering a domain with UGMail, you need to update your DNS records at your registrar so that email for your domain is delivered through UGMail's infrastructure. The DNS Records API returns the exact records you need to add — MX for inbound delivery, SPF for sender authorization, and DKIM for cryptographic signing. No guesswork required.

***

## Get DNS Records for a Domain

<br />

`GET /api/dns/{domain}`

Retrieve the DNS records required to activate email delivery for a domain. Add these records at your domain registrar or DNS provider.

### Path Parameters

<ParamField path="domain" type="string" required>
  The domain name to retrieve DNS records for (e.g., `example.com`). The domain must already be registered in your UGMail account.
</ParamField>

### Example Request

```bash theme={null}
curl "https://mail.ugmail.co/api/dns/example.com" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### Example Response

```json theme={null}
{
  "mx": [
    { "host": "@", "value": "mail.ugmail.co", "priority": 10 }
  ],
  "txt": [
    { "host": "@", "value": "v=spf1 include:ugmail.co ~all" },
    { "host": "ugmail._domainkey", "value": "v=DKIM1; k=rsa; p=MIIBIjAN..." }
  ]
}
```

### Response Fields

<ResponseField name="mx" type="array of objects">
  MX (Mail Exchanger) records that route inbound email for your domain to UGMail's mail servers.

  <Expandable title="MX record fields">
    <ResponseField name="host" type="string">
      The hostname for the record. `@` means the record applies to the root domain (e.g., `example.com`).
    </ResponseField>

    <ResponseField name="value" type="string">
      The mail server hostname to point to.
    </ResponseField>

    <ResponseField name="priority" type="integer">
      The MX priority value. Lower numbers have higher priority. Use the value returned by the API.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="txt" type="array of objects">
  TXT records for SPF and DKIM configuration.

  <Expandable title="TXT record fields">
    <ResponseField name="host" type="string">
      The hostname for the TXT record. `@` means the root domain. A value like `ugmail._domainkey` means you create the record at `ugmail._domainkey.example.com`.
    </ResponseField>

    <ResponseField name="value" type="string">
      The full TXT record value to enter at your registrar.
    </ResponseField>
  </Expandable>
</ResponseField>

***

## Understanding the Records

The API returns three types of records, each serving a distinct purpose:

### MX Record — Inbound Mail Routing

The MX record tells other mail servers where to deliver email for your domain. Add exactly one MX record pointing to `mail.ugmail.co` with the priority value provided.

| Host | Type | Value            | Priority |
| ---- | ---- | ---------------- | -------- |
| `@`  | MX   | `mail.ugmail.co` | `10`     |

### SPF Record — Sender Authorization

The SPF TXT record tells receiving servers which hosts are authorized to send email on behalf of your domain. This reduces the chance of your mail being marked as spam.

| Host | Type | Value                           |
| ---- | ---- | ------------------------------- |
| `@`  | TXT  | `v=spf1 include:ugmail.co ~all` |

### DKIM Record — Cryptographic Signing

The DKIM TXT record publishes your domain's public key so receiving servers can verify that outgoing messages were signed by UGMail. Add this record at `ugmail._domainkey.example.com` (replacing `example.com` with your domain).

| Host                | Type | Value                           |
| ------------------- | ---- | ------------------------------- |
| `ugmail._domainkey` | TXT  | `v=DKIM1; k=rsa; p=MIIBIjAN...` |

See the [DKIM Configuration](/api-reference/dkim) page for step-by-step instructions on setting up DKIM signing.

***

## Adding Records at Your Registrar

<Steps>
  <Step title="Copy the records from the API response">
    Call `GET /api/dns/{domain}` and note the exact values returned for your domain.
  </Step>

  <Step title="Log in to your DNS provider">
    Go to the DNS management console for your domain. This is typically your domain registrar (e.g., Namecheap, GoDaddy, Cloudflare, Route 53).
  </Step>

  <Step title="Add the MX record">
    Create an MX record with the host, value, and priority from the API response. Remove any existing MX records pointing to a different provider if you are migrating.
  </Step>

  <Step title="Add the SPF TXT record">
    Create a TXT record at `@` (root) with the SPF value. If you already have an SPF record, merge the `include:ugmail.co` mechanism into it rather than creating a second TXT record.
  </Step>

  <Step title="Add the DKIM TXT record">
    Create a TXT record at `ugmail._domainkey` with the full DKIM public key value from the API response.
  </Step>
</Steps>

<Note>
  DNS changes typically propagate within a few minutes to a few hours, but can take up to 48 hours in some cases. You can verify propagation using a tool like [MXToolbox](https://mxtoolbox.com).
</Note>
