Temp Mail API
Create a temporary mailbox, wait for the verification email and read the code with four HTTP calls. Private inboxes on your account, keys you can restrict, an OpenAPI document and an MCP server for AI agents.
What the API is for
Sign-up tests, password-reset flows, OTP checks in CI and AI agents that need to receive a code: anything that needs a real address for a few minutes and then a way to read what arrived. The MoeMail REST API does exactly that, under the same account and mailboxes as the web inbox at moemail.app.
Mailboxes are private to your account. Nobody can read them by guessing the address, and a restricted key can be limited to the mailboxes it created itself.
Quick start
Send your key in the X-API-Key header. These four calls are a whole verification round trip; the comments show the real response shapes.
# 1. a mailbox that lives for an hour (expiryTime is in milliseconds)
curl -s https://moemail.app/api/emails/generate \
-H "X-API-Key: mk_••••••••••••" -H "Content-Type: application/json" \
-d '{"name":"signup-test","expiryTime":3600000,"domain":"moemail.app"}'
# {"id":"k3f…","email":"signup-test@moemail.app"}
# 2. wait for the verification mail (the server holds the request up to 50 s)
curl -s "https://moemail.app/api/emails/k3f…/wait?timeout=50" -H "X-API-Key: mk_••••••••••••"
# {"messages":[{"id":"m81…","from_address":"no-reply@example.com",
# "subject":"Your code is 482913",…}],"cursor":"…"}
# 3. read it
curl -s https://moemail.app/api/emails/k3f…/m81… -H "X-API-Key: mk_••••••••••••"
# {"message":{"id":"m81…","content":"Enter 482913 to finish signing up.",…}}
# 4. clean up
curl -s -X DELETE https://moemail.app/api/emails/k3f… -H "X-API-Key: mk_••••••••••••"
# {"success":true}wait returns as soon as a new message arrives, or after the timeout with an empty list: pass the returned cursor as since and call it again. Every call, waits included, counts as one API call.
The endpoints you need
Everything else is in the OpenAPI 3.1 document the API serves itself, and in the docs.
- POST /api/emails/generate
- Create a mailbox:
name(random when empty),expiryTimein ms anddomain. Returnsidandemail. - GET /api/emails/{id}/wait
- Long-poll until a message newer than
sincearrives (up to 50 s per call). - GET /api/emails/{id}
- Messages of one mailbox, newest first, 20 per page with
cursor. - GET /api/emails/{id}/{messageId}
- One message: subject, text
contentandhtml. - GET /api/emails
- Your unexpired mailboxes, newest first.
- POST /api/emails/{id}/send
- Send from one of your mailboxes, if your role has a send quota.
- DELETE /api/emails/{id}
- Delete a mailbox and everything in it.
Keys you can restrict
Create keys in your profile under API Key Management. A key can be cut down to what a job needs, and the limits are fixed for the life of the key:
- Actions: any subset of read, create, send and delete. A key without send cannot send mail, whatever your role allows.
- Only the mailboxes it creates: the key never sees the rest of your account.
- Requests per day: a ceiling for one key, so a runaway loop stops at a number you chose.
- Lifetime: from one hour to one year.
A restricted key gets 403 outside its actions and 429 with Retry-After at its daily limit.
No key to copy: moemail login
The CLI can sign in through the browser instead. It prints a link and a short code; you approve it on any device and it saves a new key with the restrictions you asked for.
npm i -g @moemail/cli
moemail login --scopes read,create --own-mailboxes --expires 7d --daily-limit 500
# opens a link with a short code; approve it in the browser and the CLI saves the new keyFor AI agents: the MCP server
The same API is available as MCP tools at https://moemail.app/mcp. Claude, ChatGPT and Claude Code connect with OAuth: you approve the app once, choose what it may do, and revoke it from your profile. Each connected app gets its own restricted key.
Quota and price
Every request made with a key counts toward your account's monthly quota: 100,000 calls a month for Duke. The default plan includes no API calls; buy an API-call pack or a Duke upgrade in the shop with MoeCoin. When the quota is used up, the API answers 429 with monthlyLimit and monthlyUsed.
Creating mailboxes and reading mail in the web inbox stays free. Sending has its own daily allowance by role, separate from API calls.