---
title: "Mailbox SDK"
description: "Put the mailbox in your own app. Send and read mail as the person signed in, from a browser, a phone or a server."
url: "https://nextmail.sh/docs/mailbox"
area: "Client"
category: "Getting started"
---

# Mailbox SDK

Put the mailbox in your own app. Send and read mail as the person signed in, from a browser, a phone or a server.

## What it is

`@nextmail/mailbox` is the Mailbox surface of the Nextmail API, for an app a person signs in to: their mail and threads, drafts, labels, calendars, contacts, automations, tasks, rules, templates and the workspace screens around them. It is built on `@nextmail/sdk`, taking its transport from it, so every call, error and retry behaves the same, and it adds one rule: it acts as a person, with their access token, and never with an API key. For anything infrastructure-shaped, domains, webhooks, keys, tracking and sending, use `@nextmail/sdk` itself.

**Install**

_pnpm_

```text
pnpm add @nextmail/mailbox
```

_npm_

```text
npm install @nextmail/mailbox
```

_yarn_

```text
yarn add @nextmail/mailbox
```

_bun_

```text
bun add @nextmail/mailbox
```

**send-email.ts**

```
import { createClient } from '@nextmail/mailbox'

const client = createClient({
  accessToken: () => fetch('/api/mail-token').then((response) => response.text()),
})

await client.emails.send({
  from: 'ada@acme.com',
  to: 'grace@example.com',
  subject: 'Tomorrow',
  html: '<p>Still on for ten?</p>',
})
```

## Which SDK to use

|  | `@nextmail/sdk` | `@nextmail/mailbox` |
| --- | --- | --- |
| Acts as | The workspace, with an API key | The person signed in, with an access token |
| Runs | On a server | In a browser, in a phone app or on a server |
| Reaches | Sending, domains, webhooks, keys, tracking and the rest of the infrastructure | Mail and threads, drafts, labels, calendars, contacts, automations, tasks and templates |
| Use it for | Your backend, jobs and the sending infrastructure | A mailbox inside your product |

## Where to go

- [Install](https://nextmail.sh/docs/mailbox/install.md): Add it and send your first message.
- [Sign in](https://nextmail.sh/docs/mailbox/sign-in.md): Where the access token comes from.
- [Send an email](https://nextmail.sh/docs/mailbox/emails/send.md): Send, and reply in a thread.
- [Threads](https://nextmail.sh/docs/mailbox/threads.md): Read the mailbox.
- [Errors](https://nextmail.sh/docs/mailbox/errors.md): What throws, and how to narrow it.
- [Reference](https://nextmail.sh/docs/mailbox/reference.md): Everything the client offers.
