Mailbox API
Let your own server read, organise and send email for a @shoora.me mailbox over plain HTTPS and JSON.
1. Get a key
- A Shoora super admin opens Admin → Mail (
shoora.me/stats/mail), then Edit · password · delete on the mailbox. - Under 🔌 API, press Create API key. The key starts with
shm_and is shown once: copy it to your server's secret store. - Every new key may read write send. Untick any of them and press Save rights to limit it.
- Replace key makes a new one and stops the old one at once. Remove key turns the API off for that mailbox.
One key per mailbox. Keep it like a password: anyone with it can act as that mailbox. Shoora keeps only a hash of it, so a lost key cannot be shown again; replace it instead.
2. Call it
Base URL: https://shoora.me/api/mail/v1. Send the key in every request:
Authorization: Bearer shm_your_key
Bodies are JSON (Content-Type: application/json). Answers are JSON.
curl -s https://shoora.me/api/mail/v1/me -H "Authorization: Bearer $SHOORA_MAIL_KEY"
# {"address":"[email protected]","read":true,"write":true,"send":true}
3. Endpoints
| Call | Right | What it does |
|---|---|---|
GET /me | any | The mailbox this key belongs to and its rights. |
GET /folders | read | Folders with total and unread counts. |
GET /messages | read | Newest first. Query: folder (inbox, sent, drafts, junk, trash, archive, a folder name or id; default inbox), q (text search), unread=1, limit (1–100, default 25), offset. |
GET /messages/{id} | read | One message with text, html and its attachment list. Opening it marks it read. |
GET /messages/{id}/attachments/{attId} | read | Downloads one attachment (raw file). |
PATCH /messages/{id} | write | Any of {"seen": true|false, "flagged": true|false, "folder": "archive"}. |
DELETE /messages/{id} | write | Moves it to Trash. Deleting a message that is already in Trash removes it for good. |
POST /drafts | write | Saves a draft: {"to":[…],"cc":[…],"subject":"…","text":"…"}. Returns its id. |
POST /send | send | Sends from the mailbox. A copy goes to Sent. |
Send
curl -s https://shoora.me/api/mail/v1/send \
-H "Authorization: Bearer $SHOORA_MAIL_KEY" -H "Content-Type: application/json" \
-d '{
"to": ["[email protected]"],
"cc": [],
"subject": "Your visit summary",
"text": "Hello, …",
"html": "<p>Hello, …</p>",
"from_name": "Shoora",
"reply_to": "[email protected]",
"in_reply_to": ["<[email protected]>"],
"attachments": [{ "name": "summary.pdf", "type": "application/pdf", "content_base64": "JVBERi0x…" }]
}'
# {"ok":true}
Required: to, subject, and text or html. Up to 50 recipients per message and 10 attachments; the whole request may be up to 30 MB. To reply in the same thread, pass the original message_id in in_reply_to and references.
Read new mail (Python)
import os, requests
API = "https://shoora.me/api/mail/v1"
H = {"Authorization": "Bearer " + os.environ["SHOORA_MAIL_KEY"]}
new = requests.get(f"{API}/messages", headers=H, params={"folder": "inbox", "unread": 1}).json()
for m in new["messages"]:
full = requests.get(f"{API}/messages/{m['id']}", headers=H).json() # marks it read
print(full["from"], full["subject"], full["text"][:200])
requests.patch(f"{API}/messages/{m['id']}", headers=H, json={"folder": "archive"})
Node.js
const API = 'https://shoora.me/api/mail/v1';
const H = { Authorization: `Bearer ${process.env.SHOORA_MAIL_KEY}`, 'Content-Type': 'application/json' };
await fetch(`${API}/send`, { method: 'POST', headers: H,
body: JSON.stringify({ to: ['[email protected]'], subject: 'Hello', text: 'Sent from our server.' }) });
4. Errors and limits
| Status | Meaning |
|---|---|
400 | Something in the request is missing or wrong; message says what. |
401 | No key, or the key was replaced or removed. |
403 | The key does not have this right (read, write or send). |
404 | No such message, folder or endpoint. |
429 | Too many calls: at most 600 per 15 minutes from one address. Wait for Retry-After seconds. |
502 | The mail server had a problem; try again shortly. |
Errors look like {"error": "forbidden", "message": "This key may not send."}.
Sending shares the Shoora daily limit of 300 recipients across all mailboxes. Every send is logged on the admin Mail page with the key's last four characters.
5. Good practice
- Give each outside server only the rights it needs: a server that only sends should have read and write unticked.
- Keep the key in an environment variable or secret store, never in code or a browser.
- Check for new mail every minute or so (
unread=1), not in a tight loop. - Mail can hold personal or health information. Only connect servers that are allowed to process it.