# create()

Canonical URL: https://developers.iagenify.com/sdk/ref/mail/create/
Language: en

`api.mail.create({ address, name }) → Promise<Mailbox>`

Creates a mailbox on an enabled host. The quota comes from the plan, never from the caller.

Status: POST /api/mail · host must be enabled · quota from the plan

```javascript
const box = await api.mail.create({ address: "hello@example.com", name: "Hello" });

box.address;   // "hello@example.com"
box.host;      // "example.com"
box.local;     // "hello"
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `address` | string | required | The full address. Its host must be one where mail is enabled. |
| `name` | string |  | The display name. |

## The host must be enabled first {#host}

```javascript
import { IaGenifyError } from "iagenify";

try {
  await api.mail.create({ address: "hello@team.example.com" });
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "mail_not_enabled") {
    await domain.mail.enable({ subdomain: "team" });
  }
}
```

The refusal names the host that is missing, so the fix is one call away.

## The caller does not choose the quota {#quota}

> **It comes from the plan, and it is the account's object storage**
>
> A mailbox has no space of its own. quotaBytes is the account's, read fresh each time — which is why a mailbox gets fuller when a host deploys something or a storage fills up.

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| mail_not_enabled | 403 | The host has no mail records yet. |
| mail_not_in_plan | 403 | The plan has no mail service. |
| address_taken | 409 | The address, or an alias of it, exists. |
| address_reserved | 400 | A name the domain is expected to answer for. |

## What follows {#then}

[update()](/sdk/ref/mailbox/update) for a picture and a signature, [aliases.add()](/sdk/ref/mailbox/aliases/add) for other addresses that land here, [forward()](/sdk/ref/mailbox/forward) for copies elsewhere.

- [mail.enable()](/sdk/ref/domain/mail/enable): Turning a host on before a mailbox can exist.
- [Mailbox](/sdk/ref/mailbox): What a mailbox carries, and what you can do to it.
- [usage()](/sdk/ref/mail/usage): Checking first.

```python
box = api.mail.create(address="hello@example.com", name="Hello")

box.address   # "hello@example.com"
box.host      # "example.com"
box.local     # "hello"
```

```python
from iagenify import IaGenifyError

try:
    api.mail.create(address="hello@team.example.com")
except IaGenifyError as error:
    if error.code != "mail_not_enabled":
        raise
    domain.mail.enable(subdomain="team")
```
