Obtenir une analyse des prix

Utilisez ce point de terminaison pour récupérer les analyses de tarification pour un WhatsApp Business Account (WABA) spécifique. Il fournit des informations sur la répartition des prix et les paliers pour tout message délivré dans une plage de dates spécifiée.

Vous pouvez demander des données analytiques avec une granularité demi-horaire, quotidienne ou mensuelle. Tous les horodatages sont renvoyés en UTC.

Exemple

Vous trouverez ci-dessous la description de toutes les variables utilisées dans chaque extrait de code :

CléDescription
CHANNEL_MANAGER_WABA_ID

The waba_id of the WhatsApp Business Account (WABA) for which to retrieve the template analytics data.

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.

Conditions préalables

Si vous n'avez pas de demande, vous pouvez créer un. Veillez également à configurer vos webhooks.

Rédiger le code

Ajouter ce qui suit à get-pricing-analytics.sh:

curl -G https://api.nexmo.com/v1/channel-manager/whatsapp/wabas/"${CHANNEL_MANAGER_WABA_ID}"/pricing-analytics \
  -u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
  -H 'Accept: application/json' \
  --data-urlencode start=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START \
  --data-urlencode end=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END \
  --data-urlencode granularity=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_GRANULARITY

Voir la source complète

Exécutez votre code

Enregistrez ce fichier sur votre machine et exécutez-le :

bash get-pricing-analytics.sh