RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
OverviewActivity seriesEngagementTop usersPeak hours
Sample requestsSample responsesStatus codesAppendixChangelog

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:

FieldDescription
hourHour of day as an integer from 0 (midnight) to 23.
countNumber of messages that occurred during that hour across the selected window (aggregated, not a single day).
GET{baseUrl}/api/{apiVersion}/analytics/peak-hours?days=7

Authentication

Required (Bearer token)

Tenant-scoped

Yes (tenant DB — requires x-client-id)

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>Client Access Token with tenant admin privileges.
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true.

Query Parameters

ParameterRequiredExampleDescription
daysOptional7Look-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.

json
{
  "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

json
{
  "success": false,
  "message": "Access denied: tenant admin privileges required",
  "data": null,
  "error": null
}

HTTP 401 Unauthorized — No token

json
{
  "success": false,
  "message": "No token, authorization denied",
  "data": null,
  "error": "Unauthorized"
}
CodeReason
401 UnauthorizedAccess Token is missing, invalid, or expired.
403 ForbiddenAccess denied: tenant admin privileges required (for example, a non-client token was used).
500 Internal Server ErrorAn 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 days window (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.

PreviousTop usersNextList users

On this page

OverviewWhen to use this endpoint?Response DataRequest HeadersQuery ParametersSuccess ResponseCommon ErrorsBest Practices