Developer tools
TypeScript SDK
Register an inbox and wait for email from Node.js or Bun.
First follow client installation and set your API address and project key in the terminal environment. The examples below also support a repository checkout.
TypeScript SDK from the same checkout
Save this as first-email.ts at the repository root and run bun run first-email.ts. Send your email to the printed address while the wait is pending. The client needs an explicit hosted origin; its local default is not your hosted project.
import { InboxSpec } from "./packages/sdk/src/index.ts";
const baseUrl = process.env.INBOXSPEC_API_URL;
const apiKey = process.env.INBOXSPEC_API_KEY;
if (!baseUrl || !apiKey) throw new Error("Set the API address and project key");
const client = new InboxSpec({ baseUrl, apiKey });
const run_id = "first-" + crypto.randomUUID();
const inbox = await client.inboxes.forRun({ run_id });
console.log("Send test mail to:", inbox.address);
const result = await client.messages.wait({
inbox: inbox.address, match: { has_code: true }, timeout_ms: 60000,
});
if (result.status === "timeout") {
console.log(result.hint, result.non_matching_arrivals);
} else {
console.log("Code candidates:", result.message.codes);
console.log(await client.messages.body(result.message.id, "text"));
}