GET - Get stats

The stats endpoint allows you to track the result transactional messages using its group id.

Request structure

Route

The transactional API exposes a GET endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID

Here are examples of valid cURL, PHP or Python requests syntax:

  • Bash
  • PHP
  • Python
curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10" \
-H "Content-Type: application/json" \
-H "X-Authorization: BATCH_REST_API_KEY"

The GROUP_ID value is the id you set when you create a transactional message.

Note: Only LIVE API Keys are supported by this API

Get parameters

IdDescription
sinceString - Required. Must be lower than 'until' parameter.
Value that indicates the first date of the window over which stats are fetched. The maximum window size is 6 months.
E.g."/transactional/stats/GROUP_ID?since=2018-03-01"
untilString - Required, Default : today's date (GMT)
Value that indicates the last date of the window over which stats are fetched.
E.g."/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10"

Here is an example of a valid cURL CLI request, which would return daily stats about the group id welcome from 1 to 10 March 2018 :

curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
"https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/welcome?since=2018-03-01&until=2018-03-10"

Headers

In order to authenticate with the API, you need to provide your company REST API Key as the value of the X-Authorization header.

Responses

Success

If the GET to the API endpoint is successfull you will receive an HTTP 200 confirmation and information on your campaign.

{
    "group_id": "welcome",
    "detail": [
        {
            "date": "2018-03-05",
            "sent": 754,
            "direct_open": 102,
            "influenced_open": 98,
            "reengaged": 12,
            "errors": 0
        },
        {
            "date": "2018-03-07",
            "sent": 582,
            "direct_open": 96,
            "influenced_open": 85,
            "reengaged": 12,
            "errors": 1
        }
    ]
}

You can use this information to show the results of your transactional messages in your business intelligence tools.

Also, you can easily calculate the open-rate by using the following formula:
open-rate = (direct_open + influenced_open) / sent

Failure

If the GET data does not meet the API requirements you will receive an actionable error message. Contact us at support@batch.com if you need further support.

  • AUTHENTICATION_INVALID (Http status code: 401, Error code: 10)
  • API_MISUSE (Http status code: 403, Error code: 12)
  • ROUTE_NOT_FOUND (Http status code: 404, Error code: 20)
  • SERVER_ERROR (Http status code: 500, Error code: 0)