# Organization API: Customer Portal: Mailbox

> The 3 Organization API operations for mailbox.

Source: https://www.coritan.com/docs/api/reference/organizations/customer-portal/mailbox/

Part of [Customer Portal](/docs/api/reference/organizations/customer-portal/).

## Operations

| Method | Path | Summary |
| --- | --- | --- |
| GET | [`/api/v1/orgs/{org_slug}/portal/mailbox`](#op-get-api-v1-orgs-org-slug-portal-mailbox) | The signed-in customer's own email address on the storefront's mail domain |
| POST | [`/api/v1/orgs/{org_slug}/portal/mailbox`](#op-post-api-v1-orgs-org-slug-portal-mailbox) | Make the signed-in customer's email address on the storefront's mail domain |
| GET | [`/api/v1/orgs/{org_slug}/portal/mailbox/availability`](#op-get-api-v1-orgs-org-slug-portal-mailbox-availability) | Whether a name is free for the signed-in customer's email address |

### The signed-in customer's own email address on the storefront's mail domain {#op-get-api-v1-orgs-org-slug-portal-mailbox}

`GET /api/v1/orgs/{org_slug}/portal/mailbox`

The signed-in customer's own email address on the storefront's mail domain.

The answer is `{"offer", "mailbox", "webmail_url"}`. `offer` is
`{"enabled", "domain"}`, as `GET /auth/mailbox-domain` answers it.
`mailbox` is null while the customer has no address, else `{"address",
"status", "created_at"}`: `status` is `active`, or `disabled` when we
turned the address off or paused its sending. `webmail_url` is where the
customer reads the mail in a browser, null when the organization has no
webmail. A customer keeps the address they have when the organization
stops offering new ones, so `mailbox` can be set while `offer.enabled` is
false.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `org_slug` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Make the signed-in customer's email address on the storefront's mail domain {#op-post-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.

Send `local_part` (the name before the @) and `password`, the customer's
account password. The password confirms the request and becomes the
address's password, for webmail and for mail apps. We answer 201 with the
body of `GET /portal/mailbox`, which now holds the address. An account
has one address and its name cannot be changed afterwards.

Every refusal is `{"detail", "code"}` with a sentence to show:

- 404 `mailbox_not_offered`: the organization offers no address.
- 409 `mailbox_exists`: the account already has one.
- 422 `mailbox_password_required`: the account has no password (it signs
  in with a social account or a code). The customer sets one first.
- 422 `mailbox_wrong_password`: the password is not the account's. It is
  never 401, which a page reads as its session ending.
- 422 `mailbox_name_invalid` or `mailbox_name_reserved`, and 409
  `mailbox_taken`: the name cannot be used. Ask for another.
- 403 `mailbox_network_refused`: we do not make mailboxes from the
  customer's network (a blocked network, a hosting, VPN, proxy or Tor
  network when we refuse those, or one whose earlier mailbox we paused in
  the last 7 days).
- 429 `mailbox_rate_limited`: 5 tries an hour for one customer, and one
  network can make 3 mailboxes an hour and 5 a day across every sign-up
  and account. `Retry-After` says how long to wait.
- 503 `mailbox_unavailable` or `mailbox_not_saved`: the mail service
  could not make it. Nothing was made, so the customer can try again in
  a few minutes.

A support session that signed in as the customer gets 403: the address is
the customer's to make.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `org_slug` | path | string | yes |

#### Request body

`application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `local_part` | string | yes | The name before the @. GET /portal/mailbox/availability says whether it can be used. |
| `password` | string | yes | The customer's account password. It confirms the request and becomes the address's password. |

#### Responses

| Status | Meaning |
| --- | --- |
| `201` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Whether a name is free for the signed-in customer's email address {#op-get-api-v1-orgs-org-slug-portal-mailbox-availability}

`GET /api/v1/orgs/{org_slug}/portal/mailbox/availability`

Whether a name is free for the signed-in customer's email address.

The account page asks as the customer types. The answer is the one `GET /auth/mailbox-availability` gives, with one
difference: the customer's own login address counts as free for them, so
someone who signs in with `sam@<domain>` can take `sam`.

404 when the organization offers no address. 429 after 60 checks a minute
by one customer: wait a few seconds and ask again.

#### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org_slug` | path | string | yes |  |
| `local_part` | query | string | yes | The name before the @, 1 to 64 characters as typed. We trim it and lower its case before the check. A usable name has 3 to 40 letters, digits, dots, dashes or underscores, and starts and ends with a letter or digit. |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |
