Skip to main content
GET
/
backend
/
reports
/
{orgId}
/
chats
/
availability
curl --location --request GET 'https://api-v2.opencopilot.so/backend/reports/123456/chats/availability?startDate=2023-01-01T00:00:00Z&endDate=2023-01-31T23:59:59Z' \
--header 'Authorization: Bearer YOUR_API_KEY'
{
  "availability_percentage": 98.5,
  "down_times": [
    {
      "start_time": "2023-01-15T10:30:00Z",
      "end_time": "2023-01-15T11:00:00Z",
      "duration": 1800000,
      "session_id": "session123"
    },
    {
      "start_time": "2023-01-20T14:45:00Z",
      "end_time": "2023-01-20T15:00:00Z",
      "duration": 900000,
      "session_id": "session456"
    }
  ],
  "total_down_time": 2700000,
  "total_time": 2678400000
}

Authentication

Authorization
string
required
Bearer token for authentication

Path Parameters

orgId
string
required
The ID of the organization to retrieve chat availability for

Query Parameters

startDate
string
required
The start date for the report period (ISO 8601 format)
endDate
string
required
The end date for the report period (ISO 8601 format)
channel
string
The specific channel to filter results (if applicable)

Response

availability_percentage
number
The availability percentage as a number between 0 and 100
down_times
array
An array of objects representing periods of downtime
down_times[].start_time
string
The start time of the downtime period (ISO 8601 format)
down_times[].end_time
string
The end time of the downtime period (ISO 8601 format)
down_times[].duration
number
The duration of the downtime period in milliseconds
down_times[].session_id
string
The session ID associated with the downtime period
total_down_time
number
The total downtime in milliseconds for the specified period
total_time
number
The total time in milliseconds for the specified period
curl --location --request GET 'https://api-v2.opencopilot.so/backend/reports/123456/chats/availability?startDate=2023-01-01T00:00:00Z&endDate=2023-01-31T23:59:59Z' \
--header 'Authorization: Bearer YOUR_API_KEY'
{
  "availability_percentage": 98.5,
  "down_times": [
    {
      "start_time": "2023-01-15T10:30:00Z",
      "end_time": "2023-01-15T11:00:00Z",
      "duration": 1800000,
      "session_id": "session123"
    },
    {
      "start_time": "2023-01-20T14:45:00Z",
      "end_time": "2023-01-20T15:00:00Z",
      "duration": 900000,
      "session_id": "session456"
    }
  ],
  "total_down_time": 2700000,
  "total_time": 2678400000
}

Calculation Method

The chat availability is calculated using the following method:
  1. Message Gap Analysis: The system analyzes the time gaps between consecutive messages within the specified date range.
  2. Downtime Threshold: A gap of more than 2 minutes between messages is considered as potential downtime.
  3. Downtime Calculation: For each gap exceeding 2 minutes, the downtime is calculated as:
    Downtime = (Time between messages) - 2 minutes
    
  4. Total Downtime: The system sums up all individual downtimes to get the total downtime.
  5. Availability Percentage: The availability percentage is calculated as:
    Availability % = ((Total Time - Total Downtime) / Total Time) * 100
    
    Where Total Time is the duration between the specified start and end dates.