Retrieve Messaging Analytics
Use this endpoint to retrieve messaging analytics for a specific WhatsApp Business Account (WABA). It provides the number and type of messages sent and delivered by the phone numbers associated with the WABA.
You can request analytics data with half-hourly, daily, or monthly granularity. All timestamps are returned in UTC.
Example
Find the description for all variables used in each code snippet below:
| Key | Description |
|---|---|
CHANNEL_MANAGER_WABA_ID | The |
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START | The start date and time in ISO-8601 format for the analytics data to be retrieved from, in the format YYYY-MM-DD. |
CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END | The end date and time in ISO-8601 format for the analytics data to be retrieved to, in the format YYYY-MM-DD. The maximum difference between the start and end dates is 90 days. |
CHANNEL_MANAGER_WHATSAPP_ANALYTICS_GRANULARITY | The granularity of the analytics data to be retrieved. |
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Write the code
Add the following to get-messaging-analytics.sh:
curl --get https://api.nexmo.com/v1/channel-manager/whatsapp/wabas/"${CHANNEL_MANAGER_WABA_ID}"/messaging-analytics \
-u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
-H 'Accept: application/json' \
-d 'start="'${CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START}'"' \
-d 'end="'${CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END}'"' \
-d 'granularity="'${CHANNEL_MANAGER_WHATSAPP_ANALYTICS_GRANULARITY}'"'Run your code
Save this file to your machine and run it: