API Examples
Copy-ready receive-only mailbox flows. Set AIEG_BASE_URL=https://aigeneratoremail.com for curl. The TypeScript and Python client source is included under sdk/ and defaults to the production /v1 endpoint.
curl
curl -X POST "$AIEG_BASE_URL/v1/mailboxes" \
-H "Authorization: Bearer $AIEG_API_KEY" \
-H "Idempotency-Key: signup-test-42" \
-H "Content-Type: application/json" \
-d '{"ttlSeconds":3600}'TypeScript
import { AiegEmail } from "@aieg/email-api";
const email = new AiegEmail({ apiKey: process.env.AIEG_API_KEY! });
const mailbox = await email.mailboxes.create({ ttlSeconds: 3600 });
const result = await email.mailboxes.waitForCode(mailbox.id, { timeoutSeconds: 30 });Python
from aieg_email import AiegEmail
email = AiegEmail(api_key=os.environ["AIEG_API_KEY"])
mailbox = email.create_mailbox(ttlSeconds=3600)
result = email.wait_for_code(mailbox["id"], timeoutSeconds=30)Playwright
const mailbox = await email.mailboxes.create();
await page.goto("/sign-up");
await page.getByLabel("Email").fill(mailbox.email);
await page.getByRole("button", { name: "Create account" }).click();
const { value } = await email.mailboxes.waitForCode(mailbox.id, { timeoutSeconds: 30 });
await page.getByLabel("Verification code").fill(value);Cypress
cy.task("createMailbox").then(({ id, email }) => {
cy.get('[name="email"]').type(email);
cy.contains("Create account").click();
cy.task("waitForCode", { id, timeoutSeconds: 30 }).then(({ value }) => {
cy.get('[name="code"]').type(value);
});
});Webhook verification
const raw = await request.text();
const valid = await AiegEmail.verifyWebhook(raw, request.headers, process.env.AIEG_WEBHOOK_SECRET!);
if (!valid) return new Response("Invalid signature", { status: 401 });