# Give customers an email address on your domain

> Offer each customer account one free address on your storefront's mail domain, at sign-up or from the account page, with the Organization API.

Source: https://www.coritan.com/docs/organizations/storefront/portal-mailbox/

Your storefront can give each customer account one free email address on a mail domain of yours, such as `alex@example.gg`. The customer picks the name when they sign up, or later from their account page. Their own email stays the address they sign in with, and the new address is an inbox they read in webmail or in any mail app. This page shows the calls a storefront makes and what to show for each refusal.

It differs from [Mail Hosting](/docs/organizations/storefront/portal-mail/), which a customer buys to run mailboxes on a domain of their own.

## Before you begin

- Ask [support](https://www.coritan.com/dashboard/support) to turn customer addresses on for your organization and to name the mail domain. Coritan staff declare the domain for your storefront and set up its mail service. You cannot set it through the API. Until then the offer answers `enabled: false` and the other routes on this page refuse.
- Ask support to set your organization's webmail address, so the account page can link to it. See [Run Mail Hosting for your customers](/docs/organizations/mail/).
- Get a customer token for the account page calls, as [Sign customers in to your storefront](/docs/organizations/storefront/customer-sign-in/) describes. They send it as `Authorization: Bearer $CUSTOMER_TOKEN`.
- If your sign-up form shows a security check, keep sending its answer as `turnstile_token`. A sign-up that asks for an address passes the same check.

## Check whether your storefront offers an address

```bash
curl "https://api.coritan.com/api/v1/orgs/acme/auth/mailbox-domain"
```

```json
{"enabled": true, "domain": "example.gg"}
```

The call needs no token. Show the name field only while `enabled` is `true`, and print `domain` after it. An organization that offers no address answers `200` with `{"enabled": false, "domain": null}`. `domain` can hold a name while `enabled` is `false`: the domain is declared but not ready, so offer nothing yet.

## Check a name as the customer types

```bash
curl "https://api.coritan.com/api/v1/orgs/acme/auth/mailbox-availability?local_part=alex"
```

```json
{"available": true, "reason": "ok", "detail": null, "address": "alex@example.gg"}
```

`local_part` is the name before the `@`, 1 to 64 characters. We trim it and lower its case before the check. The answer has these fields:

| Field | What it holds |
| --- | --- |
| `available` | `true` when the customer can take the name. |
| `reason` | `ok`, `invalid` (the name breaks a rule), `reserved` (a name we keep back, such as `support` or `admin`) or `taken`. |
| `detail` | A sentence to show under the field, or `null` when the name is free. |
| `address` | The whole address, or `null` for an invalid name. |

A usable name has 3 to 40 letters, digits, dots, dashes or underscores. It starts and ends with a letter or a digit, has no plus sign and no two dots in a row. A name is taken when a mailbox has the address, or when another of your customers signs in with it.

The check answers `404` when your organization offers no address. One network can ask 60 times a minute. After that the answer is `429`: wait a few seconds and ask again. Your form can go on without an answer, because the request that makes the address checks the name again.

## Make the address at sign-up

Add `mailbox_local_part` to the sign-up request from [Register a customer](/docs/organizations/storefront/customer-sign-in/#register-a-customer):

```bash
curl -X POST "https://api.coritan.com/api/v1/orgs/acme/auth/register" \
  -H "Content-Type: application/json" \
  -d '{"email": "alex@example.com", "password": "a long passphrase", "mailbox_local_part": "alex", "turnstile_token": "..."}'
```

`email` is still required and is still what the customer signs in with. The answer is the `201` a sign-up always gives, with one more field:

```json
{"access_token": "...", "refresh_token": "...", "token_type": "bearer", "expires_in": 86400, "customer_id": 4812, "mailbox_address": "alex@example.gg"}
```

`mailbox_address` is the address we made. It is `null` when the request left `mailbox_local_part` out or sent it blank, and then the sign-up works exactly as it did before. An answer that asks for a two-factor step carries `mailbox_address` too.

We make the account and the address together or not at all. When we refuse the address, no account exists, and your form can send the request again with another name or without the field. We make the address at once and do not wait for the customer to confirm `email`.

The address takes the account password as its own password. Tell the customer on the form, for example: "Its password is your account password."

## Show the address on the account page

```bash
curl "https://api.coritan.com/api/v1/orgs/acme/portal/mailbox" \
  -H "Authorization: Bearer $CUSTOMER_TOKEN"
```

```json
{
  "offer": {"enabled": true, "domain": "example.gg"},
  "mailbox": {"address": "alex@example.gg", "status": "active", "created_at": "2026-11-14T10:00:00+00:00"},
  "webmail_url": "https://mail.example.gg"
}
```

| Field | What it holds |
| --- | --- |
| `offer` | What `GET /auth/mailbox-domain` answers for your organization. |
| `mailbox` | `null` while the customer has no address. Otherwise `address`, `status` and `created_at`. |
| `mailbox.status` | `active`, or `disabled` when we turned the address off or paused its sending. |
| `webmail_url` | Where the customer reads the mail in a browser, or `null` when your organization has no webmail. |

A customer keeps their address if you stop offering new ones, so `mailbox` can be set while `offer.enabled` is `false`. Offer the form in the next section only while `mailbox` is `null` and `offer.enabled` is `true`.

## Let a signed-in customer make their address

Check the name as the customer types. This check knows who is asking, so the customer's own sign-in address counts as free for them: someone who signs in with `sam@example.gg` can take `sam`.

```bash
curl "https://api.coritan.com/api/v1/orgs/acme/portal/mailbox/availability?local_part=alex" \
  -H "Authorization: Bearer $CUSTOMER_TOKEN"
```

The answer has the same fields as the check before sign-up. It answers `404` when your organization offers no address, and `429` after 60 checks a minute by one customer.

Then make the address. Ask the customer for their account password in the same form:

```bash
curl -X POST "https://api.coritan.com/api/v1/orgs/acme/portal/mailbox" \
  -H "Authorization: Bearer $CUSTOMER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"local_part": "alex", "password": "a long passphrase"}'
```

The password confirms the request and becomes the address's password. The answer is `201` with the body of `GET /portal/mailbox`, which now holds the address.

> [!CAUTION]
> An account has one address, and its name cannot be changed afterwards. Ask the customer to confirm the whole address before you send the request.

A customer who signs in only with a social account or an emailed code has no password. Email them a password link with `POST /auth/forgot-password`, as [Verify an address and reset a password](/docs/organizations/storefront/customer-sign-in/#verify-an-address-and-reset-a-password) describes, then offer the form again.

## What follows the account

- The address signs in with the account password, in webmail and in mail apps. When the customer changes or resets their account password, or sets a first one, the address takes the new password. A password your staff set for the customer does not reach the address: it keeps its password until the customer next changes the account's, so a staff member cannot open a customer's mail.
- A customer can give the address a separate password in webmail. From then on it keeps that password, whatever happens to the account password.
- The address sends mail only while the customer's account is active.
- When a customer closes their account, or your staff close it for good, we delete the address and its mail first. If the mail service cannot delete it at that moment, the close answers `409` and the account stays open, so the customer can try again. No route deletes the address on its own.
- The addresses are your customers' personal inboxes. Your organization's Email pages do not list them, and your staff cannot read them, delete them or reset a mailbox password there.

One network, an IPv4 address or an IPv6 /64, can make 3 addresses an hour and 5 a day, counting sign-ups and account pages together.

## Result

The customer has `name@<your domain>`, and `GET /portal/mailbox` returns it with `status` `active`. They open `webmail_url` and sign in with the address and their account password.

## Troubleshooting

A refusal about the address has `detail`, one sentence you can show under the name field, and `code`, a word that starts with `mailbox_`. A refusal about anything else on the sign-up form has another `code` or none, so your page can tell where to show each.

`422` with `mailbox_not_offered` at sign-up, `404` with `mailbox_not_offered` on the account page
: Your organization offers no address. Hide the field, and send the sign-up again without `mailbox_local_part`.

`422` with `mailbox_name_invalid`
: The name breaks a rule, and `detail` says which, such as `Pick at least 3 characters.` Ask for another name.

`422` with `mailbox_name_reserved`
: `That name is reserved. Try another name.` We keep back role names such as `support` and `billing`.

`409` with `mailbox_taken`
: `That address is already taken. Try another name.`

`422` with `mailbox_refused`
: We could not use the name for a reason the check did not catch, such as someone taking it a moment earlier. Show `detail` and ask for another name.

`403` with `mailbox_network_refused`
: We do not make mailboxes from the customer's network. `detail` says why: the network is blocked, it is a hosting, VPN, proxy or Tor network, or we paused a mailbox made from it in the last 7 days. Another name does not help. Let the customer sign up without an address and add one later from another network.

`429` with `mailbox_rate_limited`
: The customer's network has made as many addresses as it may for now, or the customer tried the account page form more than 5 times in an hour. `Retry-After` says how many seconds to wait. At sign-up, offer to go on without an address.

`503` with `mailbox_unavailable` or `mailbox_not_saved`
: Our mail service could not make the address. Nothing was made, and at sign-up no account was made. Try again in a few minutes, or let the customer sign up without an address.

`409` with `mailbox_exists`
: `This account already has an address.` Read `GET /portal/mailbox` and show it.

`422` with `mailbox_wrong_password`
: `That is not your account password.` The answer is never `401`, so your page does not mistake it for an expired session.

`422` with `mailbox_password_required`
: The account has no password yet. The customer sets one with a password link, then tries again.

`403 A support session cannot make the customer's email address. Ask the customer to make it from their account.`
: A member of your staff is signed in as the customer. Only the customer makes their address.

`401`
: The token is missing, expired, or belongs to a customer of another organization.

`409` with the header `X-Close-Refused-Reason: mailbox_not_deleted` when closing an account
: We could not delete the customer's address from the mail service, so the account is still open. Send the close request again in a few minutes.

## Related

- [Sign customers in to your storefront](/docs/organizations/storefront/customer-sign-in/)
- [Build the customer account area](/docs/organizations/storefront/customer-portal/)
- [Let customers use Mail Hosting and SMTP Relay](/docs/organizations/storefront/portal-mail/)
- [Run Mail Hosting for your customers](/docs/organizations/mail/)

## API

- `GET /api/v1/orgs/{org_slug}/auth/mailbox-domain`: Whether this storefront gives each account a free email address, and on which domain (https://www.coritan.com/docs/api/reference/organizations/customer-authentication/auth/#op-get-api-v1-orgs-org-slug-auth-mailbox-domain)
- `GET /api/v1/orgs/{org_slug}/auth/mailbox-availability`: Whether a name is free for a new account's email address (https://www.coritan.com/docs/api/reference/organizations/customer-authentication/auth/#op-get-api-v1-orgs-org-slug-auth-mailbox-availability)
- `GET /api/v1/orgs/{org_slug}/portal/mailbox`: The signed-in customer's own email address on the storefront's mail domain (https://www.coritan.com/docs/api/reference/organizations/customer-portal/mailbox/#op-get-api-v1-orgs-org-slug-portal-mailbox)
- `POST /api/v1/orgs/{org_slug}/portal/mailbox`: Make the signed-in customer's email address on the storefront's mail domain (https://www.coritan.com/docs/api/reference/organizations/customer-portal/mailbox/#op-post-api-v1-orgs-org-slug-portal-mailbox)
- `GET /api/v1/orgs/{org_slug}/portal/mailbox/availability`: Whether a name is free for the signed-in customer's email address (https://www.coritan.com/docs/api/reference/organizations/customer-portal/mailbox/#op-get-api-v1-orgs-org-slug-portal-mailbox-availability)
