What expires by itself
In Zyntra, mail is deleted automatically after 1 day for addresses never created in the dashboard; 7 days on Free, 30 days on Starter, 90 days on Pro for inboxes created there. A suite that builds a new address per test leaves nothing behind that a later run can trip over.
When deleting is worth it
- Reused inboxes. A seeded user or a named QA inbox gets mail on every run; a clean inbox makes the next run's "newest email" unambiguous.
- Personal data. If staging emails carry copied customer data, don't keep it for weeks.
- Assertions about absence. "Asking for a reset of an unknown address sends nothing" needs an inbox that starts empty.
Deleting over the API
List the inbox (up to 50 emails per page, newest first), then delete each email by its UUID. Each call is one API request.
const API = "https://api.zyntra.app";
const headers = { "X-API-Key": process.env.ZYNTRA_API_KEY! };
export async function emptyInbox(inbox: string) {
for (;;) {
const res = await fetch(
`${API}/emails?inbox=${encodeURIComponent(inbox)}&limit=50`,
{ headers },
);
const emails: { uuid: string }[] = await res.json();
if (emails.length === 0) return;
for (const { uuid } of emails) {
const del = await fetch(`${API}/emails/message?message_uuid=${uuid}`, {
method: "DELETE",
headers,
});
if (!del.ok) throw new Error(`Delete failed: ${del.status}`);
}
}
}Run it in a fixture's teardown, not at the start of the next test, so a crashed run does not leave the next one waiting on stale mail.
The cost in requests
Emptying an inbox with ten emails costs eleven requests: one list, ten deletes. On a plan that limits API requests, a teardown on every test can cost more than the tests themselves. Prefer fresh addresses, and keep deletes for the inboxes that really are reused.