SpecinboxDocs
← Dashboard

Quickstart

Create a key and an inbox, receive a message and extract a 6-digit OTP in curl, JavaScript and Python.

1. Create an API key

In the dashboard, open API keys and create a key. A test key (tm_test_) only reaches sandbox inboxes on a test domain, never counts toward your e-mail or inbox limits, and every inbox it creates already holds one fixture message with the code 424242, so the steps below work before any real mail exists. A live key (tm_live_) creates real inboxes that receive real mail. Either way the key needs the inboxes:write and messages:read scopes (a secret key has every scope).

2. Create an inbox

POST /v1/inboxes with an empty body returns a fresh address on a shared domain. The optional JSON body takes expires_in (seconds, 60 to 2592000) and, on a verified custom domain, domain and local_part.

{
  "id": "inb_7Qx2mN9kLp",
  "object": "inbox",
  "address": "[email protected]",
  "domain": "sandbox.temp-mail.lol",
  "livemode": false,
  "status": "active",
  "created_at": "2026-12-07T08:01:12Z",
  "expires_at": null
}

3. Send a test mail to it

With a live key, sign up on your own app with address, or send it a message from any mailbox. With a test key, nothing can email the inbox from outside, so inject the message instead: POST /v1/test/inboxes/{inbox_id}/messages with subject, text and optionally html and from. It returns 403 forbidden for live keys. Injected mail also fires your test-mode webhooks.

4. Wait for the message and extract the code

GET /v1/inboxes/{inbox_id}/messages lists summaries newest first (id, from, subject, received_at); the body is on GET /v1/messages/{message_id} as text and html. Poll every couple of seconds, then match the first 6-digit run. Pass ?since=<ISO 8601> to ignore mail that arrived before you triggered the flow, or register a webhook and skip polling.

cURL
KEY=tm_test_YOUR_KEY
API=https://devapi.temp-mail.lol/v1

# 2. Create an inbox
INBOX_ID=$(curl -s -X POST $API/inboxes -H "Authorization: Bearer $KEY" | jq -r .id)

# 3. Sign up on your app with the address, or (test keys only) inject the mail
curl -s -X POST $API/test/inboxes/$INBOX_ID/messages \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"subject": "Your verification code is 731942", "text": "Your code is 731942"}' > /dev/null

# 4. Wait for a message, read it, pull the 6-digit code
for i in $(seq 1 30); do
  MSG_ID=$(curl -s "$API/inboxes/$INBOX_ID/messages?limit=1" -H "Authorization: Bearer $KEY" | jq -r '.data[0].id // empty')
  [ -n "$MSG_ID" ] && break
  sleep 2
done
curl -s $API/messages/$MSG_ID -H "Authorization: Bearer $KEY" | jq -r .text | grep -oE '\b[0-9]{6}\b' | head -1
# 731942
JavaScript (fetch)
const KEY = "tm_test_YOUR_KEY";
const API = "https://devapi.temp-mail.lol/v1";
const headers = { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" };

// 2. Create an inbox
const inbox = await fetch(`${API}/inboxes`, { method: "POST", headers }).then((r) => r.json());

// 3. Sign up on your app with inbox.address, or (test keys only) inject the mail
await fetch(`${API}/test/inboxes/${inbox.id}/messages`, {
  method: "POST",
  headers,
  body: JSON.stringify({"subject": "Your verification code is 731942", "text": "Your code is 731942"}),
});

// 4. Wait for a message, read it, pull the 6-digit code
async function waitForOtp(inboxId, timeoutMs = 60_000) {
  const deadline = Date.now() + timeoutMs;
  while (Date.now() < deadline) {
    const { data } = await fetch(`${API}/inboxes/${inboxId}/messages?limit=1`, { headers }).then((r) => r.json());
    if (data.length) {
      const message = await fetch(`${API}/messages/${data[0].id}`, { headers }).then((r) => r.json());
      const match = `${message.subject}\n${message.text}`.match(/\b\d{6}\b/);
      if (match) return match[0];
    }
    await new Promise((r) => setTimeout(r, 2_000));
  }
  throw new Error("No OTP arrived in time");
}

console.log(await waitForOtp(inbox.id)); // 731942
Python (requests)
import re, time, requests

KEY = "tm_test_YOUR_KEY"
API = "https://devapi.temp-mail.lol/v1"
headers = {"Authorization": f"Bearer {KEY}"}

# 2. Create an inbox
inbox = requests.post(f"{API}/inboxes", headers=headers).json()

# 3. Sign up on your app with inbox["address"], or (test keys only) inject the mail
requests.post(f"{API}/test/inboxes/{inbox['id']}/messages", headers=headers,
              json={"subject": "Your verification code is 731942", "text": "Your code is 731942"})

# 4. Wait for a message, read it, pull the 6-digit code
def wait_for_otp(inbox_id, timeout=60):
    deadline = time.time() + timeout
    while time.time() < deadline:
        data = requests.get(f"{API}/inboxes/{inbox_id}/messages", headers=headers, params={"limit": 1}).json()["data"]
        if data:
            message = requests.get(f"{API}/messages/{data[0]['id']}", headers=headers).json()
            match = re.search(r"\b\d{6}\b", f"{message['subject']}\n{message['text']}")
            if match:
                return match.group()
        time.sleep(2)
    raise TimeoutError("No OTP arrived in time")

print(wait_for_otp(inbox["id"]))  # 731942
A test inbox already holds the fixture message (code 424242) when it is created, so without the inject step the snippet prints 424242. Lists are newest first, so after injecting you get 731942.

Next steps

API reference for every route and the OpenAPI spec · Webhooks to get the message pushed to you · Custom domains so your signup form never sees a shared domain · Test mode for deterministic CI runs.