面向开发者的 Jo Mail API

通过代码创建临时收件箱并读取收到的邮件,例如用于测试注册流程。

身份验证

在控制面板中创建密钥,并在每个请求中通过以下请求头之一发送。

X-Api-Key: jm_xxxxxxxxxxxxxxxx
# or
Authorization: Bearer jm_xxxxxxxxxxxxxxxx

接口

POST   /api/inbox                         create an inbox   {"guest":true,"name":"optional","domain":"jo-mail.org","ttl_minutes":60}
                                          -> {"inbox":{"id":1,"address":"...","expires_at":...},"key":"1.abcdef..."}
GET    /api/inbox                         list messages     (header X-Inbox: <key>)
GET    /api/inbox/wait?after=<lastId>     long-poll: returns {"changed":true} as soon as a new message arrives
GET    /api/inbox/messages/{id}           read one message  (subject, from, text, html, attachments)
GET    /api/inbox/attachments/{id}        download an attachment
DELETE /api/inbox/messages/{id}           delete a message
POST   /api/inbox/renew                   extend the lifetime
DELETE /api/inbox                         delete the inbox

示例

# 1) create an inbox
curl -s -X POST https://jo-mail.org/api/inbox \
  -H "X-Api-Key: $JM_KEY" -H "Content-Type: application/json" \
  -d '{"guest":true}'

# 2) wait for mail, then read it
curl -s "https://jo-mail.org/api/inbox/wait?after=0" -H "X-Inbox: $INBOX_KEY"
curl -s https://jo-mail.org/api/inbox -H "X-Inbox: $INBOX_KEY"
// JavaScript
const r = await fetch('https://jo-mail.org/api/inbox', {
  method: 'POST',
  headers: { 'X-Api-Key': KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ guest: true }),
});
const { inbox, key } = await r.json();
console.log(inbox.address);   // use it to sign up, then poll /api/inbox/wait

限制:每个密钥每小时 600 个收件箱。收件箱密钥是保密的:持有密钥的人可以读取该收件箱。