Temp Mail API: temporary inboxes for your code
One request creates a temporary email address. The next ones read its mail as JSON. Made for sign-up tests, checks of transactional email and apps that need a throwaway inbox.
The TempMailo app for Android reads mail through the same methods.
# 1. Create an address curl -X POST \ https://tempmailo.co/api/v2/create/ \ -H "X-Api-Key: YOUR_API_KEY" \ -d lifetime=3600 # 2. Read its mail with the token from step 1 curl https://tempmailo.co/api/v2/messages/ \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Authorization: Bearer MAILBOX_TOKEN"
import time
import requests
API = "https://tempmailo.co/api/v2"
KEY = {"X-Api-Key": "YOUR_API_KEY"}
box = requests.post(API + "/create/", headers=KEY,
data={"lifetime": 3600}).json()
print("Address:", box["mailbox"]["email"])
auth = dict(KEY, Authorization="Bearer " + box["token"])
for _ in range(60):
mail = requests.get(API + "/messages/", headers=auth).json()
if mail["messages"]:
print(mail["messages"][0]["subject"])
break
time.sleep(5)
// Node.js 18 or newer, as an ES module
const API = 'https://tempmailo.co/api/v2';
const KEY = { 'X-Api-Key': 'YOUR_API_KEY' };
const res = await fetch(API + '/create/', {
method: 'POST',
headers: KEY,
body: new URLSearchParams({ lifetime: '3600' })
});
const box = await res.json();
console.log('Address:', box.mailbox.email);
const auth = { ...KEY, Authorization: 'Bearer ' + box.token };
for (let i = 0; i < 60; i++) {
const r = await fetch(API + '/messages/', { headers: auth });
const mail = await r.json();
if (mail.messages.length) {
console.log(mail.messages[0].subject);
break;
}
await new Promise((done) => setTimeout(done, 5000));
}
The API at a glance
- Price
- Free
- Access
- API key from a free account
- Format
- JSON over HTTPS
- New addresses
- 100 per day
- Address lifetime
- 10 or 60 minutes
- Receive only, up to 15 MB
Terms checked on . Every limit is in the table Free limits.
What it is for
Sign-up tests
Create an address, register a test user in your app, read the confirmation code and finish the flow. Each run gets a clean inbox.
Checks of your own email
Confirm that a welcome or reset email arrives. Read its HTML and plain text, the raw source and the attachments.
An inbox inside your product
Give users a throwaway address in an app or a bot. The TempMailo app for Android is built this way.
When the API is the wrong tool
- You need to send email. TempMailo addresses only receive. Use a transactional email service for sending.
- You need a mailbox for longer than 60 minutes. The address and its mail are deleted when the timer ends. Use a regular mailbox for anything you keep.
- The mail is confidential. Messages are stored as received until the address expires. Do not route private data through a temporary inbox.
Quick start
Three steps to the first email.
-
Get an API key. Create a free account, confirm its email and create a key on the API page of your account.
Create a free account -
Create an address. Send your key in the
X-Api-Keyheader. The reply holds the address and a token for its mailbox.Requestcurl -X POST \ https://tempmailo.co/api/v2/create/ \ -H "X-Api-Key: YOUR_API_KEY" \ -d lifetime=3600
Response{ "ok": true, "time": 1795801080, "token": "3f1c9a7e5b2d4c6e8a0b1d3f5a7c9e1b", "mailbox": { "email": "ed9qfemu@example.org", "login": "ed9qfemu", "domain": "example.org", "created": 1795801080, "expired": 1795804680, "lifetime": 3600 }, "quota": { "create_day": { "used": 1, "limit": 100, "reset": 1795824000 }, "create_hour": { "used": 1, "limit": 30, "reset": 1795802400 } } } -
Read the mail. Ask for messages with the mailbox token. Poll every 5 seconds or slower, and pass
afterwith the last message id to get only new mail.Requestcurl https://tempmailo.co/api/v2/messages/ \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Authorization: Bearer MAILBOX_TOKEN"
Response{ "ok": true, "time": 1795801102, "mailbox": { "email": "ed9qfemu@example.org", "login": "ed9qfemu", "domain": "example.org", "created": 1795801080, "expired": 1795804680, "lifetime": 3600 }, "messages": [ { "id": 3, "from": "noreply@app.example", "from_name": "Example App", "subject": "Your code is 418 507", "preview": "Enter this code to sign in.", "date": 1795801102, "unread": true, "attachments": 0 } ] }The
messagemethod returns one email in full: text, HTML, recipients and attachments.
Free limits
What a free key can do.
| Limit | Value | At the limit |
|---|---|---|
| New addresses | 100 per day and 30 per hour, per account | Reply 429 rate_limited. The hour count starts again on the hour, the day count at 00:00 UTC. A new key does not reset them. |
| Requests | 60 per minute, per account | Reply 429 rate_limited. The Retry-After header gives the seconds to wait. |
| API keys | One per account | A new key switches the old one off. |
| Address lifetime | 10 or 60 minutes, your choice | After that the mailbox methods reply 410 expired. |
| Messages per request | Up to 100, newest first | Pass after to get only newer mail. |
| Email size | Up to 15 MB with attachments | Larger emails do not arrive. |
| Sending mail | Not available | The address only receives. |
| Price | Free | Higher limits will be a paid option. See Need higher limits? |
Limits checked on . When a limit changes, this table changes first.
Every reply to a request with a key carries the headers X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset for the count of requests per minute. The usage method shows all your counters.
Fair use
- One key per account. Keep it private and out of public code.
- No spam, fraud or bulk sign-ups on other sites. Such keys are blocked.
- A key that keeps going over the limits can be paused.
- One account per person or team. Accounts opened to get around the limits are closed.
The full rules are in the Terms of use.
Methods
Version 2.
The base address is https://tempmailo.co/api/v2/<method>/. Send parameters in the query string, as a form or as JSON. Every reply except an attachment file is JSON with ok and the server time. The API sends no CORS headers, so call it from a server, a test or an app, not from a web page.
API key
Identifies your account. Send it in the X-Api-Key header with every request. You can replace it in your account at any time, and the old key stops working at once.
Mailbox token
Comes back from create and opens one mailbox. Send it in the header Authorization: Bearer next to a key of the same account. It opens the mailbox until the address expires or is deleted.
| Method | HTTP | Needs | What it does |
|---|---|---|---|
domains | GET | API key | Lists the domains you can use, the allowed lifetimes and the rules for your own login. |
create | POST | API key | Creates an address. Returns the mailbox token and the mailbox. |
status | GET | Key and token | Shows the address, whether it is active, and the total and unread counts. Works after the address expires. |
messages | GET | Key and token | Lists messages, newest first, up to 100. |
message | GET | Key and token | Returns one message in full by id and marks it as read. |
source | GET | Key and token | Returns the raw source of a message by id. |
attachment | GET | Key and token | Returns the attachment file by message id and index. |
delete | POST | Key and token | Deletes the address, its mail and the token. |
usage | GET | API key | Shows your plan, your limits and how much of each is used. |
| Parameter | Value | Default |
|---|---|---|
lifetime | 600 or 3600 seconds | 3600 |
domain | One of the names returned by domains | Random |
login | Your own name: 5 to 32 characters from a-z 0-9 . _ -, with a letter or digit at both ends | Random, 8 characters |
client | Name and version of your app, for example signup-tests 1.0 | Empty |
You only get mail that arrived after you created the address. If someone used the same name before, their old messages stay hidden from you.
Errors
A failed request returns an HTTP status and a short code in error.
HTTP/1.1 429 Too Many Requests
Retry-After: 37
{
"ok": false,
"time": 1795801103,
"error": "rate_limited",
"limit": {
"scope": "requests_minute",
"limit": 60,
"reset": 1795801140
}
}
| Code | HTTP | What happened and what to do |
|---|---|---|
auth_required | 401 | The request has no API key. Send it in the X-Api-Key header. |
bad_key | 401 | The API key has the wrong form, is unknown or was replaced by a newer one. Use your current key, or create a new one in your account. |
key_blocked | 403 | The account that owns the key is blocked or deleted. Write to us if you think this is a mistake. |
bad_token | 401 | The mailbox token is missing or unknown, the address was deleted, or it was created by another account. Create a new address. |
expired | 410 | The address lifetime is over. Create a new address. |
rate_limited | 429 | Too many new addresses or requests. The limit field names the limit. Wait for the seconds in the Retry-After header, then retry. The numbers are in Free limits. |
login_taken | 409 | That address is in use right now. Pick another login or domain. A reserved name such as postmaster gets the same code with status 400. |
bad_lifetime bad_domain bad_login bad_login_length bad_after bad_message_id bad_attachment_index | 400 | A parameter is wrong. The code names it. |
message_not_found attachment_not_found unknown_method | 404 | This mailbox has no such message or attachment, or the method name is wrong. |
method_not_allowed | 405 | create and delete accept POST only. |
app_only | 403 | The push method works only in the TempMailo apps. |
dberror no_domains | 503 | The service is busy or under maintenance. Retry after a pause. |
system_error | 500 | An error on our side. Retry, and write to us if it repeats. |
Need higher limits?
The free limits fit tests and small projects. Higher limits are planned as a paid option, and there is no price list yet. Tell us what you are building and how many addresses you need per day. We will answer by email.
Questions and answers
Is the TempMailo API free?
Yes. The TempMailo API is free within the limits on this page: 100 new addresses per day, 60 requests per minute, and addresses that live 10 or 60 minutes. You need a free account to get a key. Higher limits are planned as a paid option.
Can I send email through the API?
No. TempMailo addresses only receive mail. The API creates addresses and reads what arrives.
How long are messages kept?
Until the address expires: 10 or 60 minutes after you create it, or sooner if you call delete. After that the address and its mail are removed and cannot be restored.
Can someone else read the mail of my address?
Only a request with your API key and the mailbox token can read it, so keep both private. Mail that came to the same name before you created the address is never shown to you.