Skip to content

Reports

This guide explains how to use the reporting features of the WhatsGate API to monitor message delivery and device usage.

Prerequisites

Before you can access reports, you need to:

  1. Create an API token for authentication
  2. Link a WhatsApp device to your account
  3. Send some messages using the API

Available Reports

The WhatsGate API provides the following reporting endpoints:

  • Device Balance: Get information about message counts and remaining balance
  • Failed Numbers: Get a list of phone numbers where message sending failed

Device Balance

To get the message balance information for a device, make a GET request to the /reports/balance/{device} endpoint:

bash
curl -X GET \
  https://{subdomain}.whatsgate.net/api/reports/balance/123456789 \
  -H 'Access-Token: your_api_token_here'

Parameters

  • device: The mobile number of the device you want to check

Response

If successful, you'll receive a response with the device's message statistics:

json
{
  "success": true,
  "remaining": 1000,
  "successful_count": 500,
  "pending": 50,
  "failed": 10
}

The response includes the following information:

  • remaining: The number of messages remaining in your balance
  • successful_count: The number of messages successfully sent
  • pending: The number of messages pending delivery
  • failed: The number of messages that failed to send

Error Handling

If the device is not found, you'll receive an error response:

json
{
  "success": false,
  "message": "Device not found"
}

Failed Numbers

To get a list of phone numbers where message sending failed, make a GET request to the /reports/failed_numbers endpoint:

bash
curl -X GET \
  'https://{subdomain}.whatsgate.net/api/reports/failed_numbers?device=123456789&from=2023-01-01&to=2023-01-31' \
  -H 'Access-Token: your_api_token_here'

Parameters

  • device (optional): Filter by device mobile number
  • from (optional): Filter by start date (format: YYYY-MM-DD)
  • to (optional): Filter by end date (format: YYYY-MM-DD)

Response

If successful, you'll receive a response with a list of failed numbers:

json
{
  "success": true,
  "data": [
    {
      "number": "987654321",
      "date": "2023-01-01T12:00:00Z"
    },
    {
      "number": "987654322",
      "date": "2023-01-02T14:30:00Z"
    }
  ]
}

The response includes an array of objects, each containing:

  • number: The phone number where message sending failed
  • date: The date and time when the failure occurred

Error Handling

If there's an error with your request, you'll receive an error response:

json
{
  "success": false,
  "message": "The selected device is invalid."
}

Using Reports

Monitoring Message Delivery

  • Regularly check the device balance to monitor your message delivery statistics
  • If you notice a high number of failed messages, investigate the failed numbers report
  • Use the date filters to narrow down when failures occurred

Troubleshooting

If you're experiencing message delivery issues:

  1. Check the device status to ensure it's connected
  2. Review the failed numbers report to identify patterns
  3. Verify that the phone numbers are in the correct format
  4. Check if the device has sufficient balance remaining

Next Steps

Released under the MIT License.