Mailboxes
A mailbox is an address on one of your reply domains, such as claude-otp@inbound.example.com, that receives email. Email that is accepted for it is stored and reported through the inbound webhook event, and you can read it from the API. An Outbound admin must turn on Inbound for your account before you can create mailboxes.
New to inbound mail? The Receive Email on Your Own Addresses guide walks through a complete setup. This page is the method reference.
All examples assume you've set the API key in the constructor. For multi-tenant usage, pass { apiKey } as the last argument to any method. See Configuration.
Inbound is required
Every method returns ForbiddenError (403) until Inbound is enabled for your account.
List Reply Domains
The reply domains you can create mailboxes on. Only active domains are listed.
const { domains } = await outbound.mailboxes.listDomains();
const customDomains = domains.filter((d) => d.customNames);Response
{
domains: [
{ hostname: 'inbound.example.com', isDefault: true, customNames: true },
{ hostname: 'reply.outbound.yourbrand.com', isDefault: false, customNames: false }
]
}| Field | Description |
|---|---|
hostname | The domain. Pass it as replyDomain when you create a mailbox |
isDefault | Used when a create call leaves out replyDomain |
customNames | true when the domain is assigned to your account alone, so you can choose the localPart. See Address Rules |
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
Create Mailbox
Create an address that receives email. Leave out localPart to get a generated address.
const { mailbox } = await outbound.mailboxes.create({
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
label: 'Login codes',
metadata: { purpose: 'otp' },
allowedSenders: ['*@yourcompany.com'],
});
console.log(mailbox.address); // 'claude-otp@inbound.example.com'Parameters
Every field is optional.
| Field | Type | Required | Description |
|---|---|---|---|
localPart | string | No | The part before the @. Only on a reply domain your account uses alone. See Address Rules |
replyDomain | string | No | A reply domain hostname from List Reply Domains. Defaults to your default domain |
label | string | null | No | A name for your own use, up to 255 characters |
metadata | Record<string, unknown> | No | Your own data, returned with every inbound event for this mailbox. Up to 50 keys and 4 KB of JSON |
allowedSenders | string[] | No | Who can write to the mailbox. Empty accepts everyone. See Allowed Senders |
Response
Status 201.
{
mailbox: {
id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
address: 'claude-otp@inbound.example.com',
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
kind: 'custom',
label: 'Login codes',
metadata: { purpose: 'otp' },
allowedSenders: ['*@yourcompany.com'],
enabled: true,
createdAt: '2026-11-23T09:00:00.000Z',
lastReceivedAt: null
}
}The mailbox object has these fields. The same shape is returned by every mailbox method, except that Get Mailbox also adds messageCount.
| Field | Description |
|---|---|
id | Mailbox ID. Use it in every method that takes a mailboxId |
address | The full address, localPart@replyDomain |
localPart | The part before the @ |
replyDomain | The reply domain hostname |
kind | custom when you chose the localPart, generated when the platform chose it |
label | Your label, or null |
metadata | Your metadata, {} when none was set |
allowedSenders | The sender rules, with domain entries written as *@domain. An empty array accepts everyone |
enabled | true when the mailbox accepts mail. false when it is turned off. See Update Mailbox |
createdAt | When the mailbox was created |
lastReceivedAt | When the last message arrived, or null |
Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | An invalid or reserved localPart, a label, metadata or allowedSenders value that is not valid, or a field that does not exist, such as name or domain |
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
ConflictError | 409 | The address already exists on that domain (the message names the address) |
OutboundError | 422 | The replyDomain is not an active reply domain for your account (details.availableDomains lists the ones you can use), your account has no default domain and you did not pass replyDomain, a custom localPart on a domain that other accounts share, or your account already has 1,000 mailboxes |
List Mailboxes
One page of your mailboxes, newest first. Pages are cursor based: pass the previous response's pagination.nextCursor as cursor to get the next page.
const page = await outbound.mailboxes.list({ replyDomain: 'inbound.example.com', limit: 25 });
if (page.pagination.nextCursor) {
const next = await outbound.mailboxes.list({ limit: 25, cursor: page.pagination.nextCursor });
}Parameters
| Field | Type | Required | Description |
|---|---|---|---|
replyDomain | string | No | Only mailboxes on this reply domain |
limit | number | No | Page size from 1 to 100. Default 50 |
cursor | string | No | pagination.nextCursor from the previous page |
Response
{
mailboxes: [
{
id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
address: 'claude-otp@inbound.example.com',
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
kind: 'custom',
label: 'Login codes',
metadata: { purpose: 'otp' },
allowedSenders: ['*@yourcompany.com'],
enabled: true,
createdAt: '2026-11-23T09:00:00.000Z',
lastReceivedAt: '2026-11-23T09:14:02.000Z'
}
],
pagination: {
limit: 50,
hasMore: false,
nextCursor: null
}
}| Field | Description |
|---|---|
mailboxes | Mailbox objects, as in Create Mailbox |
pagination.limit | The page size used |
pagination.hasMore | true when another page exists |
pagination.nextCursor | Pass as cursor to get the next page, or null |
Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | limit is outside 1 to 100 |
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
List All Mailboxes
listAll() is an async generator. It fetches the pages for you and yields one mailbox at a time. It takes the same filters as list(), except cursor.
for await (const mailbox of outbound.mailboxes.listAll({ replyDomain: 'inbound.example.com' })) {
console.log(mailbox.address, mailbox.lastReceivedAt);
}Possible Errors
The same as List Mailboxes.
Get Mailbox
const { mailbox } = await outbound.mailboxes.get('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f');Parameters
| Field | Type | Required | Description |
|---|---|---|---|
mailboxId | string | Yes | The mailbox id. First argument |
Response
{
mailbox: {
id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
address: 'claude-otp@inbound.example.com',
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
kind: 'custom',
label: 'Login codes',
metadata: { purpose: 'otp' },
allowedSenders: ['*@yourcompany.com'],
enabled: true,
createdAt: '2026-11-23T09:00:00.000Z',
lastReceivedAt: '2026-11-23T09:14:02.000Z',
messageCount: 42
}
}The fields are described under Create Mailbox. messageCount is the number of messages in the mailbox that have not been deleted.
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | No mailbox with this ID for your account, or the mailbox was deleted |
Update Mailbox
Change the label, metadata, allowed senders or whether the mailbox is on. The localPart and replyDomain cannot change. To use a different address, create a new mailbox. Pass only the fields you want to change. To clear the label, pass null.
const { mailbox } = await outbound.mailboxes.update('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f', {
allowedSenders: ['*@yourcompany.com', 'alerts@vendor.com'],
});Parameters
| Field | Type | Required | Description |
|---|---|---|---|
mailboxId | string | Yes | The mailbox id. First argument |
label | string | null | No | A new label, or null to clear it |
metadata | Record<string, unknown> | No | Replaces the whole metadata object. Up to 50 keys and 4 KB of JSON |
allowedSenders | string[] | No | Replaces the whole list. Up to 100 entries. An empty array accepts everyone |
enabled | boolean | No | false turns the mailbox off. true turns it back on |
Pass at least one field. Changes apply to the next message. Messages that already arrived are not changed.
Turning a Mailbox Off
Set enabled to false to stop delivery without deleting the mailbox. Its address, its messages and its id are kept. Mail sent to it while it is off is not delivered and fires no inbound event. Set enabled back to true to start receiving mail again. Mail that arrived while the mailbox was off is not recovered.
await outbound.mailboxes.update(mailboxId, { enabled: false });Response
The updated mailbox, in the same shape as Create Mailbox.
{
mailbox: {
id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
address: 'claude-otp@inbound.example.com',
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
kind: 'custom',
label: 'Login codes',
metadata: { purpose: 'otp' },
allowedSenders: ['*@yourcompany.com', 'alerts@vendor.com'],
enabled: true,
createdAt: '2026-11-23T09:00:00.000Z',
lastReceivedAt: '2026-11-23T09:14:02.000Z'
}
}Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | No field given, enabled is not true or false, or a field has a value that is not valid |
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | No mailbox with this ID for your account, or the mailbox was deleted |
Delete Mailbox
Delete a mailbox. Mail to its address stops being delivered at once, and its messages are hidden. See Retention for when they are removed. The address can be used again by a new mailbox. To stop delivery without deleting anything, use enabled: false instead.
const result = await outbound.mailboxes.delete('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f');
// { deleted: true, id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f' }Parameters
| Field | Type | Required | Description |
|---|---|---|---|
mailboxId | string | Yes | The mailbox id. First argument |
Response
| Field | Description |
|---|---|
deleted | true |
id | The ID of the deleted mailbox |
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | No mailbox with this ID for your account, or it was already deleted |
List Messages
One page of the messages in a mailbox, newest first. Pages are cursor based, as in List Mailboxes. Deleted messages are not listed.
const page = await outbound.mailboxes.listMessages('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f', {
since: '2026-11-23T00:00:00Z',
limit: 50,
});Parameters
| Field | Type | Required | Description |
|---|---|---|---|
mailboxId | string | Yes | The mailbox id. First argument |
limit | number | No | Page size from 1 to 100. Default 25 |
cursor | string | No | pagination.nextCursor from the previous page |
since | string | Date | No | Only messages received at or after this time. A Date is sent as toISOString() |
Response
{
messages: [
{
id: '0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23',
mailboxId: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
recipient: 'claude-otp+gmail@inbound.example.com',
tag: 'gmail',
from: 'noreply@accounts.example.org',
fromName: 'Example Accounts',
subject: 'Your login code is 482913',
snippet: 'Use this code to finish signing in. It expires in 10 minutes.',
hasHtml: true,
attachmentCount: 0,
senderAuth: 'verified',
automated: true,
simulated: false,
receivedAt: '2026-11-23T09:14:02.000Z'
}
],
pagination: {
limit: 50,
hasMore: false,
nextCursor: null
}
}| Field | Description |
|---|---|
id | Message ID. Use it with Get Message and the other message methods |
recipient | The exact address the message was sent to, including any +tag |
tag | The plus tag without the +, or null |
from / fromName | Sender address and display name, or null |
subject | Subject, or null |
snippet | A short preview of the plain text |
hasHtml | true when an HTML body exists. Fetch it with Get Message HTML |
attachmentCount | Number of attachments |
senderAuth | verified, unverified, failed or internal. null when unknown |
automated | true when the message looks machine-generated, such as an auto-reply or a notification |
simulated | true when the message was created with sandbox.simulateInbound() |
receivedAt | When the message was received |
Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | limit is outside 1 to 100, or since is not a valid date-time |
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | Mailbox not found |
List All Messages
listAllMessages() is an async generator. It fetches every page and yields one message summary at a time. It takes the same parameters as listMessages(), except cursor.
for await (const message of outbound.mailboxes.listAllMessages('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f', {
since: '2026-11-01T00:00:00Z',
})) {
console.log(message.receivedAt, message.from, message.subject);
}Possible Errors
The same as List Messages.
Get Message
The full message, including its plain text body and attachment list. Message methods take the message id only. The mailbox is part of the message.
const { message } = await outbound.mailboxes.getMessage('0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23');
console.log(message.text);Parameters
| Field | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | A message id from List Messages or an inbound event. First argument |
Response
{
message: {
id: '0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23',
mailboxId: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
recipient: 'claude-otp+gmail@inbound.example.com',
tag: 'gmail',
from: 'noreply@accounts.example.org',
fromName: 'Example Accounts',
replyTo: [],
to: ['claude-otp+gmail@inbound.example.com'],
cc: [],
subject: 'Your login code is 482913',
snippet: 'Use this code to finish signing in. It expires in 10 minutes.',
text: 'Your login code is 482913.\n\nUse this code to finish signing in. It expires in 10 minutes.',
textTruncated: false,
hasHtml: true,
attachmentCount: 0,
attachments: [],
senderAuth: 'verified',
automated: true,
automatedReason: null,
rfcMessageId: '<8d1c2f@accounts.example.org>',
inReplyTo: null,
sizeBytes: 18432,
simulated: false,
receivedAt: '2026-11-23T09:14:02.000Z'
}
}| Field | Description |
|---|---|
replyTo, to, cc | Addresses from the headers |
text | The plain text body, capped in length. Sender-written, so escape it before you show it |
textTruncated | true when text was cut short. The rest of the body is not stored |
rfcMessageId | The Message-ID header, or null |
inReplyTo | The In-Reply-To header, or null |
sizeBytes | Size of the raw message in bytes |
automatedReason | Why automated is true, or null |
simulated | true when the message was created with sandbox.simulateInbound() |
attachments | Attachment metadata. See below |
Each attachment has id, filename, contentType, size, contentId and inline. inline is true when the HTML body refers to the file instead of offering it as a download.
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | Message not found. The message does not exist for your account, was deleted, or its mailbox was deleted |
Attachments and the Original Email
Download an attachment with getAttachment(). It returns the file bytes and the metadata from the message:
const file = await outbound.mailboxes.getAttachment(messageId, attachmentId);
const bytes = Buffer.from(file.data);
console.log(file.contentType, file.filename, file.size);| Field | Type | Description |
|---|---|---|
data | ArrayBuffer | The file contents |
contentType | string | The MIME type from the message, or application/octet-stream |
filename | string | null | The file name the sender gave. Sender-written, so do not use it as a path on disk |
size | number | Size of the file in bytes |
The original .eml file is not part of the SDK. Call the REST API with your API key in the X-Api-Key header:
const res = await fetch(
`https://outbound-api.unionstack.in/v1/mailboxes/messages/${messageId}/raw`,
{ headers: { 'X-Api-Key': process.env.OUTBOUND_API_KEY! } },
);
const eml = Buffer.from(await res.arrayBuffer());The raw endpoint returns the message as message/rfc822.
Get Message HTML
The HTML body of one message, cleaned up for safe display. Remote images are blocked by default, so opening a message does not tell its sender that you read it.
const { html, remoteImagesBlocked } = await outbound.mailboxes.getMessageHtml(messageId);
iframe.setAttribute('sandbox', '');
iframe.srcdoc = html;Parameters
| Field | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | The message id. First argument |
images | boolean | No | Keep remote images in the HTML. Default false. Second argument, as { images: true } |
Response
{
html: '<div dir="ltr"><p>Your login code is <b>482913</b>.</p></div>',
remoteImagesBlocked: 0,
inlineImagesOmitted: 0
}| Field | Description |
|---|---|
html | The sanitized HTML. Render it inside a sandboxed iframe |
remoteImagesBlocked | Remote images that were removed. When above 0, you can offer a "Show images" action that calls the method again with { images: true } |
inlineImagesOmitted | Images embedded in the email that were too large to include |
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | Message not found, or the message has no HTML body |
Delete Message
Delete one message. The message is hidden at once, and every message method returns NotFoundError for it from then on. Outbound keeps the stored copy, including the text, HTML, original email and attachments. Deleting a message does not erase its content. To erase a person's data, use outbound.conversations.erase({ email }).
const result = await outbound.mailboxes.deleteMessage(messageId);
// { deleted: true, id: '0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23' }Parameters
| Field | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | The message id. First argument |
Response
| Field | Description |
|---|---|
deleted | true |
id | The ID of the deleted message |
What Happens After a Delete
- The message no longer appears in List Messages, and it no longer counts in
messageCount. - Get Message, Get Message HTML, Get Attachment and the raw download all return
404for it. - A second
deleteMessage()for the same ID returns404. - The message's content is still stored. The retention setting does not remove it. See Retention.
- If the same email is delivered to the mailbox again, it stays deleted. Outbound recognizes it as the message you already deleted.
Possible Errors
| Error | Status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | Message not found. The message does not exist for your account, or it was already deleted |
Address Rules
Local Parts
A localPart is the part before the @. Outbound trims it and lowercases it before it checks the rules. A localPart must:
- Be 1 to 64 characters long
- Use only letters, digits,
.,-and_ - Start and end with a letter or a digit
- Not contain two dots in a row
These names are reserved and cannot be used: postmaster, abuse, mailer-daemon, and any name shaped like a reply address (r1 followed by five letters or digits and a dash).
Addresses are not case sensitive. Claude-OTP@inbound.example.com and claude-otp@inbound.example.com are the same mailbox.
Custom and Generated Addresses
A mailbox is either custom or generated:
- Custom addresses use a
localPartyou choose, such assupport. You can only choose it on a reply domain that is assigned to your account alone.customNamesin List Reply Domains tells you which domains those are. - Generated addresses use a
localPartthe platform makes, such asmb-7kx2pqr9nd. LeavelocalPartout to get one. Generated addresses work on every active domain you have.
A localPart is unique per domain among your active mailboxes. Creating one that is already taken returns ConflictError. A deleted mailbox frees its localPart.
Shared Domains
A domain that other accounts also use does not allow custom names. On those domains, leave out localPart and you get a generated address. Passing a localPart returns OutboundError with status 422. Use listDomains() to check the flag before you create a mailbox.
Plus Addressing
Any text after a + in the recipient address is a tag. Mail to claude-otp+gmail@inbound.example.com is delivered to the claude-otp mailbox with tag set to gmail. The tag does not need to be created first. Use tags to tell apart the sources that forward into one mailbox:
const { mailbox } = await outbound.mailboxes.create({
localPart: 'claude-otp',
replyDomain: 'inbound.example.com',
});
// Both addresses deliver to the same mailbox.
// 'claude-otp@inbound.example.com' -> tag: null
// 'claude-otp+gmail@inbound.example.com' -> tag: 'gmail'Allowed Senders
allowedSenders limits which mail a mailbox accepts. It is a list of up to 100 entries. Each entry is one of:
| Entry | Matches |
|---|---|
alerts@vendor.com | That exact address only |
*@vendor.com | Any sender at exactly vendor.com |
Write a whole domain as *@vendor.com. Outbound also accepts @vendor.com and stores it as *@vendor.com, so the list you get back always uses the *@ form.
Entries are lowercased and duplicates are removed. Subdomains do not match: *@vendor.com does not match news.vendor.com.
- An exact address also matches the same address with a plus tag.
alerts@vendor.commatchesalerts+ops@vendor.com. - An empty list accepts mail from anyone.
- The message is accepted when an entry matches either the address in the
Fromheader or the envelope sender.
Mail from a sender that is not allowed is not delivered and does not fire an inbound event. No error is returned to the sender.
await outbound.mailboxes.update(mailboxId, {
allowedSenders: ['*@yourcompany.com', 'billing@vendor.com'],
});Limits
| Limit | Value |
|---|---|
| Mailboxes per account | 1,000 |
| Messages per mailbox per hour | 300. The hour is counted in UTC |
allowedSenders entries per mailbox | 100 |
metadata keys per mailbox | 50 |
metadata size per mailbox | 4 KB of JSON |
label length | 255 characters |
Mail beyond the hourly limit for a mailbox is not delivered. It does not fire an event.
What Is Not Delivered
Outbound does not store or report these messages, and no inbound event fires for them:
- Spam and messages with viruses
- Mail from a sender that your mailbox's
allowedSendersdoes not allow - Mail past the hourly limit for the mailbox
- Mail to a mailbox that is turned off (
enabled: false) - Mail to an address with no active mailbox, including the address of a mailbox you deleted. Outbound treats it the same as an address that never existed
- A duplicate of a message the mailbox already stored, such as the same message delivered twice with the same
Message-ID. This includes a message you deleted
Retention
The retention setting of your Conversations account applies to messages that you have not deleted. Read it with outbound.conversations.getSettings(), which returns retentionDays. When that value is a number of days, messages that have not been deleted are removed once that many days have passed since they were received. When it is null, they are kept until you delete them.
Deleted messages are not removed by the retention setting. They are kept until your account is erased or closed. To erase one person's data, including their mailbox messages, use outbound.conversations.erase({ email }). See Delete Message.
Deleting a mailbox works like this:
- Delivery to its address stops at once.
- Its messages are hidden from every method straight away.
- Its messages that have not been deleted are removed overnight. Messages you deleted with
deleteMessage()are kept, as described above. - The address is free. A new mailbox can use the same name, but it does not get the old messages.