/api/qmail/db/messages/list

GET

Retrieve 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.

Pagination

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.

Party identity: sender vs. recipient

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.

Resolved contact fields

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

success boolean
Always true on success.
count integer
The number of emails returned in this response.
folder integer
The folder ID that was queried (0=Inbox, 1=Sent, 2=Drafts, 3=Trash, 4=Starred, 5=Archive).
limit integer
The limit value used for this request.
offset integer
The offset value used for this request.
total_in_folder integer
Total number of emails in the queried folder.
unread_count integer
Total number of unread emails across all folders.
emails array of objects
An array of email summary objects. Each object contains the properties listed below.

Email Object Properties

email_id string
Hexadecimal identifier for the email.
subject string
The email subject line.
sender_sn integer (int64)
The serial number of the party. For incoming folders this is the sender; for Sent/Drafts it is the primary recipient (see “Party identity” above).
sender_denomination_code integer
Denomination code of the party's address, 04 (0=bit, 1=byte, 2=kilo, 3=mega, 4=giga). Used with sender_sn to build the canonical QMail address.
sender_denomination number
The human-readable denomination value derived from sender_denomination_code (e.g. 1000 for kilo).
sender_address string
The canonical dotted-decimal QMail address of the party (e.g. 6.197@bit), built from sender_sn and sender_denomination_code. Present when both are known.
sender_name string
Display name of the sender, resolved from the saved contacts database by serial number. Contains the contact's first and last name joined with a space; collapses to whichever part exists if only one is stored. Empty string when the sender is not a saved contact. Clients should prefer this over sender_address when non-empty.
sender_is_favorite boolean
Whether the resolved sender contact is marked as a favorite. false when the sender is not a saved contact.
sender_trust_level integer
Trust level of the resolved sender contact (e.g. -1=blocked, 0=unknown, 1=trusted). 0 when the sender is not a saved contact.
sender_class_name string
Optional class/category label stored on the resolved sender contact. Empty string when unset or when the sender is not a saved contact.
sender_description string
Optional free-text description stored on the resolved sender contact. Empty string when unset or when the sender is not a saved contact.
sender_user_notes string
Optional private notes the user stored on the resolved sender contact. Empty string when unset or when the sender is not a saved contact.
recipient_count integer
Number of recipients on this email. 0 for incoming mail with no stored recipients. The remaining recipient_* fields describe the primary (first TO) recipient.
recipient_sn integer (int64)
Serial number of the primary recipient. Present when recipient_count > 0.
recipient_denomination_code integer
Denomination code (04) of the primary recipient's address. May be -1 for older rows where it could not be resolved.
recipient_denomination number
Human-readable denomination value of the primary recipient, derived from recipient_denomination_code.
recipient_address string
Canonical dotted-decimal QMail address of the primary recipient. Present when the recipient's serial number and denomination are both known.
recipient_name string
Display name of the primary recipient, resolved from the saved contacts database. Empty string when the recipient is not a saved contact. For Sent/Drafts, clients should prefer this over recipient_address when non-empty.
recipient_is_favorite boolean
Whether the resolved recipient contact is a favorite. false when the recipient is not a saved contact.
recipient_trust_level integer
Trust level of the resolved recipient contact. 0 when the recipient is not a saved contact.
recipient_class_name string
Optional class/category label on the resolved recipient contact. Empty string when unset or not a saved contact.
recipient_description string
Optional description on the resolved recipient contact. Empty string when unset or not a saved contact.
recipient_user_notes string
Optional private notes on the resolved recipient contact. Empty string when unset or not a saved contact.
received_timestamp integer (int64)
Unix timestamp (in seconds) of when the email was received.
sent_timestamp integer (int64)
Unix timestamp (in seconds) of when the sender sent the email. May be 0 for older mail received before this field was stored; fall back to received_timestamp in that case.
is_read boolean
Whether the email has been marked as read.
is_starred boolean
Whether the email has been starred/flagged by the user.
folder integer
The folder containing this email (0=Inbox, 1=Sent, 2=Drafts, 3=Trash, 4=Starred, 5=Archive).
inbox_fee integer (int64)
The inbox fee currently stored with the sender contact for this email.
attachment_count integer
Number of attachments stored with this email. 0 when the email has none.
body_preview string
A preview snippet of the email body (first 200 characters).

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

http://localhost:8082/api/qmail/db/messages/list?folder=0&limit=50&offset=0

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.