March 28, 2026

Tag-Based Addresses: Test Email Addresses Without an API Call

Tag-Based AddressesTestingAPI

What Are Tag-Based Addresses?

MailBrew's tag-based addresses let you receive emails at {anything}@{company}.mailbrew.dev:

[email protected]
[email protected]
[email protected]

These addresses don't need a creation API call first. The address is registered automatically when its first email arrives. Before the first email arrives, the list endpoint returns 404, but the wait endpoint can be called in advance for addresses on your own domain. In tests, waiting with the wait endpoint is the reliable approach.

Traditional vs Tag-Based

Traditional: Create via API

// 1. Call API to create address (network latency)
const addr = await mb.createAddress({ ttl: 300 });

// 2. Use the created address
await page.fill('[name="email"]', addr.address);

Tag-Based: Use Immediately

// Generate UUID and use directly (no creation API call)
const addr = `test-${crypto.randomUUID()}@acme.mailbrew.dev`;
await page.fill('[name="email"]', addr);

Benefits

  1. No creation API latency — Use the address string in your test immediately
  2. No creation API rate-limit usage — Retrieval and wait API calls remain rate-limited as usual
  3. Well suited to parallel tests — with UUIDs, collisions are practically impossible
  4. Simple — No SDK call needed just to prepare an address

Usage Patterns

Pattern 1: Per-Test Addresses

test('signup flow', async ({ page }) => {
  const email = `signup-${Date.now()}@acme.mailbrew.dev`;
  // ...
});

Pattern 2: Per-Service Addresses

In microservice environments, use service-specific prefixes:

auth-service-{id}@acme.mailbrew.dev
billing-{id}@acme.mailbrew.dev
notification-{id}@acme.mailbrew.dev

Pattern 3: Multi-Language Testing

const locales = ['ja', 'en', 'zh'];
for (const locale of locales) {
  const email = `lang-test-${locale}@acme.mailbrew.dev`;
  await testSignupFlow(email, locale);
}

Retrieving Emails

Emails sent to tag-based addresses can be retrieved via the standard API:

const email = await mb.waitForEmail(
  `[email protected]`,
  { timeout: 30000 }
);

Combined with Custom Domains

With a custom domain configured, you can use tag-based addresses on your own domain too (available on every plan):

test-{id}@mail.your-company.com

Test with your own domain's email addresses, even for applications with domain-based validation.

Summary

With tag-based addresses, you need no API call to prepare a test email address. They are especially useful for parallel E2E tests and CI environments.

Try it now →

← Back to blog