Skip to main content

POST WhatsApp Stats

This endpoint returns aggregated statistics for WhatsApp messages sent from your account within a specified time range. Use it to monitor delivery performance, track message volumes, and analyze trends across different time intervals.

Configure the API Endpoint

https://api.betatel.com/api/v1/connect-hub/whatsapp/stats
  • Method: POST

Set Up the Headers

ParamValueDescription
Content-typeapplication/jsonSpecifies the payload format.
x-api-key{{x-api-key}}API key for authorization.
x-account-id{{x-account-id}}User identifier for added security and tracking.

Craft the Request Body

Design the JSON payload to specify the stat type, time range, and timezone.

Example of body
{
"type": "daily",
"start_time": "2024-01-01T00:00:00.000Z",
"end_time": "2024-01-31T23:59:59.000Z",
"timezone": "UTC"
}
FieldTypeRequiredDescription
typestringNoThe aggregation interval (default: today). See supported types below.
start_timestringNoStart of the reporting period in ISO 8601 format.
end_timestringNoEnd of the reporting period in ISO 8601 format.
timezonestringNoTimezone for date grouping (default: "UTC").

Supported Stat Types

TypeDescription
todayAggregated totals for the current day.
hourlyGrouped by hour within the specified range.
dailyGrouped by day within the specified range.
weeklyGrouped by week within the specified range.
monthlyGrouped by month within the specified range.
yearlyGrouped by year within the specified range.
lasthAggregated totals for the last 60 minutes.
last12hAggregated totals for the last 12 hours.
last24hAggregated totals for the last 24 hours.
last30mAggregated totals for the last 30 minutes.
last10mAggregated totals for the last 10 minutes.
last5mAggregated totals for the last 5 minutes.
lastmAggregated totals for the last 1 minute.
lastmonthAggregated totals for the last 30 days.

Code Snippets

Example - cURL
curl --location 'https://api.betatel.com/api/v1/connect-hub/whatsapp/stats' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-account-id: YOUR_ACCOUNT_ID' \
--data '{
"type": "daily",
"start_time": "2024-01-01T00:00:00.000Z",
"end_time": "2024-01-31T23:59:59.000Z",
"timezone": "UTC"
}'

Understanding the Response

The endpoint returns an array of stat objects, one entry per time interval within the requested range.

JSON Schema:

[
{
"total_requests": 1248,
"total_transactions": 1201,
"total_amount": 24.02,
"currency": "EUR"
},
{
"total_requests": 983,
"total_transactions": 951,
"total_amount": 19.02,
"currency": "EUR"
}
]
FieldTypeDescription
total_requestsnumberTotal number of OTP messages requested in the interval.
total_transactionsnumberNumber of messages that were successfully processed.
total_amountnumberTotal billing amount for the interval.
currencystringCurrency of the reported amounts (default: "EUR").

Error Handling

  • 400 - Bad Request: Invalid stat type, missing fields, or malformed time range
  • 401 - Unauthorized: Authentication failed
  • 500 - Internal Server Error: An unexpected error occurred on the server