SDKs for your tests
The official clients cover the whole HTTP API, with objects and named values for what tests do most. Both have no dependencies and are open source (PlexusLabsDev/simmail-sdks).
| Language | Install |
|---|---|
| JavaScript / TypeScript (Node 18+) | npm install --save-dev @plexuslabs/simmail |
| Python (3.9+) | pip install simmail |
Any other language works too: every method is one plain HTTP call, listed at the end.
Both clients read their settings from the environment, or take them as options:
| Variable | Meaning |
|---|---|
SIMMAIL_URL | Your universe’s server, without /api, such as https://c1.simmail.dev (shown on your account page). |
SIMMAIL_API_KEY | An API key, smk_… (Organization → API keys). |
SIMMAIL_UNIVERSE | Optional: only needed when the key can reach more than one universe. |
Your app sends through simmail’s SMTP as usual (the dashboard’s Get started shows the settings); the client is for your tests.
JavaScript
Section titled “JavaScript”A sign-up test with Playwright
Section titled “A sign-up test with Playwright”import { test, expect } from "@playwright/test";import { Simmail } from "@plexuslabs/simmail";
const mail = new Simmail();
test("new users can verify their email", async ({ page }) => { const inbox = await mail.testAddress({ tag: "signup" }); // a fresh address, such as [email protected] await page.goto("/signup"); await page.fill("#email", inbox.address);
const waiting = inbox.waitForEmail({ subject: "verify", timeout: "20s" }); await page.click("text=Create account"); const msg = await waiting;
expect(msg.codes).toHaveLength(1); await page.fill("#code", msg.codes[0]); // or: await page.goto(msg.magicLinks[0]) await inbox.expectNoEmail({ within: "5s" }); // and nothing else arrives await inbox.cleanup();});Start the wait before the click: a wait only sees mail that arrives after it starts, unless you pass existing: true. Any address works too: mail.mailbox("[email protected]").waitForEmail({…}).
Objects you can act on
Section titled “Objects you can act on”Answers are objects with the API’s fields and methods for what you do next:
import { Simmail, EventAlias, Folder } from "@plexuslabs/simmail";
const sent = await mail.mailbox("[email protected]").send({ to: ["[email protected]"], subject: "Offer", text: "Would you take 165k?" });
await dana.waitFor(EventAlias.Replied, { fast: true }); // or "declined", "clicked", "bounced"const reply = await mail.waitForReply({ from: dana.address, inReplyTo: sent.message_id });await reply.reply({ text: "Great, I'll send the papers." }); // threaded, from the mailbox it is inconst talk = await reply.waitUntilQuiet({ quiet: "10s" }); // the conversation, once it settlesconsole.log(talk.messages.length, talk.latest.subject);
await reply.move(Folder.Archive);await mail.clock.advance("2d"); // follow-ups and nudges that were due happenawait dana.runDue(); // or run her pending work nowSettings with fixed choices have named values (Temperament.Skeptical, FaultScenario.GmailRate, MailboxStatus.Disabled, …), each the API’s plain string, so a string works too. Calls are grouped (mail.personas, mail.cases, mail.clock, mail.jobs, mail.world, mail.faults, mail.recipients, mail.webhooks, mail.events, …); the package README lists every call.
A failed call throws an error by kind, all SimmailError: WaitTimeoutError (with nearMisses: what almost matched, and why not), UnexpectedEmailError (from expectNoEmail, with the email), ValidationError (with field and allowed), NotFoundError, PlanLimitError, RateLimitedError and others, each with the server’s code and requestId.
Python
Section titled “Python”A pytest example
Section titled “A pytest example”from simmail import Simmail
mail = Simmail()
def test_password_reset(client): inbox = mail.test_address(tag="reset") client.post("/signup", data={"email": inbox.address, "password": "pw-123456789"}) client.post("/forgot-password", data={"email": inbox.address})
msg = inbox.wait_for_email(subject="reset", existing=True, timeout=20) assert msg.magic_links, msg.text inbox.cleanup()Timeouts are seconds, or a duration such as "45s" (at most five minutes). Answers are dataclasses (Message, Persona, Case, …) that still read like the plain answer (msg["magic_links"]).
Objects you can act on
Section titled “Objects you can act on”from simmail import EventAlias, Folder
sent = mail.mailbox("[email protected]").send(["[email protected]"], "Offer", text="Would you take 165k?")
dana.wait_for(EventAlias.REPLIED, fast=True) # or "declined", "clicked", "bounced"reply = mail.wait_for_reply(dana.address, in_reply_to=sent["message_id"])reply.reply("Great, I'll send the papers.")talk = reply.wait_until_quiet(quiet=10)print(len(talk.messages), talk.latest.subject)
reply.move(Folder.ARCHIVE)mail.clock.advance("2d")dana.run_due()Named values are str enums (Temperament.SKEPTICAL == "skeptical"), each with a label and description. Errors are the same classes as in JavaScript, with near_misses, field, allowed, code and request_id. The package README lists every call.
Retries and request ids
Section titled “Retries and request ids”Every send and inject carries its own Idempotency-Key, so a write the client tries again is never done twice. Both clients retry reads and keyed writes after a network error, 502 or 503 (retries, default 2), and an answer the server had already given says replayed. To follow a test’s requests in your universe’s logs, use mail.withRequestId("ci-1234") (with_request_id in Python): every error carries that id.
The calls behind them
Section titled “The calls behind them”| Method | API call |
|---|---|
testAddress / test_address | POST /api/addresses; cleanup() is DELETE /api/messages?to=… (or ?tag=…) |
waitForEmail / wait_for_email | GET /api/wait |
expectNoEmail / expect_no_email | GET /api/wait/none |
waitForReply / wait_for_reply | GET /api/wait/reply |
persona.waitFor / wait_for_event | GET /api/wait/event |
waitUntilQuiet / wait_for_thread | GET /api/wait/thread |
send, inject | POST /api/send, POST /api/inject |
mailbox(…).list(), message() | GET /api/mailboxes/{address}/messages, …/messages/{folder}/{uid} |
msg.health() / health | GET /api/inspect?message_id=…: the health report |
extract | POST /api/extract: codes and links from any text or HTML |
mail.personas, mail.cases | /api/personas, /api/cases |
mail.clock, mail.jobs, runDue / run_due | /api/clock, /api/jobs, POST /api/jobs/run-due |
mail.events | GET /api/events (the live stream), GET /api/log |
mail.faults | /api/faults |
mail.recipients | /api/recipients |
mail.world | /api/world |
mail.webhooks | /api/webhooks |
mail.schema() | GET /api/schema: every setting’s allowed values (the SDKs’ named values come from it) |
Every call sends Authorization: Bearer <your key>; anything else is in the API reference, and mail.request(method, path, body, query) makes any call.