# Add an email domain

> Add a domain to send email from. Returns the DNS records to publish (DKIM CNAMEs are required; SPF, DMARC, and MAIL FROM are recommended). Publish them at your DNS provider, then verify.

`POST https://api.zavu.dev/v1/email-domains`

Add a domain to send email from. Returns the DNS records to publish (DKIM CNAMEs are required; SPF, DMARC, and MAIL FROM are recommended). Publish them at your DNS provider, then verify.

## Body

- `domain` (string, required): Bare domain, e.g. example.com.

## Responses

### 201

Domain added.

- `domain` (object, required)
  - `id` (string, required)
  - `domain` (string, required)
  - `status` (string, required): Overall verification status.
  - `dkimStatus` (string, required)
  - `dnsRecords` (object[]): DNS records to publish. Present when fetching a single domain or after adding one.
    - `type` (string, required): DNS record type.
    - `name` (string, required): Record host/name to create.
    - `value` (string, required): Record value.
    - `priority` (integer): Priority (MX records only).
    - `purpose` (string, required): What the record is for. `ownership` is a TXT at `_zavu-verification.<domain>`, returned only when another Zavu account also added this domain and neither has verified it: DKIM records are the same for everyone, so the domain verifies only once this account's own token is published. One of: `dkim`, `spf`, `dmarc`, `mail_from`, `ownership`.
    - `required` (boolean, required): Whether the record is required to verify + send (DKIM) or recommended for deliverability.

### 400

Invalid domain or setup failed.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 409

`domain_taken`: another Zavu account has already verified this domain. A sending domain belongs to one account; if it is yours, contact support.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X POST "https://api.zavu.dev/v1/email-domains" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "example.com"
}'
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.emailDomains.create({
  domain: "example.com",
});

console.log(result);
```
