Automating OTP Signups in E2E Tests with Stateless Bearer Inboxes
Learn how to test signup and email verification flows in Playwright or CI pipelines using InboxFlick's cookie-free REST and Fetch SSE API.
End-to-end signup tests frequently fail for two avoidable reasons: shared test inboxes suffer from race conditions when parallel CI workers read the same mailbox, and fixed sleep() intervals make test suites slow and flaky.
InboxFlick V2 solves both problems with per-test disposable mailboxes protected by one-time Bearer tokens and Server-Sent Events (SSE) push notifications.
1. Provision an Isolated Inbox Per Test Run
Call POST /v1/mailboxes at the start of each test case. Every test worker gets its own unique 14-character address and cryptographic access_token:
curl -sS -X POST https://api.inboxflick.com/v1/mailboxes \
-H "Content-Type: application/json" \
-d '{}'
Store data.mailbox.address to submit into your application’s signup form, and keep data.access_token in memory for reading incoming mail.
2. Wait Deterministically via SSE Instead of Polling
Rather than polling every two seconds, open an authenticated stream to GET /v1/mailboxes/me/events with Authorization: Bearer <access_token>. As soon as our background worker parses and sanitizes the inbound email, Redis Pub/Sub emits a message.ready frame containing the message_id.
3. Read the Message and Clean Up
Fetch GET /v1/mailboxes/me/messages/{message_id} to inspect text_body or html_body, extract your OTP or magic link, and call DELETE /v1/mailboxes/me in your test teardown hook so active IP quotas remain clean across parallel runs.