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

# Get Email Stats

> Retrieve aggregate email sending statistics

Get aggregate statistics for email sending including totals by type and success rates.

## Examples

<CodeGroup>
  ```typescript JavaScript theme={null}
  import { MailBreeze } from "mailbreeze";

  const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });

  const stats = await mailbreeze.emails.stats();

  console.log(`Total: ${stats.total}`);
  console.log(`Sent: ${stats.sent}`);
  console.log(`Failed: ${stats.failed}`);
  console.log(`Transactional: ${stats.transactional}`);
  console.log(`Marketing: ${stats.marketing}`);
  console.log(`Success rate: ${stats.successRate}%`);
  ```

  ```python Python theme={null}
  from mailbreeze import MailBreeze

  client = MailBreeze(api_key="sk_live_xxx")

  stats = await client.emails.stats()

  print(f"Total: {stats.total}")
  print(f"Sent: {stats.sent}")
  print(f"Failed: {stats.failed}")
  print(f"Transactional: {stats.transactional}")
  print(f"Marketing: {stats.marketing}")
  print(f"Success rate: {stats.success_rate}%")
  ```

  ```go Go theme={null}
  client := mailbreeze.NewClient("sk_live_xxx")

  stats, err := client.Emails.Stats(ctx)
  if err != nil {
      log.Fatal(err)
  }

  fmt.Printf("Total: %d\n", stats.Total)
  fmt.Printf("Sent: %d\n", stats.Sent)
  fmt.Printf("Failed: %d\n", stats.Failed)
  fmt.Printf("Transactional: %d\n", stats.Transactional)
  fmt.Printf("Marketing: %d\n", stats.Marketing)
  fmt.Printf("Success rate: %.1f%%\n", stats.SuccessRate)
  ```

  ```php PHP theme={null}
  $mailbreeze = new MailBreeze('sk_live_xxx');

  $response = $mailbreeze->emails->stats();
  $stats = $response['data']['stats'];

  echo "Total: " . $stats['total'] . "\n";
  echo "Sent: " . $stats['sent'] . "\n";
  echo "Failed: " . $stats['failed'] . "\n";
  echo "Transactional: " . $stats['transactional'] . "\n";
  echo "Marketing: " . $stats['marketing'] . "\n";
  echo "Success rate: " . $stats['successRate'] . "%\n";
  ```

  ```java Java theme={null}
  MailBreeze mailbreeze = MailBreeze.builder()
      .apiKey("sk_live_xxx")
      .build();

  EmailStats stats = mailbreeze.emails().stats();

  System.out.println("Total: " + stats.getTotal());
  System.out.println("Sent: " + stats.getSent());
  System.out.println("Failed: " + stats.getFailed());
  System.out.println("Transactional: " + stats.getTransactional());
  System.out.println("Marketing: " + stats.getMarketing());
  System.out.println("Success rate: " + stats.getSuccessRate() + "%");
  ```

  ```rust Rust theme={null}
  let client = MailBreeze::new("sk_live_xxx")?;

  let stats = client.emails.stats().await?;

  println!("Total: {}", stats.total);
  println!("Sent: {}", stats.sent);
  println!("Failed: {}", stats.failed);
  println!("Transactional: {}", stats.transactional);
  println!("Marketing: {}", stats.marketing);
  println!("Success rate: {}%", stats.success_rate);
  ```

  ```bash cURL theme={null}
  curl "https://api.mailbreeze.com/api/v1/emails/stats" \
    -H "Authorization: Bearer sk_live_xxx"
  ```
</CodeGroup>

## Response

The API returns a nested response with stats inside a `stats` object.

<ResponseField name="stats" type="object">
  The statistics object containing all metrics.

  <Expandable title="Stats object">
    <ResponseField name="total" type="integer">
      Total emails processed.
    </ResponseField>

    <ResponseField name="sent" type="integer">
      Total emails successfully sent.
    </ResponseField>

    <ResponseField name="failed" type="integer">
      Total emails that failed to send.
    </ResponseField>

    <ResponseField name="transactional" type="integer">
      Count of transactional emails.
    </ResponseField>

    <ResponseField name="marketing" type="integer">
      Count of marketing emails.
    </ResponseField>

    <ResponseField name="successRate" type="number">
      Percentage of successfully sent emails (0-100).
    </ResponseField>
  </Expandable>
</ResponseField>

```json Example Response theme={null}
{
  "success": true,
  "data": {
    "stats": {
      "total": 124,
      "sent": 124,
      "failed": 0,
      "transactional": 110,
      "marketing": 14,
      "successRate": 100
    }
  },
  "meta": {
    "timestamp": "2025-12-27T13:35:49.055Z",
    "requestId": "f11f8792-d984-4fb2-a0e4-67f58d1b4000",
    "path": "/api/v1/emails/stats"
  }
}
```

## Understanding the Metrics

| Metric            | Description                                                 |
| ----------------- | ----------------------------------------------------------- |
| **total**         | Total emails processed through the system                   |
| **sent**          | Successfully delivered to recipient servers                 |
| **failed**        | Emails that couldn't be delivered                           |
| **transactional** | Single-recipient triggered emails (receipts, notifications) |
| **marketing**     | Bulk campaign emails                                        |
| **successRate**   | Percentage: `(sent / total) * 100`                          |

<Note>
  SDKs automatically extract the nested `stats` object, so you access fields directly (e.g., `stats.total` instead of `response.stats.total`).
</Note>
