# Retrieve a domain

> Retrieve the status and DNS verification details for a sending domain.

`GET https://api-connect.nxiom.com/api/v1/emails/domains/{domainId}`

## Authorization

Requires `email.full_access`.

## Path parameters

| Field | Type | Description |
| --- | --- | --- |
| `domainId` | string · required | The domain identifier in the URL path. |

## Request

### cURL

```shell
curl "https://api-connect.nxiom.com/api/v1/emails/domains/YOUR_DOMAIN_ID" \
  -H "Authorization: Bearer $NEXIOM_API_KEY"
```

### Node.js

```typescript
import { NexiomConnect } from '@nexiom/connect';

const apiKey = process.env.NEXIOM_API_KEY;
if (!apiKey) throw new Error('Set NEXIOM_API_KEY');

const nexiom = new NexiomConnect({ apiKey });

const { data, error } = await nexiom.domains.get('YOUR_DOMAIN_ID');

if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(data.domain, data.status);
```

### PHP

```php
<?php

use Nexiom\Connect\NexiomConnect;

$apiKey = getenv('NEXIOM_API_KEY');
if (!$apiKey) {
    throw new RuntimeException('Set NEXIOM_API_KEY');
}

$nexiom = new NexiomConnect($apiKey);

$domain = $nexiom->domains->get('YOUR_DOMAIN_ID');

echo $domain['domain'], ' ', $domain['status'];
```

## Response

HTTP `200`. The domain is returned under `data`. 

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Domain identifier. |
| `domain` | string | Sending subdomain. |
| `status` | string | `pending`, `verified`, or `failed`. |
| `region` | string | Sending region. |
| `open_tracking` | boolean | Whether open tracking is enabled. |
| `verification_error` | string or null | What still needs attention when the domain is not verified. |
| `verification_attempts` | number | How many verification checks ran. |
| `verification_attempted_at` | string or null | When the last verification check ran. |
| `dns_records` | array | DNS records to publish, each with `id`, `purpose`, `record_type`, `name`, `value`, `priority`, `status`, `required_for_sending`, `last_checked_at`, `error_code`, and `error_message`. |
| `last_verified_at` | string or null | Last successful verification timestamp. |
| `created_at` | string | Creation timestamp. |
| `updated_at` | string | Last change timestamp. |

### 200 OK

Example response. Domain and DNS fields shown are illustrative; use the records returned for your own domain.

```json
{
  "message": "Email domain details fetched",
  "data": {
    "id": "domain_example",
    "domain": "mail.example.com",
    "status": "pending",
    "region": "global",
    "open_tracking": true,
    "last_verified_at": null,
    "dns_records": [
      {
        "id": "dns_example",
        "purpose": "dkim",
        "record_type": "CNAME",
        "name": "selector._domainkey.mail.example.com",
        "value": "selector.dkim.example.net",
        "priority": null,
        "status": "pending",
        "required_for_sending": true
      }
    ]
  }
}
```

### 401 Unauthorized

The API key is missing, malformed, revoked, or expired.

```json
{
  "error": "unauthorized",
  "message": "Invalid API key",
  "correlationId": "req_example"
}
```

### 403 Forbidden

The API key lacks a required permission, or its domain restriction does not allow this sender.

```json
{
  "error": "not_allowed",
  "message": "Missing required API key permissions: email.full_access",
  "correlationId": "req_example"
}
```

### 404 Not Found

No resource with this ID exists in the API key’s project.

```json
{
  "error": "not_found",
  "code": "resource_not_found",
  "message": "Resource not found",
  "correlationId": "req_example"
}
```

---

Source: https://connect.nxiom.com/docs/api/email-domains/retrieve
