# Stats and Analytics

> GET /forwarding/stats for call, minute and cost totals over a period, and GET /forwarding/analytics for a daily series and per-number breakdown with answer rate.

Source: https://edesy.in/docs/call-forwarding/api/stats

Two endpoints report forwarding usage. `GET /v1/forwarding/stats` returns totals for a period (rules, calls, answered, failed, minutes and cost), defaulting to the last 30 days. `GET /v1/forwarding/analytics` adds a day-by-day series and a per-number breakdown with answer rate, for the last 1 to 90 days. They power the portal's dashboard and Analytics page.

## Usage totals

```
GET /v1/forwarding/stats
```

| Name | Type | Description |
|---|---|---|
| `start_date` | RFC 3339 | Start of the period. Default 30 days ago |
| `end_date` | RFC 3339 | End of the period. Default now |

```bash
curl "https://voice-api.edesy.in/v1/forwarding/stats" \
  -H "Authorization: Bearer sk_your_api_key"
```

```json
{
  "data": {
    "total_rules": 2,
    "active_rules": 1,
    "total_calls": 148,
    "answered_calls": 121,
    "failed_calls": 9,
    "total_minutes": 312.5,
    "total_cost": 338
  },
  "meta": { "timestamp": "2026-10-16T09:30:00Z" }
}
```

| Field | Description |
|---|---|
| `total_rules`, `active_rules` | Forwarding rules in the workspace, and how many are active |
| `total_calls` | Calls in the period |
| `answered_calls` | Calls that were answered |
| `failed_calls` | Calls that failed |
| `total_minutes` | Minutes in the period |
| `total_cost` | Spend in INR |

## Analytics

```
GET /v1/forwarding/analytics
```

| Name | Type | Description |
|---|---|---|
| `days` | integer, 1 to 90 | How many days back. Default 30 |

```bash
curl "https://voice-api.edesy.in/v1/forwarding/analytics?days=7" \
  -H "Authorization: Bearer sk_your_api_key"
```

```json
{
  "data": {
    "range_start": "2026-10-09T09:30:00Z",
    "range_end": "2026-10-16T09:30:00Z",
    "totals": { "total_rules": 2, "active_rules": 1, "total_calls": 31, "answered_calls": 27, "failed_calls": 1, "total_minutes": 64, "total_cost": 70 },
    "timeseries": [
      { "date": "2026-10-15", "calls": 6, "answered": 5, "minutes": 11.5, "cost": 13 }
    ],
    "by_number": [
      { "did_number": "8071387146", "calls": 31, "answered": 27, "minutes": 64, "cost": 70, "answer_rate": 0.87 }
    ]
  },
  "meta": { "timestamp": "2026-10-16T09:30:00Z" }
}
```

| Field | Description |
|---|---|
| `range_start`, `range_end` | The period covered |
| `totals` | Same fields as [usage totals](#usage-totals) |
| `timeseries[]` | One entry per day (`YYYY-MM-DD`): calls, answered, minutes, cost. Days with no calls are included as zeros |
| `by_number[]` | Per virtual number: calls, answered, minutes, cost and `answer_rate` (0 to 1) |

The example figures are illustrative.
