Skip to content

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).

LanguageInstall
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:

VariableMeaning
SIMMAIL_URLYour universe’s server, without /api, such as https://c1.simmail.dev (shown on your account page).
SIMMAIL_API_KEYAn API key, smk_… (Organization → API keys).
SIMMAIL_UNIVERSEOptional: 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.

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({…}).

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?" });
const dana = await mail.personas.byAddress("[email protected]");
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 in
const talk = await reply.waitUntilQuiet({ quiet: "10s" }); // the conversation, once it settles
console.log(talk.messages.length, talk.latest.subject);
await reply.move(Folder.Archive);
await mail.clock.advance("2d"); // follow-ups and nudges that were due happen
await dana.runDue(); // or run her pending work now

Settings 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.

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"]).

from simmail import EventAlias, Folder
sent = mail.mailbox("[email protected]").send(["[email protected]"], "Offer", text="Would you take 165k?")
dana = mail.personas.by_address("[email protected]")
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.

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.

MethodAPI call
testAddress / test_addressPOST /api/addresses; cleanup() is DELETE /api/messages?to=… (or ?tag=…)
waitForEmail / wait_for_emailGET /api/wait
expectNoEmail / expect_no_emailGET /api/wait/none
waitForReply / wait_for_replyGET /api/wait/reply
persona.waitFor / wait_for_eventGET /api/wait/event
waitUntilQuiet / wait_for_threadGET /api/wait/thread
send, injectPOST /api/send, POST /api/inject
mailbox(…).list(), message()GET /api/mailboxes/{address}/messages, …/messages/{folder}/{uid}
msg.health() / healthGET /api/inspect?message_id=…: the health report
extractPOST /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.eventsGET /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.