API Reference
Peak Hours
Overview
Retrieve message volume by hour of day (0–23) for your tenant over a look-back window — useful for spotting when chatter is busiest.
Use the optional days query parameter to control the aggregation window. Ideal for heatmap or bar charts that inform staffing, support hours, or campaign timing.
When to use this endpoint?
Use Peak Hours when:
- You need an hour-of-day distribution of message traffic.
- You want to decide support coverage or bot escalation windows based on real usage.
- You already load overview or activity elsewhere and only need to refresh the peak-hours chart.
- You prefer a lighter payload than Analytics Overview.
This endpoint requires tenant admin privileges with a valid client Access Token. End-user tokens are rejected. Hours are typically returned in UTC unless your deployment documents another timezone.
Response Data
Each item in data.peakHours includes:
| Field | Description |
|---|---|
| hour | Hour of day as an integer from 0 (midnight) to 23. |
| count | Number of messages that occurred during that hour across the selected window (aggregated, not a single day). |
{baseUrl}/api/{apiVersion}/analytics/peak-hours?days=7Authentication
Required (Bearer token)
Tenant-scoped
Yes (tenant DB — requires x-client-id)
Request Headers
| Header | Value | Description |
|---|---|---|
| Authorization | Bearer <access_token> | Client Access Token with tenant admin privileges. |
| is-tenant | true | Targets the tenant DB ("true", needs x-client-id). |
| x-client-id | {{clientId}} | Tenant (client) id. Required when is-tenant=true. |
Query Parameters
| Parameter | Required | Example | Description |
|---|---|---|---|
| days | Optional | 7 | Look-back window in days (for example 7, 30, or 90). Defaults apply when omitted. Shorter windows react faster to recent schedule changes. |
Success Response (HTTP 200 OK)
On success, the API returns hour buckets with message counts for the selected window.
{
"success": true,
"message": "Peak hours fetched successfully",
"data": {
"peakHours": [
{
"hour": 0,
"count": 12
},
{
"hour": 9,
"count": 540
},
{
"hour": 14,
"count": 612
},
{
"hour": 20,
"count": 305
}
]
},
"error": null
}Common Errors
Peak Hours fails when the token is missing, expired, or lacks tenant admin privileges.
HTTP 403 Forbidden — Tenant admin required
{
"success": false,
"message": "Access denied: tenant admin privileges required",
"data": null,
"error": null
}HTTP 401 Unauthorized — No token
{
"success": false,
"message": "No token, authorization denied",
"data": null,
"error": "Unauthorized"
}| Code | Reason |
|---|---|
| 401 Unauthorized | Access Token is missing, invalid, or expired. |
| 403 Forbidden | Access denied: tenant admin privileges required (for example, a non-client token was used). |
| 500 Internal Server Error | An unexpected error occurred while aggregating peak hours. |
Best Practices
- Fill missing hours with zero in your UI if the API omits quiet buckets, so the chart always spans 0–23.
- Document the timezone you display (UTC vs local) so admins interpret peaks correctly.
- Use a shorter
dayswindow (for example 7) when you care about recent schedule shifts. - Always send tenant headers with a client Bearer token over HTTPS.
Peak hours ready
Plot the hour buckets on your peak-hours chart, then combine with Activity Series for daily trends and Engagement for overall usage depth.