> ## 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.

# Daily Metrics

> Get day-by-day time series metrics

# Daily Metrics

Returns daily time series data for your interactions. Use this endpoint to build trend charts, identify patterns, and track performance over time.

## Request

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

### 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` |
| `type`      | string | -           | Filter by interaction type               |

## Response

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

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="daily" type="array">
      Array of daily metric objects, sorted by date ascending
    </ResponseField>
  </Expandable>
</ResponseField>

### Daily Object

| Field                    | Type    | Description             |
| ------------------------ | ------- | ----------------------- |
| `date`                   | string  | Date (YYYY-MM-DD)       |
| `total`                  | integer | Total interactions      |
| `calls`                  | integer | Voice calls             |
| `conversations`          | integer | WhatsApp conversations  |
| `inbound`                | integer | Inbound interactions    |
| `outbound`               | integer | Outbound interactions   |
| `appointments_scheduled` | integer | Appointments booked     |
| `success_rate`           | number  | Success rate percentage |
| `avg_duration_seconds`   | number  | Average call duration   |

## Examples

### Basic Request

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

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.getdoppel.ai/api/v1/metrics/daily', {
    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/daily',
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  data = response.json()
  ```
</CodeGroup>

### Get Last 7 Days

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

  ```javascript JavaScript theme={null}
  // Calculate dates
  const today = new Date();
  const weekAgo = new Date(today);
  weekAgo.setDate(weekAgo.getDate() - 7);

  const params = new URLSearchParams({
    date_from: weekAgo.toISOString().split('T')[0],
    date_to: today.toISOString().split('T')[0]
  });

  const response = await fetch(
    `https://api.getdoppel.ai/api/v1/metrics/daily?${params}`,
    {
      headers: {
        'Authorization': 'Bearer dpl_live_YOUR_API_KEY'
      }
    }
  );
  ```

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

  today = datetime.now()
  week_ago = today - timedelta(days=7)

  response = requests.get(
      'https://api.getdoppel.ai/api/v1/metrics/daily',
      params={
          'date_from': week_ago.strftime('%Y-%m-%d'),
          'date_to': today.strftime('%Y-%m-%d')
      },
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  ```
</CodeGroup>

### Filter by Channel

Get daily metrics for voice calls only:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.getdoppel.ai/api/v1/metrics/daily?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/daily?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/daily',
      params={'channel': 'voice'},
      headers={'Authorization': 'Bearer dpl_live_YOUR_API_KEY'}
  )
  ```
</CodeGroup>

### Response Example

```json theme={null}
{
  "success": true,
  "data": {
    "daily": [
      {
        "date": "2024-12-29",
        "total": 45,
        "calls": 30,
        "conversations": 15,
        "inbound": 20,
        "outbound": 25,
        "appointments_scheduled": 12,
        "success_rate": 71.1,
        "avg_duration_seconds": 175
      },
      {
        "date": "2024-12-30",
        "total": 52,
        "calls": 35,
        "conversations": 17,
        "inbound": 22,
        "outbound": 30,
        "appointments_scheduled": 15,
        "success_rate": 73.5,
        "avg_duration_seconds": 182
      },
      {
        "date": "2024-12-31",
        "total": 28,
        "calls": 18,
        "conversations": 10,
        "inbound": 12,
        "outbound": 16,
        "appointments_scheduled": 8,
        "success_rate": 68.2,
        "avg_duration_seconds": 165
      },
      {
        "date": "2025-01-01",
        "total": 15,
        "calls": 10,
        "conversations": 5,
        "inbound": 8,
        "outbound": 7,
        "appointments_scheduled": 4,
        "success_rate": 66.7,
        "avg_duration_seconds": 155
      },
      {
        "date": "2025-01-02",
        "total": 58,
        "calls": 40,
        "conversations": 18,
        "inbound": 25,
        "outbound": 33,
        "appointments_scheduled": 18,
        "success_rate": 75.2,
        "avg_duration_seconds": 190
      }
    ]
  },
  "request_id": "req_abc123xyz",
  "timestamp": "2025-01-05T10:30:00.000Z"
}
```

## Use Cases

### Build a Trend Chart

Use the daily data to create visualizations:

```javascript theme={null}
async function getChartData(apiKey, days = 30) {
  const today = new Date();
  const startDate = new Date(today);
  startDate.setDate(startDate.getDate() - days);

  const response = await fetch(
    `https://api.getdoppel.ai/api/v1/metrics/daily?date_from=${startDate.toISOString().split('T')[0]}&date_to=${today.toISOString().split('T')[0]}`,
    {
      headers: { 'Authorization': `Bearer ${apiKey}` }
    }
  );
  const { data } = await response.json();

  // Format for charting libraries (Chart.js, Recharts, etc.)
  return {
    labels: data.daily.map(d => d.date),
    datasets: [
      {
        label: 'Total Interactions',
        data: data.daily.map(d => d.total)
      },
      {
        label: 'Appointments Scheduled',
        data: data.daily.map(d => d.appointments_scheduled)
      }
    ]
  };
}
```

### Calculate Week-over-Week Growth

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

def calculate_wow_growth(api_key):
    today = datetime.now()

    # This week
    this_week_end = today
    this_week_start = today - timedelta(days=7)

    # Last week
    last_week_end = this_week_start
    last_week_start = last_week_end - timedelta(days=7)

    def get_week_total(start, end):
        response = requests.get(
            'https://api.getdoppel.ai/api/v1/metrics/daily',
            params={
                'date_from': start.strftime('%Y-%m-%d'),
                'date_to': end.strftime('%Y-%m-%d')
            },
            headers={'Authorization': f'Bearer {api_key}'}
        )
        daily = response.json()['data']['daily']
        return sum(d['total'] for d in daily)

    this_week = get_week_total(this_week_start, this_week_end)
    last_week = get_week_total(last_week_start, last_week_end)

    if last_week > 0:
        growth = ((this_week - last_week) / last_week) * 100
    else:
        growth = 0

    return {
        'this_week': this_week,
        'last_week': last_week,
        'growth_percentage': round(growth, 1)
    }

# Usage
growth = calculate_wow_growth('dpl_live_YOUR_API_KEY')
print(f"Week-over-week growth: {growth['growth_percentage']}%")
```

### Identify Busy Days

Find your busiest days of the week:

```javascript theme={null}
async function analyzeDayPatterns(apiKey) {
  const today = new Date();
  const startDate = new Date(today);
  startDate.setDate(startDate.getDate() - 90); // Last 90 days

  const response = await fetch(
    `https://api.getdoppel.ai/api/v1/metrics/daily?date_from=${startDate.toISOString().split('T')[0]}&date_to=${today.toISOString().split('T')[0]}`,
    {
      headers: { 'Authorization': `Bearer ${apiKey}` }
    }
  );
  const { data } = await response.json();

  const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  const dayTotals = new Array(7).fill(0);
  const dayCounts = new Array(7).fill(0);

  data.daily.forEach(d => {
    const dayOfWeek = new Date(d.date).getDay();
    dayTotals[dayOfWeek] += d.total;
    dayCounts[dayOfWeek]++;
  });

  const dayAverages = dayNames.map((name, i) => ({
    day: name,
    average: dayCounts[i] > 0 ? Math.round(dayTotals[i] / dayCounts[i]) : 0
  }));

  return dayAverages.sort((a, b) => b.average - a.average);
}

// Usage
const patterns = await analyzeDayPatterns('dpl_live_YOUR_API_KEY');
console.log('Busiest days:', patterns.slice(0, 3));
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Metrics Summary" icon="chart-line" href="/api-reference/metrics/summary">
    Get aggregated totals instead of daily breakdown.
  </Card>

  <Card title="Outcome Breakdown" icon="chart-pie" href="/api-reference/metrics/outcomes">
    See how outcomes distribute across all interactions.
  </Card>
</CardGroup>
