---
title: "Create another sending domain"
url: https://docs.corefinity.com/api/reference/site-settings/create-site-email-domain
type: endpoint
last_updated: 2026-11-13
feature: email
related:
  - https://docs.corefinity.com/guides/sites/site-settings/outbound-email.md
  - https://docs.corefinity.com/mcp/tools/corestack_email_domain_add.md
---
# Create another sending domain

Adds a sending domain for mail from another of the site's domains, on a Magento 2 site that already has its
first one: `prefix` (by default `mg`) in front of `from_domain`. A site can have up to 5 sending domains.
Try-it is off because the request creates a sending domain.

```http
POST /api/corestack/sites/{site}/email/domains
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 12 a minute
- Long-running: answers with an operation to poll
- Try it in the console: off. It has not been cleared for the console. Copy the request and run it yourself when you are sure.

## Path parameters

- `site` (integer, required): The id of a site row. A website's production site and each of its environments has its own id. Digits only.

## Body

- `domain` (string): The whole sending domain, under `from_domain` and not `from_domain` itself, in place of `prefix`.
- `from_domain` (string, required): The domain the mail comes from, one of the site's domains or under one of them. At most 240 characters.
- `prefix` (string): What goes in front of `from_domain` to make the sending domain: one DNS label of letters, digits and hyphens, 1 to 63 characters, that neither starts nor ends with a hyphen. By default `mg`. Not read when `domain` is sent. The sending domain it makes may be at most 253 characters. Defaults to `mg`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/email/domains \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "from_domain": "harbourandfinch.example.net"
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/email/domains', [
        'from_domain' => 'harbourandfinch.example.net',
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/email/domains', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    from_domain: 'harbourandfinch.example.net',
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/sites/1042/email/domains",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "from_domain": "harbourandfinch.example.net",
    },
)

data = res.json() if res.content else None
```

## Responses

### 201 The sending domain is being added. Follow `operation.id` until it completes.

```json
{
  "email": {
    "add": {
      "allowed": true,
      "count": 2,
      "default_prefix": "mg",
      "max": 5,
      "reason": null
    },
    "cloudflare": {
      "can_write_records": true,
      "connected": true,
      "written_at": null,
      "zone": {
        "id": "example-zone-id",
        "name": "harbourandfinch.example.com"
      }
    },
    "default_domain": "mg.harbourandfinch.example.com",
    "domains": [
      {
        "active": true,
        "added_at": "2026-11-03T09:16:40Z",
        "added_by": "Daniel Reyes",
        "can_make_default": false,
        "can_remove": false,
        "can_rotate": false,
        "can_test": false,
        "cloudflare": {
          "can_write_records": true,
          "connected": true,
          "written_at": null,
          "zone": {
            "id": "example-zone-id",
            "name": "harbourandfinch.example.com"
          }
        },
        "error": null,
        "from_domain": "harbourandfinch.example.com",
        "id": 3101,
        "is_default": true,
        "last_checked_at": "2026-11-03T09:16:40Z",
        "last_test": null,
        "make_default_reason": null,
        "operation_id": 5120,
        "records": [
          {
            "cloudflare": null,
            "found": null,
            "name": "mg.harbourandfinch.example.com",
            "priority": null,
            "purpose": "spf",
            "required": true,
            "state": "missing",
            "type": "TXT",
            "value": "v=spf1 include:mail.example.net ~all"
          },
          {
            "cloudflare": null,
            "found": null,
            "name": "pic._domainkey.mg.harbourandfinch.example.com",
            "priority": null,
            "purpose": "dkim",
            "required": true,
            "state": "missing",
            "type": "TXT",
            "value": "k=rsa; p=SYNTHETIC-DKIM-PUBLIC-KEY"
          },
          {
            "cloudflare": null,
            "found": null,
            "name": "mg.harbourandfinch.example.com",
            "priority": 10,
            "purpose": "mx",
            "required": false,
            "state": "missing",
            "type": "MX",
            "value": "mxa.eu.mail.example.net"
          },
          {
            "cloudflare": null,
            "found": null,
            "name": "mg.harbourandfinch.example.com",
            "priority": 10,
            "purpose": "mx",
            "required": false,
            "state": "missing",
            "type": "MX",
            "value": "mxb.eu.mail.example.net"
          },
          {
            "cloudflare": null,
            "found": null,
            "name": "email.mg.harbourandfinch.example.com",
            "priority": null,
            "purpose": "tracking",
            "required": true,
            "state": "missing",
            "type": "CNAME",
            "value": "eu.mail.example.net"
          }
        ],
        "remove_reason": "The default can be removed once no other domain is left. Make another one the default first.",
        "sender": {
          "address": "noreply@harbourandfinch.example.com",
          "name": "Harbour & Finch"
        },
        "sending_domain": "mg.harbourandfinch.example.com",
        "state": "pending_dns",
        "state_label": "Waiting for DNS",
        "test_reason": "Test emails can be sent once the sending domain is verified",
        "verified_at": null
      },
      {
        "active": false,
        "added_at": "2026-11-03T09:16:40Z",
        "added_by": "Daniel Reyes",
        "can_make_default": false,
        "can_remove": false,
        "can_rotate": false,
        "can_test": false,
        "cloudflare": {
          "can_write_records": false,
          "connected": true,
          "written_at": null,
          "zone": null
        },
        "error": null,
        "from_domain": "harbourandfinch.example.net",
        "id": 3102,
        "is_default": false,
        "last_checked_at": null,
        "last_test": null,
        "make_default_reason": "Only a verified sending domain the site already sends through can be the default.",
        "operation_id": 5123,
        "records": [],
        "remove_reason": null,
        "sender": {
          "address": "noreply@harbourandfinch.example.net",
          "name": null
        },
        "sending_domain": "mg.harbourandfinch.example.net",
        "state": "creating",
        "state_label": "Creating",
        "test_reason": "Test emails can be sent once the sending domain is verified",
        "verified_at": null
      }
    ],
    "error": null,
    "last_checked_at": "2026-11-03T09:16:40Z",
    "mailpit": null,
    "operation": {
      "id": 5123,
      "scope": "site",
      "status": "executing",
      "status_label": "Creating the sending domain",
      "summary": "Sending domain mg.harbourandfinch.example.net",
      "to_version": null,
      "type": "mail_setup",
      "type_label": "Email sending"
    },
    "records": [
      {
        "cloudflare": null,
        "found": null,
        "name": "mg.harbourandfinch.example.com",
        "priority": null,
        "purpose": "spf",
        "required": true,
        "state": "missing",
        "type": "TXT",
        "value": "v=spf1 include:mail.example.net ~all"
      },
      {
        "cloudflare": null,
        "found": null,
        "name": "pic._domainkey.mg.harbourandfinch.example.com",
        "priority": null,
        "purpose": "dkim",
        "required": true,
        "state": "missing",
        "type": "TXT",
        "value": "k=rsa; p=SYNTHETIC-DKIM-PUBLIC-KEY"
      },
      {
        "cloudflare": null,
        "found": null,
        "name": "mg.harbourandfinch.example.com",
        "priority": 10,
        "purpose": "mx",
        "required": false,
        "state": "missing",
        "type": "MX",
        "value": "mxa.eu.mail.example.net"
      },
      {
        "cloudflare": null,
        "found": null,
        "name": "mg.harbourandfinch.example.com",
        "priority": 10,
        "purpose": "mx",
        "required": false,
        "state": "missing",
        "type": "MX",
        "value": "mxb.eu.mail.example.net"
      },
      {
        "cloudflare": null,
        "found": null,
        "name": "email.mg.harbourandfinch.example.com",
        "priority": null,
        "purpose": "tracking",
        "required": true,
        "state": "missing",
        "type": "CNAME",
        "value": "eu.mail.example.net"
      }
    ],
    "sender": {
      "address": "noreply@harbourandfinch.example.com",
      "name": "Harbour & Finch"
    },
    "sending_domain": "mg.harbourandfinch.example.com",
    "state": "pending_dns",
    "state_label": "Waiting for DNS",
    "store_mapping": null,
    "test": {
      "last_sent_at": null,
      "last_to": null,
      "remaining_today": 20
    },
    "verified_at": null
  },
  "operation": {
    "applied_at": "2026-11-03T09:16:40Z",
    "can_retry": false,
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "committed_at": null,
    "completed_at": null,
    "created_at": "2026-11-03T09:16:40Z",
    "environment": {
      "env_id": "rs-northwind-harbourandfinch-example-com",
      "hostname": "harbourandfinch-example-com.northwind.cfstack.example.net",
      "id": 1042,
      "name": "Production",
      "role": "production",
      "role_label": "Production",
      "slug": "production"
    },
    "error": null,
    "failure_reason": null,
    "from_version": null,
    "hot": false,
    "id": 5123,
    "install": null,
    "label": "Sending domain created",
    "notes": [],
    "parent_operation_id": null,
    "requested_by": {
      "id": 2012,
      "name": "Daniel Reyes"
    },
    "reset_target": null,
    "result": null,
    "result_state": "none",
    "retried_by_operation_id": null,
    "retries_operation_id": null,
    "retry_requires": null,
    "revealed": null,
    "scope": "site",
    "site": {
      "domain": "harbourandfinch.example.com",
      "id": 1042
    },
    "status": "executing",
    "status_label": "Creating the sending domain",
    "step": "domain",
    "steps": [
      {
        "key": "domain",
        "label": "Sending domain created",
        "state": "current"
      },
      {
        "key": "secret",
        "label": "Credentials stored",
        "state": "todo"
      },
      {
        "key": "dns",
        "label": "DNS records added",
        "state": "todo"
      },
      {
        "key": "verified",
        "label": "Verified",
        "state": "todo"
      }
    ],
    "subject": null,
    "summary": "Sending domain mg.harbourandfinch.example.net",
    "to_version": null,
    "type": "mail_setup",
    "type_label": "Email sending"
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use), your company requires two-factor authentication and you have not set it up, or your account has no company that can use Managed Clusters, for example because the company was closed (`company_unavailable` or `company_not_enabled`, whichever the route checks first). For Managed Clusters routes; any other route uses `ForbiddenScopeOrTwoFactor`.

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 The domain cannot be added now. `reason` says why: `unavailable` (several sending domains are for Magento 2 sites, or this environment does not send email itself), `state` (the site's first sending domain is not set up and in use yet), `limit` (the site has its 5 sending domains), `duplicate` (the site already has a sending domain for mail from `from_domain`, or the sending domain is already one of this site's or another's), `exists` (the email provider already has this domain: contact support), `staff_managed`, `busy`, `restore_running`, `removed`, `deleted`, `provisioning` or `managed_elsewhere`.

```json
{
  "code": "busy",
  "message": "Another change to this site is in progress. Wait for it to finish.",
  "reason": "busy"
}
```

### 422 A field is missing or wrong (`invalid`, with `field` and `errors`).

```json
{
  "code": "invalid",
  "errors": {
    "from_domain": [
      "The domain must be one of this site's domains, or under one of them"
    ]
  },
  "field": "from_domain",
  "message": "The domain must be one of this site's domains, or under one of them",
  "reason": "invalid"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 502 The email provider did not answer, or refused the request (`upstream_unavailable`). Nothing was changed. Try again in a minute.

```json
{
  "code": "upstream_unavailable",
  "message": "Mailgun is busy. Try again in a minute.",
  "reason": "upstream_unavailable"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `duplicate` | The same thing already exists here. Use the existing one, or choose another name or value. |
| 409 | `limit` | A limit on how many of these there can be, or how often this can be done, has been reached. Read the message: remove or close one, or try again later. |
| 409 | `state` | What the request acts on is not in a state that allows this. Read the message. |
| 409 | `unavailable` | This is not available for the site or environment, or not at the moment. Read the message; try again later where it says so, or contact support. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 502 | `upstream_unavailable` | A service the action depends on did not answer. Try again later. |

## The same task elsewhere

- Guide: [Outbound email](https://docs.corefinity.com/guides/sites/site-settings/outbound-email.md)
- MCP tool: [`corestack_email_domain_add`](https://docs.corefinity.com/mcp/tools/corestack_email_domain_add.md)
