# Contact base analytics

`GET /analytics/contacts`

Returns aggregates over the contact base of one shop (`shop_id`) or
all your shops: reachability (SMS opt-in and blacklist, email),
data coverage, source and gender distribution, and loyalty program
stats. `sms_reachable` counts contacts with SMS opt-in and not
blacklisted; `with_email` counts contacts that merely have an email
address, which can differ widely from `email_reachable` (opt-in).

Requires the `contacts:read` scope.

**Returns** a single object of counters computed over the whole current
base; there is no date filter on this endpoint. Counts are `0` when the
base is empty. The `loyalty` block only counts contacts enrolled in the
loyalty program.

## Example request

```bash
curl "https://api.dokaa.app/v1/analytics/contacts" \
  -H "Authorization: Bearer dk_live_..."
```

## Query parameters

- `shop_id` (string) – Restrict to a single shop (omit to query all your shops)

## Responses

### 200 – Contact aggregates

```json
{
  "contact_count": 5240,
  "sms_reachable": 3390,
  "sms_optin": 3450,
  "sms_blacklisted": 120,
  "email_reachable": 890,
  "with_email": 2100,
  "with_birthdate": 1240,
  "sources": [
    {
      "source": "loyalty",
      "count": 2100
    },
    {
      "source": "campaign",
      "count": 1400
    }
  ],
  "genders": {
    "male": 1900,
    "female": 2200,
    "unknown": 1140
  },
  "loyalty": {
    "members": 2100,
    "total_points": 184000,
    "total_visits": 25600,
    "with_card": 1350,
    "marketing_optin": 1600
  }
}
```

### 401 – Missing, invalid, or revoked API key

### 403 – The API key does not grant access to this resource

### 422 – Invalid request parameters

Errors are `application/problem+json` (RFC 9457) with `type`, `title`, `status` and `detail` fields.
