# GET /mail/stats

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Get mail statistics and the Postfix queue size

- Who may call it: administrator
- Token scope, any of: mail, read, all
- Answers: 200 OK

The stats object contains Rspamd counters for scanned messages, actions taken, and Bayes learning, along with today's mail totals from pflogsumm and the Postfix queue size.

Each fresh reading requires pflogsumm to scan the entire mail log. Use max_age to reuse a recent reading. The API returns 400 if max_age falls outside the allowed whole-number range.

## As a command

- [urbestack-mail-stats](https://urbestack.com/docs/commands/urbestack-mail-stats.md): Reports Rspamd's counters for messages scanned, actions taken and Bayes learning, along with today's mail log totals from pflogsumm and the Postfix queue size.

## Parameters

- `max_age` (query, integer, 1 to 86400): Maximum age in seconds of a saved reading eligible for reuse, from 0 to 86400. A reused reading is marked cached.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X GET "$API/mail/stats?max_age=1" \
  -H "Authorization: Bearer $TOKEN"
```

Response, 200 OK:

```
{
  "stats": {
    "cached": true,
    "queue": 1,
    "read_at": "text",
    "rspamd": {},
    "today": {}
  }
}
```

## Errors

- 400: <what> must be a whole number from 0 to <max>
- 401: Authentication required
