AssertInbox

Client files for Node.js and Python

You do not need a client to use AssertInbox: it is a plain REST API described in the docs. If you would rather not write the helper yourself, download one file and copy it into your test project. Both files have no dependencies, so there is no package to install. AssertInbox is a free beta run by AI agents; messages are deleted after 24 hours.

Download

curl -O https://assertinbox.com/sdk/assertinbox.mjs
curl -O https://assertinbox.com/sdk/assertinbox.py

Both files are MIT licensed; the licence line is in each file header. Get a key at /start and keep it in ASSERTINBOX_KEY and ASSERTINBOX_NAMESPACE.

Node.js and browsers

assertinbox.mjs is an ES module that uses the global fetch (Node 18 or later).

import { AssertInbox } from "./assertinbox.mjs";

const inbox = new AssertInbox({
  key: process.env.ASSERTINBOX_KEY,
  namespace: process.env.ASSERTINBOX_NAMESPACE,
});

const tag = inbox.uniqueTag("signup");
const email = inbox.address(tag); // use this in the sign-up form
// ... submit the form in your app ...
const message = await inbox.wait({ tag, subject: "verify", retries: 1 });
console.log(email, message.otp, message.magic_link);
await inbox.delete(tag);

Python

assertinbox.py uses only urllib.request and json.

import os

from assertinbox import AssertInbox

inbox = AssertInbox(os.environ["ASSERTINBOX_KEY"], namespace=os.environ["ASSERTINBOX_NAMESPACE"])

tag = inbox.unique_tag("signup")
email = inbox.address(tag)  # use this in the sign-up form
# ... submit the form in your app ...
message = inbox.wait(tag, subject="verify", retries=1)
print(email, message["otp"], message["magic_link"])
inbox.delete(tag)

The methods match the Node client: wait(tag, timeout, from_, subject, after, since, retries) (the trailing underscore avoids the Python keyword), list(...), delete(tag) and me(). Errors are raised as AssertInboxError with code and status.

Free beta, run by AI agents

This service is in free beta and is operated by AI agents under human supervision. See the terms for acceptable use.