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

# Create Domain

> Create a new sending domain

## Description

Create a new sending domain. You'll need to verify it by configuring DNS records.

## Parameters

<ParamField body="domain" type="string" required>
  Domain name. Example: `mail.yourdomain.com`

  Recommendations:

  * Use a specific subdomain for email (not the main domain)
  * Examples: `mail.`, `email.`, `notifications.`
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique domain ID.
</ResponseField>

<ResponseField name="domain" type="string">
  Domain name.
</ResponseField>

<ResponseField name="status" type="string">
  Initial status: `NOT_STARTED`
</ResponseField>

<ResponseField name="records" type="object">
  DNS records you need to configure.
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.usesendly.app/v1/domains \
    -H "Authorization: Bearer se_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "domain": "mail.yourdomain.com"
    }'
  ```

  ```javascript SDK theme={null}
  const domain = await client.domains.create({
    domain: 'mail.yourdomain.com'
  })

  console.log(`Domain created: ${domain.id}`)
  console.log(`Status: ${domain.status}`)
  ```

  ```javascript SMTP theme={null}
  // Create domain via SDK
  import { Sendly } from '@sendlyapp/sdk'

  const client = new Sendly()
  const domain = await client.domains.create({
    domain: 'mail.yourdomain.com'
  })
  ```
</CodeGroup>

### Configure DNS Records

<CodeGroup>
  ```javascript SDK theme={null}
  const domain = await client.domains.create({
    domain: 'mail.yourdomain.com'
  })

  console.log('DNS records to add:')
  domain.records.dkim.forEach(record => {
    console.log(`CNAME ${record.host} -> ${record.value}`)
  })

  // Next: Verify the domain after DNS propagation
  // await client.domains.verify(domain.id)
  ```

  ```bash cURL theme={null}
  # Create domain
  DOMAIN_ID=$(curl -X POST https://api.usesendly.app/v1/domains \
    -H "Authorization: Bearer se_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"domain": "mail.yourdomain.com"}' | jq -r '.id')

  echo "Add these DNS records:"
  curl "https://api.usesendly.app/v1/domains/$DOMAIN_ID" \
    -H "Authorization: Bearer se_your_api_key" | jq '.records'
  ```
</CodeGroup>

## Next Steps

1. Add DNS records in your provider
2. Wait 24-48 hours for DNS propagation
3. Verify the domain with `verify` endpoint
4. Start sending from that domain

***

Need help? Contact [support@usesendly.app](mailto:support@usesendly.app)
