Skip to main content
Stably’s email inbox lets you receive emails during tests and extract structured data like OTPs and magic links. Each inbox is scoped to your test, preventing interference between parallel runs.
Why use email inbox? Testing email-based flows (sign-up verification, password reset, magic links) requires receiving real emails. The inbox handles email delivery, filtering, and AI-powered extraction so you can focus on testing your application.

Installation

Install the @stablyai/email package:
Works with any test framework — Playwright, Jest, Vitest, Cypress, or backend scripts.

Finding Your Email Address

Your organization’s email address follows the pattern {org-name}@mail.stably.ai. To find your specific address:
  1. Settings: Go to Settings > Email Inbox in your Stably project
  2. In code: Call Inbox.build() — the returned inbox.address contains your org’s full email
Allowlisting: If your email provider blocks automated emails, add mail.stably.ai to your allowlist.

Viewing Received Emails

You can view all emails received by your inbox directly from the Stably web portal or programmatically via the SDK.
Go to Settings > Email Inbox in your Stably project. The bottom of the page shows a list of all received emails with sender, recipient, subject, and date.
Email Inbox settings page showing received emails
Use the Refresh button to fetch the latest emails. The “To” column shows which suffixed address each email was sent to, making it easy to trace emails back to specific test runs.

Email Object

Methods like inbox.listEmails(), inbox.waitForEmail(), and inbox.getEmail() return Email objects with these properties:

Basic Usage

Create an inbox, trigger an email from your app, wait for it to arrive, and extract the data you need:

Inbox.build

Creates an inbox instance scoped to your test. Requires STABLY_API_KEY and STABLY_PROJECT_ID environment variables (or pass them directly).

Options

Using a unique suffix for each test is highly recommended. It ensures tests running in parallel don’t interfere with each other by giving each test its own isolated inbox address.

Inbox Properties

The inbox automatically filters out emails received before createdAt, so you only see emails from your current test.

inbox.waitForEmail

Polls until a new email matching your filters arrives. Only sees emails received after the inbox was created.

Options

Throws EmailTimeoutError if no matching email arrives within the timeout.

inbox.extractFromEmail

Extracts data from an email using AI. Returns { data, reason } where data is the extracted value and reason describes how the extraction was performed.
The method throws EmailExtractionError if extraction fails.

inbox.listEmails

Lists emails in the inbox. By default, only returns emails received after the inbox was created.

Options

inbox.getEmail

Gets a specific email by ID.

inbox.deleteEmail / inbox.deleteAllEmails

Delete emails to clean up after your test.
deleteAllEmails() only deletes emails sent to this inbox’s address, not your entire org mailbox.

Common Extraction Prompts

Using Fixtures

Create a reusable inbox fixture for automatic cleanup:

Troubleshooting

Tests interfere with each other Use unique suffixes with Inbox.build({ suffix: 'test-' + Date.now() }) to give each test its own isolated inbox. The inbox automatically filters to only show emails received after it was created.