/api/qmail/db/messages/list
GETRetrieve a paginated list of emails from a specified folder with unread counts.
Description
The /api/qmail/db/messages/list endpoint retrieves a paginated list of emails from a specified folder. By default it returns the inbox (folder 0), but you can query sent (1), drafts (2), trash (3), starred (4), or archive (5) as well. The response includes email metadata, pagination information, and a global unread count across all folders.
Use the limit and offset parameters to implement efficient pagination. The response includes total_in_folder to help calculate the total number of pages available. Maximum of 200 results per request.
Each email object carries a set of sender_* fields describing the other party in the conversation. For incoming folders (0 Inbox, 3 Trash, 4 Starred, 5 Archive) these describe the sender. For outgoing folders (1 Sent, 2 Drafts) the primary recipient is mapped into the same sender_* fields, so a client can render the party without branching on folder.
Each email carries a sender block and a recipient block, and each block is independently resolved against the saved contacts database by serial number. When a party matches a saved contact, the block includes resolved details — the sender block emits sender_name, sender_is_favorite, sender_trust_level, sender_class_name, sender_description, sender_user_notes; the recipient block emits the recipient_-prefixed equivalents. When a party is not a saved contact, its name is an empty string and the remaining resolved fields take their defaults (false, 0, or empty string). Clients should treat a non-empty name as the display name and fall back to the corresponding address / serial number otherwise. Pick the sender block for incoming folders and the recipient block for Sent/Drafts (see “Party identity” above).
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
folder |
integer | No | Folder ID to list emails from. 0 = Inbox (default), 1 = Sent, 2 = Drafts, 3 = Trash, 4 = Starred, 5 = Archive. |
limit |
integer | No | Maximum number of emails to return per page. Range: 1-200. Default: 50. |
offset |
integer | No | Number of emails to skip before starting to return results. Default: 0. |
Response
Returns a JSON object containing the email list, pagination metadata, folder totals, and a global unread count.
Response Properties
true on success.Email Object Properties
0–4 (0=bit, 1=byte, 2=kilo, 3=mega, 4=giga). Used with sender_sn to build the canonical QMail address.sender_denomination_code (e.g. 1000 for kilo).6.197@bit), built from sender_sn and sender_denomination_code. Present when both are known.sender_address when non-empty.false when the sender is not a saved contact.-1=blocked, 0=unknown, 1=trusted). 0 when the sender is not a saved contact.0 for incoming mail with no stored recipients. The remaining recipient_* fields describe the primary (first TO) recipient.recipient_count > 0.0–4) of the primary recipient's address. May be -1 for older rows where it could not be resolved.recipient_denomination_code.recipient_address when non-empty.false when the recipient is not a saved contact.0 when the recipient is not a saved contact.0 for older mail received before this field was stored; fall back to received_timestamp in that case.0 when the email has none.Example Response
{
"success": true,
"count": 2,
"folder": 0,
"limit": 50,
"offset": 0,
"total_in_folder": 127,
"unread_count": 14,
"emails": [
{
"email_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"subject": "Q4 Budget Report",
"sender_sn": 1048576,
"sender_denomination_code": 2,
"sender_denomination": 100,
"sender_address": "16.0.0@kilo",
"sender_name": "Alice Johnson",
"sender_is_favorite": true,
"sender_trust_level": 1,
"sender_class_name": "Work",
"sender_description": "Finance team lead",
"sender_user_notes": "Prefers replies before noon.",
"recipient_count": 0,
"recipient_name": "",
"recipient_is_favorite": false,
"recipient_trust_level": 0,
"recipient_class_name": "",
"recipient_description": "",
"recipient_user_notes": "",
"received_timestamp": 1739453400,
"sent_timestamp": 1739453280,
"is_read": false,
"is_starred": true,
"folder": 0,
"inbox_fee": 0,
"attachment_count": 1,
"body_preview": "Hi team, please find attached the Q4 budget report for your review. Let me know if you have any questions or need additional details about the projected figures..."
},
{
"email_id": "b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7",
"subject": "Meeting Tomorrow",
"sender_sn": 197,
"sender_denomination_code": 0,
"sender_denomination": 1,
"sender_address": "197@bit",
"sender_name": "",
"sender_is_favorite": false,
"sender_trust_level": 0,
"sender_class_name": "",
"sender_description": "",
"sender_user_notes": "",
"recipient_count": 0,
"recipient_name": "",
"recipient_is_favorite": false,
"recipient_trust_level": 0,
"recipient_class_name": "",
"recipient_description": "",
"recipient_user_notes": "",
"received_timestamp": 1739438100,
"sent_timestamp": 1739438040,
"is_read": true,
"is_starred": false,
"folder": 0,
"inbox_fee": 100,
"attachment_count": 0,
"body_preview": "Just a reminder that we have a team sync scheduled for tomorrow at 10 AM. Please prepare your status updates and any blockers you would like to discuss..."
}
]
}
Try It Out
Examples
cURL
# List inbox emails (default folder)
curl -X GET "http://localhost:8082/api/qmail/db/messages/list" \
-H "Accept: application/json"
# List inbox with pagination
curl -X GET "http://localhost:8082/api/qmail/db/messages/list?folder=0&limit=20&offset=0" \
-H "Accept: application/json"
# List sent folder
curl -X GET "http://localhost:8082/api/qmail/db/messages/list?folder=1&limit=50&offset=0" \
-H "Accept: application/json"
# List trash folder, page 2
curl -X GET "http://localhost:8082/api/qmail/db/messages/list?folder=3&limit=50&offset=50" \
-H "Accept: application/json"
JavaScript (async/await)
const API_BASE = 'http://localhost:8082/api';
const FOLDERS = { 0: 'Inbox', 1: 'Sent', 2: 'Drafts', 3: 'Trash', 4: 'Starred', 5: 'Archive' };
async function listInbox(folder = 0, limit = 50, offset = 0) {
try {
const params = new URLSearchParams({
folder: folder,
limit: limit,
offset: offset
});
const response = await fetch(`${API_BASE}/qmail/db/messages/list?${params}`);
const data = await response.json();
if (data.success) {
console.log(`Folder: ${FOLDERS[data.folder]}`);
console.log(`Showing ${data.count} of ${data.total_in_folder} emails`);
console.log(`Unread across all folders: ${data.unread_count}`);
data.emails.forEach(email => {
const status = email.is_read ? 'Read' : 'UNREAD';
const star = email.is_starred ? ' *' : '';
// Prefer the resolved contact name; fall back to the address, then the SN.
const who = email.sender_name || email.sender_address || `SN ${email.sender_sn}`;
const fav = email.sender_is_favorite ? ' [FAV]' : '';
console.log(`[${status}${star}] ${email.subject} — from ${who}${fav}`);
console.log(` Preview: ${email.body_preview}`);
});
} else {
console.error('Request failed:', data.message);
}
return data;
} catch (error) {
console.error('Error fetching inbox:', error);
}
}
// List inbox
listInbox();
// List sent folder, page 2
// listInbox(1, 50, 50);
Python
import requests
API_BASE = 'http://localhost:8082/api'
FOLDERS = {0: 'Inbox', 1: 'Sent', 2: 'Drafts', 3: 'Trash', 4: 'Starred', 5: 'Archive'}
def list_inbox(folder=0, limit=50, offset=0):
"""Retrieve a paginated list of emails from a folder."""
params = {
'folder': folder,
'limit': limit,
'offset': offset
}
response = requests.get(f'{API_BASE}/qmail/db/messages/list', params=params)
data = response.json()
if data.get('success'):
print(f"Folder: {FOLDERS.get(data['folder'], 'Unknown')}")
print(f"Showing {data['count']} of {data['total_in_folder']} emails")
print(f"Unread across all folders: {data['unread_count']}")
for email in data['emails']:
status = 'Read' if email['is_read'] else 'UNREAD'
star = ' *' if email['is_starred'] else ''
# Prefer the resolved contact name; fall back to the address, then the SN.
who = email.get('sender_name') or email.get('sender_address') or f"SN {email['sender_sn']}"
fav = ' [FAV]' if email.get('sender_is_favorite') else ''
print(f"[{status}{star}] {email['subject']} — from {who}{fav}")
print(f" Preview: {email['body_preview']}")
else:
print(f"Request failed: {data.get('message')}")
return data
# List inbox
list_inbox()
# List sent folder, page 2
# list_inbox(folder=1, limit=50, offset=50)
Related Endpoints
/api/qmail/net/messages/download
Download new emails from the RAIDA network before listing them in the inbox.
/api/qmail/db/messages/get
Get full details for a specific email by its email_id from the inbox listing.