HTML version: https://cooperemail.com/email-testing-api

Email testing API

# An email testing API for end-to-end tests: real inboxes per test run

Cooper Email gives your test suite real, private inboxes over HTTP. Create one per test run with a TTL, trigger the email in your app, block on wait-for-code or wait until it arrives, assert on the parsed message, and delete the inbox. Free is $0 a month with no card: 5 inboxes, 5,000 emails a month, and 1 custom domain.

## The test loop

End-to-end tests for signup, password reset, invitations, and magic links all need one thing: an address the test owns and can read. With Cooper the loop is four calls. Create an inbox with ttl_hours so a crashed run cleans itself up. Use its address in the form. Wait for the message. Delete the inbox.

Unlike polling in a sleep loop, GET /api/v1/inboxes/:id/wait holds the request for up to 55 seconds and returns as soon as mail is stored, so a test is only as slow as your app's mail.

## Playwright example

This test signs up with a fresh address and reads the verification code. The same calls work from Cypress, Jest, pytest, or a shell script in CI.

```
import { test, expect } from "@playwright/test";

const BASE = "https://cooperemail.com/api/v1";
const H = { Authorization: "Bearer " + process.env.COOPER_API_KEY,
            "content-type": "application/json" };

test("signup sends a verification code", async ({ page }) => {
  const inbox = await (await fetch(BASE + "/inboxes", { method: "POST", headers: H,
    body: JSON.stringify({ username: "e2e-" + Date.now(), ttl_hours: 1 }) })).json();

  await page.goto("https://staging.example.com/signup");
  await page.fill("#email", inbox.email);
  await page.click("text=Create account");

  const res = await fetch(BASE + "/inboxes/" + inbox.id + "/wait-for-code?wait=55",
    { headers: H });
  const { code, timed_out } = await res.json();
  expect(timed_out).toBe(false);
  await page.fill("#code", code);

  await fetch(BASE + "/inboxes/" + inbox.id, { method: "DELETE", headers: H });
});
```

## Assert on the message, not just the code

wait-for-code returns the message id, sender, and subject next to the code. Fetch the full message to check the HTML, the extracted text, links, headers, and attachments. kind=link returns the confirmation link without opening it, so your test decides when to visit it. from and subject filters ignore unrelated mail, and alias lets parallel tests share one inbox through plus addresses.

For unit tests that should not depend on your mail provider, POST /api/v1/inboxes/:id/inbound injects a message into an inbox directly. Injected mail carries no DKIM or DMARC results, so use real sends for anything that checks authentication.

```
AUTH=(-H "Authorization: Bearer $COOPER_API_KEY")
curl -s https://cooperemail.com/api/v1/inboxes/$INBOX/inbound "${AUTH[@]}" \
  -H 'content-type: application/json' \
  -d '{"from":"Acme <no-reply@acme.test>","subject":"Your code","text":"Your verification code is 482913"}'
```

## Many inboxes per run

POST /api/v1/inboxes/batch creates up to 5 inboxes in one call on Free, 25 on Starter, and 100 on Pro, with one prefix, labels, and a TTL. GET /api/v1/inboxes?label= finds them again. Temporary inboxes count toward the plan's inbox limit until they expire or are deleted.

## Compared with MailSlurp

From MailSlurp's pricing page (https://app.mailslurp.com/pricing/, read 2026-11-22): Free is $0 with 250 emails received and 100 inboxes created a month, temporary inboxes only, and external sending not included. Starter is $19.99 and Pro is $69.

MailSlurp is ahead for QA teams that need email client previews, inbox placement tests, warmup, or SMS test numbers, and its Free plan creates more inboxes a month (100) than Cooper Free holds at once (5). Cooper does not offer those testing features. On Cooper the 5,000 a month is a send cap, received mail does not count against it, and the test inbox can send. The full table is on the MailSlurp comparison page.

## Keep test mail clean

Send test mail to addresses you own. A new Free account's sends are rate limited for the first days, and sending pauses for any account whose bounce or complaint rate crosses the published thresholds. Tests that only receive are not affected by either.

A Free account in its first 7 days can send 10 messages an hour, 30 messages a UTC day, 20 distinct new recipients. The next send returns HTTP 429 new_account_send_limit and does not send or store the message. Starter, Pro, and grandfathered accounts are exempt. After that window, Free has no standing daily cap.

## FAQ

### Can tests share one inbox?

Yes. Give each test a plus address such as qa+test-17@cooperemail.com and pass alias=test-17 to wait-for-code. Each test only sees mail for its own tag.

### Is there a free email testing API?

Yes. Free is $0 a month with no card: 5 inboxes, 5,000 emails a month, and 1 custom domain. Webhooks, wait endpoints, search, HTML, and attachments are on every plan.

### How do I wait for an email in a test without sleeping?

Call GET /api/v1/inboxes/:id/wait?wait=55 or /wait-for-code?wait=55. Each holds the request until mail is stored or the wait ends, then returns. timed_out true means nothing arrived.

### Can I test magic links?

Yes. wait-for-code with kind=link returns the top-ranked https link and up to five candidates. Cooper does not open the link, so your test controls when it is visited.

### Will test inboxes pile up?

Not if you set ttl_hours or expires_at. The daily cron deletes expired inboxes. DELETE /api/v1/inboxes/:id frees the slot at once.

## Related

[Temp mail API](/temp-mail-api) · [Cooper vs MailSlurp](/compare/mailslurp) · [wait-for-code](/docs/reference/inbox-wait-for-code) · [Inbound injector](/docs/reference/inbound) · [Limits](/limits) · [Docs](/docs) · [Pricing](/pricing)

Operator: Avatar 8 LLC (ops@avatar33.com). Last updated 2026-11-22.

Canonical: https://cooperemail.com/email-testing-api
