Skip to content

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.

ts
const { domains } = await outbound.mailboxes.listDomains();
const customDomains = domains.filter((d) => d.customNames);

Response ​

ts
{
  domains: [
    { hostname: 'inbound.example.com', isDefault: true, customNames: true },
    { hostname: 'reply.outbound.yourbrand.com', isDefault: false, customNames: false }
  ]
}
FieldDescription
hostnameThe domain. Pass it as replyDomain when you create a mailbox
isDefaultUsed when a create call leaves out replyDomain
customNamestrue when the domain is assigned to your account alone, so you can choose the localPart. See Address Rules

Possible Errors ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account

Create Mailbox ​

Create an address that receives email. Leave out localPart to get a generated address.

ts
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.

FieldTypeRequiredDescription
localPartstringNoThe part before the @. Only on a reply domain your account uses alone. See Address Rules
replyDomainstringNoA reply domain hostname from List Reply Domains. Defaults to your default domain
labelstring | nullNoA name for your own use, up to 255 characters
metadataRecord<string, unknown>NoYour own data, returned with every inbound event for this mailbox. Up to 50 keys and 4 KB of JSON
allowedSendersstring[]NoWho can write to the mailbox. Empty accepts everyone. See Allowed Senders

Response ​

Status 201.

ts
{
  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.

FieldDescription
idMailbox ID. Use it in every method that takes a mailboxId
addressThe full address, localPart@replyDomain
localPartThe part before the @
replyDomainThe reply domain hostname
kindcustom when you chose the localPart, generated when the platform chose it
labelYour label, or null
metadataYour metadata, {} when none was set
allowedSendersThe sender rules, with domain entries written as *@domain. An empty array accepts everyone
enabledtrue when the mailbox accepts mail. false when it is turned off. See Update Mailbox
createdAtWhen the mailbox was created
lastReceivedAtWhen the last message arrived, or null

Possible Errors ​

ErrorStatusCause
BadRequestError400An 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
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
ConflictError409The address already exists on that domain (the message names the address)
OutboundError422The 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.

ts
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 ​

FieldTypeRequiredDescription
replyDomainstringNoOnly mailboxes on this reply domain
limitnumberNoPage size from 1 to 100. Default 50
cursorstringNopagination.nextCursor from the previous page

Response ​

ts
{
  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
  }
}
FieldDescription
mailboxesMailbox objects, as in Create Mailbox
pagination.limitThe page size used
pagination.hasMoretrue when another page exists
pagination.nextCursorPass as cursor to get the next page, or null

Possible Errors ​

ErrorStatusCause
BadRequestError400limit is outside 1 to 100
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound 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.

ts
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 ​

ts
const { mailbox } = await outbound.mailboxes.get('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f');

Parameters ​

FieldTypeRequiredDescription
mailboxIdstringYesThe mailbox id. First argument

Response ​

ts
{
  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 ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404No 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.

ts
const { mailbox } = await outbound.mailboxes.update('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f', {
  allowedSenders: ['*@yourcompany.com', 'alerts@vendor.com'],
});

Parameters ​

FieldTypeRequiredDescription
mailboxIdstringYesThe mailbox id. First argument
labelstring | nullNoA new label, or null to clear it
metadataRecord<string, unknown>NoReplaces the whole metadata object. Up to 50 keys and 4 KB of JSON
allowedSendersstring[]NoReplaces the whole list. Up to 100 entries. An empty array accepts everyone
enabledbooleanNofalse 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.

ts
await outbound.mailboxes.update(mailboxId, { enabled: false });

Response ​

The updated mailbox, in the same shape as Create Mailbox.

ts
{
  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 ​

ErrorStatusCause
BadRequestError400No field given, enabled is not true or false, or a field has a value that is not valid
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404No 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.

ts
const result = await outbound.mailboxes.delete('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f');
// { deleted: true, id: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f' }

Parameters ​

FieldTypeRequiredDescription
mailboxIdstringYesThe mailbox id. First argument

Response ​

FieldDescription
deletedtrue
idThe ID of the deleted mailbox

Possible Errors ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404No 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.

ts
const page = await outbound.mailboxes.listMessages('0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f', {
  since: '2026-11-23T00:00:00Z',
  limit: 50,
});

Parameters ​

FieldTypeRequiredDescription
mailboxIdstringYesThe mailbox id. First argument
limitnumberNoPage size from 1 to 100. Default 25
cursorstringNopagination.nextCursor from the previous page
sincestring | DateNoOnly messages received at or after this time. A Date is sent as toISOString()

Response ​

ts
{
  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
  }
}
FieldDescription
idMessage ID. Use it with Get Message and the other message methods
recipientThe exact address the message was sent to, including any +tag
tagThe plus tag without the +, or null
from / fromNameSender address and display name, or null
subjectSubject, or null
snippetA short preview of the plain text
hasHtmltrue when an HTML body exists. Fetch it with Get Message HTML
attachmentCountNumber of attachments
senderAuthverified, unverified, failed or internal. null when unknown
automatedtrue when the message looks machine-generated, such as an auto-reply or a notification
simulatedtrue when the message was created with sandbox.simulateInbound()
receivedAtWhen the message was received

Possible Errors ​

ErrorStatusCause
BadRequestError400limit is outside 1 to 100, or since is not a valid date-time
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404Mailbox 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.

ts
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.

ts
const { message } = await outbound.mailboxes.getMessage('0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23');

console.log(message.text);

Parameters ​

FieldTypeRequiredDescription
messageIdstringYesA message id from List Messages or an inbound event. First argument

Response ​

ts
{
  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'
  }
}
FieldDescription
replyTo, to, ccAddresses from the headers
textThe plain text body, capped in length. Sender-written, so escape it before you show it
textTruncatedtrue when text was cut short. The rest of the body is not stored
rfcMessageIdThe Message-ID header, or null
inReplyToThe In-Reply-To header, or null
sizeBytesSize of the raw message in bytes
automatedReasonWhy automated is true, or null
simulatedtrue when the message was created with sandbox.simulateInbound()
attachmentsAttachment 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 ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404Message 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:

ts
const file = await outbound.mailboxes.getAttachment(messageId, attachmentId);

const bytes = Buffer.from(file.data);
console.log(file.contentType, file.filename, file.size);
FieldTypeDescription
dataArrayBufferThe file contents
contentTypestringThe MIME type from the message, or application/octet-stream
filenamestring | nullThe file name the sender gave. Sender-written, so do not use it as a path on disk
sizenumberSize 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:

ts
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.

ts
const { html, remoteImagesBlocked } = await outbound.mailboxes.getMessageHtml(messageId);

iframe.setAttribute('sandbox', '');
iframe.srcdoc = html;

Parameters ​

FieldTypeRequiredDescription
messageIdstringYesThe message id. First argument
imagesbooleanNoKeep remote images in the HTML. Default false. Second argument, as { images: true }

Response ​

ts
{
  html: '<div dir="ltr"><p>Your login code is <b>482913</b>.</p></div>',
  remoteImagesBlocked: 0,
  inlineImagesOmitted: 0
}
FieldDescription
htmlThe sanitized HTML. Render it inside a sandboxed iframe
remoteImagesBlockedRemote images that were removed. When above 0, you can offer a "Show images" action that calls the method again with { images: true }
inlineImagesOmittedImages embedded in the email that were too large to include

Possible Errors ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404Message 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 }).

ts
const result = await outbound.mailboxes.deleteMessage(messageId);
// { deleted: true, id: '0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23' }

Parameters ​

FieldTypeRequiredDescription
messageIdstringYesThe message id. First argument

Response ​

FieldDescription
deletedtrue
idThe 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 404 for it.
  • A second deleteMessage() for the same ID returns 404.
  • 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 ​

ErrorStatusCause
AuthenticationError401Invalid or missing API key
ForbiddenError403Inbound is not enabled for your account
NotFoundError404Message 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 localPart you choose, such as support. You can only choose it on a reply domain that is assigned to your account alone. customNames in List Reply Domains tells you which domains those are.
  • Generated addresses use a localPart the platform makes, such as mb-7kx2pqr9nd. Leave localPart out 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:

ts
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:

EntryMatches
alerts@vendor.comThat exact address only
*@vendor.comAny 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.com matches alerts+ops@vendor.com.
  • An empty list accepts mail from anyone.
  • The message is accepted when an entry matches either the address in the From header 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.

ts
await outbound.mailboxes.update(mailboxId, {
  allowedSenders: ['*@yourcompany.com', 'billing@vendor.com'],
});

Limits ​

LimitValue
Mailboxes per account1,000
Messages per mailbox per hour300. The hour is counted in UTC
allowedSenders entries per mailbox100
metadata keys per mailbox50
metadata size per mailbox4 KB of JSON
label length255 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 allowedSenders does 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.

Released under the MIT License.