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

# Get Metrics

> Retrieve usage metrics and statistics

### Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token. Format: `Bearer synthra_live_abc123def456`
</ParamField>

### Query Parameters

<ParamField query="startDate" type="string" required>
  Start date in ISO 8601 format
</ParamField>

<ParamField query="endDate" type="string" required>
  End date in ISO 8601 format
</ParamField>

<ParamField query="granularity" type="string" default="day">
  Data granularity. Options: `hour`, `day`, `week`, `month`
</ParamField>

### Response

<ResponseField name="period" type="object">
  Time period for metrics
</ResponseField>

<ResponseField name="sessions" type="object">
  Session statistics
</ResponseField>

<ResponseField name="messages" type="object">
  Message statistics
</ResponseField>

<ResponseField name="tokens" type="object">
  Token usage statistics
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.synthra.ai/v1/analytics/metrics?startDate=2024-03-01T00:00:00Z&endDate=2024-03-08T23:59:59Z' \
    --header 'Authorization: Bearer synthra_live_abc123def456'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.synthra.ai/v1/analytics/metrics?startDate=2024-03-01T00:00:00Z&endDate=2024-03-08T23:59:59Z',
    {
      headers: {
        'Authorization': `Bearer ${process.env.SYNTHRA_API_KEY}`
      }
    }
  );
  ```

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

  response = requests.get(
      'https://api.synthra.ai/v1/analytics/metrics',
      headers={
          'Authorization': f'Bearer {api_key}'
      },
      params={
          'startDate': '2024-03-01T00:00:00Z',
          'endDate': '2024-03-08T23:59:59Z'
      }
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "period": {
      "start": "2024-03-01T00:00:00Z",
      "end": "2024-03-08T23:59:59Z",
      "granularity": "day"
    },
    "sessions": {
      "total": 1847,
      "active": 342,
      "averageDuration": 1847
    },
    "messages": {
      "total": 15293,
      "averagePerSession": 8.3,
      "userMessages": 7647,
      "assistantMessages": 7646
    },
    "tokens": {
      "total": 184729,
      "prompt": 92364,
      "completion": 92365,
      "averagePerMessage": 12.1
    }
  }
  ```
</ResponseExample>
