# Retrieve a sub-account's stats (/docs/api-reference/sub-accounts/get-subaccount-stats)

The sub-account's sending per UTC day: recipients, sent, delivered, bounced, complained, failed and suppressed, counted from its emails as they are now (a later bounce moves its day's numbers). Emails are kept 45 days, so earlier days are left out.

`GET https://api.coss.com/v1/subaccounts/{subaccount}/stats`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Path parameters

- `subaccount` (string, required): The sub-account's `id` (`sub_…`) or your `uid` for it.

## Query parameters

- `from` (string, date): First day (UTC, `YYYY-MM-DD`); default 30 days before `to`.
- `to` (string, date): Last day (UTC, `YYYY-MM-DD`), included; default today.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.email.subaccounts.stats("user_8812", {
  from: "2026-10-01",
  to: "2026-10-15",
});
```

HTTP:

```sh
curl -X GET "https://api.coss.com/v1/subaccounts/user_8812/stats?from=2026-10-01&to=2026-10-15" \
  -H "Authorization: Bearer $COSS_API_KEY"
```

Python:

```python
from coss import Coss
import datetime

client = Coss()  # api_key= or COSS_API_KEY

client.email.subaccounts.stats(
    subaccount="user_8812",
    from_=datetime.date.fromisoformat("2026-10-01"),
    to=datetime.date.fromisoformat("2026-10-15"),
)
```

Go:

```go
import (
	"context"

	coss "github.com/cosscom/coss-go"
	cossclient "github.com/cosscom/coss-go/client"
	email "github.com/cosscom/coss-go/email"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &email.StatsSubaccountsRequest{
    Subaccount: "user_8812",
    From: coss.Time(
        coss.MustParseDate(
            "2026-10-01",
        ),
    ),
    To: coss.Time(
        coss.MustParseDate(
            "2026-10-15",
        ),
    ),
}
client.Email.Subaccounts.Stats(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.email.subaccounts.stats(
  subaccount: "user_8812",
  from: "2026-10-01",
  to: "2026-10-15"
)
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Email\Subaccounts\Requests\StatsSubaccountsRequest;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->email->subaccounts->stats(
    'user_8812',
    new StatsSubaccountsRequest([
        'from' => new DateTime('2026-10-01'),
        'to' => new DateTime('2026-10-15'),
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.email.subaccounts.requests.StatsSubaccountsRequest;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.email().subaccounts().stats(
    "user_8812",
    StatsSubaccountsRequest
        .builder()
        .from("2026-10-01")
        .to("2026-10-15")
        .build()
);
```

.NET:

```csharp
using Coss;
using Coss.Email;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Email.Subaccounts.StatsAsync(
    new StatsSubaccountsRequest
    {
        Subaccount = "user_8812",
        From = new DateOnly(2026, 10, 1),
        To = new DateOnly(2026, 10, 15),
    }
);
```

## Response 200

The sub-account's stats.

- `object` ("subaccount_stats", required)
- `subaccount_id` (string, required)
- `from` (string, required, date)
- `to` (string, required, date)
- `data` (object[], required): One entry per day with sends, oldest first; recipients count by their current status.
  - `date` (string, required, date)
  - `recipients` (integer, required): Recipients of the emails sent that day.
  - `sent` (integer, required): Handed to the provider (delivered or not).
  - `delivered` (integer, required)
  - `bounced` (integer, required)
  - `complained` (integer, required)
  - `failed` (integer, required)
  - `suppressed` (integer, required): Skipped: on a suppression list.

Example:

```json
{
  "object": "subaccount_stats",
  "subaccount_id": "sub_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "from": "2026-10-15",
  "to": "2026-10-15",
  "data": [
    {
      "date": "2026-10-15",
      "recipients": 120,
      "sent": 118,
      "delivered": 115,
      "bounced": 2,
      "complained": 0,
      "failed": 0,
      "suppressed": 2
    }
  ]
}
```

## Errors

- `400`: The `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: No sub-account with this id or uid exists in the API key's environment (`subaccount_not_found`).
- `422`: A query parameter failed validation (`validation_error`), or `from` is after `to` (`invalid_range`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).