> ## Documentation Index
> Fetch the complete documentation index at: https://ahasend.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# ahasend stats: Delivery and Bounce Reports

> Pull AhaSend deliverability, bounce and delivery-time reports from the CLI, grouped by hour, day, week or month and exported to CSV or JSON.

AhaSend CLI `stats` commands report delivery, bounce and delivery-time statistics; this page covers filters and output.

Before running the examples, [log in](https://ahasend.com/docs/cli/authentication.md) with an API key that has the `statistics-transactional:read:all` [scope](https://ahasend.com/docs/api-reference/scopes.md#statistics-and-reports), and replace `example.com` in `--sender-domain` with one of your sending domains.

## Overview

```text theme={null}
ahasend stats [subcommand] [flags]
```

Available subcommands:

* `deliverability` - Message counts and delivery and open rates per period
* `bounces` - Bounces per period by classification
* `delivery-time` - Average delivery time per period and per recipient domain

The three subcommands take the same flags:

* `--from-time`: Start time. The default is `7d`, 7 days ago. An empty value leaves the start to the API.
* `--to-time`: End time. Without it, the API uses now.
* `--group-by`: `hour`, `day` (the default), `week` or `month`.
* `--sender-domain`: Filter by sender domain.
* `--recipient-domain`: Filter by recipient domain.
* `--tag`: Filter by message tag. A tag cannot hold a comma.

`--from-time` and `--to-time` take an RFC 3339 time, such as `2026-09-01T00:00:00Z`, or a relative time that counts back from now, such as `24h`, `7d` or `3mo`. `--from-time` must be before `--to-time`. With the default `--from-time`, a `--to-time` more than 7 days ago fails, so give an earlier `--from-time` too. An invalid time fails before any request is sent, with exit code 4.

`--sender-domain`, `--recipient-domain` and `--tag` can be used multiple times, or take values separated by commas. The CLI sends only the filters you give.

`--output json` prints the API's response unchanged. Table and plain output show each period's time in your local time zone. `--output csv` writes one row per period, or per classification or recipient domain where the report has them.

## Deliverability Statistics

Each period shows how many messages were received, delivered, deferred, bounced, failed, suppressed, opened and clicked. The CLI works out the delivery rate (delivered out of received) and the open rate (opened out of delivered) from these counts.

```bash theme={null}
# The last 7 days, by day
ahasend stats deliverability

# A fixed date range
ahasend stats deliverability \
  --from-time 2026-09-01T00:00:00Z \
  --to-time 2026-10-01T00:00:00Z

# The last 24 hours, by hour, for one sender domain
ahasend stats deliverability \
  --from-time 24h \
  --group-by hour \
  --sender-domain example.com

# Two recipient domains
ahasend stats deliverability \
  --recipient-domain gmail.com \
  --recipient-domain googlemail.com
```

### Export to CSV

```bash theme={null}
ahasend stats deliverability --from-time 30d --output csv > deliverability-report.csv
```

## Bounce Analysis

Each period shows its bounces by classification, with each classification's count and its share of the period's bounces. `ahasend stats bounces --help` describes the common classifications:

| Classification | Meaning |
| - | - |
| `AuthenticationFailed` | Message rejected due to DMARC or authentication issues |
| `BadConnection` | The connection to the recipient server or its TLS failed |
| `BadDomain` | The recipient domain doesn't exist |
| `DNSFailure` | The domain's MX record is invalid |
| `InactiveMailbox` | The mailbox provider has deactivated the email address |
| `InvalidRecipient` | The email address doesn't exist |
| `PolicyRelated` | Blocked due to recipient server policies (spam or blocklists) |
| `ProtocolErrors` | SMTP communication issues with the recipient mail server |
| `QuotaIssues` | The recipient's mailbox is full |
| `RoutingErrors` | The recipient mail server couldn't route the email |
| `TransientFailure` | The recipient server temporarily rejected the message |
| `Uncategorized` | Other bounce types not specifically categorized |

The API may return other classifications too; the output shows each as the API names it. See [bounce statistics](https://ahasend.com/docs/api-reference/reports/get-bounce-report.md).

```bash theme={null}
# The last 7 days, by day
ahasend stats bounces

# The last 30 days, by week
ahasend stats bounces --from-time 30d --group-by week

# One sender domain, exported to CSV
ahasend stats bounces --sender-domain example.com --from-time 30d --output csv
```

## Delivery Time Performance

Each period shows the average delivery time, and the time for each recipient domain with the number of delivered messages it covers. Table and plain output give each time in seconds, minutes or hours, whichever reads best. CSV output gives times in seconds, as the API sends them.

```bash theme={null}
# The last 7 days, by day
ahasend stats delivery-time

# The last 24 hours, by hour, for two recipient domains
ahasend stats delivery-time \
  --from-time 24h \
  --group-by hour \
  --recipient-domain gmail.com \
  --recipient-domain outlook.com
```

## Filter by Tag

```bash theme={null}
# Messages tagged campaign-summer
ahasend stats deliverability --tag campaign-summer --from-time 30d

# Filter by two tags
ahasend stats deliverability --tag welcome --tag onboarding
```

## Command Flags

These flags come from the CLI's `--help`. All commands also accept the [global flags](https://ahasend.com/docs/cli/configuration.md#global-flags).

### `stats bounces`

| Flag | Description and default |
| - | - |
| `--from-time string` | Start time (RFC3339, or relative like '7d' or '24h' for 7 days or 24 hours ago; empty leaves it to the API) (default "7d") |
| `--group-by string` | Group results by: hour, day, week or month (default "day") |
| `--recipient-domain strings` | Filter by recipient domain (can be used multiple times) |
| `--sender-domain strings` | Filter by sender domain (can be used multiple times) |
| `--tag strings` | Filter by message tag, none with a comma (can be used multiple times) |
| `--to-time string` | End time (RFC3339, or relative like '1d' for 1 day ago; empty leaves it to the API, which uses now) |

### `stats deliverability`

| Flag | Description and default |
| - | - |
| `--from-time string` | Start time (RFC3339, or relative like '7d' or '24h' for 7 days or 24 hours ago; empty leaves it to the API) (default "7d") |
| `--group-by string` | Group results by: hour, day, week or month (default "day") |
| `--recipient-domain strings` | Filter by recipient domain (can be used multiple times) |
| `--sender-domain strings` | Filter by sender domain (can be used multiple times) |
| `--tag strings` | Filter by message tag, none with a comma (can be used multiple times) |
| `--to-time string` | End time (RFC3339, or relative like '1d' for 1 day ago; empty leaves it to the API, which uses now) |

### `stats delivery-time`

| Flag | Description and default |
| - | - |
| `--from-time string` | Start time (RFC3339, or relative like '7d' or '24h' for 7 days or 24 hours ago; empty leaves it to the API) (default "7d") |
| `--group-by string` | Group results by: hour, day, week or month (default "day") |
| `--recipient-domain strings` | Filter by recipient domain (can be used multiple times) |
| `--sender-domain strings` | Filter by sender domain (can be used multiple times) |
| `--tag strings` | Filter by message tag, none with a comma (can be used multiple times) |
| `--to-time string` | End time (RFC3339, or relative like '1d' for 1 day ago; empty leaves it to the API, which uses now) |

## Next Steps

* [Configure webhooks for real-time tracking](https://ahasend.com/docs/cli/commands/webhooks.md)
* [Manage suppressions](https://ahasend.com/docs/cli/commands/suppressions.md)
* [Send messages](https://ahasend.com/docs/cli/commands/messages.md)

## Related Guides

* [Install the CLI](https://ahasend.com/docs/cli/installation.md), [CLI authentication](https://ahasend.com/docs/cli/authentication.md), [Delivery statistics API](https://ahasend.com/docs/api-reference/reports/get-deliverability-report.md).
* [API rate limits](https://ahasend.com/docs/api-reference/rate-limits.md), [CLI configuration and output](https://ahasend.com/docs/cli/configuration.md), [API authentication](https://ahasend.com/docs/api-reference/authentication.md).
* [Permission scopes](https://ahasend.com/docs/api-reference/scopes.md), [Domain setup](https://ahasend.com/docs/domains.md), [Sandbox behavior](https://ahasend.com/docs/send-api/sandbox.md).
* [Tracking setup](https://ahasend.com/docs/tracking/open-tracking.md), [Suppression durations](https://ahasend.com/docs/bounces.md#suppression-duration).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.