Quick start

From zero to a test that receives an email, in four steps. You need a terminal with curl; the last step uses Playwright, but any test runner works the same way.

1. Create an account and a project

Sign up and confirm your email address: that gives you $1 of free credit, enough for 1,000 messages. Then create a project. It gets its own random domain, for example k3x9q2m7a1zt.eoinbox.com.

Every address at that domain works at once. There is nothing to create per address: a test makes up a fresh one, such as signup-1712345@k3x9q2m7a1zt.eoinbox.com, every time it runs.

2. Make an API key

On the project's Quick start page in the console, press Create key. Copy the key (it starts with wfm_ and is shown only once) and keep it with the project id:

export WAITFORMAIL_API_KEY=wfm_...
export WAITFORMAIL_PROJECT=...   # the project id from the console
export WAITFORMAIL_DOMAIN=k3x9q2m7a1zt.eoinbox.com

3. Wait for a message

This request waits up to 60 seconds for the first message to hello@ your domain:

curl -H "Authorization: Bearer $WAITFORMAIL_API_KEY" \
  "https://api.waitformail.com/v1/projects/$WAITFORMAIL_PROJECT/messages/wait?to=hello@$WAITFORMAIL_DOMAIN&timeout=60"

While it waits, send any email to that address from your own mailbox. The request returns the moment the message is stored, as JSON:

{
  "id": "6f1c...",
  "to": "hello@k3x9q2m7a1zt.eoinbox.com",
  "from": { "address": "you@example.com", "name": "You" },
  "subject": "Hello",
  "text": "Confirm your account: https://example.com/confirm?t=abc\nCode 482913",
  "links": [{ "url": "https://example.com/confirm?t=abc", "text": "" }],
  "codes": ["482913"],
  "auth": { "spf": { "result": "pass", "domain": "example.com" }, "dkim": [], "dmarc": null }
}

No message within the timeout? The answer is 408 with the error code message_timeout.

4. Use it in a test

The same request from a Playwright test: sign up in your application with a new address, wait for the confirmation email and open its link.

import { expect, test } from '@playwright/test';

const api = `https://api.waitformail.com/v1/projects/${process.env.WAITFORMAIL_PROJECT}`;
const headers = { authorization: `Bearer ${process.env.WAITFORMAIL_API_KEY}` };

test('sign up and confirm the email address', async ({ page }) => {
  test.setTimeout(60_000); // the wait below takes up to 30 s
  const email = `signup-${Date.now()}@${process.env.WAITFORMAIL_DOMAIN}`;

  await page.goto('/signup');
  await page.getByLabel('Email').fill(email);
  await page.getByRole('button', { name: 'Create account' }).click();

  const res = await fetch(`${api}/messages/wait?to=${encodeURIComponent(email)}&timeout=30`, {
    headers,
  });
  expect(res.status).toBe(200);
  const message = await res.json();

  await page.goto(message.links[0].url);
});

Next