API Documentation
Programmatic access to your Mighty Temp Mail account. Create inboxes, fetch messages, extract OTP codes — all from your scripts and apps.
/api/v1/.
The legacy
/api/
prefix still works and will not be removed.
Authentication
Authenticate every request with your API key in the Authorization header. API keys are managed from the dashboard at /app.html#api.
| Method | Header | Use for |
|---|---|---|
| API key | Authorization: Bearer mk_live_… |
Scripts, servers, AI agents, mobile apps — any non-browser client. |
Which endpoints accept which method
| Endpoint | Accepts |
|---|---|
POST /api/v1/inboxes | Session or API key |
GET /api/v1/inboxes | Session or API key |
DELETE /api/v1/inboxes/:id | Session or API key |
GET /api/v1/inboxes/:id/messages | Session or API key |
GET /api/v1/messages/:id | Session or API key |
GET /api/v1/api-keys | Dashboard session only |
POST /api/v1/api-keys | Dashboard session only |
DELETE /api/v1/api-keys/:id | Dashboard session only |
API keys cannot create, list, or revoke other API keys. That's a deliberate safety rule — a leaked key cannot mint its own replacement.
Inboxes
Create an inbox
/api/v1/inboxes
costs 1 free inbox or your balance
curl -X POST https://tempmail.heartsyncmatch.com/api/v1/inboxes \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"localPart":"myinbox"}'
Body: localPart is optional. Omit it for a random address.
Response:
{
"id": 42,
"address": "myinbox@heartsyncmatch.com",
"user_id": 1,
"paid_with": "balance",
"cost_cents": 250,
"created_at": 1791292042
}
402 error if your balance is empty and free inboxes are used up:
{
"error": "insufficient_balance",
"required_cents": 250,
"balance_cents": 0
}
List your inboxes
/api/v1/inboxes
curl https://tempmail.heartsyncmatch.com/api/v1/inboxes \
-H "Authorization: Bearer YOUR_KEY"
Delete an inbox
/api/v1/inboxes/:id
curl -X DELETE https://tempmail.heartsyncmatch.com/api/v1/inboxes/42 \
-H "Authorization: Bearer YOUR_KEY"
Messages & OTP
Fetch messages (with optional long-polling)
/api/v1/inboxes/:id/messages
Query parameters:
?wait=30— hold the request open for up to 30 seconds, returning as soon as a new message arrives. Saves you from polling in a tight loop.?since=1791292000— only return messages received after this unix timestamp.
curl "https://tempmail.heartsyncmatch.com/api/v1/inboxes/42/messages?wait=30" \
-H "Authorization: Bearer YOUR_KEY"
Fetch a single message with automatic OTP extraction
/api/v1/messages/:id?otp=true
Add ?otp=true and the response includes code (6-digit OTP) and magic_link (verification URL) extracted from the email content.
curl "https://tempmail.heartsyncmatch.com/api/v1/messages/msg_1791292792644_ddebe13d?otp=true" \
-H "Authorization: Bearer YOUR_KEY"
Response:
{
"id": "msg_1791292792644_ddebe13d",
"from": "noreply@example.com",
"subject": "Your verification code",
"body_text": "Your verification code is 344666",
"code": "344666",
"magic_link": null,
"received_at": 1791292792
}
API keys
/api/v1/api-keys
list your keys (metadata only)
/api/v1/api-keys
create a key — plaintext returned once
/api/v1/api-keys/:id
revoke
You can have up to 5 active keys at a time. Revoke old ones from the dashboard if you hit the limit.
Keys can be created with an optional expiration: Never, 30 days, 90 days, 6 months, or 1 year. Expired keys stop working automatically and no longer count toward your 5-key limit — but their metadata remains visible in the dashboard for reference.
Create a key with expiration
Key creation is dashboard-only. A leaked API key cannot mint its own replacement — this is a deliberate safety rule.
Set expires_in_days to 0 or omit it for a key that never expires. Maximum is 730 days (2 years).
Permissions & scopes
Every API key can be restricted to a specific set of actions. This lets you hand out a key that can only do what it needs to — a read-only widget can't spend your balance, an OTP bot can't delete inboxes.
Presets
| Preset | Scopes | Can do |
|---|---|---|
| Full access (default) | * |
Everything |
| Read-only | inboxes:read, messages:read |
List inboxes, read messages. No create, delete, or OTP. |
| Automation | 4 scopes | Create inboxes, read messages, extract OTPs. Cannot delete. |
All available scopes
inboxes:read— list and view inboxesinboxes:create— create new inboxesinboxes:delete— delete inboxesmessages:read— read messages in owned inboxesotp:extract— extract OTP / magic-link from messages
Create a key with scopes
Pass scopes as a preset name (full, read-only, automation)
or an array of concrete scope strings. Omit it for full access.
Errors
When a key tries to do something outside its scopes:
HTTP 403
{
"error": "This API key is not allowed to do that.",
"required_scope": "inboxes:delete",
"key_scopes": ["inboxes:read", "messages:read"]
}
Session cookies (the dashboard) always have full access and are never scope-checked.
Examples
Python — create inbox, wait for OTP, extract code
import requests
API_KEY = "mk_live_YOUR_KEY"
BASE = "https://tempmail.heartsyncmatch.com"
# 1. Create an inbox
inbox = requests.post(
f"{BASE}/api/v1/inboxes",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"localPart": "python-test"},
).json()
print("Inbox:", inbox["address"])
# 2. Use inbox["address"] on the target service, then long-poll
messages = requests.get(
f"{BASE}/api/v1/inboxes/{inbox['id']}/messages?wait=30",
headers={"Authorization": f"Bearer {API_KEY}"},
).json()
# 3. Extract the OTP
msg = requests.get(
f"{BASE}/api/v1/messages/{messages[0]['id']}?otp=true",
headers={"Authorization": f"Bearer {API_KEY}"},
).json()
print("OTP code:", msg["code"])
Node.js — same flow
const API_KEY = "mk_live_YOUR_KEY";
const BASE = "https://tempmail.heartsyncmatch.com";
const headers = { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" };
// 1. Create an inbox
const inbox = await fetch(`${BASE}/api/v1/inboxes`, {
method: "POST", headers, body: JSON.stringify({ localPart: "node-test" }),
}).then(r => r.json());
// 2. Long-poll for the message
const messages = await fetch(
`${BASE}/api/v1/inboxes/${inbox.id}/messages?wait=30`,
{ headers }
).then(r => r.json());
// 3. Extract the OTP
const msg = await fetch(
`${BASE}/api/v1/messages/${messages[0].id}?otp=true`,
{ headers }
).then(r => r.json());
console.log("OTP:", msg.code);
SDKs
Official client libraries that wrap the REST API. Both are zero-dependency.
Python
pip install mighty-temp-mail
from mighty_temp_mail import MightyMail
mail = MightyMail("mk_live_YOUR_KEY")
inbox = mail.inboxes.create()
print("Send email to:", inbox.address)
message = inbox.wait_for_message(timeout=30)
print("OTP:", message.otp)
Node.js
npm install @mightythunder/temp-mail
import { MightyMail } from "@mightythunder/temp-mail";
const mail = new MightyMail("mk_live_YOUR_KEY");
const inbox = await mail.inboxes.create();
console.log("Send email to:", inbox.address);
const message = await inbox.waitForMessage({ timeout: 30 });
console.log("OTP:", message.otp);
Common methods
mail.inboxes.create(localPart?)— create an inboxmail.inboxes.list()— list your inboxesmail.inboxes.delete(id)— delete an inboxinbox.waitForMessage(timeout)— long-poll and return the next message with OTP extractedmail.messages.get(id, otp=true)— fetch a message with OTP extractionmail.usage(days)— usage analytics for the current period
Webhooks
Instead of polling, register a webhook and we'll POST to your URL the moment email arrives.
Account default vs per-key override
Each account can have one account default webhook. Each API key can also have its own override. When an event fires, we route it in this order:
- Per-key webhook (if the key has one configured and enabled)
- Account default webhook (if enabled)
- Nothing — event is dropped, no delivery attempted
Which key "owns" an event is determined by which API key created the inbox the message arrived in. Inboxes created via the dashboard use the account default.
Event payload
{
"event": "message.received",
"timestamp": 1791292792,
"data": {
"inbox": { "id": 42, "address": "abc@heartsyncmatch.com" },
"message": {
"id": "msg_1791292792644_ddebe13d",
"from": "noreply@example.com",
"to": "abc@heartsyncmatch.com",
"subject": "Your verification code",
"body_text": "Your verification code is 344666",
"received_at": 1791292792
}
}
}
Signature verification
Every request carries these headers:
X-Mighty-Event: message.receivedX-Mighty-Delivery: <delivery-id>X-Mighty-Timestamp: <unix-seconds>X-Mighty-Signature: sha256=<hex>
The signature is HMAC-SHA256 over the string <timestamp>.<rawBody> using your webhook secret.
Node.js verification example:
import crypto from 'crypto';
function verify(rawBody, headers, secret) {
const ts = headers['x-mighty-timestamp'];
const sig = headers['x-mighty-signature'];
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(`${ts}.${rawBody}`)
.digest('hex');
return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}
Retry policy
We retry failed deliveries up to 5 times with exponential backoff:
| Attempt | Wait before retry |
|---|---|
| 1st | Immediate |
| 2nd | 60 seconds |
| 3rd | 5 minutes |
| 4th | 30 minutes |
| 5th | 2 hours |
| After 5th | Given up (status: exhausted) |
Return 2xx within 10 seconds to acknowledge. Anything else counts as a failed attempt.
Usage analytics
Per-key counters for the current period.
/api/v1/usage?days=30days 1–90{
"days": 30,
"totals": { "requests": 128, "inboxes_created": 12, "messages_received": 47, "otp_extracts": 31 },
"series": [ { "date": "2026-10-01", "requests": 4, "inboxes_created": 0, "messages_received": 1, "otp_extracts": 1 } ],
"by_key": [ { "key_id": 9, "requests": 82, "inboxes_created": 8, "messages_received": 30, "otp_extracts": 22 } ]
}
Rate limits
- Inbox creation: 30 per hour per account
- Long-poll wait: 30 seconds max per request
- Keys per account: 5
Need a higher limit or bulk operations? Contact us on WhatsApp.