GET - Get campaign stats

The stats endpoint allows you to track the result of any existing campaign using its token number.

Request structure

Route

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

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/campaigns/stats/CAMPAIGN_TOKEN" \
-H "Content-Type: application/json" \
-H "X-Authorization: BATCH_REST_API_KEY"

The BATCH_API_KEY value is your Live Batch API key from the settings page of your app within the dashboard (Settings → General). Only LIVE API Keys are supported by this API.

The CAMPAIGN_TOKEN value is the token you receive when you successfully create a push campaign using the API.

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. You can find it in ⚙ Settings → General.

Responses

Success

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

{
  "campaign_token": "d9d5e5a52ca08110d4893af3254ec21b",
  "detail": [
    {
      "date": "2015-11-20",
      "sent": 754,
      "sent_optins": 521,
      "direct_open": 102,
      "influenced_open": 98,
      "reengaged": 12,
      "errors": 0
    }
  ]
}

Here is how it looks for an A/B test campaign:

{
  "campaign_token": "aae13559e0493c0b350c547533f5b28f",
  "detail": [
    {
      "date": "2016-03-29",
      "sent": 972,
      "direct_open": 98,
      "influenced_open": 75,
      "reengaged": 36,
      "errors": 0,
      "versions": {
        "a": {
          "sent": 486,
          "sent_optins": 459,
          "direct_open": 67,
          "influenced_open": 46,
          "reengaged": 24
        },
        "b": {
          "sent": 486,
          "sent_optins": 451,
          "direct_open": 31,
          "influenced_open": 29,
          "reengaged": 12
        }
      }
    }
  ]
}

You can use this information to show the results of your campaigns 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)
  • TOO_MANY_REQUESTS (Http status code: 429, Error code: 60)
    If you get a "too many requests" response, please wait for at least 5 seconds before trying again. Further requests might still return this error.