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

# Metrics Summary

> Get aggregated KPIs and summary statistics

# Metrics Summary

Returns aggregated key performance indicators (KPIs) for your interactions. This endpoint provides a high-level overview of your call and conversation volumes, success rates, and other important metrics.

## Request

```bash theme={null}
GET https://api.getdoppel.ai/api/v1/metrics/summary
```

### Headers

| Header          | Required | Description                    |
| --------------- | -------- | ------------------------------ |
| `Authorization` | Yes      | Bearer token with your API key |

### Query Parameters

| Parameter   | Type   | Default     | Description                              |
| ----------- | ------ | ----------- | ---------------------------------------- |
| `date_from` | string | 30 days ago | Start date (ISO 8601)                    |
| `date_to`   | string | Today       | End date (ISO 8601)                      |
| `clinic_id` | string | -           | Filter by clinic UUID                    |
| `channel`   | string | -           | Filter by channel: `voice` or `whatsapp` |

## Response

<ResponseField name="success" type="boolean">
  Whether the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="total_interactions" type="integer">
      Total number of interactions in the period
    </ResponseField>

    <ResponseField name="total_calls" type="integer">
      Total voice calls
    </ResponseField>

    <ResponseField name="total_conversations" type="integer">
      Total WhatsApp conversations
    </ResponseField>

    <ResponseField name="inbound_count" type="integer">
      Total inbound interactions
    </ResponseField>

    <ResponseField name="outbound_count" type="integer">
      Total outbound interactions
    </ResponseField>

    <ResponseField name="avg_duration_seconds" type="number">
      Average call duration in seconds
    </ResponseField>

    <ResponseField name="total_duration_seconds" type="integer">
      Total call duration in seconds
    </ResponseField>

    <ResponseField name="success_rate" type="number">
      Percentage of successful outcomes (0-100)
    </ResponseField>

    <ResponseField name="appointments_scheduled" type="integer">
      Number of appointments scheduled
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

### Basic Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.getdoppel.ai/api/v1/metrics/summary" \
    -H "Authorization: Bearer dpl_live_YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.getdoppel.ai/api/v1/metrics/summary', {
    headers: {
      'Authorization': 'Bearer dpl_live_YOUR_API_KEY'
    }
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.getdoppel.ai/api/v1/metrics/summary',
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  data = response.json()
  ```
</CodeGroup>

### With Date Range

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.getdoppel.ai/api/v1/metrics/summary?date_from=2024-01-01&date_to=2024-12-31" \
    -H "Authorization: Bearer dpl_live_YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.getdoppel.ai/api/v1/metrics/summary?date_from=2024-01-01&date_to=2024-12-31',
    {
      headers: {
        'Authorization': 'Bearer dpl_live_YOUR_API_KEY'
      }
    }
  );
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.getdoppel.ai/api/v1/metrics/summary',
      params={
          'date_from': '2024-01-01',
          'date_to': '2024-12-31'
      },
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  ```
</CodeGroup>

### Filter by Channel

Get metrics for voice calls only:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.getdoppel.ai/api/v1/metrics/summary?channel=voice" \
    -H "Authorization: Bearer dpl_live_YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.getdoppel.ai/api/v1/metrics/summary?channel=voice',
    {
      headers: {
        'Authorization': 'Bearer dpl_live_YOUR_API_KEY'
      }
    }
  );
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.getdoppel.ai/api/v1/metrics/summary',
      params={'channel': 'voice'},
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  ```
</CodeGroup>

### Response Example

```json theme={null}
{
  "success": true,
  "data": {
    "total_interactions": 1250,
    "total_calls": 800,
    "total_conversations": 450,
    "inbound_count": 500,
    "outbound_count": 750,
    "avg_duration_seconds": 180.5,
    "total_duration_seconds": 144400,
    "success_rate": 72.5,
    "appointments_scheduled": 320
  },
  "request_id": "req_abc123xyz",
  "timestamp": "2024-01-15T10:30:00.000Z"
}
```

## Use Cases

### Dashboard Overview

Build a KPI dashboard showing key metrics:

```javascript theme={null}
async function getDashboardMetrics(apiKey) {
  const response = await fetch(
    'https://api.getdoppel.ai/api/v1/metrics/summary',
    {
      headers: { 'Authorization': `Bearer ${apiKey}` }
    }
  );
  const { data } = await response.json();

  return {
    totalInteractions: data.total_interactions,
    successRate: `${data.success_rate}%`,
    appointmentsBooked: data.appointments_scheduled,
    avgCallDuration: `${Math.round(data.avg_duration_seconds / 60)} min`
  };
}
```

### Monthly Reports

Generate monthly comparison reports:

```python theme={null}
import requests
from datetime import datetime, timedelta

def get_monthly_metrics(api_key, year, month):
    # Calculate month boundaries
    start_date = f"{year}-{month:02d}-01"
    if month == 12:
        end_date = f"{year + 1}-01-01"
    else:
        end_date = f"{year}-{month + 1:02d}-01"

    response = requests.get(
        'https://api.getdoppel.ai/api/v1/metrics/summary',
        params={
            'date_from': start_date,
            'date_to': end_date
        },
        headers={'Authorization': f'Bearer {api_key}'}
    )
    return response.json()['data']

# Compare Q4 months
for month in [10, 11, 12]:
    metrics = get_monthly_metrics('dpl_live_YOUR_API_KEY', 2024, month)
    print(f"Month {month}: {metrics['appointments_scheduled']} appointments")
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Outcome Breakdown" icon="chart-pie" href="/api-reference/metrics/outcomes">
    Get detailed breakdown of outcomes.
  </Card>

  <Card title="Daily Metrics" icon="calendar" href="/api-reference/metrics/daily">
    Get day-by-day time series data.
  </Card>
</CardGroup>
