/api/qmail/folders

GET

List all available mail folders.

GET /api/qmail/folders

Description

The GET /api/qmail/folders endpoint returns a list of all available mail folders. Each folder has a numeric ID and a name. The folder IDs are used by other endpoints such as /api/qmail/move and /api/qmail/inbox to specify which folder to operate on.

Fixed Folder Set

The folder list is fixed at 6 folders: inbox (0), sent (1), drafts (2), trash (3), starred (4), and archive (5). Custom folders are not supported in Phase I.

Parameters

This endpoint requires no parameters.

Response

Returns a JSON object with an array of folder objects.

Response Properties

success boolean
Indicates whether the operation completed successfully.
folders array
Array of folder objects.
id integer
Numeric folder ID (0-5).
name string
Folder name.

Example Success Response

{
  "success": true,
  "folders": [
    {"id": 0, "name": "inbox"},
    {"id": 1, "name": "sent"},
    {"id": 2, "name": "drafts"},
    {"id": 3, "name": "trash"},
    {"id": 4, "name": "starred"},
    {"id": 5, "name": "archive"}
  ]
}

Try It Out

Examples

cURL

curl "http://localhost:8080/api/qmail/folders"

JavaScript (async/await)

const API_HOST = 'http://localhost:8080';

async function listFolders() {
    try {
        const response = await fetch(`${API_HOST}/api/qmail/folders`);
        const result = await response.json();

        if (result.success) {
            result.folders.forEach(folder => {
                console.log(`${folder.id}: ${folder.name}`);
            });
        }
        return result;
    } catch (error) {
        console.error('Error listing folders:', error);
    }
}

listFolders();

Python

import requests

API_HOST = 'http://localhost:8080'

def list_folders():
    response = requests.get(f'{API_HOST}/api/qmail/folders')
    result = response.json()

    if result.get('success'):
        for folder in result['folders']:
            print(f"{folder['id']}: {folder['name']}")

    return result

list_folders()

Related Endpoints

/api/qmail/counts

Get per-folder email counts including total and unread.

/api/qmail/move

Move an email to a different folder by folder ID.

/api/qmail/inbox

List emails filtered by folder.