Using Batch APIs

Batch features rely on a set of RESTful APIs, making any third party integrations easy. Access and export your campaign reports anywhere. Trigger campaigns from the comfort of your back-end. Command multiple apps at once. Possibilities are endless.

With these APIs, push notifications can be sent directly from your backend, your CMS or your app.

Transactional API

The Transactional API is made for 1-to-1 interactions. It allows you to push a specific user ID or a group of IDs (device token, install ID or custom user ID). See here to know more.

Use it to send action-oriented or time-sensitive push notifications.

  • Action-oriented notifications: New message, friend request, reached credit limit, user's turn in a game, etc.
  • Time-sensitive notifications: Delivered order, delayed flight, canceled train, etc.

Campaigns API

The Campaigns API is made for 1-to-many interactions. Use it if none of the above examples fit your use case. It allows you to target a large audience or users. See here to know more.

You can use the Campaigns API to send generic/optional notifications. Here are a few examples:

  • Medias: Breaking news, interest based notifications, etc.
  • E-commerce: Flash sales, abandoned cart reminder, etc.
  • Fitness: Workout reminders, subscription offers, etc.

Connecting Batch to a CMS

With our Campaigns API, you can connect your CMS to Batch to send push notifications. It gives you the same level of features as Batch's dashboard:

  • Targeting: Basic, native and custom attributes targeting.
  • Scheduling: Scheduled and recurring push campaigns.
  • Messaging: A/B testing, deeplink, custom payload, rich push notifications, etc.

Here is how a basic Campaigns API + CMS setup looks like: Campaigns API integration

With the Campaigns API you can:

  • POST - Create or edit an existing push campaign. If the POST to the API endpoint is successfull you will receive an HTTP 201 confirmation with a campaigns token.
  • GET - Track the results of a campaign using a campaign token. Each time you send a push campaign, Batch also receives feedback from APNS/FCM and cleans the invalid tokens for you.

Please note that Batch manages iOS and Android apps separately. You will need to call our APIs twice if your app has an iOS and an Android version.

Have any questions on a specific Batch+CMS integration? Feel free to ping us at

Sending event-based notifications

Event-based notifications allow you to reach specific users each time an event is triggered in your back-end. You can send these notifications using Batch Transactional API and specifying up to 10K user IDs.

API transactional

As described in the above example, you need to write server-side code to:

  1. Monitor changes in your back-end or your Firebase database.
  2. Trigger a call to the transactional API targeting one or several user IDs.

A small NodeJS or PHP script can do the job perfectly if you are familiar with those technologies. Here is a sample if you want to know how a working script looks like.

There are three type of user IDs you can use to target your users with the Transactional API:

  • Custom user ID: If your app has a login system, Batch can associate several push tokens to a single user ID. This allows you to use the Transactional API with your own IDs, regardless of the OS of the user (know more here: iOS/Android).
  • installation ID: In case your app doesn't have a login system or you don't want to share your user IDs with Batch, you can use the Installation ID. This anonymised ID is generated automatically by Batch and offers the same advantages as with custom IDs (know more here: iOS/Android).
  • Device token: We recommend against using push tokens with the transactional API. Push tokens are linked to a specific device and OS. They also change on Android and iOS when users reinstall your app.

Using Batch in a messaging app

If you have a messaging app, there are two approaches to send push messages to your users using Batch. You can either call the transactional API from your back-end or from your app.

A. Calling the API from your back-end

You can trigger push notifications from your back-end using the transactional API each time a message is sent to a user. All you need to do is to monitor changes in your back-end and trigger the transactional API on certain events (e.g. unread_message=true).

B. Calling the Transactional API from your app

You can also call the transactional API from your app but we discourage it for security reasons. Users with bad intentions may reverse engineer your app, extract the REST API key and push your users on your behalf.

If you still want to push from code though, you will need to use the standard HTTP library of your platform: NSURLSession on iOS, or HttpUrlConnection on Android. Here is how a basic integration looks like:

App to app

The API is called from User A's device and targets User B's ID each time User A sends a message to user B. You can use our iOS code sample (Swift 2 / Swift 3) if you want to see how this solution works.