Only this pageAll pages
Powered by GitBook
Couldn't generate the PDF for 328 pages, generation stopped at 100.
Extend with 50 more pages.
1 of 100

API & SDK Documentation

Loading...

API

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

sdk

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Developer Portal

Welcome to Batch's developer portal!

Here, you’ll find everything you need to integrate with Batch—whether you’re working on the client side using our SDKs, or on the server side with our APIs.

Our resources include high-level usage guides, sample code, and detailed API references to help you get started quickly.

Customer Engagement Platform APIs

Batch’s Customer Engagement Platform APIs give you server-side access to our new, profile-oriented data model—making it easy to manage and act on user data at scale.

SDKs

Batch's SDKs bring our features to your app in a developer-friendly API.

What is an SDK?

"SDK" stands for Software Development Kit.

An SDK is a set of tools developers can use to create apps for a specific platform or to add features to their apps without having to redevelop them from scratch. Apps usually integrate a wide variety of third-party analytics and marketing SDKs.

Here is a non-exhaustive list of the purposes the SDK serves:

  • Analytics: registers new installs, sends app usage data and feedback on push and In-App interactions (e.g. push displayed, opened, In-App message dismissed, etc).

  • Data collection: collects and sends Profile data (attributes, events) to Batch servers to improve your segmentation and personalization.

  • Push notifications: collects and sends the push token to Batch servers, required to deliver a push to your users' devices. On Android, the receiver included in the SDK is in charge of receiving and displaying the notifications.

  • In-App messaging: pulls the list of In-app campaigns matching your users' install from Batch servers and displays the In-app messages.

Available SDKs and Plugins

SDK Downloads

Most SDKs and Plugins are not to be downloaded directly but integrated by using a package manager: the ones Batch support and how to use the SDK with them is detailed in the "SDK Integration" pages.

You can also find us on where you will find our SDKs & Plugins source code and sample apps you can use to test our features with.

Mobile Engagement Platform APIs

  • Inbox: Provides the history of push notifications sent to the install or the user ID attached to the install. This is useful if you want to add a notification centre to your app.

  • API Changelog
    GitHub
    Cover

    Profiles

    Update or export profile attributes & events

    Cover

    Audiences

    Manage and populate audiences

    Cover

    Campaigns

    Create omnichannel campaigns

    Cover

    Exports

    Manage requested exports

    iOS

    Android

    Web

    Flutter

    React Native

    Cordova

    Transactional

    Campaigns

    In-app Campaigns

    Custom Audience

    Custom Data

    App Data

    GDPR

    Export

    Webhooks

    Trigger Events

    Audiences

    Audiences APIs allow brands to Create, Update, Replace, Remove, List and View Audiences.

    Audiences are lists of Custom User IDs, Emails, or Install IDs that can be used for targeting with Batch Platform, when performing Campaigns and Automations.

    Audiences can also be associated with attributes that can be used for personalization purposes (more information here).

    CreateUpdateReplaceRemoveList

    Custom Audience

    Transactional

    In-app Campaigns

    Trigger Events

    Export

    iOS

    v1.1 (install ids only)

    Custom Data

    SDK Integration

    API - Customer Engagement Platform

    Projects and Profiles

    Before we begin, we would like to talk about two paradigms:

    Projects group Android/iOS apps, Websites and all channels leveraged together in a single entity. Projects have their own identifier for use with our new project-level APIs (called the Project key).

    Data used to be siloed between different apps: projects remove that limitation by introducting profiles.

    Profiles centralize data and events from multiple sources (Apps, Websites, APIs) in a single place based on the Custom user ID. They can also store a profile's email, phone number, etc. and email, SMS, etc. subscriptions. This allows Batch to support more complex and cross-channel lifecycles: it is now possible to message a user on a channel even though its profile data is fed from another one.

    For example, this use case is now supported:

    • A user creates an account from your Android app. You use the Android SDK to set a and add .

    • You collect their email and use the Profile API to tell Batch about it.

    • This user then logs in on your website, which sets the Custom User ID.

    • The user performs some action on your website, which you send to Batch using the

    You will now be able to create an email, SMS etc. automation or campaign, which automatically uses the data from the app, website and profile API and reacts to both events the user did on your website and tracked by your backend thanks to the Custom User ID.

    Using Project APIs

    Prerequisites

    Before sending your first call to our API, make sure you have:

    • Your REST API key.

    • Your Project Key.

    You will find these IDs in your project settings, on Batch dashboard (⚙️ Settings → General). Please note you need to be the manager of the account to see the REST API key.

    Please make sure that you keep your REST API key secret: it is sensitive and should not be shared in any form. You should never use it in client apps to call APIs from there as it would easily be extractable. Our support team will never ask for your REST API key.

    Request headers and authentication

    Three headers are required to use the API:

    • Content-Type must be set to application/json.

    • The REST API key should be in the Authorization header, prefixed by Bearer . Example: Authorization: Bearer EC3DBFXPZ67RTCDEF. If you are logging your requests, you should exclude this header from the logs.

    Example:

    Note: You will find cURL examples for the API endpoints in the documentation pages, by clicking on "Test it"

    Rate Limiting

    To ensure fair usage and platform stability, all CEP API endpoints are subject to rate limiting.

    Unless specified otherwise, APIs are subject to a rate limit of 1 request per second per project key.

    Some APIs like Profile update and Edit catalog items have custom rate limits. In those cases, the limits are documented both on the root page of this API's documentation and on their specific endpoints.

    If either threshold is exceeded, the API will respond with an HTTP 429 Too Many Requests error. You are expected to handle those responses appropriately. When that happens, slow down your requests or reduce the batch size (when applicable) to comply with the limit.

    Differences with v1 APIs

    APIs on the 2.0 and higher endpoints work differently than the previous APIs:

    • The REST API key does not use X-Authorization anymore, but the standard Authorization header

    • The Project key is in a HTTP header rather than in the route

    • The 2.x APIs are not RESTful by design: endpoints are structured differently and will use GET/POST methods only

    OpenAPI Spec

    The OpenAPI Spec .

    Update catalog

    Use /catalogs/update to update an existing catalog.

    Request structure

    Route

    The Catalog API exposes a POST endpoint that allows to update an existing catalog:

    /catalogs/update

    A catalog can have up to 25 fields.

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the catalog.

    Here is a how a complete JSON payload looks like:

    Responses

    Success

    If the call to the API endpoint is successful you will receive an HTTP 202 confirmation.

    Failure

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

    Remove

    See to see an introduction about Audience API.

    API Description

    Request structure

    View catalog

    Use /catalogs/view to view an existing catalog.

    Request structure

    Route

    Delete campaign

    It allows the deletion of a campaign.

    API Description

    Request structure

    Orchestrations

    Orchestrations is the word we use to encompass Campaigns and Automations. This API allows the retrieval of:

    • the listing of all orchestrations you manage with Batch, using a GET list request,

    • the performance metrics of all orchestrations you manage with Batch, using a GET stats request.

    Exports

    If you want to export your entire profile based or segments, the export request has to be done via the Profiles API, see this section to know more: .

    The Exports API allows you to list exports requested, view them and finally retrieve export files.

    Download export file

    The export API allows you to download files extracted by your export request.

    API Description

    Route

    The Project Export API exposes a GET endpoint that allows to download result files:

    Campaigns

    Campaigns API is designed for broad audience interactions, allowing you to send messages to large groups of users. You can target either your entire user base or specific segments using Batch's segmentation features.

    This API supports the creation, updating, and deletion of campaigns, giving you full control over your messaging strategies.

    List orchestrations
    Get orchestrations stats
    Create campaign
    Update campaign
    Delete campaign

    Campaigns

    v1.0

    App Data

    GDPR

    Profile Data

    List export requests
    View export request
    Download export file
    Exporting Profiles

    If some action is triggered in your backend, changing that user's profile or triggering an event, you can call the Profile API to update the user's profile.

    Your Project key goes in the X-Batch-Project header. Example: X-Batch-Project: project_2bcdf83eubjhfdmk78jf.
    Custom User ID
    Profile Attributes
    events
    can be downloaded here
    curl --request POST \
      --url https://api.batch.com/2.0/audiences/create \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Bearer your_rest_key_here' \
      --header 'X-Batch-Project: your_project_key_here' \
      --data '{
      "name": "AUDIENCE_NAME",
      "display_name": "The audience description",
      "type": "custom_ids"
    }'
    Route

    The Audience API exposes a POST endpoint that allows to delete a audience :

    /audiences/remove

    NOTE: If the deleted audience is already used as a campaign targeting, Batch will consider it as an empty audience.

    Headers and authentication

    See Overview → Using Project APIs.

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the audience.

    Here is a how a complete JSON payload looks like:

    Responses

    Success

    If the call to the API endpoint is successful you will receive an HTTP 202 confirmation.

    Failure

    If the POST 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.

    See the list of potential failures in the API Description.

    create
    The Catalog API exposes a GET endpoint that allows to get information about an existing catalog:

    /catalogs/view

    Headers and authentication

    See Overview → Using Project APIs.

    Query parameters

    See the API Description.

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your catalog.

    The indexing_state is the processing status of updated catalog items that returned the given indexing_token. If there is no indexing token provided, no indexing state will be returned.

    2 values are possible for indexing state:

    • IN_PROGRESS : catalog item update processing is in progress

    • APPLIED : catalog item update processing is finished

    Failure

    If the POST 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.

    Route

    The Campaign API exposes a POST endpoint that allows to delete a campaign:

    /campaigns/delete

    Headers and authentication

    See Overview → Using Project APIs.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 204 confirmation.

    Failure

    If the POST 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.

    /exports/download

    Headers and authentication

    See Overview → Using Project APIs.

    Success

    Batch will respond with an HTTP status code: 307. The download link is located under the location section of the response header.

    The link to the file will expire after 20 minutes. You will need to call again the API to generate a new file.

    Failure

    If the POST 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.

    See the list of potential failures in the API Description.

    Overview → Using Project APIs
    support@batch.com

    Update

    See create to see an introduction about Audience API.

    API Description

    Request structure

    Route

    The Audience API exposes a POST endpoint that allows to add or delete users from an audience:

    /audiences/update

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the audience.

    Here is a how a complete JSON payload looks like:

    NOTE: If multiple actions are given for the same ID, only the last one will be taken into account.

    Responses

    Success

    If the PATCH to the API endpoint is successful you will receive an HTTP 202 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

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

    Processing time

    While the indexation of IDs is usually done in real time, we offer no guarantees. If you send a campaign right after the audience creation, you might end up with a campaign targeting nobody. A call to the view action with the indexing token replies with an APPLIED indexing state if the processing is finished (and IN_PROCESS if it is still ongoing).

    View

    See create to see an introduction about Audience API.

    API Description

    Request structure

    Route

    The Audience API exposes a GET endpoint that allows to get information about a audience :

    /audiences/view

    Headers and authentication

    See .

    Query parameters

    See the API Description.

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audience.

    The indexing state is the indexing state of the update that returned the given indexing token. If there is no indexing token provided, the state of the last update will be used. 3 values are possible for indexing state

    • IN_PROGRESS : update processing is in progress

    • APPLIED : update processing is finished

    • REPLACED : the audience content has been replaced since the issue of the indexing token.

    Failure

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

    See the list of potential failures in the API Description.

    List catalogs

    Use /catalogs/list to list existing catalogs.

    Request structure

    Route

    The Catalog API exposes a GET endpoint that allows to list catalogs :

    /catalogs/list

    Headers and authentication

    See .

    Query parameters

    See API Description.

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your catalogs.

    Pagination infos:

    • next_from can be used for the next call to list to retrieve the next page

    • count is only returned for the first page

    Failure

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

    See the list of potential failures in the API Description.

    Create catalog

    Use /catalogs/create to create a new catalog. You are allowed to create up to 5 catalogs per project.

    Request structure

    Route

    The Catalog API exposes a POST endpoint that allows to create an audience:

    /catalogs/create

    You will be allowed to create up to 5 catalogs for a project. A catalog can have up to 25 fields.

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the catalog.

    Here is a how a complete JSON payload looks like:

    Responses

    Success

    If the call to the API endpoint is successful you will receive an HTTP 201 confirmation.

    Failure

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

    DELETE - Remove

    The App Data API enables you to create, update, delete and list data you associated to your application. App Data lets you create tables of key/value pairs. It is for application centric data as opposed to user centric data. You can use the data in your targeting queries and/or in a message template.

    Request structure

    Route

    The App Data API exposes a DELETE endpoint that allows to delete a table:

    https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME

    Here is a valid cURL example:

    The TABLE_NAME value must be a string that only contains letters, numbers or the following characters: _, -.

    NOTE: Make sure before deletion that this App Data table is not used by any campaign.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 call to the API endpoint is successful you will receive an HTTP 200 confirmation and an empty json payload.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Remove catalog

    Use /catalogs/remove to remove an existing catalog.

    Request structure

    Route

    The Catalog API exposes a POST endpoint that allows to remove an existing catalog:

    /catalogs/remove

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the catalog.

    Here is a how a complete JSON payload looks like:

    Responses

    Success

    If the call to the API endpoint is successful you will receive an HTTP 202 confirmation.

    Failure

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

    DELETE - Remove

    The Custom Audience API 1.0 only accepts custom user IDs and avertising IDs. For audiences with install IDs, the version 1.1 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs or advertising IDs (GAID or IDFA).

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    Request structure

    Route

    The Custom Audience API exposes a DELETE endpoint that allows to delete a custom audience :

    https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value is the name of the existing audience you want this operation to be applied to.

    NOTE: If the deleted custom audience is already used as a campaign targeting, Batch will consider it as an empty custom audience.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 call to the API endpoint is successful you will receive an HTTP 200 confirmation.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    GET - Get all requests

    The Export API allows you to create export requests and get their status. This page documents the requests endpoint.

    Request structure

    Route

    The Export API exposes a GET endpoint to get last requests created and their status:

    https://api.batch.com/1.0/BATCH_API_KEY/export/requests

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 successful you will receive an HTTP 200 confirmation and information about last Export requests.

    This information is an array of all requests we currently know of for your application. The output contains requests created in the last 4 months (sorted desc and limited to ~1000) Each object in the array contains exactly the same information as you would get if you made a with the request id.

    Failure

    Same as GET request

    POST - Delete campaign

    The delete endpoint allows you to remove a campaign using its token number.

    Request structure

    Route

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

    POST - Delete In-App campaign

    The delete endpoint allows you to remove an In-App campaign using its token number.

    Request structure

    Route

    The In-App campaigns API exposes a POST endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/delete/CAMPAIGN_TOKEN

    Catalogs

    Catalogs API allow brands to Create, Update, Remove, List, View and Edit catalog items, making it easy to maintain up-to-date content—like products, events, or offers—that can be dynamically injected into your campaigns or automations.

    Rate Limiting

    To ensure fair usage and platform stability, all Catalog API endpoints are subject to rate limiting.

    General Catalog API rate limit

    All Catalog API endpoints (including Create,

    Profiles

    Profiles centralize data and events from multiple sources (apps, websites, APIs) in a single place based on the Custom ID.

    The Profiles API allows you to update profiles and create exports requests for Profile data.

    Profile updates: choosing the right API endpoint

    Two endpoints are available for profiles update, each optimized for distinct use cases.

    GET - View

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    Mass update profile

    Profiles centralize data and events from multiple sources (Apps, Websites, APIs) in a single place based on the Custom ID.

    Use /profiles/mass-update for large-scale periodic imports. Learn more about selecting the right endpoint here: .

    API Description

    GET - View

    The Custom Audience API 1.0 only accepts custom user IDs and avertising IDs. For audiences with install IDs, the version 1.1 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the .

    Request structure

    DELETE - Remove

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the .

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    Replace

    See to see an introduction about Audience API.

    API Description

    Request structure

    Prerequisites

    Creating an app

    Let's get going!

    The very first step is to go to and create a new iOS app.

    PATCH - Update

    The App Data API enables you to create, update, delete and list data you associated to your application. App Data lets you create tables of key/value pairs. It is for application centric data as opposed to user centric data. You can use the data in your targeting queries and/or in a message template.

    Request structure

    GET - Get request info

    The Export API allows you to create export requests and get their status. This page documents the request endpoint.

    Request structure

    Route

    {
      "name": "AUDIENCE_NAME"
    }
    {
        "name": "MOVIES",
        "items": 8807,
        "size": 7746977,
        "created": "2025-07-14T16:27:14Z",
        "updated": "2025-07-21T09:20:44Z",
        "fields": [
            {
                "name": "director",
                "type": "string"
            },
            {
                "name": "title",
                "type": "string"
            },
            {
                "name": "release_year",
                "type": "integer"
            },
            {
                "name": "cast",
                "type": "array"
            },
            {
                "name": "description",
                "type": "string"
            }
        ],
        "indexing_state": "APPLIED"
    }
    {
        "name": "MOVIES",
        "fields": [
            {
                "action": "add",
                "name": "director",
                "type": "string"
            },
            {
                "action": "remove",
                "name": "duration"
            }
        ]
    }
    Update
    ,
    Remove
    ,
    View
    , and
    List
    ) are limited to
    5 requests per second
    . If the limit is exceeded, the API returns an HTTP
    429 Too Many Requests
    response. When this occurs, please wait a few seconds before retrying.

    Specific limit for /catalogs/items/edit

    The /catalogs/items/edit endpoint has additional operational limits due to its higher data throughput:

    • Up to 5 requests per second.

    • Up to 1,000 items updated per second.

    • Each item in your payload counts as one update toward the limit.

    If either threshold is exceeded, the API will respond with an HTTP 429 Too Many Requests error. When that happens, slow down your requests or reduce the batch size to comply with the limit.

    Create catalog
    Remove catalog
    List catalogs
    Update catalog
    View catalog
    Edit catalog items
    1. /profiles/update endpoint

    This endpoint is designed for real-time profile updates or for frequent, small-sized batches. It is ideal for scenarios where updates are generated continuously ("as they happen"), such as individual modifications initiated by users or systems requiring light, regular synchronizations.

    • Primary usage:

      • Live updates.

      • Processing small volumes of frequent updates (e.g., if you batch modifications every 5mins to save on HTTP calls).

    • Bulk size: Up to 200 updates per call.

    • Rate limit: 300 updates per second.

    • Burst: Supports peaks up to 1000 updates.

    2. /profiles/mass-update endpoint

    This endpoint is optimized for ingesting large volumes of data, typically during massive synchronizations or partial or total database dumps. Its use is intended for less frequent operations, around one to two times per day. While it handles a much higher volume per second than /profiles/update, the total time to complete a full mass update task will be longer due to the volume of data.

    • Primary usage:

      • Massive database synchronizations (partial or complete).

      • Data "dump" type operations.

    • Bulk size: Up to 10,000 updates per call.

    • Rate limit: 10,000 updates per second.

    • Burst: No burst (the rate limit already sustains a significant volume).

    In summary, prioritize /profiles/update for continuous streams and rapid processing of small batches where quick data ingestion is key. Use /profiles/mass-update for large-scale periodic imports, understanding that while its per-second throughput is high for bulk, the overall task completion time for very large datasets will be longer than a single small update via /profiles/update.

    Exporting Profiles

    Requests to export profiles can be done via the Profiles API, via the export request type.

    The Profiles API allows you to export the following profiles data:

    • Export profile native attributes

    • Export profile custom attributes

    • Export profile identifiers

    • Export profile events

    The export request can be limited to segments defined in Batch, thanks to a filter capability, or request the full profile base.

    You can manage export requests via the Exports API. This other API allows you to:

    • list exports

    • view export requests

    • download exports requested

    Update profile
    Mass update profile
    Export profile data
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • support@batch.com
    GET request
    failures
    Request structure

    Route

    The Custom Audience API exposes a GET endpoint that allows to get information about a custom audience :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Get parameters

    Id
    Description

    indexing_token

    String - Optional The indexing token returned by the replace and update routes. E.g."/custom-audience/audience1?indexing_token=INDEXING_TOKEN"

    Here is an example of a valid cURL CLI request :

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audience.

    The indexing state is the indexing state of the update that returned the given indexing token. If there is no indexing token provided, the state of the last update will be used.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Route

    The Custom Audience API exposes a GET endpoint that allows to get information about a custom audience :

    https://api.batch.com/1.0/BATCH_API_KEY/custom-audience

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Get parameters

    [ { "id": "indexing_token", "type": "String", "req": "Optional", "desc": "The indexing token returned by the replace and update routes.", "ex": "/custom-audience/audience1?indexing_token=INDEXING_TOKEN" } ]

    Here is an example of a valid CURL CLI request :

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audience.

    The indexing state is the indexing state of the update that returned the given indexing_token. If there is no indexing token provided, the state of the last update will be used.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Campaigns API
    Request structure

    Route

    The Custom Audience API exposes a DELETE endpoint that allows to delete a custom audience :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value is the name of the existing audience you want this operation to be applied to.

    NOTE: If the deleted custom audience is already used as a campaign targeting, Batch will consider it as an empty custom audience.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 call to the API endpoint is successful you will receive an HTTP 200 confirmation.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Campaigns API
    Route

    The App Data API exposes a PATCH endpoint that lets you add, update or delete keys and their associated values from a table:

    https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME

    Here is a valid cURL example:

    The TABLE_NAME value must be a string that only contains letters, numbers or the following characters: _, -.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Patch data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the App Data table.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    [ { "id": "overwrite", "type": "boolean", "req": "Required", "desc": "Determines whether all the table data should be overwritten" }, { "id": "values", "type": "object", "req": "Required", "desc": "A dictionary of key/value. A value must be a string or null. A null value will delete the associated key. Supports up to 10,000 elements." } ]

    NOTE: In overwrite mode, null values are not supported.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an empty json payload.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Processing time

    While the indexation of application data is usually done in realtime, we offer no guarantees. If you send a campaign right after the app-data creation, you might end up with missing keys.

    The Export API exposes a GET endpoint to get the status of a single Export request if created less than 6 months ago:

    https://api.batch.com/1.0/BATCH_API_KEY/export/request/REQUEST_ID

    Here is a valid cURL example:

    The REQUEST_ID value is the token you get when creating the request.

    The BATCH_API_KEY value is your Live Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 POST to the API endpoint is successful you will receive an HTTP 200 confirmation and the following information:

    The file_url value contains a URL. That URL is a redirection to the CSV file containing the data you requested. To retrieve the download link, use the provided URL to make a second GET request passing the X-Authorization header.

    Here is a valid cURL example:

    Batch will respond with an HTTP status code: 302. The download link is located under the location section of the response header.

    The error_msg field will give you information about what went wrong.

    The link to the csv file wil expire after 20 minutes. You will need to call again the API to generate a new file.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (HTTP status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (HTTP status code: 400, Error code: 31)

    • SERVER_ERROR (HTTP status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (HTTP status code: 503, Error code: 2)

    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X DELETE "https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X DELETE "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X GET "https://api.batch.com/1.0/BATCH_API_KEY/export/requests"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.1/BATCH_API_KEY//custom-audience/audience1?indexing_token=INDEXING_TOKEN"
    {
      "name": "audience1",
      "type": "install_ids",
      "description": "The audience1 description",
      "created": "2018-06-29T13:12:09",
      "updated": "2018-06-29T13:42:59",
      "nb_ids": 16743,
      "indexing_state": "IN_PROGRESS" // IN_PROGRESS, APPLIED
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.0/BATCH_API_KEY//custom-audience/audience1?indexing_token=INDEXING_TOKEN"
    {
      "name": "audience1",
      "type": "custom_ids",
      "description": "The audience1 description",
      "created": "2018-06-29T13:12:09",
      "updated": "2018-06-29T13:42:59",
      "nb_ids": 16743,
      "indexing_state": "IN_PROGRESS" // IN_PROGRESS, APPLIED
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X DELETE "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X PATCH -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME"
    {
      "overwrite": true,
      "values": {
        "aKey1": "value to add",
        "aKey2": null // value to delete
      }
    }
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X GET "https://api.batch.com/1.0/BATCH_API_KEY/export/request/REQUEST_ID"
    {
      "id": "9aed764e-7a79-4197-b378-df82da994f78",
      "uri": "/1.0/BATCH_API_KEY/inapp-campaign/CAMPAIGN_TOKEN/events",
      "request_date": "2019-08-14T22:00:00",
      "file_url": "https://api.batch.com/1.0/API_KEY/export/request/REQUEST_ID/results/filename.csv",
      "status": "CREATED|PENDING|ERROR|SUCCESS|EXPIRED",
      "completion_date": "2019-08-14T22:00:00",
      "request" :  
      {
        "from": "2019-08-14T22:00:00",
        "to": "now",
        "events": ["push_sent", "push_open"],
        "ids": ["install_id", "custom_id", "advertising_id"],
      }
    }
    curl -i -H "X-Authorization: BATCH_REST_API_KEY" \
         -X GET ""https://api.batch.com/1.0/API_KEY/export/request/REQUEST_ID/results/FILENAME.csv""

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

    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/delete/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/delete/CAMPAIGN_TOKEN", [
    	"headers" => [
    		
    
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/delete/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General).

    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 POST to the API endpoint is successfull you will receive an HTTP 200 confirmation.

    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.

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

    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/delete/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/delete/CAMPAIGN_TOKEN", [
    	"headers" => [
    		
    
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/delete/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    

    The CAMPAIGN_TOKEN value is the token you receive when you successfully create an In-App 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 POST to the API endpoint is successful you will receive an HTTP 200 confirmation.

    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.

    Rate Limiting

    To ensure fair usage and platform stability, the /profiles/mass-update endpoint is subject to rate limiting, following the Token Bucket algorithm:

    • API rate: Up to 10000 profile updates per second are allowed.

    • Burst capacity: No burst

    • If you exceed these limits, the API will respond with an HTTP 429 Too Many Requests error. When you receive this error, please wait a few seconds before retrying, as further attempts may continue to be rejected until your rate falls back within the allowed limits.

    Note that our API rate limit is measured in updates per second.

    Unlike other API rate limits which are often measured in requests per second or minute, our rate is calculated based on the number of Custom IDs processed within your requests.

    What constitutes one "update"? One update corresponds to the processing associated with a single Custom ID included in your request. For example, if a request contains data for 10 different Custom IDs, it will consume 10 updates from your rate limit, regardless of the number of attributes updated or events tracked for each individual Custom ID within that same request.

    This unit of measurement has been chosen to effectively manage the processing load, particularly when utilizing bulk operations. Processing multiple Custom IDs in a single bulk request is more efficient, and tracking the rate by the number of IDs processed (updates) ensures fair usage and system stability under heavy load from bulk submission.

    Request structure

    Route

    The Profile API exposes a POST endpoint that allows to update a batch of profiles:

    /profiles/mass-update

    You can update one or several profiles via this endpoint, within the limit of 10 000 profiles.

    Headers and authentication

    See Overview → Using Project APIs.

    See Update profile for more details & examples on the request payload & error management.

    Failure

    If the POST 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)

    • ROUTE_NOT_FOUND (HTTP status code: 404, error_code: 20)

    • MISSING_PARAMETER (HTTP status code: 400, error_code: 30)

    • MALFORMED_PARAMETER (HTTP status code: 400, error_code: 31)

    • MALFORMED_JSON_BODY (HTTP status code: 400, error_code: 32)

    • SERVER_ERROR (HTTP status code: 500, error_code: 1)

    • MAINTENANCE_ERROR (HTTP status code: 503, error_code: 2)

    • 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.

    Profile updates: choosing the right API endpoint
    Route

    The Audience API exposes a POST endpoint that allows to replace all audience profiles. It removes all previously added profiles and adds the given ones:

    /audiences/replace

    Headers and authentication

    See Overview → Using Project APIs.

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the audience.

    Here is a how a complete JSON payload looks like:

    NOTE: If multiple actions are given for the same ID, only the last one will be taken into account.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a token.

    Once you get your token, you can use it to check the indexing state of this update with the API.

    Failure

    If the POST 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.

    See the list of potential failures in the API Description.

    Processing time

    While the indexation of IDs is usually done in real time, we offer no guarantees. If you send a campaign right after the audience creation, you might end up with a campaign targeting nobody. A call to the view action with the indexing token replies with an APPLIED indexing state if the processing is finished (and IN_PROCESS if it is still ongoing).

    create
    Configuring notifications

    Once your app is created, you will need to download a .p8 file and upload it to Batch's Dashboard.

    As a reminder, Batch servers need to have a valid certificate in order to communicate with Apple Push Notification Services (APNS). There are two types of files you can use:

    • .p8 files (recommended) : Valid for all the apps added to your Apple developer account. You will need to specify the Application Identifier (App ID) or the Bundle ID of your app on Batch's dashboard.

    • .p12 certificates: Generated for a unique App ID and are only valid for one year. If you need a .p12 certificate, please follow these instructions: Generating a .p12 certificate.

    Step 1. Downloading the .p8 file

    Head to the Apple Developer Member center, then go to the "Keys" menu and add a new key.

    Adding a key

    Give a name to your key, tick the "Apple Push Notifications Service" box (1) and press "Configure" (2).

    Configuring the key

    There, in the "Environment" dropdown, select "Sandbox & Production".

    Configuring the environment

    Click "Save" and continue until you can download the P8 key. Write down your Key ID.

    Step 2. Uploading the .p8 file

    Now go to Batch's dashboard → ⚙ Settings → Push settings, and upload your .p8 file.

    Uploading your certificate

    There are two IDs you need to find to save your certificate and send notifications to your app:

    • App ID / Bundle ID: We recommend you use the bundle ID you will find in Xcode. You can also use the app ID available from the Developer Console here.

    • Team ID: The team ID is also available from the Developer Console here. It is also shown under your name in the top bar of the place you created your p8 key.

    • Key ID: The Key ID should be automatically filled if you didn't rename the p8 file you downloaded from Apple. If it was not, use the Key ID you have written down earlier. You can also find the Key ID in the Apple Developer Member center, where you generated it.

    License Attribution

    As Batch uses open-source software, you must include attribution text in your application. This usually goes in a "Legal Notices" or "About" screen.

    You can get the attribution text here.

    Batch's dashboard
    Registering a new app
    Overview → Using Project APIs
    check the indexing state
    support@batch.com
    Overview → Using Project APIs
    support@batch.com
    Overview → Using Project APIs
    support@batch.com
    Overview → Using Project APIs
    support@batch.com
    Overview → Using Project APIs
    support@batch.com

    Update campaign

    It allows to update some parameters of a campaign.

    API Description

    Request structure

    The Campaign API exposes a POST endpoint that allows to update a campaign:

    /campaigns/update

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the campaign.

    Exemple of a request body:

    identifier block

    Campaign identifier is received in the API Campaign create response.

    Campaign block

    See for details about parameters.

    Responses

    Success

    If the POST to the API endpoint is successfull you will receive an HTTP 200 confirmation.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    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:

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

    Note: Only LIVE API Keys are supported by this API

    Get parameters

    Id
    Description

    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 :

    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.

    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 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)

    API Changelog

    2025/11/21

    Version 2.8: Profile API Updates

    Added support for new Mobile Landing & In-App event types

    New event types:

    • in_app_delivered

    • in_app_click

    • in_app_dismissed

    • mobile_landing_delivered

    • mobile_landing_click

    • mobile_landing_dismissed

    Added support for new SMS event type

    New event type:

    • sms_click

    Added open_type field to push_open events

    Possible values: direct, influenced.

    Added support for installation_id as an identifier

    Now supported on relevant events (push, mobile_landing, in-app).

    2025/11/05

    Version 2.8: Create and Update campaign API

    • Support for "DRAFT" state

    • Support for up to 5 pre-created labels

    2025/10/07

    Version 2.7 : Audience API support email and install_id keys.

    2025/08/07

    Version 2.6 : The now supports a filter parameter to allow exporting profiles by segment.

    2025/07/03

    Version 2.5 :

    • Orchestration API is now available and allows you to list all CEP orchestrations and gather messages analytics for one specific orchestration

    • Add send rate support to

    2025/06/06

    Version 2.4: We added a to manage mass updates.

    2025/01/31

    SMS & Push event type support

    Version 2.4: We added SMS & Push event type support to .

    Available new event types: sms_sent, sms_delivered, sms_bounced, sms_unsubscribed, push_sent, push_open, push_bounced.

    Orchestration ID filter

    Version 2.4: We added filter by orchestration ID support to .

    2024/12/03

    Multi-language support

    Version 2.4: Multi-language support has been added to the . You can now use the languages array to define content translations.

    Specific platform targeting & Web Push support

    Version 2.4: Changes for :

    • Added support for sending pushes to the web platform through API.

    • Added platform targeting: you can now use platform_type to select what kind of platform you want to target. Breaking: platform_type is a new, required field with no default value: if want to send to all platforms, set the value to "ios","android","web". Version 2.3 and lower of the API will only send to iOS and Android.

    Imported-tokens support

    Version 2.4: Added imported tokens support to .

    2024/08/12

    Version 2.3: Added Push Notifications support to

    2024/07/20

    Version 2.0: Added events export to

    POST - Update campaign

    The update endpoint allows you to update campaigns created from the API.

    Request structure

    Route

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

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

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General).

    The CAMPAIGN_TOKEN value is the token you receive when you 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.

    Post data

    The body of the request must contain a containing at least the same number of parameters you used when you first created your campaign or more.

    Please note that: - Complete campaigns cannot be set live again. - Parameters added after an update cannot be removed. - You cannot switch back to a one-time campaign after chosing a recurring campaign.

    Responses

    Success

    If the POST to the API endpoint is successfull you will receive an HTTP 200 confirmation.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    List export requests

    The export API allows you to list all export requests and get their status.

    This information is an array of all requests we currently know of for your application. The output contains requests created in the last 3 months. Each object in the array contains exactly the same information as you would get if you made a GET request with the request id.

    API Description

    Request structure

    Route

    The Export API exposes a GET endpoint that allows you to list all export requests and get their status :

    /exports/list

    Headers and authentication

    See .

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your export requests.

    Some information are only available when the status field is SUCCESS.

    If your export request returns no data, the files array will be empty.

    Pagination infos:

    • next_from can be used for the next call to list to retrieve the next page

    • count is the number of items in the current page

    Failure

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

    See the list of potential failures in the API Description.

    Create

    API Description

    Request structure

    Route

    The Audience API exposes a POST endpoint that allows to create an audience:

    /audiences/create

    Headers and authentication

    See .

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the audience.

    Here is a how a complete JSON payload looks like:

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

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

    List orchestrations

    Request structure

    Route

    The orchestration API exposes a GET endpoint that allows you to export a list of Orchestrations with key information like name, creation date, and channel.

    /orchestrations/list

    Headers and authentication

    See .

    Query parameters

    See the API Description.

    Responses

    Success

    A successful GET request to this endpoint will return an HTTP 200 OK response. The body of the response will contain a JSON array of orchestration objects that match the provided query parameters.

    Each orchestrations in the array includes the following fields :

    • id (string) : A unique identifier for the orchestration. This identifier can also be used to query for the orchestration's statistics.

    • type (string) : The type of orchestration. Possible values are campaign, recurring, or trigger.

    • Core details : source, name, status, created_date, start_time, channels

    Note: The content of the messages is not included in the response.

    If your request returns no data, the orchestrations array will be empty.

    Pagination infos:

    • next_from can be used for the next call to list to retrieve the next page

    • count is the number of items in the current page

    Failure

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

    See the list of potential failures in the API Description.

    View export request

    The export API allows you to retrieve a specific export request with its ID.

    API Description

    Route

    The Project Export API exposes a GET endpoint that allows to get information about an export request:

    /exports/view

    Headers and authentication

    See .

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your export request.

    The response includes all the extraction files available for download if any (in the files field). The files can be downloaded via the provided URL in the url field (see ). Depending on the amount of data extracted, a request may have multiple output JSON files with a maximum size of 100MB.

    Some information are only available when the status field is SUCCESS. 5 values are possible for request status:

    • CREATED: for export request created and not yet PENDING

    • PENDING: for export request ready-to-execute

    • RUNNING: for export request being executed

    Failure

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

    See the list of potential failures in the API Description.

    GET - Get all requests

    The GDPR API allows you to create GDPR requests and get their status. This page documents the requests endpoint.

    Request structure

    Route

    The GDPR API exposes a GET endpoint to get all requests stored:

    https://api.batch.com/1.0/BATCH_API_KEY/gdpr/requests

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 successful you will receive an HTTP 200 confirmation and information about all GDPR requests.

    This information is an array of all requests we currently know of for your application.

    Here is an example:

    Each object in the array contains exactly the same information as you would get if you made a with the request id.

    Note: Expired requests are not returned by this API.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    POST - Update In-App campaign

    The update endpoint allows you to update In-App campaigns created from the API.

    Request structure

    Route

    The campaigns API exposes a POST endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/update/CAMPAIGN_TOKEN

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

    The CAMPAIGN_TOKEN value is the token you receive when you an In-App 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.

    Post data

    The body of the request must contain a containing at least the same number of parameters you used when you first created your campaign or more.

    Please note that: - Parameters added after an update cannot be removed.

    Responses

    Success

    If the POST to the API endpoint is successfull you will receive an HTTP 200 confirmation.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    API - Mobile Engagement Platform

    What are the Batch APIs?

    With Batch RESTful APIs you can easily send custom data and push notifications to take advantage of Batch’s advanced features from your own systems. There are 7 APIs you can use to cover your needs: engaging with your users, sending custom user data and being GDPR-compliant.

    Engage your users

    All Batch engagement channels: Mobile push, Web push and In-App messages can be completely used remotely via our APIs.

    • The is made for 1-to-1 or 1-to-few interactions. It allows you to send push notifications to a specific list of user IDs (push token, Advertising IDs or Custom User IDs) based on events in your back-end (e.g. "You have a new friend request").

    • The is made for 1-to-many interactions. It allows you to send push notifications in mass to your users according to (using your custom data or Batch generated data) or with your own segmentation engine with .

    • The allows you to send customized to your users, the targeting method being quite close to the Campaigns API.

    Send custom data

    You probably want to send Batch some custom data for campaign targeting and message personnalisation purposes. Our APIs enables you to send us data at three different scale: the app, a group of users and a single user.

    • The allows you to send custom data you associated to your application. This is particularly useful if you need app-level in your campaigns, such as dates or attributes (e.g. Quick! Premium subscription discount will end in 3 days)

    • The allows you to send Batch specific lists of user IDs for your push and In-App campaign targeting. Your own segmentation will then be available on the dashboad as a .

    • The to send custom data on specific custom user IDs to improve your campaign targetings and personnalization with your own custom data.

    Protecting your users' data

    Being GDPR-compliant, Batch let you make requests to fetch and/or delete user data from our database. Our allows you to make those requests and regain control of Batch's collected user data.

    Get data export

    Batch let you make requests to get data from our database. Our allows you to make those requests and get back data concerning to your audience.

    Take a look at if you want to know more on how to use our APIs.

    How do I get started?

    Prerequisites

    Before sending your first notification with Batch REST API, make sure you have:

    • Your Batch REST API key.

    • Your app API key or your website SDK API key.

    You will find these IDs in your app settings, on Batch dashboard (⚙️ Settings → General). Please note you need to be the manager of the account to see the REST API key.

    Request headers

    You will need to use the same api keys and headers for both the campaigns or the transactional API. Here is an example of a valid request syntax:

    • BATCH_REST_API_KEY is your REST API key. It goes in the X-Authorization header.

    • BATCH_API_KEY is you app API key or the SDK API key of your website. It is the one that goes in the URL.

    DELETE - Remove

    Note: The Custom Data API is a feature included in Premier and Enterprise plans.

    Request structure

    The users data endpoint allows you to delete user data either for one user, or for multiple users.

    Important Note: Any data changed by calling this API will not be available in real time: processing time can be requires. See this section for more info.

    Route

    The custom data API exposes two DELETE endpoints:

    • https://api.batch.com/1.0/BATCH_API_KEY/data/users/YOUR_USER_ID for a single delete

    • https://api.batch.com/1.0/BATCH_API_KEY/data/users for bulk deletes

    NOTE: YOUR_USER_ID is a custom id as described for iOS and for Android.

    Bulk delete allow you to remove custom data for multiple users with one API call.

    Here are two valid cURL examples.

    Single delete:

    Bulk deletes:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General). You can find it in ⚙ Settings → General.

    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.

    Single delete

    For a single delete, there is no payload. You only need to provide the user id in the route.

    Bulk deletes

    For bulk deletes, you need to provide a valid JSON payload containing the list of user ids for whom to remove the custom data.

    Here is a how a complete JSON payload looks like:

    NOTE: there is a limit of 10000 user ids per API call.

    Responses

    Success

    If the DELETE to the API endpoint is successful you will receive an HTTP 200 confirmation and a unique token reprensenting the transaction.

    Please keep this token: it will be useful for upcoming features, and it will also help in getting faster support.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    GET - List

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    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:

    GET - Get request

    The GDPR API allows you to create GDPR requests and get their status. This page documents the request endpoint.

    Request structure

    Route

    POST - Create

    The App Data API enables you to create, update, delete and list data you associated to your application. App Data lets you create tables of key/value pairs. It is for application centric data as opposed to user centric data. You can use the data in your targeting queries and/or in a message template.

    Request structure

    GET - List

    The App Data API enables you to create, update, delete and list data you associated to your application. App Data lets you create tables of key/value pairs. It is for application centric data as opposed to user centric data. You can use the data in your targeting queries and/or in a message template.

    Request structure

    Get orchestrations stats

    Request structure

    Route

    The orchestration API exposes a GET endpoint that allows you to export message analytics for a specific Orchestration within a defined date range. This includes metrics such as sent, open, and click counts, with daily granularity.

    GET - View In-App campaign

    The get endpoint allows you to get details about an In-App campaign using its unique token.

    Request structure

    Route

    The In-App campaigns API exposes a GET endpoint at:

    Parameters

    The Event object

    The Event object represents the event being tracked for a given Custom User ID. You can enrich events to pass any relevant data, which will be later used to trigger personalized messages.

    Id
    Description

    List

    See to see an introduction about Audience API.

    API Description

    Request structure

    {
        "error_code": "MALFORMED_PARAMETER",
        "error_message": "Invalid project key project_062ay7ywmgvqccwanj647mmqm1smq2k"
    }
    {
      "name": "AUDIENCE_NAME",
      "ids": [
        {
          "id": "INSTALL-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2012-08-12T22:30:05"
          }
        },
        {
          "id": "INSTALL-ID-2",
          "attributes": {
            "att1": 2,
            "att2": "string",
            "date(att15)": "2013-08-12T22:30:05"
          }
        }
      ]
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    {
      "name": "AUDIENCE_NAME",
      "ids": [
        {
          "action": "add",
          "id": "CUSTOM-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2023-08-12T22:30:05Z",
            "url(att20)": "https://example.com/image.jpg"
          }
        },
        {
          "action": "add",
          "id": "CUSTOM-ID-2",
          "attributes": {
            "att1": 2,
            "att2": "string",
            "date(att15)": "2023-08-12T22:30:05Z",
            "url(att20)": "https://example.com/image.jpg"
          }
        }
      ]
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    {
      "name": "string",
      "display_name": "MBE123",
      "type": "CUSTOM_ID",
      "nb_ids": 2,
      "indexing_state": "APPLIED",
      "created": "2023-10-03T09:35:08Z",
      "updated": "2023-10-03T09:35:08Z"
    }
    
    {
      "catalogs": [
        {
          "name": "MOVIES",
          "items": 8807,
          "size": 7746977,
          "created": "2025-07-14T16:27:14Z",
          "updated": "2025-07-21T09:20:44Z",
          "fields": [
            {
              "name": "director",
              "type": "string"
            },
            {
              "name": "title",
              "type": "string"
            },
            {
              "name": "release_year",
              "type": "integer"
            },
            {
              "name": "cast",
              "type": "array"
            },
            {
              "name": "description",
              "type": "string"
            }
          ]
        }
      ],
      "count": 3,
      "has_more": false,
      "next_from": "676DEZREZ"
    }
    {
        "name": "MOVIES",
        "fields": [
            {
                "name": "director",
                "type": "string"
            },
            {
                "name": "title",
                "type": "string"
            },
            {
                "name": "release_year",
                "type": "integer"
            },
            {
                "name": "cast",
                "type": "array"
            }
            {
                "name": "description",
                "type": "string"
            }
        ]
    }
    {
        "name": "MOVIES"
    }
    )
    "Content-Type"
    =>
    "application/json"
    ,
    "X-Authorization" => "BATCH_REST_API_KEY"
    ]
    ]);
    )
    "Content-Type"
    =>
    "application/json"
    ,
    "X-Authorization" => "BATCH_REST_API_KEY"
    ]
    ]);
    Profile API export route
    campains API
    new endpoint to the Profile API
    Profile API
    Profile API
    Project Campaign API
    Project Campaign API
    Project Campaign API
    Project Campaign API
    Profile API - Export profile data
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • 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.

  • successfully create
    valid JSON payload
    support@batch.com
    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/update/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY" \
    -d '{
    	"name": "Updated Test Campaign Name",
    	"live": true
    }'
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/update/CAMPAIGN_TOKEN", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	],
    	"json" => [
    		"name" => "Updated Test Campaign Name",
    		"live" => true
    	]
    ]);
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/update/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	},
    	data=json.dumps({
    		'name': 'Updated Test Campaign Name',
    		'live': True
    	})
    )
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • 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.

  • successfully create
    valid JSON payload
    support@batch.com
    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/update/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY" \
    -d '{
    	"name": "Updated Test Campaign Name",
    	"live": true
    }'
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/update/CAMPAIGN_TOKEN", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	],
    	"json" => [
    		"name" => "Updated Test Campaign Name",
    		"live" => true
    	]
    ]);
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/update/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	},
    	data=json.dumps({
    		'name': 'Updated Test Campaign Name',
    		'live': True
    	})
    )
    SERVER_ERROR (Http status code: 500, Error code: 0)

    since

    String - 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"

    until

    String - 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"

    create
    support@batch.com
    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"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	]
    ]);
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    )
    MISSING_PARAMETER (HTTP status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (HTTP status code: 400, Error code: 31)

  • SERVER_ERROR (HTTP status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (HTTP status code: 503, Error code: 2)

  • GET request
    support@batch.com
    Transactional API
    Push Campaigns API
    targeting criteria
    Custom Audiences
    In-App campaigns API
    In-App messages
    App Data API
    Custom Audience API
    Custom Audience
    Custom Data API
    GDPR API
    Export API
    this guide
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • here
    here
    support@batch.com
    Request structure

    Route

    The Custom Audience API exposes a GET endpoint that allows to list custom audiences :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Get parameters

    Id
    Description

    from

    Integer - Optional, Default : 0 Value used for pagination : it indicates the offset of the first custom audience to be returned. Custom audiences are ordered by creation date (from the most recent to the oldest). E.g."/custom-audience?from=10"

    limit

    Integer - Optional, Default : 10, Max : 100 Value that indicates the number of custom audiences to be returned per API call. E.g."/custom-audience?limit=20"

    Here is an example of a valid cURL CLI request, which would return 5 custom audiences, starting from the 10th audience :

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audiences.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Route

    The App Data API exposes a GET endpoint that lets you list App Data tables:

    https://api.batch.com/1.0/BATCH_API_KEY/app-data

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Get parameters

    Id
    Description

    from

    Integer - Optional, Default : 0 Value used for pagination : it indicates the offset of the first table to be returned. Tables are sorted by creation date (from the most recent to the oldest). E.g."/app-data?from=10"

    limit

    Integer - Optional, Default : 10, Max : 100 Value that indicates the maximum number of tables to be returned per API call. E.g."/app-data?limit=20"

    Here is an example of a valid cURL command which would return 5 tables, starting from the 10th table (sorted by creation date in descending order):

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audiences.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Date - Optional The time date and time an event occurred. It has to respect YYYY-MM-ddTHH:mm:ss format. You can track events that happened in the last 24 hours, and no events in the future. If this parameter is not included in your request, Batch will use the time the event arrives at the server. E.g.{"time":"2012-08-12T22:30:05"}

    label

    String - Optional The event label (up to 200 characters). E.g.{"label":"shoes"}

    attributes

    Object - Optional An object containing all attributes you would like to attach to the event (up to 15 attributes). E.g.{"attributes":{"sub_category":"boots"}}

    tags

    Array - Optional An array containing all tags to attach to the event (up to 10 tags, maximum 64 chars per tag). E.g.{"tags":["private-sales","summer-discount"]}

    If limits are not respected, an error will be returned.

    The Attributes object

    You can attach up to 15 attributes to an event sent with the Trigger Events API.

    Naming

    Attribute names are strings. They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters (e.g. "sub_category").

    Values

    Values can be any of the following type:

    • string: up to 64 characters, e.g.{"sub_category": "shoes"}

    • integer: up to 64 characters, e.g.{"level": 23}

    • boolean: e.g.{"is_premium": true}

    • float: e.g.{"level_progress": 45.09}

    Additional types

    Date

    We support dates, unfortunately JSON does not, thus we need extra information to know an attribute is actually a date. We do this via wrapping the key name in the date() function.

    If you're using date() on a string, be sure to use the format YYYY-MM-ddTHH:mm:ss. Be aware that we will interpret the date as UTC in both cases.

    URL

    URL type is also supported. You will need to wrap the key name in the url() function.

    You need to provide a valid URL, in the limit of 2048 characters:

    • A scheme is compulsory (myapp://, https://...)

    • :// is compulsory after the scheme

    If the URL provided isn't valid, the API call will fail.

    name

    string - Required Event name E.g.{"name":"ue.added_to_cart"}

    time

    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"
    {
        "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
            }
        ]
    }
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X GET "https://api.batch.com/1.0/BATCH_API_KEY/gdpr/requests"
    [
      {
        "request_id": "6c256bd1-485a-47d1-8c36-7e3d5be013aa",
        "request_date": "2021-01-03T16:52:16.051",
        "status": "done",
        "request_type": "review",
        "trigger_type": "api",
        "error": "user not found",
        "id": {
          "type": "advertising_id",
          "value": "196b3360-59d7-408a-8e99-c4be99c4fff0"
        }
      },
      {
        "request_id": "b17774dc-3a97-41af-be5f-6ed3fd09f032",
        "request_date": "2021-01-19T16:52:16.051",
        "status": "pending",
        "request_type": "review",
        "trigger_type": "api",
        "id": {
          "type": "custom_id",
          "value": "john.doe"
        }
      },
      {
        "request_id": "7e2142f1-b0a3-4ed0-aef3-67d3f41270b6",
        "request_date": "2020-11-04T10:37:06.512",
        "status": "done",
        "error": "user not found",
        "request_type": "remove",
        "trigger_type": "dashboard",
        "id": {
          "type": "custom_id",
          "value": "foobar"
        }
      }
    ]
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d
    "@payload.json" "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/create"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/stats/CAMPAIGN_TOKEN"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X DELETE "https://api.batch.com/1.0/BATCH_API_KEY/data/users/YOUR_USER_ID"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X DELETE -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/data/users"
    ["user1", "user2", "user3"]
    { "token": "fd576e9f-8b07-4844-91f9-ecfc2137c6f8" }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.1/BATCH_API_KEY/custom-audiences?from=10&limit=5"
    {
      "custom_audiences": [
        {
          "name": "audience2",
          "type": "custom_ids",
          "description": "The audience2 description",
          "nb_ids": 23764,
          "created": "2018-06-29T14:59:03",
          "updated": "2018-06-29T15:07:32"
        },
        {
          "name": "audience1",
          "type": "advertising_ids",
          "description": "The audience1 description",
          "nb_ids": 16743,
          "created": "2018-06-29T13:12:09",
          "updated": "2018-06-29T13:42:59"
        }
      ]
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET "https://api.batch.com/1.0/BATCH_API_KEY/app-data"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.0/BATCH_API_KEY/app-data?from=10&limit=5"
    {
      "app_data": [
        {
          "name": "your_table_name",
          "description": "The table description",
          "nb_rows": 135, // the number of keys
          "size": 40500, // the size in bytes
          "created": "2018-06-29T14:59:03",
          "updated": "2018-12-29T15:07:32"
        },
        {
          "name": "another_table",
          "description": "The table description",
          "nb_rows": 268,
          "size": 80800, // the size in bytes
          "created": "2018-06-29T13:12:09",
          "updated": "2018-06-29T13:42:59"
        }
      ]
    }
    {
      "date(promo_starts)": 1451642400,
      "date(promo_ends)": "2021-01-01T04:00:00.000"
    }
    {
      "url(product_image)": "https://batchstore/product/4729/image.png",
      "url(product_deeplink)": "myapp://path/to/content"
    }
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • 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.

  • Overview → Using Project APIs
    API Campaigns create
    support@batch.com

    The following additional fields may also be present if applicable:

    • labels (array): An array of labels associated with the orchestration. This is available for all orchestration types.

    • recurrence (object): A block of data describing the recurrence rules. This field is only present for recurring orchestrations.

    • messages_steps (array): An array of objects, where each object represents a step in the message flow and includes its step_name and step_id. This field is only present for triggerorchestrations.

    Overview → Using Project APIs
    support@batch.com
    SUCCESS: for export request completed with success
  • ERROR: for export request terminated with an error

  • Overview → Using Project APIs
    Download export API
    support@batch.com
    https://api.batch.com/1.1/BATCH_API_KEY/campaigns/stats/CAMPAIGN_TOKEN

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

    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"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/stats/CAMPAIGN_TOKEN", [
    	"headers" => [
    		
    
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/stats/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'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.

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

    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.

    The GDPR API exposes a GET endpoint to get the status of a single GDPR request:

    https://api.batch.com/1.0/BATCH_API_KEY/gdpr/request/REQUEST_ID

    Here is a valid cURL example:

    The REQUEST_ID value is the token you get when creating the request.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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 successful you will receive an HTTP 200 confirmation and information about the GDPR request.

    Fields breakdown

    Following is the detail about each possible field in the response object.

    Id
    Description

    request_date

    String - The date at which the request was made (always in UTC).

    status

    String - Indicates the status of the request. There are two possible states, `pending` which means the request is currently being processed, `done` which means the request has been processed.

    request_type

    String - Indicates if the request is to either `review` or `remove` the data. This is the same thing you provide when calling the API to create a request.

    trigger_type

    String - Indicates if the request was created via the Batch dashboard or via the public API. Possible values are `dashboard` or `api`.

    error

    String - Indicates if there was an error processing the request.

    data_url

    String - Only present if the `request_type` is `review`. This is a link to a zip file containing the data.

    Details about the error field

    The error field is a generic field indicating something went wrong while processing the request.

    Right now only the user not found error is possible.

    Examples

    • Finished review request :

    • Pending request :

    • Finished remove request :

    • Request in error :

    Note: Expired requests are not returned by this API.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (HTTP status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (HTTP status code: 400, Error code: 31)

    • SERVER_ERROR (HTTP status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (HTTP status code: 503, Error code: 2)

    Route

    The App Data API exposes a POST endpoint that lets you create a table:

    https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME

    Here is a valid cURL example:

    The TABLE_NAME must be a string that only contains letters, numbers or the following characters: _, -.

    Since the available table size is limited we strongly encourage you to set the retention on your data and watch closely how much size your table is using, especially if you're inserting values into the same table on a regular basis.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload optionally containing the description, and time_to_live (retention).

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    description

    string - Optional Description of the Application Data table. E.g.{"description":"The table description"}

    time_to_live

    integer - Optional The time to live (retention) of the values once they've been set by the update method. In days E.g.{"time_to_live":24}

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and an empty json payload.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • ENTITY_ALREADY_EXISTS (Http status code: 400, Error code: 33)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    /orchestrations/stats

    Headers and authentication

    See Overview → Using Project APIs.

    Query parameters

    See the API Description.

    Responses

    Success

    A successful GET request to this endpoint will return an HTTP 200 OK response. The body of the response will contain a JSON object with the statistics for the requested orchestration over the specified date range.

    Response Body

    The main JSON object contains the following fields:

    • id (string): The unique identifier of the orchestration for which statistics are being returned.

    • details (array): An array of objects, where each object contains the daily statistics for a specific date. This can include:

      • Step Detail: For trigger orchestrations.

      • Variant Detail: For A/B tested orchestrations.

    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.

    See the list of potential failures in the API Description.

    https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/CAMPAIGN_TOKEN

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

    curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/CAMPAIGN_TOKEN", [
    	"headers" => [
    		
    
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    

    Note: Only LIVE API Keys are supported by this 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 details about your In-App campaign.

    The output format is the same than the one used to create a campaign, except that the four following fields are added :

    Id
    Description

    campaign_token

    String - The token number of the campaign.

    from_api

    Boolean - Value that indicates whether or not the campaign were created with the API. `false` value means the campaign were created with the dashboard.

    dev_only

    Boolean - Value that indicates whether or not the campaign only targets developers.

    created_date

    String - Creation date of the campaign.

    Here is an example of output :

    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.

    Route

    The Audience API exposes a GET endpoint that allows to list audiences :

    /audiences/list

    Headers and authentication

    See Overview → Using Project APIs.

    Query parameters

    See API Description.

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audiences.

    3 values are possible for indexing state

    • IN_PROGRESS : update processing is in progress

    • APPLIED : update processing is finished

    • REPLACED : the audience content has been replaced since the issue of the indexing token.

    Pagination infos:

    • next_from can be used for the next call to list to retrieve the next page

    • count is only returned for the first page

    Failure

    If the POST 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.

    See the list of potential failures in the API Description.

    create
    Overview → Using Project APIs
    support@batch.com
    Overview → Using Project APIs
    check the indexing state
    support@batch.com

    Edit catalog items

    Use /catalogs/items/edit to edit a catalog item. A catalog can contain up to 2 million items.

    Rate Limiting

    To ensure fair usage and platform stability, the /catalogs/items/edit endpoint is subject to rate limiting, following the Token Bucket algorithm:

    • Up to 5 requests per second are allowed.

    • Up to 1000 items updated per second are allowed.

    • If you exceed these limits, the API will respond with an HTTP 429 Too Many Requests error. When you receive this error, please wait a few seconds before retrying, as further attempts may continue to be rejected until your rate falls back within the allowed limits.

    What constitutes one "update"? One update corresponds to the processing associated with a single item included in your request. For example, if a request contains data for 10 different items, it will consume 10 updates from your rate limit, regardless of the number of attributes updated for each individual item within that same request.

    Request structure

    Route

    The Catalog API exposes a POST endpoint that allows to update items of an existing catalog:

    /catalog/items/edit

    You can update one or several items via this endpoint, within the limit of 200 items.

    Headers and authentication

    See .

    Update item

    The body of the request must contain a valid JSON payload describing the update operations to execute for a set of given items and catalog.

    • All attributes provided in the request must already exist in the catalog schema. Otherwise, the request will result in an error. (See the documentation to learn more about adding or removing fields from a catalog schema.)

    • Attributes that are omitted from the request will be ignored and left unchanged in the catalog.

    Attributes

    You can set custom attributes associated with your items, with a name and a value.

    Key names should be made of letters, numbers or underscores ([a-z0-9_]). They cannot be longer than 30 characters and cannot contain uppercase characters.

    The following value types are supported:

    • String

    • Integer

    • Float

    • Date

    String

    String types attributes cannot be empty or over 10,000 characters, they can be null. Setting a string to null completely removes this attribute from the item.

    Integer

    Integer attributes are supported and can be null. Setting an integer to null completely removes this attribute from the item.

    Float

    Float attributes are supported and can be null. Setting a float to null completely removes this attribute from the item.

    Date

    JSON does not support date natively. Therefore, we require additional information to identify an attribute as a date. This is achieved by wrapping the attribute key in the date() function.

    Dates are accepted in TS format in seconds and RFC 3339 format (2012-08-12T22:30:05Z).

    URL

    URL type is also supported. You will need to wrap the key name in the url() function.

    Values must be valid URLs and no longer than 2048 characters:

    • A scheme is compulsory (myapp://, https://...)

    • :// is compulsory after the scheme

    Boolean

    Boolean attributes can be true or false.

    String arrays

    Arrays of strings are supported. A string in an array cannot be longer than 64 chars. You cannot have more than 15 elements in an array of string.

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

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

    Processing time

    While the indexation of items is usually done in real time, we offer no guarantees. If you send a campaign right after the catalog item update, you might end up with stale items. A call to the view action with the indexing token replies with an APPLIED indexing state if the processing is finished (and IN_PROCESS if it is still ongoing).

    GET - List

    The Custom Audience API 1.0 only accepts custom user IDs and avertising IDs. For audiences with install IDs, the version 1.1 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs or advertising IDs (GAID or IDFA).

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    Request structure

    Route

    The Custom Audience API exposes a GET endpoint that allows to list custom audiences :

    https://api.batch.com/1.0/BATCH_API_KEY/custom-audience

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Get parameters

    Id
    Description

    Here is an example of a valid cURL CLI request, which would return 5 custom audiences, starting from the 10th audience :

    Responses

    Success

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audiences.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    GET - List In-App campaigns

    The list endpoint allows you to get an In-App campaign list.

    Request structure

    Route

    The In-App campaigns API exposes a GET endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/list

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

    Get parameters

    Id
    Description

    Here is an example of a valid cURL CLI request, which would return 5 live (running or completed) In-App campaigns created from the api, starting from the 10th campaign :

    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 campaigns. The endpoint only returns basic information about campaigns. If you need more information about a campaign, use the endpoint using the campaign_token.

    Failure

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

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • AUTHENTICATION_INVALID (Http status code: 401, Error code: 10)

    • API_MISUSE (Http status code: 403, Error code: 12)

    GET - View campaign

    The get endpoint allows you to get details about a campaign or push automation using its unique token.

    Request structure

    Route

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

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

    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 a push campaign using the API.

    Please note Batch manages each platform separately. You will have to call the API twice with a different API key if you want to target iOS and Android.

    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 details about your campaign.

    The output format is the same than the one used to , except that the four following fields are added :

    Id
    Description

    Here is an example of output :

    Failure

    If the GET data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    PATCH - Update

    The Custom Audience API 1.0 only accepts custom user IDs and avertising IDs. For audiences with install IDs, the version 1.1 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs or advertising IDs (GAID or IDFA).

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    Request structure

    Route

    The Custom Audience API exposes a PATCH endpoint that allows to add or delete users from a custom audience :

    https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value is the name of the existing audience you want this operation to be applied to.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Patch data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the custom audience.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    NOTE: If both add and remove actions are applied to the same ID, the ID will be deleted from the audience.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Processing time

    While the indexation of IDs is usually done in realtime, we offer no guarantees. If you send a campaign right after the custom audience creation, you might end up with a campaign targeting nobody.

    PUT - Replace

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    Request structure

    Route

    The Custom Audience API exposes a PUT endpoint that allows to replace all custom audience users. It removes all previously added users and adds the given ones :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value is the name of the existing audience you want this operation to be applied to.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Put data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the custom audience.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    NOTE: If multiple actions are given for the same ID, only the last one will be taken into account.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Processing time

    While the indexation of IDs is usually done in realtime, we offer no garanties. If you send a campaign right after the custom audience creation, you might end up with a campaign targeting nobody.

    POST - Create request

    The GDPR API allows you to create GDPR requests and get their status. This page documents the creation endpoint.

    A request concerns a single user. Two types of request can be created :

    • A review request which generates a data report containing the user's data.

    • A remove request which triggers the removal of the user's data.

    You can check the status of a request in two ways:

    • provide a callback URL in the request. This URL will be called once the request is done.

    • make a .

    Note: GDPR request information is available via our Dashboard and APIs for 20 to 30 days after request creation. After this time, you will not be able to query its status anymore. Pending requests are always available.

    Request structure

    Route

    The GDPR API exposes a POST endpoint that allows to create a GDPR request :

    https://api.batch.com/1.0/BATCH_API_KEY/gdpr/request

    Here is a valid cURL example:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload describing the request to be executed, and information about the concerned user.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    NOTE: The callback URL allows you to be notified when the request processing is done. The call is performed with a POST method, the payload is the same than the one we return on the . The URL must be secured with HTTPS.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a unique token representing the request.

    Please keep this token: It will be useful to .

    Failure

    If the user in the POST data is currently being processed, the API will return a HTTP 409 Conflict status code.

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    PATCH - Update

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    Request structure

    Route

    The Custom Audience API exposes a PATCH endpoint that allows to add or delete users from a custom audience :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value is the name of the existing audience you want this operation to be applied to.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).

    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.

    Patch data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the custom audience.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    NOTE: If multiple actions are given for the same ID, only the last one will be taken into account.

    The documentation describes what the attribute name and value formats are, and which type to use depending on your use case. The main differences are that Custom Audiences attributes do not use the "u." prefix, and tag collections are not supported.

    Responses

    Success

    If the PATCH to the API endpoint is successful you will receive an HTTP 201 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Processing time

    While the indexation of IDs is usually done in realtime, we offer no guarantees. If you send a campaign right after the custom audience creation, you might end up with a campaign targeting nobody.

    POST - Create

    The Custom Audience API 1.0 only accepts custom user IDs and avertising IDs. For audiences with install IDs, the version 1.1 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs or advertising IDs (GAID or IDFA).

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    Request structure

    Route

    The Custom Audience API exposes a POST endpoint that allows to create a custom audience :

    https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value must be a string that only contains letters (a-z, A-Z), numbers (0-9) or the following characters : _, -. Audience names can be up to 255 characters long. They are case sensitive.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    Please note Batch manages each platform separately, so you will have to call the API twice with a different API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the custom audience.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and an empty json payload.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    POST - Create

    The Custom Audience API 1.1 only accepts install IDs for the moment. For audiences with custom user IDs or advertising IDs, the version 1.0 should be used.

    The Custom Audience API enables you to create, update, delete and list custom audiences. A custom audience can contain a list of custom user IDs, advertising IDs (GAID or IDFA) or install IDs.

    This is useful to target segments with push notifications or In-App messages, either they are coming from your userbase or created by third-party tools.

    Custom audiences created using the API can be targeted from Batch’s dashboard or the Campaigns API.

    NOTE: Custom Audiences with install IDs are only supported from the 1.1 version of the Custom Audience API. Also note that this version doesn't support custom user IDs and advertising IDs for the moment.

    Request structure

    Route

    The Custom Audience API exposes a POST endpoint that allows to create a custom audience :

    https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME

    Here is a valid cURL example:

    The AUDIENCE_NAME value must be a string that only contains letters (a-z, A-Z), numbers (0-9) or the following characters : _, -. Audience names can be up to 255 characters long. They are case sensitive.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    Please note Batch manages each platform separately, so you will have to call the API twice with a different API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload describing the operations to be executed on the custom audience.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a token.

    Once you get your token, you can use it to of this update with the API.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Initial setup

    Integrating the SDK

    Native SDK

    The iOS SDK is a standard mergeable dynamic library, compatible with iOS 15.0 and higher (iOS 16.0 or higher for Mac Catalyst only). Xcode 26.1+ is required, but Batch will work with all Swift versions, along with Objective-C.

    It supports the following architectures:

    • x86_64

    • arm64 (both for iOS, and iOS Simulator on Apple Silicon)

    Catalyst is supported.

    The iOS SDK also supports visionOS in a restricted usage since:

    • In-App messaging and mobile landings are unavailable.

    • In-App rating is not supported on visionOS due to an OS limitation.

    Integrating with:

    Use Xcode's Swift Package Manager wizard to add

    CocoaPods 1.15 required

    First, simply add this line to your Podfile to integrate Batch in your project:

    Then, run pod install in your Podfile folder, and open the .xcworkspace that was created. You're ready to go! In order to update Batch SDK, simply run pod update in that directory.

    If you don't have a Podfile or are unsure on how to proceed, see the .

    Your first start

    Implement the Batch startWithAPIKey: method in your AppDelegate application:didFinishLaunchingWithOptions: method:

    If you're making a SwiftUI app, you will need to add a delegate first.

    YOUR_API_KEY is your SDK API Key. You'll find it in ⚙ Settings → General.

    This API key must not be mistaken for the APNS environment Batch will output to the Xcode logs when starting. The environment depends on the app's provision, not on the Batch API Key used.

    Testing your integration

    Congratulations on finishing the bulk of the integration!

    If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in the Xcode console.

    Batch also provides a simple that allows you to test your integration (⚙ Settings → Debug) and a that shows all the data available for a specific user ID.

    POST - Create campaign

    The Push Campaigns API is made for 1-to-many interactions. It allows you to send notifications to a large audience of users. You can use it to target all your userbase or a specific segment of users relying on Batch segmentation.

    You can use the Push 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.

      {
        "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
        "campaign": {
          "name": "The campaign name",
          "state": "RUNNING",
          "when": {
            "local_time": false,
            "start_time": "2024-01-24T10:22:00Z"
          },
          "targeting": {
            "languages": [
              "fr"
            ],
            "regions": [
              "FR"
            ],
            "query": {
              "firstname": {
                "$eq": "Jane"
              }
            }
          },
          "messages": [
            {
              "channel_type": "email",
              "subject": "The campaign subject",
              "sender_identity_id": "4012",
              "reply_to": {
                "email_address": "jane.doe@demobatch.com"
              },
              "html": "The campaign HTML content"
            }
          ]
        }
      }
    "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q"
    {
      "orchestrations": [
       {
          "id": "orchestration_06bw2hjbja6dzui3r71r1vff7s1xbq63",
          "type": "onetime",
          "channels": [
            "email"
          ],
          "source": "dashboard",
          "name": "my_campaign_1",
          "status": "completed",
          "created_date": "2025-06-30T14:38:19Z",
          "labels": [
            "NEWSLETTER"
          ],
          "start_time": "2025-06-30T17:31:00Z"
        },
        {
          "id": "orchestration_068a348ws8zjtfwfxvjzpe9sv4tsqcc1k",
          "type": "recurring",
          "channels": [
            "sms"
          ],
          "source": "dashboard",
          "capping": 0,
          "recurrence": {
            "repeat_unit": "weekly",
            "repeat_fequency": 1
          },
          "name": "welcome_campaign",
          "status": "running",
          "created_date": "2025-03-30T12:00:25Z",
          "start_time": "2025-04-01T12:54:00Z"
        }
      ],
      "count": 18,
      "has_more": true,
      "next_from": "U29sZGVzX0N1aXNzYXJkc19Db3JlX0ZlbW1lX0NsaWVudHNAMjAyNS0wNi0zMFQxMjo1MzozNlo="
    }
    {
        "id": "export_nvctr8tgdjf7bppacxxt2aeemnjehfmw",
        "request_date": "2024-02-28T16:28:42Z",
        "scope": "PROFILE_ATTRIBUTES",
        "status": "SUCCESS",
        "request": {
            "export_type": "ATTRIBUTES",
            "attributes": [
                "$region",
                "$phone_number",
                "$timezone",
                "$email_marketing",
                "$sms_marketing",
                "$language",
                "$email_address"
            ],
            "identifiers": [
                "installation_ids",
                "custom_id"
            ]
        },
        "completion_date": "2024-02-28T16:28:48Z",
        "start_date": "2024-02-28T16:28:48Z",
        "files": [
            {
                "id": "file_etxhwckcfc05egew7y97bdjtc75p7g8b",
                "part": 1,
                "size": 592752,
                "url": "https://api.batch.com/2.4/exports/download?id=file_etxhwckcfc05egew7y97bdjtc75p7g8b"
            }
        ]
    }
    {
      "campaign_token": "d9d5e5a52ca08110d4893af3254ec21b",
      "detail": [
        {
          "date": "2015-11-20",
          "sent": 754,
          "sent_optins": 521,
          "direct_open": 102,
          "influenced_open": 98,
          "reengaged": 12,
          "errors": 0
        }
      ]
    }
    {
      "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
            }
          }
        }
      ]
    }
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X GET "https://api.batch.com/1.0/BATCH_API_KEY/gdpr/request/REQUEST_ID"
    {
      "request_date": "2021-01-03T16:52:16.051",
      "status": "done",
      "request_type": "review",
      "trigger_type": "api",
      "id": {
        "type": "custom_id",
        "value": "john.doe"
      },
      "data_url": "https://api.batch.com/1.0/[APIKEY]/gdpr/request/[REQUEST_ID]/results/[RESULT_ID].zip"
    }
    {
      "request_date": "2020-12-24T06:16:00.000",
      "status": "pending",
      "request_type": "review",
      "trigger_type": "api",
      "id": {
        "type": "custom_id",
        "value": "john.doe"
      }
    }
    {
      "request_date": "2020-09-05T11:32:48.204",
      "status": "done",
      "request_type": "remove",
      "trigger_type": "api",
      "id": {
        "type": "custom_id",
        "value": "john.doe"
      }
    }
    {
      "request_date": "2020-05-15T01:28:22.588",
      "status": "done",
      "request_type": "remove",
      "trigger_type": "api",
      "id": {
        "type": "custom_id",
        "value": "john.doe"
      },
      "error": "user not found"
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME"
    {
      "description": "The app-data description",
      "time_to_live": 90
    }
    {
      "id": "orchestration_0694rjc8znu6rdvfzkxp2wab2m704kne",
      "details": [
        {
          "date": "2025-06-03",
          "sent": 129,
          "delivered": 125,
          "sent_optin" : 121,
          "unsubscribe": 1,
          "unique_open": 33,
          "total_open": 52,
          "unique_machine_open": 11,
          "unique_click": 8,
          "total_click": 10,
          "total_bounce": 4,
          "message_steps": [
            {
              "step_id": "MESSAGE__ndPS6g3",
              "sent": 1,
              "delivered": 1
            },
            {
              "step_id": "MESSAGE__3gZK1yp",
              "sent": 128,
              "delivered": 124,
              "sent_optin" : 121,
              "unsubscribe": 1,
              "unique_open": 33,
              "total_open": 52,
              "unique_machine_open": 11,
              "unique_click": 8,
              "total_click": 10,
              "total_bounce": 4
            }
          ]
        },
        {
          "date": "2025-06-02",
          "sent": 336,
          "delivered": 327,
          "sent_optin" : 303,
          "unsubscribe": 2,
          "skipped": 2,
          "unique_open": 150,
          "total_open": 242,
          "unique_machine_open": 80,
          "unique_click": 36,
          "total_click": 57,
          "total_bounce": 5,
          "message_steps": [
            {
              "step_id": "MESSAGE__3gZK1yp",
              "sent": 326,
              "delivered": 317,
              "sent_optin" : 303,
              "unsubscribe": 2,
              "skipped": 2,
              "unique_open": 150,
              "total_open": 242,
              "unique_machine_open": 80,
              "unique_click": 36,
              "total_click": 57,
              "total_bounce": 5
            },
            {
              "step_id": "MESSAGE__ndPS6g3",
              "sent": 10,
              "delivered": 10
            }
          ]
        }
      ]
    }
    {
      "campaign_token": "70448bafec76439d534ec98ea7ab712c",
      "from_api": true,
      "dev_only": false,
      "created_date": "2018-08-13T10:11:38",
      "name": "In-App campaign name",
      "live": true,
      "end_date": "2018-10-31T17:30:00",
      "trigger": {
        "capping": 10,
        "when": "next_session",
        "grace_period": {
          "every": 2,
          "unit": "HOURS"
        }
      },
      "targeting": {
        "segments": ["ONE_TIME", "ENGAGED", "NEW"]
      },
      "landing": {
        "theme": "THEME_CODE",
        "contents": [
          {
            "language": "fr",
            "title": "Landing title",
            "body": "Landing body",
            "actions": [
              {
                "action": "DISMISS",
                "label": "Ok"
              }
            ]
          }
        ]
      }
    }
    {
      "audiences": [
        {
          "name": "string",
          "display_name": "string",
          "type": "CUSTOM_ID",
          "nb_ids": 0,
          "indexing_state": "APPLIED",
          "created": "2023-08-12T22:30:05Z",
          "updated": "2023-08-12T22:30:05Z"
        }
      ],
      "count": 4012,
      "has_more": true,
      "next_from": "676DEZREZ"
    }
    {
      "exports": [
        {
          "id": "export_nvctr8tgdjf7bppacxxt2aeemnjehfmw",
          "request_date": "2024-02-28T16:28:42Z",
          "scope": "PROFILE_ATTRIBUTES",
          "status": "SUCCESS",
          "request": {
            "export_type": "ATTRIBUTES",
            "attributes": [
              "$region",
              "$phone_number",
              "$timezone",
              "$email_marketing",
              "$sms_marketing",
              "$language",
              "$email_address"
            ],
            "identifiers": [
              "installation_ids",
              "custom_id"
            ]
          },
          "completion_date": "2024-02-28T16:28:48Z",
          "start_date": "2024-02-28T16:28:48Z",
          "files": [
            {
              "id": "file_etxhwckcfc05egew7y97bdjtc75p7g8b",
              "part": 1,
              "size": 592752,
              "url": "https://api.batch.com/2.4/exports/download?id=file_etxhwckcfc05egew7y97bdjtc75p7g8b"
            }
          ]
        }
      ],
      "count": 10,
      "has_more": true,
      "next_from": "ZXhwb3J0X2dnNnN5d2RzcGg2eG00Nm1lZHNtMDRyZ3gyd2FiMDA1QDIwMjQtMDItMjdUMTQ6MTg6NTBa"
    }
    {
      "name": "AUDIENCE_NAME",
      "display_name": "The audience description",
      "type": "custom_ids"
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    "Content-Type"
    =>
    "application/json"
    ,
    "X-Authorization" => "BATCH_REST_API_KEY"
    ]
    ]);
    )
    "Content-Type"
    =>
    "application/json"
    ,
    "X-Authorization" => "BATCH_REST_API_KEY"
    ]
    ]);
    )

    id

    Object - An object describing the identifier of a user concerned by this request. This is the same object you provide when calling the API to create a request.

    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • from

    Integer - Optional, Default : 0 Value used for pagination : it indicates the offset of the first custom audience to be returned. Custom audiences are ordered by creation date (from the most recent to the oldest). E.g."/custom-audience?from=10"

    limit

    Integer - Optional, Default : 10, Max : 100 Value that indicates the number of custom audiences to be returned per API call. E.g."/custom-audience?limit=20"

    support@batch.com
    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.

  • from

    Integer - Optional, Default : 0 Value used for pagination : it indicates the offset of the first In-App campaign to be returned. In-App campaigns are ordered by creation date (from the most recent to the oldest). E.g."/in-app-campaigns/list?from=10"

    limit

    Integer - Optional, Default : 10, Max : 100 Value that indicates the number of campaigns to be returned per API call. E.g."/in-app-campaigns/list?limit=20"

    live

    Boolean - Optional Allows to filter according to the campaign LIVE state. `true` will only return running or completed campaigns, whereas `false` will only return stopped and draft campaigns. E.g."/in-app-campaigns/list?live=true"

    from_api

    Boolean - Optional Allows to filter according to the way that campaigns have been created. `true` will only return campaigns created with the API. `false` value will only return campaigns created from the dashboard. If you want all campaigns, omit this parameter. E.g."/in-app-campaigns/list?from_api=false"

    GET
    support@batch.com
    curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/list" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/list", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	]
    ]);
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/list",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    )
    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.

  • campaign_token

    String - The token number of the campaign or automation.

    from_api

    Boolean - Value that indicates whether or not the campaign were created with the API. `false` value means the campaign were created with the dashboard.

    dev_only

    Boolean - Value that indicates whether or not the campaign only targets developers.

    created_date

    String - Creation date of the campaign.

    trigger

    Object - Optional On trigger automations, will be an empty object. Use this to identify automations. Getting the detailed trigger information is not supported.

    successfully create
    create a campaign
    support@batch.com
    curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/CAMPAIGN_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/CAMPAIGN_TOKEN", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	]
    ]);
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/CAMPAIGN_TOKEN",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    )
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • type

    string - Required Type of the audience. Acceptable values include: custom_ids or advertising_ids . E.g.{"type":"custom_ids"}

    ids

    Array of Objects - Required An array of objects describing actions to be applied to the custom audience. Supports up to 10,000 elements. E.g.[{"action":"add","id":"USER_CUSTOM_ID1"}]

    action

    String - Required The action to be applied to the custom audience. Acceptable values include: add or remove . E.g.{"action":"add"}

    id

    String - Max. 128 chars - The ID that will be added to or deleted from the audience. E.g.{"id":"USER_CUSTOM_ID"}

    check the indexing state
    support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • ids

    Array of Objects - Required An array of objects describing ids to be added to the custom audience. Supports up to 10,000 elements. E.g.[{"id":"USER_CUSTOM_ID1"}]

    id

    String - The ID that will be added to the audience. E.g.{"id":"USER_CUSTOM_ID"}

    attributes

    Object - Optional. An object containing attributes to be attached to the id. Attribute names should be lowercased. Supports up to 15 elements.

    tags

    Array - Optional. An object containing tags to be attached to the id. Tags should be lowercased.

    check the indexing state
    support@batch.com
    MISSING_PARAMETER (HTTP status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (HTTP status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (HTTP status code: 400, Error code: 32)

  • SERVER_ERROR (HTTP status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (HTTP status code: 503, Error code: 2)

  • request_type

    string - Required The request type. Acceptable values include: review or remove . E.g.{"request_type":"review"}

    callback_url

    string - Optional A callback that is called when the request is finished. E.g.{"description":"https://callback.site"}

    id

    Object - Required An object describing the identifier of the user concerned by the request. E.g.[{"type":"custom_id","value":"john.doe"}]

    type

    String - Required The ID type. Acceptable values include: custom_id , advertising_id or install_id . E.g.{"type":"custom_id"}

    value

    String - The ID value. E.g.{"value":"john.doe"}

    status request
    status route
    check the status and get the result of your request
    support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • ENTITY_ALREADY_EXISTS (Http status code: 400, Error code: 33)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • type

    string - Required Type of the audience. Acceptable values include: custom_ids or advertising_ids . E.g.{"type":"custom_ids"}

    description

    string - Optional Description of the audience. E.g.{"description":"The audience description"}

    support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • ENTITY_ALREADY_EXISTS (Http status code: 400, Error code: 33)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • type

    string - Required Type of the audience. Only install_ids type is accepted for the moment. E.g.{"type":"install_ids"}

    description

    string - Optional Description of the audience. E.g.{"description":"The audience description"}

    check the indexing state
    support@batch.com

    Note: Due to CocoaPods limitations, the Batch Pod is not a mergable library and has no code signing. If you need one of those, please use SPM or manually integrate the XCFramework.

    Batch is only available on Carthage 0.30 and higher

    Simply add this line to your Cartfile to integrate Batch in your project:

    github "BatchLabs/Batch-iOS-SDK"

    Do not add Batch to the "carthage copy-frameworks" script input/output.

    XCFramework distribution is supported since Batch 1.18.0 and Carthage 0.38.

    Apple now requires Privacy Manifest that's not available with Carthage.

    Package.swift
    https://www.github.com/BatchLabs/Batch-iOS-SDK.git
    Podfile
    pod 'Batch', '~> 3.1'
    CocoaPods usage guide
    debug tool
    profile view
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience?from=10&limit=5"
    {
      "custom_audiences": [
        {
          "name": "audience2",
          "type": "custom_ids",
          "description": "The audience2 description",
          "nb_ids": 23764,
          "created": "2018-06-29T14:59:03",
          "updated": "2018-06-29T15:07:32"
        },
        {
          "name": "audience1",
          "type": "advertising_ids",
          "description": "The audience1 description",
          "nb_ids": 16743,
          "created": "2018-06-29T13:12:09",
          "updated": "2018-06-29T13:42:59"
        }
      ]
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/list?from=10&limit=5&live=true&from_api=true"
    [
      {
        "campaign_token": "70448bafec76439d534ec98ea7ab712c",
        "from_api": true,
        "dev_only": false,
        "created_date": "2018-08-13T10:11:38",
        "name": "In-App campaign name 1",
        "live": false,
        "end_date": "2018-10-31T17:30:00",
        "trigger": {
          "capping": 10,
          "when": "next_session",
          "grace_period": {
            "every": 2,
            "unit": "HOURS"
          }
        },
        "query": {
          "$or": [
            {
              "isNear(45.7583907,4.8347867,30km)": true
            },
            {
              "countForLabel(e.label_data, 'example')": 0
            }
          ]
        }
      },
      {
        "campaign_token": "70448bafec76439d534ec98ea7ab712c",
        "from_api": true,
        "dev_only": false,
        "created_date": "2018-08-13T10:11:38",
        "name": "In-App campaign name 2",
        "live": false,
        "end_date": "2018-02-29T17:30:00",
        "trigger": {
          "when": "now",
          "grace_period": {
            "every": 4,
            "unit": "DAYS"
          }
        }
      }
    ]
    {
      "campaign_token": "a0082dc6860938a26280bd3ba927303b",
      "from_api": false,
      "dev_only": true,
      "created_date": "2017-07-05T15:11:33",
      "name": "Test campaign",
      "live": true,
      "push_time": "2017-07-05T13:32:30",
      "gcm_collapse_key": "default",
      "targeting": {
        "segments": ["NEW", "ENGAGED", "ONE_TIME"]
      },
      "messages": [
        {
          "language": "en",
          "title": "Hello!",
          "body": "How's it going?"
        }
      ]
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X PATCH -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    {
      "type": "custom_ids",
      "ids": [
        {
          "action": "add",
          "id": "USER_CUSTOM_ID1"
        },
        {
          "action": "remove",
          "id": "USER_CUSTOM_ID2"
        }
      ]
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X PUT -d "@payload.json" "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    {
      "ids": [
        {
          "id": "INSTALL-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2012-08-12T22:30:05"
          },
          "tags": [
            "value-1",
            "value-2"
          ]
        },
        {
          "id": "INSTALL-ID-2",
          "attributes": {
            "att1": 2,
            "att2": "string",
            "date(att15)": "2013-08-12T22:30:05"
          },
          "tags": [
            "value-3",
            "value-4"
          ]
        }
      ]
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/gdpr/request"
    {
      "request_type": "review",
      "callback_url": "https://callback.site",
      "id": {
        "type": "custom_id",
        "value": "john.doe"
      }
    }
    { "token": "110e8400-e29b-11d4-b543-446655440000" }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    {
      "type": "custom_ids",
      "description": "The audience description"
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    {
      "type": "install_ids",
      "description": "The audience description"
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    import Batch
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        BatchSDK.start(withAPIKey: "YOUR_API_KEY")
        [..]
    }
    @import Batch;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      // Start Batch SDK.
      [BatchSDK startWithAPIKey:@"MY_API_KEY"];
    
      return YES;
    }
    import SwiftUI
    import Batch
    
    
    class MyAppDelegate: NSObject, UIApplicationDelegate {
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            BatchSDK.start(withAPIKey: "YOUR_API_KEY")
    
            return true
        }
    }
    
    @main
    struct BatchApp: App {
        // Set an explicit delegate to integrate Batch in
        @UIApplicationDelegateAdaptor(MyAppDelegate.self) var delegate
    
    
        var body: some Scene {
            WindowGroup {
                ContentView()
            }
        }
    }
    [Batch] Installation ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
    URL
  • Boolean

  • String arrays

  • Overview → Using Project APIs
    Update catalog
    check the indexing state
    support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • ids

    Array of Objects - Required An array of objects describing actions to be applied to the custom audience. Supports up to 10,000 elements. E.g.[{"action":"add","id":"USER_CUSTOM_ID1"}]

    action

    String - Required The action to be applied to the custom audience. Acceptable values include: add or remove . E.g.{"action":"add"}

    id

    String - The ID that will be added to or deleted from the audience. E.g.{"id":"USER_CUSTOM_ID"}

    attributes

    Object - Optional. Only accepted for add action. An object containing attributes to be attached to the id. They can then be used in Supports up to 15 elements. See the Custom Data API documentation for more info on attribute names and values.

    tags

    Array - Optional. Only accepted for add action. An object containing tag values to be attached to the id. See the Trigger Events API documentation for more info on value limits.

    Custom Data API
    check the indexing state
    support@batch.com
    Fitness: Workout reminders, subscription offers, etc.

    Request structure

    The create endpoint allows you to create push campaigns and target all your userbase, your own segments (attributes, events) or to segments generated by Batch (country/language, dormant users, app version, etc).

    Route

    The campaigns API exposes a POST create endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/campaigns/create

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

    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/create" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY" \
    -d '{
    	"name": "Test Campaign",
    	"live": true,
    	"push_time": "now",
    	"messages": [{
    		"language": "en",
    
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/create", [
    	"headers" => [
    		"Content-Type"
    

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    The API key changes push behaviour:

    • Dev API: Only apps built with the Dev API Key will receive notifications.

    • Live API: Depending on the targeting you set for your campaigns, apps built with the Live API key will receive notifications. Apps built with the Dev API key will receive all the notifications you send.

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload with all the parameters you chose to add for your campaign: campaign name, schedule, recurrency, targeting, messages and more.

    Here is how a minimal and valid JSON payload looks like:

    REQUIRED > Check out the list of available parameters to create your first push campaign with the API.

    Responses

    Success

    If the POST to the API endpoint is successfull you will receive an HTTP 201 confirmation and a token:

    Once you get your token, you can use it to update your campaign or check the stats with the API.

    If you don't receive the notification after a successful POST, make sure your app is not opened in the foreground (iOS) and check again your integration.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    • 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.

    POST - Track events

    The Trigger Events API allows you to track events on specific Custom User IDs. These events can be used as trigger and cancellation events of trigger automations.

    Tracking server side events is particularly useful for actions performed outside of the app (e.g. purchase, subscription, updated profile, etc).

    Request structure

    The events endpoint allows you to track events either for one user, or for multiple users.

    Route

    The Trigger Events API exposes two POST endpoints:

    • https://api.batch.com/1.0/BATCH_API_KEY/events/users/CUSTOM_USER_ID for a single upload (send one or multiple events on a single Custom User ID)

    • https://api.batch.com/1.0/BATCH_API_KEY/events/users for bulk upload (send one or multiple events on different Custom User IDs)

    NOTE: CUSTOM_USER_ID is a Custom User ID as described for iOS and for Android.

    Bulk updates allow you to track events for multiple users with one API call.

    Here are two valid cURL examples.

    Single upload

    You can track up to 1000 events for a single Custom User ID.

    Bulk upload

    You can track up to 1000 events, distributed amongst several Custom User IDs.

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    Please note Batch manages each platform separately, so you will have to call the API twice with a different API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account in a secure way that key with you or ask them to grant you access through the team manager.

    Single upload

    For a single upload, the body of the request must contain an valid JSON payload describing the event(s) you want to attach to a user's profile.

    Here is a how a valid JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    Bulk tracking

    Bulk tracking works basically the same way as a single upload, except now you need to provide an array with Custom User IDs and list of events you want to attach to their profiles.

    Here is a how a valid JSON payload looks like:

    Id
    Description

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a unique token reprensenting the transaction.

    Please keep this token: it will help in getting faster support.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Important: 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.

    POST - Create In-App campaign

    The In-App Campaigns API is made for creating, reviewing, listing, updating and deleting In-App campaigns.

    The structure of this API is very similar to the Campaigns API. Before sending your first campaign, you have to create at least one theme on the In-app theme editor and retrieve its code.

    Request structure

    The create endpoint allows you to create In-App campaigns and reach all your userbase, opt-in to notifications or not. You can also use native and custom attributes as well as Custom Audiences for your targeting.

    Route

    The in-app campaigns API exposes a POST create endpoint at: https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/create

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

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General):

    The API key changes the behaviour of the campaign:

    • Dev API: Only apps built with the Dev API Key will receive messages.

    • Live API: Depending on the targeting you set for your campaigns, apps built with the Live API key will receive messages. Apps built with the Dev API key will receive all the messages you send.

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    The body of the request must contain a valid JSON payload with all the parameters you chose to add for your campaign: campaign name, schedule, recurrency, targeting, messages and more.

    Here is how a minimal and valid JSON payload looks like:

    REQUIRED > Check out the to create your first In-App campaign with the API.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a token:

    Once you get your token, you can use it to your campaign.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    GET - List campaigns

    The list endpoint allows you to get a list of your push campaigns and push automations.

    Request structure

    Route

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

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

    The BATCH_API_KEY value is your Live Batch API key from the settings page of your app within the dashboard (Settings → General).

    Get parameters

    Id
    Description

    Here is an example of a valid cURL CLI request, which would return 5 live (running or completed) campaigns created from the api, starting from the 10th campaign :

    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 successful you will receive an HTTP 200 confirmation and information on your campaigns. The endpoint only returns basic information about campaigns. If you need more information about a campaign, use the endpoint using the campaign_token.

    Failure

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

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • AUTHENTICATION_INVALID (Http status code: 401, Error code: 10)

    • API_MISUSE (Http status code: 403, Error code: 12)

    Push setup

    Setting up the Push

    First of all, open your project in Xcode by clicking on it in the sidebar, then click on the Signing & Capabilities tab. If Push Notifications isn't already there, click on + Capability and pick Push Notifications. If there is a Fix button shown, press it.

    Events

    Batch allows you to track events that happen in your application. They automatically keep track of their count, the last time it happened and their value.

    Important Newly tracked events are hidden by default. You will need to manually display them from the dashboard settings.

    Tracking events

    Events are easy to use, but have some rules:

    Rich notifications setup

    iOS 10 introduced support for rich notifications: they can now contain custom content, such as images, videos, sounds or even a fully custom view controller. Batch comes with built-in support for these, but due to the way they're implemented, integration of a supplementary SDK is required. Don't worry, we've made it really easy.

    Note: This tutorial assumes that you haven't already added a Notification Content extension. If you do, jump straight to .

    In-App Messaging

    In-App Campaigns allow you to trigger messages when users open your app or perform a specific action. This is great to communicate with users who have turned off push notifications or to show contextual messages while your users are browsing your app (e.g. special offers, update reminder, etc).

    Displaying In-App messages

    {
      "name": "MOVIES",
      "items": [
        {
          "action": "add",
          "id": "1",
          "attributes": {
            "title": "Squid Game",
            "description": "Hundreds of cash-strapped players accept a strange invitation to compete in children's games.",
            "cast": [
              "Lee Jung-jae",
              "Park Hae-soo",
              "Wi Ha-jun"
            ]
          }
        },
        {
          "action": "remove",
          "id": "2"
        }
      ]
    }
    {"firstname": "Jane"}
    {"age": 25}
    {"level_progress": 25.5}
    {
      "date(promo_starts)": 1451642400,
      "date(promo_ends)": "2012-08-12T22:30:05Z"
    }
    {
      "url(product_image)": "https://batchstore/product/4729/image.png",
      "url(product_deeplink)": "myapp://path/to/content"
    }
    {
      "is_premium": false
    }
    "interests": ["bikes","cinema"]
    HTTP Status Code: 202
    
    Response:
    {
        "indexing_token": "eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5f_xm6sVnl7bQiFmGLmkCRk_ssYO-hTpAFm1AXo9MMiBYQW3JAx-o9aVrsCsvhL3oZ2e5Dvb4pa6KRyzenOMgc5Vcb"
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X PATCH -d "@payload.json" "https://api.batch.com/1.1/BATCH_API_KEY/custom-audience/AUDIENCE_NAME"
    {
      "ids": [
        {
          "action": "add",
          "id": "INSTALL-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2012-08-12T22:30:05",
            "url(att20)": "https://example.com/image.jpg"
          },
          "tags": ["value-1", "value-2"]
        },
        {
          "action": "remove",
          "id": "INSTALL-ID-2"
        }
      ]
    }
    {
      "indexing_token": "a0082dc6860938a26280bd3ba927303b"
    }
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/create",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	},
    	data=json.dumps({
    		'name': 'Test Campaign',
    		'live': True,
    		'push_time': 'now',
    		'messages': [{
    			'language' => 'en',
    			'body' => 'Hello!'
    		}]
    	})
    )
    {
      "name": "Test Campaign",
      "push_time": "now",
      "live": true,
      "messages": [
        {
          "language": "en",
          "title": "Hello!",
          "body": "How's it going?"
        }
      ]
    }
    { "campaign_token": "a0082dc6860938a26280bd3ba927303b" }
    message personalization.
    "body": "Hello!"
    }]
    }'
    =>
    "application/json"
    ,
    "X-Authorization" => "BATCH_REST_API_KEY"
    ],
    "json" => [
    "name" => "Test Campaign",
    "live" => true,
    "push_time" => "now",
    "messages" => [[
    "language" => "en",
    "body" => "Hello!"
    ]]
    ]
    ]);
    Fully automatic mode

    There is no code required to make In-App Messages work in automatic mode. Create some campaigns on your dashboard, and they will start coming up in your app. If they don't, please head over to the troubleshooting section.

    Disabling Dynamic Type

    Batch adapts textual content to honor the user's font size settings. This is enabled by default, you can disable it at any moment by using:

    Controlling the display using "Do Not Disturb mode"

    You can also get more control on when messages are displayed without giving up on the automatic mode, by using the "Do Not Disturb" (DnD) mode. It allows you to tell Batch to hold on a mobile landing for you, rather than display it without using the fully manual mode. For example, if launching your app results in a splash screen or a fullscreen ad, you might find it undesirable to have Batch display something on top of it.

    Turning on "Do Not Disturb" mode will make Batch enqueue the latest mobile landing, rather than display it.

    Toggling DnD

    Now, when you don't want Batch to automatically display, turn on Do Not Disturb:

    Once you want to start showing landings automatically, call the method with false to turn it off.

    Note: Disabling Do Not Disturb mode does NOT make Batch show the enqueued message

    Displaying pending mobile landings

    After coming back from DnD mode, you might want to show the enqueued message, as Batch will not do that automatically. Batch exposes two properties/methods for managing the queue:

    • BatchMessaging.hasPendingMessage , allowing you to peek into the queue.

    • BatchMessaging.popPendingMessage() , allowing you to fetch the pending message (if any). Since calling this makes Batch delete its reference to it to save memory, further calls might return nil.

    • BatchMessaging.showPendingMessage() , allowing you to try to show the pending message, if any.

    Here is a quick example of how they can be used:

    Note: Only the latest message is queued: if a mobile landing arrives while one is still pending, it will overwrite the previous one.

    Manual mode

    Like Mobile Landings, you may want to take full control over how in-app messaging behaves. Batch allows you to disable automatic displaying, and handle that yourself. For compatibility reasons, BatchMessaging.setAutomaticMode(false) does not control this behavior like it does on mobile landings.

    In order to handle messages yourself, you will have to set an implementation of the BatchInAppDelegate protocol. By implementing this, you opt-in to manual message handling, and showing them becomes your responsibility.

    Here is an example:

    Note: More advanced examples showing how to manually display the given view controller are available in the Mobile Landings manual mode documentation

    Troubleshooting

    In-App messages fail to show

    This can come from multiple things:

    • Batch might not be able to display the message: make sure all of the prerequisites are satisfied by your app. If you have a non standard UI architecture.

    • The In-App campaign might not have been synchronized yet. Try to kill and restart your app: backgrounding it might not be enough.

    • If the trigger is "next session", you might just not have triggered a new session yet. Try killing (as in swiping it up on the task manager) and restarting the app, or wait 5 minutes with the app in the background. Restarting the app might be needed twice: once to sync the campaigns, and one to trigger the "next session" event.

    • If an In-App message is triggered while a view controller is being dismissed (especially a modally presented one), showing the message can fail. You can try displaying it manually, or tracking the event that triggers an in-app message after the dismiss animation.

    If that does not fix the problem, please check the logs in Xcode/Console.app and see if Batch or UIKit outputs anything. If not, you can always contact our support team with information about your problem.

    In-App formats
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • TOO_MANY_REQUESTS(Http status code: 429, Error code: 60)

  • events

    Array - Required Array of event objects. See Event object . E.g.{"events":[{"name":"ue.added_to_cart"}]}

    id

    string - Required User's Custom User ID. E.g.{"id":"Vincent"}

    events

    Array - Required Array of event objects. See Event object . E.g.{"events":[{"name":"ue.added_to_cart"}]}

    here
    here
    support@batch.com
    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • 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.

  • list of available parameters
    update
    support@batch.com
    curl -X POST "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/create" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY" \
    -d '{
      "name": "Test Campaign",
      "local_start_date": "2017-06-01T14:00:00",
      "live": true,
      "trigger": {
        "capping": 1,
        "when": "NEXT_SESSION"
      },
      "landing": {
        "theme": "HELLO-THEME",
        "image": "https://static.batch.com/documentation/logo_batch_192.png",
        "contents": [
          {
            "language": "en",
            "header": "Welcome",
            "title": "Hello!",
            "body": "How is it going?",
            "actions": [
              {
                "label": "Continue",
                "action": "continue"
              }
            ]
          }
        ]
      }
    }'
    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.

  • from

    Integer - Optional, Default : 0 Value used for pagination : it indicates the offset of the first campaign to be returned. Campaigns are ordered by creation date (from the most recent to the oldest). E.g."/campaigns/list?from=10"

    limit

    Integer - Optional, Default : 10, Max : 100 Value that indicates the number of campaigns to be returned per API call. E.g."/campaigns/list?limit=20"

    live

    Boolean - Optional Allows to filter according to the campaign LIVE state. `true` will only return running or completed campaigns, whereas `false` will only return stopped and draft campaigns. E.g."/campaigns/list?live=true"

    from_api

    Boolean - Optional Allows to filter according to the way that campaigns have been created. `true` will only return campaigns created with the API. `false` value will only return campaigns created from the dashboard. If you want all campaigns, omit this parameter. E.g."/campaigns/list?from_api=false"

    GET
    support@batch.com
    curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list" \
    -H "Content-Type: application/json" \
    -H "X-Authorization: BATCH_REST_API_KEY"
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	]
    ]);
    import requests, json
    response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	}
    )
    BatchMessaging.setEnableDynamicType(false)
    [BatchMessaging setEnableDynamicType:false];
    BatchMessaging.doNotDisturb = true
    BatchMessaging.doNotDisturb = YES;
    func splashScreenDidDisappear() {
      BatchMessaging.doNotDisturb = false
      BatchMessaging.showPendingMessage()
    }
    - (void)splashScreenDidDisappear {
      BatchMessaging.doNotDisturb = NO;
      [BatchMessaging showPendingMessage];
    }
    
    // Application delegate
    
    var inAppMsgDelegate = InAppMsgDelegate()
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      BatchMessaging.setInAppDelegate(inAppMsgDelegate)
    }
    
    // InAppMsgDelegate implementation
    
    @objc
    class InAppMsgDelegate: NSObject, BatchInAppDelegate {
        func batchInAppMessageReady(message: BatchInAppMessage) {
            // Sample implementation that prevents messages from being displayed if the logged in user isn't the right one
            // "loggedInUsername" is an hypothetical property that returns the logged in username as a string, if logged in
            if (UserManager.loggedInUsername == message.customPayload?["username"] as? String) {
                do {
                    let vc = try BatchMessaging.loadViewController(for: message)
                    BatchMessaging.present(vc)
                } catch let error as NSError {
                    // Handle the error
                }
            }
        }
    }
    
    // Application delegate
    
    @property InAppMsgDelegate *inAppMsgDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      self.inAppMsgDelegate = [InAppMsgDelegate new];
      [BatchMessaging setInAppDelegate:self.inAppMsgDelegate];
    }
    
    // InAppMsgDelegate implementation
    
    @interface InAppMsgDelegate : NSObject <BatchInAppDelegate>
    @end
    
    @implementation InAppMsgDelegate
    
    - (void)batchInAppMessageReady:(nonnull BatchInAppMessage*)message
    {
      // Sample implementation that prevents messages from being displayed if the logged in user isn't the right one
      // "loggedInUsername" is an hypothetical property that returns the logged in username as a string, if logged in
      if ([[UserManager loggedInUsername] isEqualToString:message.customPayload["username"]])
      {
        NSError *err;
        UIViewController *vc = [BatchMessaging loadViewControllerForMessage:message error:&err];
        if (vc)
        {
          [BatchMessaging presentMessagingViewController:vc];
        }
        else
        {
          // Handle the error
        }
      }
    }
    
    @end
    
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/events/users/CUSTOM_USER_ID"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/events/users"
    {
      "events": [
        {
          "name": "ue.added_to_cart",
          "time": "2012-08-12T22:30:05",
          "label": "shoes",
          "attributes": {
            "id": "00-00-xxx-xxx",
            "sub_category": "boots",
            "date(promo_ends)": "2021-08-12T22:30:05"
          },
          "tags": [
            "private-sales",
            "summer-discount"
          ]
        }
      ]
    }
    [
      {
        "id": "vincent",
        "events": [
          {
            "name": "ue.added_to_cart",
            "time": "2012-08-12T22:30:05",
            "label": "shoes",
            "attributes": {
              "id": "00-00-xxx-xxx",
              "sub_category": "boots",
              "date(promo_ends)": "2021-08-12T22:30:05"
            },
            "tags": [
              "private-sales",
              "summer-discount"
            ]
          }
        ]
      },
      {
        "id": "claire",
        "events": [
          {
            "name": "ue.added_to_cart",
            "time": "2012-08-12T22:30:05",
            "label": "glasses",
            "attributes": {
              "id": "00-00-yyy-yyy",
              "sub_category": "accessories",
              "date(promo_ends)": "2021-08-12T22:30:05"
            },
            "tags": [
              "private-sales",
              "summer-discount"
            ]
          }
        ]
      }
    ]
    { "token": "110e8400-e29b-11d4-b543-446655440000" }
    use GuzzleHttp\Client;
    $client = new Client();
    $response = $client->request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/create", [
    	"headers" => [
    		"Content-Type" => "application/json",
    		"X-Authorization" => "BATCH_REST_API_KEY"
    	],
    	"json" => [
          "name" => "Test Campaign",
          "live" => true,
          "trigger" => [
            "capping" => 1,
            "when" => "NEXT_SESSION"
          ],
          "landing" => [
            "theme" => "HELLO-THEME",
            "image" => "https://static.batch.com/documentation/logo_batch_192.png",
            "contents" => [
              [
                "language" => "en",
                "header" => "Welcome",
                "title" => "Hello!",
                "body" => "How is it going?",
                "actions" => [
                  {
                    "label" => "Continue",
                    "action" => "continue"
                  }
                ]
              ]
            ]
          ]
        ]
    ]);
    import requests, json
    response = requests.request("POST", "https://api.batch.com/1.1/BATCH_API_KEY/in-app-campaigns/create",
    	headers={
    		'Content-Type': 'application/json'
    		'X-Authorization': 'BATCH_REST_API_KEY'
    	},
    	data=json.dumps({
          'name': 'Test Campaign',
          'local_start_date': '2017-06-01T14:00:00',
          'live': True,
          'trigger': {
            'capping': 1,
            'when': 'NEXT_SESSION'
          },
          'landing': {
            'theme': 'HELLO-THEME',
            'image': 'https://static.batch.com/documentation/logo_batch_192.png',
            'contents': [
              {
                'language': 'en',
                'header': 'Welcome',
                'title': 'Hello!',
                'body': 'How is it going?',
                'actions': [
                  {
                    'label': 'Continue',
                    'action': 'continue'
                  }
                ]
              }
            ]
          }
        })
    )
    {
      "name": "Test Campaign",
      "local_start_date": "2017-06-01T14:00:00",
      "live": true,
      "trigger": {
        "capping": 1,
        "when": "NEXT_SESSION"
      },
      "landing": {
        "theme": "HELLO-THEME",
        "image": "https://static.batch.com/documentation/logo_batch_192.png",
        "contents": [
          {
            "language": "en",
            "header": "Welcome",
            "title": "Hello!",
            "body": "How is it going?",
            "actions": [
              {
                "label": "Continue",
                "action": "continue"
              }
            ]
          }
        ]
      }
    }
    {"campaign_token":"a0082dc6860938a26280bd3ba927303b"}
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
    "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list?from=10&limit=5&live=true&from_api=true"
    [
      {
        "campaign_token": "a0082dc6860938a26280bd3ba927303b",
        "from_api": false,
        "dev_only": false,
        "created_date": "2017-03-02T09:43:17",
        "name": "Test Campaign 1",
        "live": true,
        "push_time": "2017-07-06T14:09:18"
      },
      {
        "campaign_token": "a0082dc6860938a26280bd3ba927303a",
        "from_api": false,
        "dev_only": true,
        "created_date": "2017-03-02T09:43:17",
        "name": "Test Campaign 2",
        "live": false,
        "deeplink": "deeplink",
        "custom_payload": "{\"foo\" : \"bar\"}",
        "local_push_time": "2017-03-03T13:10:19",
        "recurrence": {
          "end_date": "2017-07-22T23:59:59",
          "repeat_unit": "WEEKLY",
          "repeat_frequency": 2
        },
        "query": {
          "$or": [
            {
              "isNear(45.7583907,4.8347867,30km)": true
            },
            {
              "countForLabel(e.label_data, 'example')": 0
            }
          ]
        },
        "capping": 2
      },
      {
        "campaign_token": "a0082dc6860938a26280bd3ba927302f",
        "from_api": false,
        "dev_only": false,
        "created_date": "2020-03-02T09:45:17",
        "name": "Test Trigger Automation 1",
        "live": true,
        "push_time": "2020-07-06T14:09:18",
        "trigger": {}
      }
    ]

    Then, you need to add a few lines to your app delegate in order to receive push notifications.

    Note: If you already implement an UNUserNotificationCenterDelegate class, please read the intercepting notifications documentation to properly integrate Batch into it.

    Requesting notification permission

    To ask for the permission to display notifications and register the current device for push you can use one of the following APIs:

    Note: It's preferable to make the request in a context that helps people understand why your app needs authorization.

    Your first notification

    1. Obtaining your device token

    You can find your device's token using the debug tool or locating the token Batch posts to the Xcode console:

    Based on your Provisioning Profile, the token shown in the console will be Development ("Sandbox/Development") or Production ("Production").

    If you don't see a push token, there might be an error in the logs describing what happened. See our troubleshooting documentation for more info.

    Note: Push notifications in an iOS Simulator are only supported when using an iOS 16 or higher simulator on macOS 13 on a T2 or Apple Silicon mac. Older simulators, macOS versions or computers do not support Push in the simulator: please use a physical device.

    2. Obtaining your Installation ID

    You can then retrieve the Installation ID, which represents an installation of your app on a device, by calling the following methods:

    While Batch prints this in the debug console on start, displaying it in a settings or about page enables users to send you this identifier. This is useful for debugging, sending test notifications, etc.

    3. Sending a test push notification

    Batch enables you to send a test notification to the application installation currently running on your device.

    To do so, open the dashboard and go to ⚙ Settings → Debug. Enter your Installation ID, hit Debug and then click on "Send Test Push".

    Send Test from Debug

    You should receive a notification on your device. If not, or if you can't find your Installation ID, the SDK might not be properly configured.

    If you need to send push notifications to your device on a regular basis, then you should add your ID as a test device by clicking the "Save as a test device" button.

    Troubleshooting If you're having trouble sending test notifications, you can check our troubleshooting documentation.

    What's next

    Congratulations on finishing the integration of Batch Push!

    Here are a couple of extra steps you can take before releasing your app:

    • Rich notifications: Add support for iOS rich push notifications.

    • Mobile Landings: Make sure Mobile Landings are set up correctly.

    • Custom user identifier: Add support for custom user identifiers if you are planning to use the Transactional or the Profile APIs.

    • Analytics: Add an to automatically track your campaigns in your third-party analytics tool.

    • Universal Links: domains to Batch to open then inside of your app.

    Xcode Capabilities
    Event names are strings. They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
  • A custom data object can be attached. See the section "Event Attributes", right under this one.

  • Custom attributes have some reserved keys. See the section "Reserved event attributes" under "Event Attributes" for more info.

  • Here are some examples:

    // Simple event
    BatchProfile.trackEvent(name: "ad_seen")
    
    // Event with custom attributes
    BatchProfile.trackEvent(name: "add_to_cart", attributes: BatchEventAttributes { data in
      // Custom attribute
      data.put("bags"
    
    // Simple event
    [BatchProfile trackEvent:@"ad_seen"];
    
    // Event with custom attributes
    BatchEventAttributes *attributes = [BatchEventAttributes new];
    [attributes putString:@"sub_category" forKey:@"bags"]; // Custom attributes
    [attributes putString:
    

    Please test your implementation using our debug tool and profile view before releasing your app on the store.

    Event attributes

    Custom attributes can be attached to events using BatchEventAttributes. You will then use them when calling BatchProfile.trackEvent().

    Attribute name

    They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters (e.g. has_premium). They will be automatically lowercased, so trying to use the same key with different casing will overwrite the previously set value.

    Attribute value

    Values must be any of the following types:

    • NSString, must not be longer than 300 characters and can't be empty. For better results, you should make them upper/lowercase and trim the whitespaces.

    • Bool

    • Floats/Doubles

    • NSInteger

    • NSDate

    • NSURL, not longer than 2048 characters and must follow the format scheme://[authority][path][?query][#fragment].

    • NSArray<NSString | BatchEventAttributes>, You can set array of strings (max 300chars) and array of objects. Max 25 items. You cannot mix several attribute types in one array. Arrays can't be nested.

    • Object (using BatchEventAttributes, Objects cannot have more than 3 levels of nesting.

    Setting a value for an existing key will overwrite it. Any attempt to add an invalid attribute will fail and the event will NOT be tracked. You can use the validateWithError method which return a list of human-readable errors to ensure your event is valid before sending it.

    Reserved event attributes

    Some event attributes have reserved keys, and are all prefixed by a $ sign. This is the list of currently reserved event attributes. You cannot set an event attribute starting by a $ sign.

    Key
    Description

    $label

    String - Optional

    Event label. Must be a string, will automatically be bridged as label for application event compatibility. Max 200 chars.

    $tags

    NSArray - Optional

    Event tags. Must be an array of string, will automatically be bridged as tags for application event compatibility. Max 10 items of type string, each no longer than 64chars. The SDK will automatically lowercase them, so two same strings with different casing do not count as two different tags

    In Batch SDK v1 you were able to set a label and tags at the root of an event, with the limit of 1 label and 10 tags.

    Batch SDK v2 introduced Object and Array types in event attributes. You can set more than one array on profiles events. This is only supported for profiles, and not on the install-centric data model, which currently powers push notification and In-App messages.

    However, it's still possible to set a label and tags on events in the install-centric data model by using $label and $tags, and activate compatibility flows. This way, you will be able to use this data for your push and in-app communications.

    If you are not running any orchestrations on the Mobile Engagement Platform (MEP), you should use String and Array attributes instead of legacy $label and $tags.

    Example

    Tracking user location

    You can now natively track a user location. This uses CoreLocation's standard CLLocation object, which you usually get from the CoreLocation itself. You can also instantiate one manually from a latitude/longitude.

    Here's an example:

    This data will allow you to send geo-targeted push notifications from the dashboard or the Campaigns API.

    The SDK will throttle location tracking to optimize network and battery usage. You can track one location event every 30 seconds, any attempt at updating the location sooner will be ignored by the SDK.

    Background events

    Events can be sent while the application is in the background by asking UIApplication to begin a background task. Once the event has been sent to the server, Batch will emit a BatchEventTrackerFinishedNotification NSNotification.

    Please note that this notification might be sent multiple times: you may want to dynamically add the observer and remove it once your event has been tracked.

    Here is a sample implementation:

    Adding a Notification Service Extension

    In order to set up the Batch Extension SDK, you'll need a notification service extension. It's a standard iOS component that will take care of downloading rich content and add it to the notification.

    Open your Xcode project, click on the File menu and then pick New -> Target. Then, pick Notification Service Extension and fill in what's left of the wizard. You can name the extension as you wish: we will name it RichNotificationsExtension for the rest of this tutorial, and write it in Swift.

    Xcode target wizard screenshot

    Xcode will then ask you if you want to activate the scheme. Press Activate.

    Before going any further, you might want to check the extension's Deployment Traget. It usually is the latest iOS minor, meaning that your extension will not run on older iOS versions. We recommend that you set it to the lowest version of iOS that your app supports, but not lower than iOS 10.0 as this is the version that introduced this extension kind.

    Xcode deployment target

    Integrating Batch Extension SDK

    Framework integration

    BatchExtension is distributed as an open-source Swift package.

    Add it using Xcode with its repository URL:

    Note: If you're getting the error: "Cannot subclass a class that was declared with the 'objc_subclassing_restricted' attribute", this is because Swift classes cannot be subclassed in Objective-C, and the extension code is pure Swift and SPM doesn't support mixed language packages. To fix this please use the Pure Objective-C version if you wish to use SPM, use CocoaPods/Carthage or rewrite your extension code in Swift.

    Make sure you're setting the dependency on the extension target. If your Podfile existed before you created your extension, you might need to add it.

    Then, link the framework to the extension just like you would with any Carthage dependency.

    Automatic integration

    If you don't have your own code, you've probably noticed that Xcode added some sample code for you:

    Default extension code

    In order to have Batch automatically adding rich content to your notifications, simply remplace this code with:

    That's it, no code to write! Start your app, and try sending a rich push from the dashboard.

    Manual integration

    If you've already added your own extension code, you might want to manually integrate Batch and perform your own modifications to the notification content.

    First, import the extension SDK:

    Then, instanciate a BAERichNotificationHelper/RichNotificationHelper instance, and keep it as an instance variable of your UNNotificationServiceExtension instance.

    Note: You must NOT instanciate a new BAERichNotificationHelper/RichNotificationHelper object every time. The class needs to keep an internal state, and might not behave properly if it cannot.

    You can then use the following methods of BAERichNotificationHelper/RichNotificationHelper:

    • didReceive, which has the same signature as the one you're already in, but allows you to tweak the UNNotificationRequest beforehand

    • appendRichData, which will download and add attachments to the content, and call you back once done.

    Here's an example of a class that uses appendRichData:

    Configuring low data mode

    Starting with version 3.0.0, BatchExtension doesn't download rich notification content in low data mode anymore.

    To change this, use BAERichNotificationHelper/RichNotificationHelper:

    Integrating the Batch Extension SDK
    Rich notification example

    Inbox

    Inbox is an optional feature. If you are interested, please contact us.

    The Inbox API allows you to fetch and process notifications that this user has previously received, even if their device was offline. You can then do anything you want with the data, such as making a "notification center", where the user can catch up with previous notifications in a list.

    The API gives you access to the entire notification, including its raw payload. It also lets you know if the notification has already been read, and allows you to mark one or all notifications as such. Once received/stored in the inbox, your push notifications will remain for a 3 months period.

    This screenshot is an example of what you can achieve with the Inbox API. Please note Batch does not include any UI.

    Inbox iOS example

    Picking the Right Fetcher

    Installation Mode

    This mode will fetch notifications from the current app installation, and nothing else. If the user clears the app's data, this inbox will be cleared. This is great for applications where your users don't have to log in.

    In this mode, you can simply get the Inbox Fetcher with a context:

    Note: This may cause privacy issues if your app has an identification system. Users sharing the same device and using different accounts in your app would be able to see the push history of previous users.

    Custom User ID Mode

    This mode will fetch notifications for the specified , even if they just installed the application and already got notifications on another device logged in with the same user identifier. If your application has a login system, this is the mode you should use.

    Since notifications can have sensitive content, you cannot get a user's notifications simply with their user identifier: Batch requires you to authenticate your request.

    Getting Your Authentication Key

    First, you will need your inbox secret key. You will find that in your dashboard, below your API Keys. It is unique for every app.

    The authentication key is generated by computing a sha256 hmac hash of the API Key concatenated with the user identifier, using the secret as the key. Then, you have to encode the hash in a hexadecimal string.

    For the API Key "abcdef", user identifier "paul" and secret of "foobar", the string to hash is abcdefpaul and the expected authentication key would be 796f1ab5d119d1b2eab8201e60335b56d1befff40c0f80263d64a169a8fd2e45.

    PHP example code:

    Note: This hash HAS to be computed on your server. If you bundle the inbox secret in your application to compute the hash, attackers will be able to extract it, and read the notifications of any of your users

    Getting the Fetcher Instance

    Once you've got the authentication key from the server, you only have to give Batch the right user identifier and auth key tuple to get the Inbox Fetcher:

    Fetching Notifications

    Now that you've got your fetcher instance, it's time to fetch notifications, and display them!

    The inbox fetcher has several important methods and properties:

    • allFetchedNotifications This returns a copy of all the notifications that have been fetched. Useful for a list adapter. Warning: Calling this always makes a copy of the objects, so you should cache that method's result.

    • fetchNewNotifications() Allows you to fetch notifications that might have been received after the initial fetch. This is useful for implementing a refresh feature. This will erase the notification history returned by allFetchedNotifications to ensure consistency: you should clear the other notification pages you've already from your cache.

    Note: BatchInboxFetcher and its methods are well documented in BatchInbox.h. You can also use the of BatchInboxFetcher to get detailed explanations about what every method does.

    BatchInboxFetcher will not fetch any notification by default, so before trying to display anything, you will need to call fetchNewNotifications() or fetchNextPage()

    Both fetch methods take a block, which the SDK will call you back on either on failure, or success. Success callbacks include information about the operation to operate on the data, but you can very well do with the global methods. The block callbacks are always called on the main thread.

    Reading Notification Content

    Once you've fetched notifications, you will end up with a list of BatchInboxNotificationContent objects.

    These objects have everything you need to display these notifications:

    • Title

    • Body

    • Send timestamp (UTC)

    • Read state

    Note: Just like when you get it using iOS' standard callbacks, the raw payload (accessible from the payload property) should be used carefully on keys you do not control:

    • "aps" is considered private by Apple, and can change at any time. This has happened in the past, where the "alert" object got additional keys for new iOS features.

    • "com.batch" is Batch's internal payload: You should not make any assumption about its content, nor depend on it. We reserve the right to change it at anytime, without warning.

    • Standard parsing good practices apply: Make sure to check every cast and handle errors gracefully, and never assume anything about the payload's content.

    You can then use the same methods that you can use on push payloads to extract information. Example: BatchPush.deeplink(fromUserInfo: notificationContent.payload), where "notificationContent" is a BatchInboxNotificationContent instance.

    Marking Notifications as Read

    Notifications can be marked as read in two ways:

    • By marking only one notification as read Use markNotification(asRead: notification) with the notification you want to mark as read.

    • By marking all notifications as read Simply call markAllNotificationsAsRead()

    In both cases, the notifications will be marked as read locally, but refreshing them might mark them as unread again, as the server might not have processed the request. These methods return quickly, and are thus safe to call on your UI thread.

    Note that notifications that have been opened when received are automatically marked as read.

    Displaying Mobile Landing

    Batch allows you to display a mobile landing attached to a notification. To do so, you can simply trigger the landing message from the BatchInboxNotificationContent object as following:

    Marking Notifications as Deleted

    Notifications can be deleted using the markNotification(asDeleted: notification) method with the notification you want to mark as deleted. A deleted notification will NOT appear in the notification list the SDK provides, and you will be expected to update your UI accordingly.

    The notifications will be marked as deleted locally, but refreshing them might make them appear again, as the server might not have processed the request. These methods return quickly, and are thus safe to call on your UI thread.

    Tweaking the Fetcher

    For more advanced usages, you can also change various aspects of the Inbox Fetcher, such as:

    • The maximum number of notifications fetched per page (maxPageSize)

    • The maximum number of notifications that can be fetched using this object (limit) A default limit is set to avoid going over memory by accident.

    • 1.19.0 Disabling the filtering of silent notifications (filterSilentNotifications). A silent notification is a push that doesn't show any visible message to the user.

    Testing Your Integration

    In order to test your integration, you will need to create a push campaign on the dashboard. Please see our fore more info.

    Create campaign

    API Description

    Request structure

    Campaign API exposes a POST endpoint that allows to create a campaign:

    /campaigns/create

    POST - Set or update

    The Custom Data API allows you to send custom data on specific custom user IDs (//) and improve your campaign targetings.

    This is helpful when users can perform actions outside of the app (e.g. purchase, subscription, updated profile, etc). You can use the API to post, update data or remove data.

    Request structure

    The users data endpoint allows you to set user data either for one user, or for multiple users.

    Important Note: Any data changed by calling this API will

    Attributes

    In addition of setting a custom user ID, an email address or overriding the language/region, you can assign attributes to your users, allowing you to improve your orchestrations targeting.

    Important:

    User IDs must be managed using our implementation.

    Email address must be managed using our implementation.

    Region/language data must be managed using our implementation.

    Never use an existing tagging plan.

    Newly tracked attributes are hidden by default. You will need to manually display them from the dashboard settings.

    POST - Create request

    The Export API is a feature only available on the Enterprise plan.

    The Export API allows you to create export requests, get their and the link to download the file when ready. Exports are performed asynchronously & generated files have a TTL of one month. This page documents the creation endpoint.

    Lookback

    Some kind of exports are logs of detailed events that happened. Those raw events are not kept forever and will stop being available to export after a while: this is documented in the "Lookback" duration for each event kind. Any data older than the lookback period, even if requested with from, will be missing. Exports that represent a snapshot of data (such as Userbase) do not have this limitation.

    AppDelegate.swift
    import Batch
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Start Batch.
        BatchSDK.start(withAPIKey: "YOUR_API_KEY")
        
        // Ask for the permission to display notifications
        // The push token will automatically be fetched by the SDK
        BatchPush.requestNotificationAuthorization()
        
        // Alternatively, you can call requestNotificationAuthorization later
        // But, you should always refresh your token on each application start
        // This will make sure that even if your user's token changes, you still get notifications
        // BatchPush.refreshToken();
        
        // Sets Batch as your UNUserNotificationCenterDelegate.
        // This will disable the legacy callbacks on your app delegate (didReceiveRemoteNotification, ...).
        // If you rely on those, do not add this line and please consider migrating to the UserNotification framework.
        //
        // If you already have a UNUserNotificationCenterDelegate implementation, do not add this line.
        // Instead, add Batch's callbacks in your implementation. See 'Advanced > Intercepting notifications', 
        BatchUNUserNotificationCenterDelegate.registerAsDelegate()
    
        return true
    }
    AppDelegate.m
    @import Batch;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {  
        // Start Batch.
        [BatchSDK startWithAPIKey:@"YOUR_API_KEY"]; 
     	
        // Ask for the permission to display notifications
        // The push token will automatically be fetched by the SDK
        [BatchPush requestNotificationAuthorization];
    
        // Alternatively, you can call requestNotificationAuthorization later
        // But, you should always refresh your token on each application start
        // This will make sure that even if your user's token changes, you still get notifications
        // [BatchPush refreshToken];
    
        // Sets Batch as your UNUserNotificationCenterDelegate.
        // This will disable the legacy callbacks on your app delegate (didReceiveRemoteNotification, ...).
        // If you rely on those, do not add this line and please consider migrating to the UserNotification framework.
        //
        // If you already have a UNUserNotificationCenterDelegate implementation, do not add this line.
        // Instead, add Batch's callbacks in your implementation. See 'Advanced > Intercepting notifications', 
        [BatchUNUserNotificationCenterDelegate registerAsDelegate];
    
        return YES;
    }
        // Ask for the permission to display notifications
        // The push token will automatically be fetched by the SDK
        BatchPush.requestNotificationAuthorization()
        
        // Ask for the permission to display notifications with a completion handler.
        // The push token will automatically be fetched by the SDK
        BatchPush.requestNotificationAuthorization { success, error in
          // Handle permission result
        }
    
        // Ask for the provisionnal permission to display notifications
        // Notifications will NOT be displayed on the lock screen, or as a banner when the phone is unlocked.
        // They will directly be sent to the notification center, accessible when the user swipes up on the lockscreen, or down
        // The push token will automatically be fetched by the SDK.
        BatchPush.requestProvisionalNotificationAuthorization()
        // Ask for the permission to display notifications
        // The push token will automatically be fetched by the SDK
        [BatchPush requestNotificationAuthorization];
        
        // Ask for the permission to display notifications with a completion handler.
        // The push token will automatically be fetched by the SDK
        [BatchPush requestNotificationAuthorizationWithCompletionHandler:^(BOOL granted, NSError * _Nullable error) {
            // Handle permission result
        }];    
        // Ask for the provisionnal permission to display notifications
        // Notifications will NOT be displayed on the lock screen, or as a banner when the phone is unlocked.
        // They will directly be sent to the notification center, accessible when the user swipes up on the lockscreen, or down
        // The push token will automatically be fetched by the SDK.
        [BatchPush requestProvisionalNotificationAuthorization];
    }
    BatchUser.installationID()
    [BatchUser installationID];
    [Batch] - Push token (Apple Push Production): <push token>
    let attributes = BatchEventAttributes { data in
        data.put("man_clothes", forKey: "sub_category")
        data.put(Date(timeIntervalSince1970: 1713432899086), forKey: "end_of_sale_date")
        data.put([
            BatchEventAttributes { itemData in
                itemData.put("Basic Tee", forKey: "name")
                itemData.put("M", forKey: "size")
                itemData.put(23.99, forKey: "price")
                itemData.put(URL(string: "https://batch-store.com/basic-tee")!, forKey: "item_url")
                itemData.put(URL(string: "https://batch-store.com/basic-tee/black/image.png")!, forKey: "item_image")
                itemData.put(true, forKey: "in_sales")
            },
            BatchEventAttributes { itemData in
                itemData.put("Short socks pack x3", forKey: "name")
                itemData.put("38-40", forKey: "size")
                itemData.put(15.99, forKey: "price")
                itemData.put(URL(string: "https://batch-store.com/short-socks-pack-x3")!, forKey: "item_url")
                itemData.put(URL(string: "https://batch-store.com/short-socks-pack-x3/image.png")!, forKey: "item_image")
                itemData.put(false, forKey: "in_sales")
            }
        ], forKey: "items_list")
        data.put("accessories", forKey: "$label")
        data.put(["first_purchase", "in_promo"], forKey: "$tags")
    }
    do {
        let _ = try attributes.validate()
        BatchProfile.trackEvent(name: "purchased", attributes: attributes)
    } catch let error {
        print("Event validation error: \(error.localizedDescription)")
    }
    BatchEventAttributes *attributes = [BatchEventAttributes new];
    [attributes putString:@"man_clothes" forKey:@"sub_category"];
    [attributes putDate:[NSDate dateWithTimeIntervalSince1970:1713432899086] forKey:@"end_of_sale_date"];
    
    NSMutableArray *itemsList = [NSMutableArray array];
    BatchEventAttributes *item1 = [BatchEventAttributes new];
    [item1 putString:@"Basic Tee" forKey:@"name"];
    [item1 putString:@"M" forKey:@"size"];
    [item1 putFloat:23.99 forKey:@"price"];
    [item1 putURL:[NSURL URLWithString:@"https://batch-store.com/basic-tee"] forKey:@"item_url"];
    [item1 putURL:[NSURL URLWithString:@"https://batch-store.com/basic-tee/black/image.png"] forKey:@"item_image"];
    [item1 putBool:YES forKey:@"in_sales"];
    [itemsList addObject:item1];
    
    BatchEventAttributes *item2 = [BatchEventAttributes new];
    [item2 putString:@"Short socks pack x3" forKey:@"name"];
    [item2 putString:@"38-40" forKey:@"size"];
    [item2 putFloat:15.99 forKey:@"price"];
    [item2 putURL:[NSURL URLWithString:@"https://batch-store.com/short-socks-pack-x3"] forKey:@"item_url"];
    [item2 putURL:[NSURL URLWithString:@"https://batch-store.com/short-socks-pack-x3/image.png"] forKey:@"item_image"];
    [item2 putBool:NO forKey:@"in_sales"];
    [itemsList addObject:item2];
    
    [attributes putObjectArray:itemsList forKey:@"items_list"];
    [attributes putString:@"accessories" forKey:@"$label"];
    [attributes putStringArray:@[@"first_purchase", @"in_promo"] forKey:@"$tags"];
    
    NSError *err;
    [attributes validateWithError:&err];
    if (err == nil) {
        [BatchProfile trackEventWithName:@"purchased" attributes:attributes];
    } else {
        NSLog(@"Event validation error: %@", err.description);
    }
    // let location: CLLocation = [...]
    BatchProfile.trackLocation(location)
    // CLLocation *location = [...];
    [BatchProfile trackLocation:location];
    @objc
    class BackgroundEventSender : NSObject {
        var eventBackgroundEventTaskID: UIBackgroundTaskIdentifier?
        
        override init() {
            super.init()
            NotificationCenter.default.addObserver(self, selector: #selector(finishBackgroundTask), name: Notification.Name.BatchEventTrackerFinished, object: nil)
        }
        
        func trackBackgroundEvent() {
            guard eventBackgroundEventTaskID == nil else {
                // This sample code doesn't support tracking multiple events at once
                return
            }
            
            eventBackgroundEventTaskID = UIApplication.shared.beginBackgroundTask(withName: "batch_background_event", expirationHandler: self.finishBackgroundTask)
            
            BatchProfile.trackEvent(name: "SAMPLE_BACKGROUND_EVENT")
    
        }
        
        @objc
        func finishBackgroundTask() {
            guard let task = eventBackgroundEventTaskID else {
                return
            }
            self.eventBackgroundEventTaskID = nil
            UIApplication.shared.endBackgroundTask(task)
        }
    }
    Package.swift
    https://github.com/BatchLabs/Batch-iOS-SDK-Extension.git
    Podfile
    target 'RichNotifications' do
      use_frameworks!
      pod 'BatchExtension'
    end
    
    target 'App' do
      use_frameworks!
      pod 'Batch'
    end
    Cartfile
    github "BatchLabs/Batch-iOS-SDK-Extension"
    import BatchExtension
    
    class NotificationService: BAENotificationServiceExtension {
        
    }
    // NotificationService.h -- 
    @import BatchExtension;
    
    @interface NotificationService : BAENotificationServiceExtension
    @end
    
    // NotificationService.m
    #import "NotificationService.h"
    @implementation NotificationService
    @end
    
    import BatchExtension
    @import BatchExtension;
    
    or
    
    #import <BatchExtension/BatchExtension.h>
    class NotificationService: UNNotificationServiceExtension {
    
        let batchHelper = RichNotificationHelper()
        
        var bestAttemptContent: UNMutableNotificationContent?
    
        override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
            
            if let bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent {
                // Modify the notification content here...
                bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
                
                // Ask Batch to download and add any rich content
                batchHelper.appendRichData(toContent: bestAttemptContent, completionHandler: { (content: UNNotificationContent?, err: Error?) in
                    if let err = err {
                        print("Error while appending rich notification attachments \(err)")
                    }
                    contentHandler(content ?? bestAttemptContent)
                })
            } else {
                contentHandler(request.content)
            }
        }
    }
    // NotificationService.h
    
    #import <UserNotifications/UserNotifications.h>
    
    @interface NotificationService : UNNotificationServiceExtension
    
    @end
    
    // NotificationService.m
    #import "NotificationService.h"
    @import BatchExtension;
    
    @interface NotificationService () {
        BAERichNotificationHelper *batchHelper;
    }
    @end
    
    @implementation NotificationService
    
    - (instancetype)init {
        self = [super init];
        if (self) {
            batchHelper = [BAERichNotificationHelper new];
        }
        return self;
    }
    
    - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
        UNMutableNotificationContent *bestAttemptContent = [request.content mutableCopy];
        
        if (bestAttemptContent) {
            // Modify the notification content here...
            bestAttemptContent.title = [bestAttemptContent.title stringByAppendingString:@" [modified]"];
            
            // Ask Batch to download and add any rich content
            [batchHelper appendRichDataToContent:bestAttemptContent completionHandler:^(UNNotificationContent * _Nullable result, NSError * _Nullable error) {
                if (error) {
                    NSLog(@"Error while appending rich notification attachments %@", error);
                }
                
                if (result) {
                    contentHandler(result);
                } else {
                    contentHandler(bestAttemptContent);
                }
            }];
        } else {
            contentHandler(bestAttemptContent);
        }
    }
    
    @end
    
    import UserNotifications
    import BatchExtension
    
    class NotificationService: UNNotificationServiceExtension {
    
        override init() {
            super.init()
            RichNotificationHelper.allowInLowDataMode = true
        }
        
    }
    // NotificationService.m
    #import "NotificationService.h"
    
    @implementation NotificationService
    
    - (instancetype)init
    {
        self = [super init];
        if (self) {
            BAERichNotificationHelper.allowInLowDataMode = true;
        }
        return self;
    }
    
    @end
    
    , forKey
    :
    "sub_category"
    )
    // Compatibility reserved key
    data.put("activity", forKey: "$label")
    })
    @"$label"
    forKey
    :
    @"activity"
    ];
    // Compatibility reserved key
    [BatchProfile trackEventWithName:@"add_to_cart" attributes:attributes];
    event dispatcher
    Declare your Universal Links
    fetchNextPage()
    Fetches the next page of notifications. Batch will
    not
    fetch all notifications at once, but only small batches of them in pages. Use this method to load more notifications.
  • endReached Lets you know if more notifications might be available. Use this to make an infinite list, or a "load more" button.

  • Source (Campaign API/Dashboard or Transactional API)
  • Rich notification attachment URL

  • Raw payload (like userInfo in Apple's callbacks)

  • custom user ID
    web API Reference
    guide
    Inbox secret dashboard screenshot
    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.

    Post data

    The body of the request must contain a valid JSON payload describing the request to be executed, and information about the concerned user.

    Here is a how a complete JSON payload looks like:

    Id
    Description

    from

    string - Required 'now' or UTC Date in the 'YYYY-MM-ddTHH:mm:ss' format E.g."2019-08-14T22:00:00"

    to

    string - Required 'now' or UTC Date in the 'YYYY-MM-ddTHH:mm:ss' format E.g."2019-08-14T22:00:00"

    events

    array of strings - Required See version detail for each type.

    ids

    array of strings - Required See version detail for each type. E.g.["install_id","custom_id","advertising_id"]

    Push Campaign

    Lookback

    90 days

    Event list

    Id
    Description

    events

    array of string - Required events availables for push campaign E.g.["push_sent","push_open","push_error"]

    Push Campaign IDs

    https://api.batch.com/1.0/BATCH_API_KEY/export/campaign/CAMPAIGN_TOKEN/ids

    Here is a valid cURL example:

    Output example

    Push Campaign Events

    https://api.batch.com/1.0/BATCH_API_KEY/export/campaign/CAMPAIGN_TOKEN/events

    Here is a valid cURL example:

    Output example

    Transactional

    Lookback

    90 days

    Event list

    Id
    Description

    events

    array of string - Required events availables for transactional E.g.["push_sent","push_open","push_error"]

    Transactional IDs

    https://api.batch.com/1.0/BATCH_API_KEY/export/transactional/GROUP_ID/ids

    Here is a valid cURL example:

    Output example

    Transactional Events

    https://api.batch.com/1.0/BATCH_API_KEY/export/transactional/GROUP_ID/events

    Here is a valid cURL example:

    Output example

    In-app Campaign

    Lookback

    90 days

    Event list

    Id
    Description

    events

    array of string - Required events availables for in-app campaign E.g.["inapp_shown","inapp_clicked","inapp_closed"]

    In-app Campaign IDs

    https://api.batch.com/1.0/BATCH_API_KEY/export/in-app-campaign/CAMPAIGN_TOKEN/ids

    Here is a valid cURL example:

    Output example

    In-app Campaign Events

    https://api.batch.com/1.0/BATCH_API_KEY/export/in-app-campaign/CAMPAIGN_TOKEN/events

    Here is a valid cURL example:

    Output example

    Reachability

    A reachability event is generated when an installation's reachability status changes, meaning a change in one of these attributes:

    • is_reachable: true if the installation has a push token

    • is_optin: true if the installation enabled push notifications for the app

    • has_custom_id : true if the installation is linked to a user profile with a Custom User ID

    https://api.batch.com/1.0/BATCH_API_KEY/export/reachability/events

    Lookback

    90 days

    Request

    Here is a valid cURL example:

    The body of the request must contain a valid JSON payload describing the request to be executed, and information about the concerned user.

    Here is a how a complete JSON payload looks like:

    Id
    Description

    from

    string - Required 'now' or UTC Date in the 'YYYY-MM-ddTHH:mm:ss' format E.g."2019-08-14T22:00:00"

    to

    string - Required 'now' or UTC Date in the 'YYYY-MM-ddTHH:mm:ss' format E.g."2019-08-14T22:00:00"

    ids

    array of strings - Required See version detail for each type. E.g.["install_id","custom_id","advertising_id"]

    Output example

    Userbase

    Lookback

    Not applicable

    Request

    https://api.batch.com/1.0/BATCH_API_KEY/export/userbase

    Here is a valid cURL example:

    Post data

    The body of the request must contain a valid JSON payload describing the request to be executed, and information about the concerned user.

    Here is a how a complete JSON payload looks like:

    Output example

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a unique request_id representing the request.

    Please keep this token: It will be useful to check the status and get the result of your request.

    Failure

    If the user in the POST data is currently being processed, the API will return a HTTP 409 Conflict status code.

    If the POST 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)

    • MISSING_PARAMETER (HTTP status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (HTTP status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (HTTP status code: 400, Error code: 32)

    • SERVER_ERROR (HTTP status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (HTTP status code: 503, Error code: 2)

    status
    let inboxFetcher = BatchInbox.fetcher()
    BatchInboxFetcher* inboxFetcher = [BatchInbox fetcher];
    $APP_API_KEY = "abcdef";
    $USER_ID = "paul";
    $INBOX_SECRET = "foobar";
    $HASHED_STRING = $APP_API_KEY . $USER_ID; // "abcdefpaul". Note that . is the PHP concatenation operator. In another language, it usually is +
    hash_hmac("sha256", $HASHED_STRING, $INBOX_SECRET) // Returns "796f1ab5d119d1b2eab8201e60335b56d1befff40c0f80263d64a169a8fd2e45"
    let inboxFetcher = BatchInbox.fetcher(forUserIdentifier: "paul", authenticationKey: "796f1ab5d119d1b2eab8201e60335b56d1befff40c0f80263d64a169a8fd2e45")
    BatchInboxFetcher* inboxFetcher = [BatchInbox fetcherForUserIdentifier:@"paul" authenticationKey:@"796f1ab5d119d1b2eab8201e60335b56d1befff40c0f80263d64a169a8fd2e45"];
    func notificationClicked(notification: BatchInboxNotificationContent) {
      if (notification.hasLandingMessage) {
          notification.displayLandingMessage()
      }
    }
    - (void)notificationClicked:(BatchInboxNotificationContent *)notification {
        if (notification.hasLandingMessage) {
            [notification displayLandingMessage];
        }
    }
    
    {
      "from": "2019-08-14T22:00:00",
      "to": "now",
      "events": ["push_sent", "push_open", "push_error"],
      "ids": ["install_id", "custom_id"]
    }
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/campaign/CAMPAIGN_TOKEN/ids"
    install_id;custom_id;advertising_id;event_type
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_sent
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_opened
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_error
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/campaign/CAMPAIGN_TOKEN/events"
    install_id;custom_id;advertising_id;event_date;event_type
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T00:00:00;push_sent
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;push_opened
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;push_error
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/transactional/GROUP_ID/ids"
    install_id;custom_id;advertising_id;event_type
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_sent
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_error
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;push_opened
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/transactional/GROUP_ID/events"
    install_id;custom_id;advertising_id;event_date;event_type;transactional_token
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;push_sent;5bc1861d86c96c22685a6b6cbcc72
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;push_error;5bc1861d86c2c22685a6b6cbcc72
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;push_opened;5bc18616d02c22685a6b6cbcc72
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/in-app-campaign/CAMPAIGN_TOKEN/ids"
    install_id;custom_id;advertising_id;event_type
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;inapp_shown
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;inapp_clicked
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;inapp_closed
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/in-app-campaign/CAMPAIGN_TOKEN/events"
    install_id;custom_id;advertising_id;event_date;event_type;cta;cta_position
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;inapp_shown;;
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;inapp_clicked;batch.CustomAction;1
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;inapp_clicked;batch.dismiss;1
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;inapp_clicked;batch.deeplink;0
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T09:00:00;inapp_closed;;
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/reachability/events"
    {
      "from": "2019-08-14T22:00:00",
      "to": "now",
      "ids": ["install_id", "custom_id"]
    }
    install_id;custom_id;advertising_id;event_date;event_type;is_reachable;is_optin;has_custom_id
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;2017-07-24T00:00:00;reachability;true;true;false
    curl -H "Content-Type: application/json" \
         -H "X-Authorization: BATCH_REST_API_KEY" \
         -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/export/userbase"
    {
      "ids": ["install_id", "custom_id", "advertising_id"],
    }
    install_id;custom_id;advertising_id;is_optin_push;install_date;last_start_date;smart_segment
    INSTALLATION_ID;CUSTOM_USER_ID;ADVERTISING_ID;true;2017-07-24T09:00:00;2017-07-24T10:00:00;2017-07-24T11:00:00;Engaged
    { "requestId": "110e8400-e29b-11d4-b543-446655440000" }

    Headers and authentication

    See Overview → Using Project APIs.

    Post data

    Exemple of a request body:

    The body must include a valid JSON payload containing the following blocks:

    • General information about the campaign.

    • "When" part (Required) which indicates when to send the campaign.

    • "Targeting" which indicates who will be the recipients of the campaign (default is the entire user base).

    • "Messages" part (Required) describing the message to send. Payload will be different if you want to send an email or a push message.

    Campaign general information

    Describing name and state of the campaign.

    For the time being, Batch supports the "RUNNING", "STOPPED" and "DRAFT" state for a campaign.

    Send rate (optional)

    Send_rate sets the maximum sending speed for the campaign. The value must be an integer between 1,000 and 1,000,000, representing the number of messages sent per minute. This parameter is optional : if not set, the campaign will be sent at the maximum system speed.

    Labels (optional)

    An array of up to 5 unique label strings. These labels must have already been created via Dashboard, otherwise an error will be thrown.

    When block

    Describing when to send the campaign - required.

    Targeting block

    Describing who will be reached by the campaign. This block is not required, if you omit it, Batch will consider sending the campaign to the entire user base.

    Messages block - for email

    Describing the messages to send when sending an email campaign - required.

    messages is an array that can only contain one element.

    Channel type

    value should be email

    Sender Identity

    Sender identity describes which sender email will be used. This sender needs to be created before the API Call. If not existing, it will not generate a new ID and the API Call will fail. Sender identity ID can be found on the dashboard (Email channel settings).

    Languages array

    Email messages are available with multi-language

    Messages block - for push

    Describing the messages to send when sending a push campaign - required.

    messages is an array that can only contain one element.

    Channel type

    value should be push

    Filter push tokens

    filter_push_tokens allows you to target collected tokens or imported tokens, or both.

    • all : the campaign will target imported and collected push tokens

    • collected : the campaign will target only collected push tokens, detected by Batch SDKs

    • imported : the campaign will target only imported push tokens, not yet detected by Batch SDKs

    iOS / Android / Web platorms

    A push campaign can send the same message to several platforms, using the platform_type Array. You can select one platform only or a combination of 2 or 3 platforms. You can add some platform specific values for a platform by setting them inside of the ios, android and web objects.

    Languages array

    Push messages are available with multi-language

    iOS specific attributes

    The iOS object can specify some attributes:

    • deeplink

    • custom payload

    Android specific attributes

    The Android object comes with android properties:

    • deeplink

    • custom payload

    • media (icon)

    • Collapse key

    Web specific attributes

    The Web object can specify some attributes:

    • deeplink

    • media (icon)

    Multi-language

    languages allows you to define many translations. Each item of an array will give you translation of many attributes (content & some parameters) for the designed language.

    All required parameters at the top level of a message is also required in any given translation.

    Email & Push messages can both be translated.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    • 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.

    Note than A/B testing cannot be performed via the API.

    not
    be available in real time: Processing time can be required. See
    for more info.

    Route

    The Custom Data API exposes two POST endpoints:

    • https://api.batch.com/1.0/BATCH_API_KEY/data/users/YOUR_USER_ID for a single update

    • https://api.batch.com/1.0/BATCH_API_KEY/data/users for bulk updates

    NOTE: YOUR_USER_ID is the Custom ID matching the ones you set using the SDKs.

    Bulk updates allow you to update custom data for multiple users (up to 10,000) with one API call.

    Here are two valid cURL examples.

    Single update:

    Bulk update:

    The BATCH_API_KEY value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (Settings → General)

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    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.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    Post data

    For a single update, the body of the request must contain a valid JSON payload describing the update operations to execute for the user's custom data.

    Here is a how a complete JSON payload looks like:

    Let's see the parameters in detail.

    Id
    Description

    overwrite

    Boolean - Optional Instead of merging the data we already have for a user, the existing data will be *deleted* and replaced by the incoming data. Defaults to false E.g.{"overwrite":true}

    values

    Object - Required An object containing all attributes and tags with their respective update operations

    Using the tag operations $add and $remove when overwrite is set to true might not have the behaviour you would expect: $add will work but will append tags on an empty tag collection, clearing any previously set tag. $remove is simply ignored.

    The values object

    The values object details what operations to do on a set of attributes or tags. It has the following form:

    Only one operation per attribute or tag is allowed in one call to the API.

    The scope

    The scope determines what the key refers to: an attribute or tags:

    • u is for attributes

    • ut is for tags

    Important note: Attributes/tags names are string. They should be made of letters, numbers or underscores ([a-z0-9_]). They can't be longer than 30 characters and cannot contain uppercase characters.

    The attribute value

    The value describes what you want to do on an attribute; either set or remove a value. The rules are as follow:

    • When the value is null, the attribute is removed.

    • Otherwise the attribute's value is inserted or updated.

    The following types are supported in a value:

    • string. E.g: {"u.nickname": "Johnny"}

    • integer. E.g: {"u.age": 23}

    • boolean. E.g: {"u.is_subscribed": true}

    • float. E.g: {"u.level_progress": 45.09}

    Additional types

    Date

    We support dates, unfortunately JSON does not, thus we need extra information to know an attribute is actually a date. We do this via wrapping the key name in the date() function.

    If you're using date() on a string, be sure to use the format YYYY-MM-ddTHH:mm:ss. Be aware that we will interpret the date as UTC in both cases.

    URL

    URL type is also supported. You will need to wrap the key name in the url() function.

    You need to provide a valid URL, in the limit of 2048 characters:

    • A scheme is compulsory (myapp://, https://...)

    • :// is compulsory after the scheme

    If the URL provided isn't valid, the API call will fail.

    The tag update operation

    The value describes what you want to do on a tag. The rules are as follow:

    • When the value is null, the tag is removed.

    • When the value is in array, the tag's content is replaced.

    • When the value is an object, that object must describe the update to do. See below for the description of that object.

    Here is the description of a tag update object.

    Id
    Description

    $add

    Array - Optional The values to add to the tag E.g.{"$add":["Paris","Berlin","San Francisco"]}

    $remove

    Array - Optional The values to remove from the tag E.g.{"$remove":["Tokyo","London","New York"]}

    Here is a complete example combining all possible operations:

    Bulk post data

    Bulk updates work basically the same way as a single update, except now you need to provide an array of objects of the following type:

    Id
    Description

    id

    String - Required The user id E.g.{"id":"Vincent"}

    update

    Object - Required The update operation as described for the single update above

    Here is an example of a valid JSON payload:

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 200 confirmation and a unique token reprensenting the transaction.

    Please keep this token: it will be useful for upcoming features, and it will also help in getting faster support.

    Failure

    If the POST 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)

    • MISSING_PARAMETER (Http status code: 400, Error code: 30)

    • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

    • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

    • SERVER_ERROR (Http status code: 500, Error code: 1)

    • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

    Processing time

    Data you send using this API is processed almost instantly.

    However, your userbase's global analytics may not be. This only affects the dashboard in two places: the Userbase page, and the visual query editor.

    Since the dashboard's visual query editor depends on the same data that powers Userbase, you might see outdated or missing data in the autocompleted fields. This issue will fix itself in a matter of hours: the userbase data is refreshed at worse once per 24H, but may be refreshed more often. Calling the API again will not have any effect whatsoever on the scheduled refresh.

    Rest assured: once you actually run the campaign, the latest data will be used. Same goes for API-only usage, and the debug page.

    You can see when the userbase data was last refreshed by hovering any User level section of your app's Userbase dashboard page.

    iOS
    Android
    Web
    this section
    Managing attributes

    Before we get started on how to implement attributes, here are some rules you should know.

    Naming

    Attribute names are strings. They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters (e.g. has_premium).

    Values

    Values must be any of the following types, or their native Swift equivalent:

    NSString Must not be longer than 300 characters and cannot be empty. For better results, you should make them upper/lowercase and trim the whitespaces.

    NSNumber

    Anything bigger than a long long or a double will be rejected.

    Unsigned values will be rejected.

    Booleans are supported, but should be initialized with [NSNumber numberWithBool:<your value>] or @YES/@NO.

    NSDate Since timezones are not supported, this will typically represent UTC dates.

    Using any unsupported type as a value (NSNull, NSObject, NSArray, NSDictionary for example) will NOT work. Be careful, as it may cause [editor save] to fail.

    NSURL Must not be longer than 2048 characters and must follow the format scheme://[authority][path][?query][#fragment].

    NSArray<NSString> Must not be longer than 25 items, only values of type NSString and must respect the string attribute limitations.

    Setting an attribute

    The custom attribute API works using an editor. You need to get an instance of the editor, enqueue your changes and then call save. Changes will NOT be sent until you call this method, please make sure you call it!

    There is one setAttribute/set(attribute:forKey:) method per attribute type. Use Xcode's autocompletion or see BatchProfileEditor.h for all available variants. If you're using Swift, the appropriate method will automatically be used according to the value's type.

    Those methods throw an error if key/value failed validation according to the rules expressed higher up in this documentation. Note that no error does not mean the value has already been sent to the server.

    You might be tempted to write helpers or loops that open and save many transactions in a row, with each transaction only doing one operation. Doing so prevents Batch from optimizing disk usage and network roundtrips, which impact your user's data plan and battery life. Please try to batch as many operations as you can in a single transaction.

    Removing attributes

    Use removeAttributeForKey to remove an attribute of any type.

    Reading attributes and tag collections

    Since Batch SDK v2, updating the user's data also update the profile's data to be accessible from your project scope. This mean the following APIs only read local data related to your installation and NOT to your profile.

    You may also have noticed that APIs to set Tags or Tag Collections have been removed and replaced by array attributes. These methods are backward-compatible and array attributes are converted into tag collections to not break your implementation.

    Reading attributes

    Reading tag collections

    Note: Since tags are limited in size and are case sensitive, reading them back might produce different results than what had been saved.

    Clearing installation data

    Clearing the installation data will delete all tags and attributes set on an installation and their local cache returned by fetchAttributes and fetchTagCollections. It can be done as following:

    Note: This will NOT affect the profile related data.

    custom user ID
    email subscription
    custom region/language
    Profile attributes
      {
        "name": "The campaign name",
        "state": "RUNNING",
        "send_rate" : 100000,
        "labels": ["myLabel1", "myLabel2"],
        "when": {
          "local_time": false,
          "start_time": "now"
        },
        "targeting": {
          "languages": [
            "fr"
          ],
          "regions": [
            "FR"
          ],
          "query": {
            "firstname": {
              "$eq": "Jane"
            }
          }
        },
        "messages": [
          {
            "channel_type": "email",
            "subject": "The campaign subject",
            "sender_identity_id": "4012",
            "reply_to": {
              "email_address": "jane.doe@demobatch.com"
            },
            "html": "The campaign HTML content",
            "languages" : [
              {
                "language" : "en",
                "subject" : "The campaign subject",
                "sender_identity_id" : "4012",
                "reply_to": {
                  "email_address": "jane.doe@demobatch.com"
                },
                "html": "The campaign HTML content in english"           
              },
              {
                "language" : "fr",
                "subject" : "le sujet de la campagne",
                "sender_identity_id" : "4034",
                "reply_to": {
                  "email_address": "jean.dupont@demobatch.fr"
                },
                "html": "HTML en français"            
              }
            ]
          }
        ]
      }
      "name": "The campaign name",
      "state": "RUNNING",
      "send_rate" : 100000,
      "labels": ["myLabel1", "myLabel2"],
      "when": {
        "local_time": false,
        "start_time": "now"
      }
      "targeting": {
        "languages": [
          "fr"
        ],
        "regions": [
          "FR"
        ],
        "query": {
          "firstname": {
            "$eq": "Jane"
          }
        }
      }
      "messages": [
        {
          "channel_type": "email",
          "subject": "The campaign subject",
          "sender_identity_id": "4012",
          "reply_to": {
            "email_address": "jane.doe@demobatch.com"
          },
          "html": "The campaign HTML content",
          "languages" : [
            {
              "language" : "en",
              "subject" : "The campaign subject",
              "sender_identity_id" : "4012",
              "reply_to": {
                "email_address": "jane.doe@demobatch.com"
              },
              "html": "The campaign HTML content in english"           
            },
            {
              "language" : "fr",
              "subject" : "Le sujet de la campagne",
              "sender_identity_id" : "4034",
              "reply_to": {
                "email_address": "jean.dupont@demobatch.fr"
              },
              "html": "HTML en français"            
            }
          ]
        }
      ]
      "messages": [
        {
          "channel_type": "push",
          "platform_type" : ["ios","android"],
          "title": "The campaign title",
          "body": "The campaign body",
          "time_to_live": 3600,
          "media": {
            "picture": "https://example.com/"
          },
          "priority": "normal",
          "push_type": "alert",
          "filter_push_tokens" : "collected",
          "ios": {
            "deeplink": "https://example.com/",
            "custom_payload": "{\"tag\":\"wake up push\", \"landing_screen\":\"greeting\"}"
          },
          "android": {
            "deeplink": "https://example.com/",
            "custom_payload": "{\"tag\":\"wake up push\", \"landing_screen\":\"greeting\"}",
            "media": {
              "icon": "https://example.com/"
            },
            "collapse_key": {
              "enabled": true,
              "key": "default"
            }
          },
          "web": {
            "deeplink": "https://example.com/",
            "media": {
              "icon": "https://example.com/"
            }
          }
        }
      ]
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/data/users/YOUR_USER_ID"
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X POST -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/data/users"
    {
      "overwrite": false,
      "values": {
        "u.nickname": "The Rock",
        "u.force": 42,
        "ut.hobbies": ["Lifting", "Wrestling", "Acting"],
        "u.is_subscribed": null,
        "date(u.last_subscription)": "2016-01-10T10:00:00.000",
        "date(u.last_purchase)": 1472656161,
        "ut.locations": { "$add": ["Paris"], "$remove": ["Berlin"] }
      }
    }
    {
      "<scope>.<attribute name>": <attribute value>,
      "<scope>.<attribute name>": <attribute value>,
      "<scope>.<attribute name>": <attribute value>,
      "<scope>.<attribute name>": <attribute value>,
      "<scope>.<tag name>": <tag update operation>
    }
    {
      "date(u.promo_starts)": 1451642400,
      "date(u.promo_ends)": "2021-01-01T04:00:00.000"
    }
    {
      "url(u.product_image)": "https://batchstore/product/4729/image.png",
      "url(u.product_deeplink)": "myapp://path/to/content"
    }
    {
      "ut.hobbies": ["Cooking", "Chess"],
      "ut.previous_locations": null,
      "ut.locations": { "$add": ["Paris", "London"], "$remove": ["Berlin"] }
    }
    [
      {
        "id": "Vincent",
        "update": {
          "values": {
            "u.nickname": "Vincent",
            "u.age": 55
          }
        }
      },
      {
        "id": "Johnny",
        "update": {
          "overwrite": true,
          "values": {
            "u.nickname": "BeGood",
            "u.age": 30
          }
        }
      }
    ]
    { "token": "fd576e9f-8b07-4844-91f9-ecfc2137c6f8" }
    // Get an editor instance.
    // You need to save this in a local variable until you call save
    // Editor instances don't share changes, and calling save on an empty editor will do nothing
    let editor = BatchProfile.editor()
    
    // Set an attribute. try? allows a potential error to be silently ignored
    // This example is a valid key/attribute pair, and will not throw an error.
    try? editor.set(attribute: 26, forKey:"age")
    
    // Set an array attribute
    try? editor.set(attribute: ["add_to_cart", "has_bought"], forKey: "actions")
    
    // Add a string to an array attribute 
    try? editor.addToStringArray(item: "has_bought", forKey: "actions")
    
    
    // Set an attribute with error handling.
    do {
        // Invalid attribute name, $ is a forbidden character
        try editor.set(attribute: "patricia", forKey: "fir$t_name")
    } catch {
        // Handle the error here.
        // Error is of type BatchProfileError if you want to specifically
        // handle it.
    }
    
    // Don't forget to save the changes
    editor.save() 
    
    // Alternatively you can use `editWithBlock` and make all your changes in a closure.
    BatchProfile.editor { editor in
        try? editor.set(attribute: "patricia", forKey: "firt_name")
         // No need to save here since Batch will automatically save your change after executing the block.
    }
    // Get an editor instance.
    // You need to save this in a local variable until you call save
    // Editor instances don't share changes, and calling save on an empty editor will do nothing
    BatchProfileEditor *editor = [BatchProfile editor];
    
    // Set an attribute, silently ignoring a potential error
    // This example is a valid key/attribute pair, and will not throw an error.
    [editor setIntegerAttribute:@26 forKey:@"age" error:nil];
    
    // Set an array attribute
    [editor setStringArrayAttribute: @[@"added_to_cart", @"has_bought"] forKey:@"actions" error:nil];
    
    // Add a string to an array attribute 
    [editor addItemToStringArrayAttribute:@"actions" forKey:@"has_bought" error:nil]
    
    // Set an attribute with error handling.
    NSError *err;
    if (![editor setStringAttribute:@"patricia" forKey:@"fir$t_name" error:&err]) { ; // Invalid attribute name, $ is a forbidden character
        // Handle the error here.
    }
    // Don't forget to save the changes
    [editor save]; 
    
    // Alternatively you can use `editWithBlock` and make all your changes in a closure.
    [BatchProfile editWithBlock:^(BatchProfileEditor * _Nonnull editor) {
        [editor setStringAttribute:@"patricia" forKey:@"firt_name" error:nil];
        // No need to save here since Batch will automatically save your change after executing the block.
    }];
    // Get an editor instance.
    // You need to save this in a local variable until you call save
    // Editor instances don't share changes, and calling save on an empty editor will do nothing
    let editor = BatchProfile.editor()
    
    // Remove an attribute
    editor.removeAttribute(forKey: "age") 
    
    // Remove a string from an array
    try? editor.removeFromStringArray(item: "has_bought", forKey: "actions")
    
    // Don't forget to save the changes
    editor.save() 
    // Get an editor instance.
    // You need to save this in a local variable until you call save
    // Editor instances don't share changes, and calling save on an empty editor will do nothing
    BatchProfileEditor *editor = [BatchProfile editor];
    
    // Remove an attribute
    [editor removeAttributeForKey:@"age"]; 
    
    // Remove a string from an array
    [editor removeItemFromStringArrayAttribute:@"has_bought" forKey:@"actions" error:nil];
    
    // Don't forget to save the changes
    [editor save];
    BatchUser.fetchAttributes { attributes in
        // Attributes are retrieved in the form of a dictionary
        // Values are encapsulated in an instance of BatchUserAttribute
        let attribute: BatchUserAttribute = attributes["age"]
                
        // BatchUserAttribute holds a reference to the value of the attribute
        let rawValue: Any = attribute.value // Raw value is not typed
        print(rawValue) // Prints "NSNumber(26)"
                
        // The type of the value is specified via a BatchUserAttributeType enumeration
        print(attribute.type) // Prints "BatchUserAttributeTypeLongLong"
                
        // To obtain a typed result you can use one of the four helper methods
        attribute.numberValue() // Will return "26" here
        attribute.dateValue()   // Will return nil here
        attribute.stringValue() // Will return nil here
        attribute.urlValue()    // Will return nil here
    }
    [BatchUser fetchAttributes:^(NSDictionary<NSString *,BatchUserAttribute *> * _Nullable attributes) {
        // Attributes are retrieved in the form of a dictionary
        // Values are encapsulated in an instance of BatchUserAttribute
        BatchUserAttribute *attribute = attributes[@"age"];
    
        // BatchUserAttribute holds a reference to the value of the attribute
        id rawValue = attribute.value; // Raw value is not typed
        NSLog(rawValue); // Prints "NSNumber(26)"
            
        // The type of the value is specified via a BatchUserAttributeType enumeration
        NSLog(attribute.type); // Prints "BatchUserAttributeTypeLongLong"
        
        // To obtain a typed result you can use one of the three helper methods
        [attribute numberValue];    // Will return "26" here
        [attribute dateValue];      // Will return nil here
        [attribute stringValue];    // Will return nil here
    }];
    BatchUser.fetchTags { tagCollections in
        // Tags are also retrieved in the form of a dictionary
        // Keys are names of collections, values are sets of tags
        let tagCollection: Set<String> = tagCollections["actions"]
        print(tagCollection) // Prints "["has_bought"]"
    }
    [BatchUser fetchTags:^(NSDictionary<NSString *,NSSet<NSString *> *> * _Nullable tagCollections) {
        // Tags are also retrieved in the form of a dictionary
        // Keys are names of collections, values are sets of tags
        NSSet<NSString *> *tagCollection = tagCollections[@"actions"];
        NSLog(tagCollection) // Prints "["has_bought"]"
    }];
    BatchUser.clearInstallationData();
    [BatchUser clearInstallationData];

    Webhooks

    Webhooks feature allows you to get a real-time stream of events sent to your HTTPS endpoint. Webhooks alert you about events that have just occurred - for instance, a user displayed an In-App campaign, or subscribed to push notifications.

    Combined with our Export API, they are often used to:

    • Orchestrate multi-channel communications

    • Keep your user profile data in sync with Batch related events

    Webhooks is a paid option and will be setup with the help of your Solutions Engineer. Please contact us if you are interested.

    Overview

    HTTPS requests sent to the endpoint by Batch:

    • will use the POST method/verb.

    • will contain a JSON data payload (Content-Type: application/json).

    • will be identified with User agent (User-Agent: Batch.com/1.0).

    Requirements

    • Endpoint must use HTTPS (valid SSL certificate issued by a recognized authority).

    • Response time should be under 100 milliseconds (ms) and endpoint must be localized in the EU area.

    • Response body won't be handled by Batch. We are only expecting an HTTP 200 or 201 status code.

    • Endpoint should be able to deduplicate events based on their ID if uniqueness is required.

    Authentication

    Secret key

    In order to authenticate with your endpoint, Batch will provide your Webhook Secret as the value of the X-Authorization header.

    OAuth2

    Alternatively, if your endpoint supports an OAuth2 authentication, the header will pass the OAuth2 Access Token under the standard Authorization header:

    You'll have to provide Batch with the full URL of your authorization endpoint, and a set of grant_type, client_id and client_secret credentials.

    Retries

    If your endpoint fails to return a 200 or 201 status code Batch will retry periodically using an exponential backoff.

    Your endpoint might be disabled if we receive too many errors over a long period: if that happens a manual intervention is required to enable the endpoint.

    Batching

    Batch supports delivering more than one event in a single HTTP request. This is useful to increase the delivery throughput and reduce the load on your endpoints.

    Batching can be configured with the following properties:

    • max size which is the maximum number of events that should be in a batch. A batch is guaranteed to never have more than this number of events however it can have less events.

    • max wait time which is the maximum amount of time to wait before the batch is sent regardless of its size.

    For example if batching is enabled with a max size of 10 and a max wait time of 5s the following will happen:

    • the batch is sent as soon as 10 events are generated

    • the batch is sent after 5s even if less than 10 events are generated

    Batching is disabled by default. If you decide to enable it you can choose values in the following ranges:

    • max size must be between 10 and 1000.

    • max wait time must be between 1s and 30s.

    If you don't choose values Batch will use default values:

    • max size of 100.

    • max wait time of 5s.

    Data payload

    The body of the request will contain a valid JSON payload describing a message and a single event (or a batch of events).

    Here is how a complete JSON payload for a single event looks like:

    A batch of events is composed of a number of single events in an array. The format of each event is the same as the example above.

    Here is how a complete JSON payload for a batch of events looks like:

    Test events

    When configuring your Webhook endpoint Batch can send test events which can help you test and validate your code.

    The payload will have the same format as a normal event, other than its event_type which will always be prefixed with test_.

    All data in a test event will be randomly generated so take care not to save it.

    Event types

    push_campaign_sent

    Event generated for every Push notification sent in a campaign.

    push_campaign_open

    Event generated for every Push notification opened in a campaign.

    push_campaign_undelivered

    Event generated for every Push notification not delivered in a campaign.

    Reasons:

    • uninstalled : installation's push token has been unregistered

    • error : an error has been returned by the push API (see error code)

    • capping_limit : installation has reached a capping rule

    push_transactional_sent

    Event generated for every Push notification sent in a Transactional API request.

    push_transactional_open

    Event generated for every Push notification opened in a Transactional API request.

    push_transactional_undelivered

    Event generated for every Push notification not delivered in a Transactional API request.

    Reasons:

    • not_found : no installation could be found for the supplied ID

    • unreachable : no push token could be found for the supplied ID

    • uninstalled : installation's push token has been unregistered

    in_app_campaign_displayed

    Event generated for every In-app message displayed in a campaign.

    in_app_campaign_clicked

    Event generated for every In-app message clicked in a campaign.

    in_app_campaign_closed

    Event generated for every In-app message closed in a campaign.

    push_reachability_change

    Event generated whenever an installation's reachability status change (eg: opt-in, opt-out, uninstall the app etc.).

    Properties:

    • is_reachable : installation has a push token

    • is_optin : installation enabled Push notifications for the app

    • has_custom_id : installation is linked to a user profile

    Update profile

    Profiles centralize data and events from multiple sources (Apps, Websites, APIs) in a single place based on the Custom ID.

    Use /profiles/update for continuous streams and rapid processing of small batches where quick data ingestion is key. Learn more about selecting the right endpoint here: .

    API Description

    will be authenticated (see below).
  • will be sent at least once (depending on retries).

  • As Batch is built on a scalable infrastructure, we cannot guarantee which IPs the request can come from for IP whitelisting. Please rely on filtering based on the User-Agent & Authentication headers.

    expired : notification reached TTL before delivery
    error : an error has been returned by the push API (see error code)
  • capping_limit : installation has reached a capping rule

  • expired : notification reached TTL before delivery

  • X-Authorization: BATCH_WEBHOOK_SECRET
    Authorization: Bearer OAUTH2_ACCESS_TOKEN
    {
      // version of this message
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
    
      // fields provided on every event
      "event_type": "push_campaign_sent",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
    
      // related identifiers
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002"
      },
    
      // additional properties (optional)
      "properties": {}
    }
    {
      // version of the batch
      "version": 1,
    
      "events":
      [
        {
          // version of this message
          "version": 1,
          "api_key": "5306192C3549E92B2633D782D8A37X",
    
          // fields provided on every event
          "event_type": "push_campaign_sent",
          "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
          "occurred_at": "2020-06-25T19:50:30",
    
          // related identifiers
          "ids": {
            "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
            "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
            "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002"
          },
    
          // additional properties (optional)
          "properties": {}
        },
        {
          ...
        }
      ]
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_campaign_sent",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_campaign_open",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_campaign_undelivered",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      },
      "properties": {
        "reason": "error",
        "error_code": "apns_invalid_token"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_transactional_sent",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "group_id": "new_friend_request",
        "transactional_token": "3f98fd8c-4f44-4b8c-8f53-bf25de639b5a"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_transactional_open",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "group_id": "new_friend_request",
        "transactional_token": "3f98fd8c-4f44-4b8c-8f53-bf25de639b5a"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_transactional_undelivered",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "group_id": "new_friend_request",
        "transactional_token": "3f98fd8c-4f44-4b8c-8f53-bf25de639b5a"
      },
      "properties": {
        "reason": "error",
        "error_code": "apns_invalid_token"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "in_app_campaign_displayed",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "in_app_campaign_clicked",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      },
      "properties": {
          "cta_action": "batch_deeplink"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "in_app_campaign_closed",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002",
        "campaign_token": "566acd78ebdafceadc8b6fac0eec72ba"
      }
    }
    {
      "version": 1,
      "api_key": "5306192C3549E92B2633D782D8A37X",
      "event_type": "push_reachability_change",
      "event_id": "230ca290-b71d-11ea-8b8a-0242c0a8042a",
      "occurred_at": "2020-06-25T19:50:30",
      "ids": {
        "install_id": "D0153F35-6568-4DC7-9BBB-D1A498411637",
        "custom_id": "7d544a8b7512115fd0d2bee3ab3e",
        "advertising_id": "3b671754-07df-11eb-adc1-0242ac120002"
      },
      "properties": {
        "is_reachable": true,
        "is_optin": true,
        "has_custom_id": true
      }
    }
    Rate Limiting

    To ensure fair usage and platform stability, the /profiles/update endpoint is subject to rate limiting, following the Token Bucket algorithm:

    • API rate: Up to 300 profile updates per second are allowed.

    • Burst capacity: The API allows short bursts of up to 1000 profile updates (tokens) at once, if your bucket is full.

    • If you exceed these limits, the API will respond with an HTTP 429 Too Many Requests error. When you receive this error, please wait a few seconds before retrying, as further attempts may continue to be rejected until your rate falls back within the allowed limits.

    Note that our API rate limit is measured in profile updates per second.

    Unlike other API rate limits which are often measured in requests per second or minute, our rate is calculated based on the number of Custom IDs processed within your requests.

    What constitutes one "update"? One update corresponds to the processing associated with a single Custom ID included in your request. For example, if a request contains data for 10 different Custom IDs, it will consume 10 updates from your rate limit, regardless of the number of attributes updated or events tracked for each individual Custom ID within that same request.

    This unit of measurement has been chosen to effectively manage the processing load, particularly when utilizing bulk operations. Processing multiple Custom IDs in a single bulk request is more efficient, and tracking the rate by the number of IDs processed (updates) ensures fair usage and system stability under heavy load from bulk submission.

    Request structure

    Route

    The Profile API exposes a POST endpoint that allows to update a batch of profiles:

    /profiles/update

    You can update one or several profiles via this endpoint, within the limit of 200 profiles.

    Headers and authentication

    See Overview → Using Project APIs.

    Update profile

    The body of the request must contain a valid JSON payload describing the update operations to execute for a set of given Custom IDs.

    To update multiple profiles at the same time:

    The identifiers object

    The identifiers object allows you to indicate which profile you need to update, it has the following form:

    Batch supports sending attributes and events using the Custom ID, this custom identifier can be:

    • The unique ID you are using in your login system.

    • A stable ID used in your data store (e.g. Firebase, etc).

    • Any stable information that can help you to identify a user (e.g. hashed email address, etc).

    The attributes object

    The Profile API allows you to set and update native and custom profile attributes in the attributes object. It has the following form:

    Attribute keys refer to the names of the attributes. Set the attribute value by providing its name (key) and the value associated. You can set up to 50 attributes per profile per operation: requests exceeding this limit will be ignored. Some keys are documented as they're reserved. This object cannot weigh more than 25kB or the entire Profile API request will be rejected.

    Native attributes

    Native attributes have reserved keys, and are all prefixed by a $ sign. This is the list of currently supported native attributes. You cannot set an attribute starting by a $ sign.

    Custom attributes

    You can also set custom attributes, with a name and a value.

    Key names must be made of letters, numbers or underscores ([a-z0-9_]). They cannot be longer than 30 characters and cannot contain uppercase characters.

    The following value types are supported:

    • String

    • Integer

    • Float

    • Date

    • URL

    • Boolean

    • String arrays

    String

    String types attributes cannot be empty or over 300 characters, they can be null. Setting a string to null completely removes this attribute from the profile.

    Integer

    Integer attributes are supported and can be null. Setting an integer to null completely removes this attribute from the profile.

    Float

    Float attributes are supported and can be null. Setting a float to null completely removes this attribute from the profile.

    Date

    JSON does not support date natively. Therefore, we require additional information to identify an attribute as a date. This is achieved by wrapping the attribute key in the date() function.

    Dates are accepted in TS format in seconds and RFC 3339 format (2012-08-12T22:30:05Z).

    URL

    URL type is also supported. You will need to wrap the key name in the url() function.

    Values must be valid URLs and no longer than 2048 characters:

    • A scheme is compulsory (myapp://, https://...)

    • :// is compulsory after the scheme

    Boolean

    Boolean attributes can be true, false or null.

    String arrays

    Arrays of strings are supported at a profile level. A string in an array cannot be longer than 300 chars. When updating a profile via the API, a string array can contain up to 25 attributes per request. You can:

    • set directly all attributes of an array

    • add an attribute to an array, with $add

    • remove an attribute from an array, with $remove

    • delete an array from a profile by setting its value to null

    If some attribute is invalid in the array, the whole array will be rejected and not set on the profile.

    You can add an attribute to a non-existing array, Batch will automatically create the array if it doesn't exist yet on the targeted profile.

    Using the $add function will replace any existing attributes with the same name by an array with the set array item. If you use the $remove operation, it will delete the attribute from the profile.

    Limits and Behavior: A string array attribute stored in a Profile can contain up to 1500 attributes in total. When this limit is exceeded, the oldest attributes are automatically removed to keep the array at 1500 elements. Arrays of strings have the following properties:

    • Uniqueness of elements.

    • Deterministic order: when an element is added, it is placed at the end of the array; if it already existed, it is moved to the end.

    Deleting an attribute

    To delete an attribute, set its value to null:

    Date/URL attributes are deleted in the same way and must not have their name wrapped in date()/url().

    The events object

    The events object contains all events to track on the profile. It cannot weigh more than 125kB or contain more than 15 events. You can set up to 15 events per profile per API call. If one of these limits is exceeded, the whole Profile API call will be rejected.

    The events attributes object

    The event attributes object allows you to attach additional attributes to an event, it cannot me more than 25kB.

    It has the following structure:

    The following value types are supported:

    • String

    • Number

    • Float

    • Date

    • URL

    • Array

    • Object

    All types except for Array & Object behave as they do in profile attributes.

    Object

    Objects can be used to group attributes. They cannot have more than 3 levels of nesting, both objects and array count as one level of nesting.

    Array

    You can set array of strings (max 300 characters) and array of objects. You cannot mix several attribute types in one array. Arrays can't be nested.

    Reserved event attributes

    Some event attributes have reserved keys, and are all prefixed by a $ sign. This is the list of currently reserved event attributes. You cannot set an event attribute starting by a $ sign.

    In the Trigger Events API, you were able to set a label and tags at the root of an event, with the limit of 1 label and 10 tags.

    With the Profile API and the introduction of the array type in event attributes, you can set more that one array on profiles events. This is only supported for profiles, and not on the install centric data model, which currently powers push notification and In-App messages.

    However, it's still possible to set a label and tags on events in the install centric data model by using $label and $tags, and activate compatibility flows. This way, you will be able to use this data for your push and in-app communications.

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation. This means the API call was entirely valid and will be processed as requested.

    Success with partial errors

    If your API calls has non fatal errors, you will receive an HTTP 202 confirmation and details about the non fatal errors. Data that isn't listed in the errors array will be processed.

    Failure

    If the POST 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)

    • ROUTE_NOT_FOUND (HTTP status code: 404, error_code: 20)

    • MISSING_PARAMETER (HTTP status code: 400, error_code: 30)

    • MALFORMED_PARAMETER (HTTP status code: 400, error_code: 31)

    • MALFORMED_JSON_BODY (HTTP status code: 400, error_code: 32)

    • SERVER_ERROR (HTTP status code: 500, error_code: 1)

    • MAINTENANCE_ERROR (HTTP status code: 503, error_code: 2)

    • 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.

    Frequently asked questions

    How can I see that the profile data is correctly updated during implementation?

    The Profile view page of the dashboard displays profiles in real-time so you can review your implementation.

    How can I use objects and arrays of objects in message personalization?

    See the Message personalization documentation.

    Is the Profile API compatible with the installation based data model? Can I use the Profile API to send data and use it for push notifications and in-app messages?

    Emails are sent on the base of profiles, whereas push notifications & In-App messages are sent on an app-based userbase made of installations.

    By default, the Profile API only updates the profile base which is used to send email messages. However, compatibility flows are available to allow you to feed all user data with the Profile API, including the install centric userbase. Compatibility flows are set up by Batch team, reach out to support@batch.com for more information.

    If you send more than 15 attributes in one event, only the first 15 event attributes (alphabetical order) will be written on the install centric userbase. If you would like to set a label and tags, use the compatibility attributes $label and $tags.

    Profile updates: choosing the right API endpoint

    Mobile landings

    Mobile Landings allow you to easily introduce continuity between your app, and your pushes: A user opening a push will be greeted by a rich message related to what they opened, rather than just ending up on your app's main menu.

    They're included in the Startup, Business and Enterprise plans.

    Mobile landings visual example

    Displaying the message

    Automatic mode

    There's no code required to make mobile landings work in automatic mode: just attach a landing to your push campaign, and Batch will display it.

    You might want to go further into this documentation, and setup your delegate, or head to the documentation to add custom behaviour to buttons.

    Manual mode

    You may want to be in control of if, when and how landings will be loaded and displayed. Batch allows you to disable automatic displaying, and handle loading and displaying the view controller itself.

    First, you'll need to implement UNUserNotificationCenterDelegate in a class (for more information, please see the part):

    Then, you have to disable the automatic mode and set your class as your default UNUserNotificationCenter delegate:

    Finally, you need to ask Batch to load the right view controller for the push payload (if applicable), and display it:

    Controlling the display using "Do Not Disturb mode"

    "Do Not Disturb" (DnD) feature: It allows you to tell Batch to hold on a mobile landing for you, rather than display it without using the fully manual mode. For example, if launching your app results in a splash screen or a fullscreen ad, you might find it undesirable to have Batch display something on top of it.

    Turning on "Do Not Disturb" mode will make Batch enqueue the latest mobile landing, rather than display it.

    Toggling DnD

    Now, when you don't want Batch to automatically display, turn on Do Not Disturb:

    Once you want to start showing landings automatically, call the method with false to turn it off.

    Note: Disabling Do Not Disturb mode does NOT make Batch show the enqueued message

    Displaying pending mobile landings

    After coming back from DnD mode, you might want to show the enqueued message, as Batch will not do that automatically. Batch exposes two properties/methods for managing the queue:

    • BatchMessaging.hasPendingMessage , allowing you to peek into the queue.

    • BatchMessaging.popPendingMessage() , allowing you to fetch the pending message (if any). Since calling this makes Batch delete its reference to it to save memory, further calls might return nil.

    • BatchMessaging.showPendingMessage() , allowing you to try to show the pending message, if any.

    Here is a quick example of how they can be used:

    Note: Only the latest message is queued: if a mobile landing arrives while one is still pending, it will overwrite the previous one.

    Listening to lifecycle events and reacting to button actions

    Setting up a delegate

    Batch's messaging module supports setting up a delegate, which can be used for analytics:

    It can be any object that implements the BatchMessagingDelegate protocol.

    While your application delegate can safely implement this protocol, we split it out in a separate class in our examples for simplicity.

    Like most delegates on iOS, Batch only stores a weak reference to it. Make sure you keep a reference to your object instance so it isn't released

    Analytics delegate

    Batch can notify your delegate of lifecycle events of the in-app messages:

    The messageIdentifier variable is the message tracking identifier you've configured in the dashboard. It can be nil if you didn't specify one.

    Custom button actions

    In order to be able to use the "Custom" button action kind, you need to implement them using the Batch Actions module. More info here:

    Customizing the landing

    Setting a custom font

    If you'd like to use a custom font instead of the system's, Batch allows you to override the fonts it will use:

    The size will be overriden later, so you can use anything you want. Make sure you provide both a normal and a bold font, even if they are the same.

    This assumes you've already got custom UIFonts working. If you don't, you can find a great tutorial .

    Troubleshooting

    Nothing happens when I press an actionable button

    Take a look at your application logs in Xcode, the SDK might try to warn you about an issue. Here are some the common messages and their probable cause:

    Deeplinks on iOS are automatically called by the SDK using sharedApplication's openURL method. Since it needs a NSURL instance, the deeplink string needs to be a valid URL accepted by iOS' NSURL class. Please try again with a valid URL.

    Note: Use of universal links in deeplinks is discouraged: triggering an universal link from the app implementing them will cause iOS to open safari.

    This can happen when you specified a custom action when creating the campaign on the dashboard, but the SDK couldn't execute it.

    Make sure you always register your actions at every app start.

    Please test your implementation using our and before releasing your app on the store. Make sure you're unwrapping your optionals!

    [
      {
        "identifiers": {
          "custom_id": "129c7819-9c88-496e-9a5f-62db34a3ce61"
        },
        "attributes": {
          "$email_address": "jane_doe@batch-store.com"
        },
        "events": [
          {
            "name": "validated_purchase",
            "attributes": {
              "delivery_address": {
                "number": 43,
                "street": "Rue Beaubourg",
                "zip_code": 75003,
                "city": "Paris",
                "country": "France"
              },
              "items_list": [
                {
                  "name": "Basic Tee",
                  "size": "M",
                  "price": 23.99,
                  "url(item_url)": "https://batch-store.com/basic-tee",
                  "url(item_image)": "https://batch-store.com/basic-tee/black/image.png",
                  "in_sales": true
                },
                {
                  "name": "Short socks pack x3",
                  "size": "38-40",
                  "price": 15.99,
                  "url(item_url)": "https://batch-store.com/short-socks-pack-x3",
                  "url(item_image)": "https://batch-store.com/short-socks-pack-x3/image.png",
                  "in_sales": false
                }
              ],
              "metadata": [
                "first_purchase",
                "apple_pay"
              ]
            }
          }
        ]
      }
    ]
    [
      {
        "identifiers": {
          "custom_id": "129c7819-9c88-496e-9a5f-62db34a3ce61"
        },
        "attributes": {
          "$email_address": "jane_doe@batch-store.com"
        }
      },
      {
        "identifiers": {
          "custom_id": "92bec35f-07fa-42d9-b676-74bb165dd018"
        },
        "attributes": {
          "$email_address": "bo_b@gmail.com"
        }
      }
    ]
    "identifiers": {
        "custom_id": "129c7819-9c88-496e-9a5f-62db34a3ce61"
    }
    "attributes": {
          "$email_address": "jane.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$phone_number": "+33182837140",
          "$sms_marketing": "unsubscribed",
          "$language": "en",
          "$region": "FR",
          "$timezone": "Europe/Paris",
          "firstname": "Jane",
          "date(birthdate)": "1989-07-20T00:00:00Z",
          "interests": [
            "bikes",
            "cinema"
          ],
          "reward_programs": {
            "$add": [
              "premium_customer"
            ]
          }
    }
    {"firstname": "Jane"}
    {"age": 25}
    {"level_progress": 25.5}
    {
      "date(promo_starts)": 1451642400,
      "date(promo_ends)": "2012-08-12T22:30:05Z"
    }
    {
      "url(product_image)": "https://batchstore/product/4729/image.png",
      "url(product_deeplink)": "myapp://path/to/content"
    }
    {
      "is_premium": false
    }
    "interests": ["bikes","cinema"],
    "reward_programs": {
        "$add": [
            "premium_customer"
        ]
    }
    "firstname": null,
    "promo_starts": null,
    "attributes": {
      "items_list": [
        {
          "name": "Basic Tee",
          "size": "M",
          "price": 23.99,
          "url(item_url)": "https://batch-store.com/basic-tee",
          "url(item_image)": "https://batch-store.com/basic-tee/image.png",
          "in_sales": true
          },
          {
            "name": "Short socks pack x3",
            "size": "38-40",
            "price": 15.99,
            "url(item_url)": "https://batch-store.com/short-socks-pack-x3",
            "url(item_image)": "https://batch-store.com/short-socks-pack-x3/image.png",
            "in_sale": false
          }
        ],
        "delivery_address": {
          "number": 43,
          "street": "Rue Beaubourg",
          "zip_code": 75003,
          "city": "Paris",
          "country": "France"
        },
        "metadata": [
          "first_purchase",
          "quick_buy"
        ]
      }
    {
      "events": [
        {
          "name": "validated_purchase",
          "attributes": {
            "delivery_address": {
              "number": 43,
              "street": "Rue Beaubourg",
              "zip_code": 75003,
              "city": "Paris",
              "country": "France"
            }
          }
        }
      ]
    }
    {
      "events": [
        {
          "name": "validated_purchase",
          "attributes": {
            "items_list": [
              {
                "name": "Basic Tee",
                "size": "M",
                "price": 23.99,
                "url(item_url)": "https://batch-store.com/basic-tee",
                "url(item_image)": "https://batch-store.com/basic-tee/black/image.png",
                "in_sales": true
              },
              {
                "name": "Short socks pack x3",
                "size": "38-40",
                "price": 15.99,
                "url(item_url)": "https://batch-store.com/short-socks-pack-x3",
                "url(item_image)": "https://batch-store.com/short-socks-pack-x3/image.png",
                "in_sales": false
              }
            ],
            "metadata": [
              "first_purchase",
              "apple_pay"
            ]
          }
        }
      ]
    }
    HTTP Status Code: 202
    
    Response:
    {
      "code": "SUCCESS"
    }
    HTTP Status Code: 202
    
    {
        "code": "SUCCESS_WITH_PARTIAL_ERRORS",
        "errors": [
            {
                "category": "attribute",
                "bulk_index": 0,
                "reason": "Array attributes must not contain empty string item",
                "attribute": "array"
            }
        ]
    }
    {
        "error_code": "MALFORMED_PARAMETER",
        "error_message": "Invalid project key project_062ay7ywmgvqccwanj647mmqm1smq2k"
    }
    debug tool
    profile view
    Custom Actions
    Intercepting notifications
    Custom Actions
    here
    @objc
    class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
        func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
            AppDelegate.tryShowBatchMessage(userInfo: response.notification.request.content.userInfo as [NSObject : AnyObject])
            BatchPush.handle(userNotificationCenter: center, didReceive: response)
            completionHandler()
        }
        
        func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
            AppDelegate.tryShowBatchMessage(userInfo: notification.request.content.userInfo as [NSObject : AnyObject])
            BatchPush.handle(userNotificationCenter: center, willPresent: notification, willShowSystemForegroundAlert: true)
            completionHandler([.sound, .alert, .badge])
        }
    }
    // NotificationDelegate.h
    
    @import Foundation;
    @import UserNotifications;
    
    @interface NotificationDelegate : NSObject <UNUserNotificationCenterDelegate>
    
    @end
    
    // NotificationDelegate.m
    #import "NotificationDelegate.h"
    
    @import Batch;
    
    @implementation NotificationDelegate
    
    - (void)userNotificationCenter:(UNUserNotificationCenter *)center
    didReceiveNotificationResponse:(UNNotificationResponse *)response
             withCompletionHandler:(void (^)())completionHandler {
        [AppDelegate tryShowBatchMessage:response.notification.request.content.userInfo];
        [BatchPush handleUserNotificationCenter:center didReceiveNotificationResponse:response];
        completionHandler();
    }
    
    - (void)userNotificationCenter:(UNUserNotificationCenter *)center
           willPresentNotification:(UNNotification *)notification
             withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
        [AppDelegate tryShowBatchMessage:response.notification.request.content.userInfo];
        [BatchPush handleUserNotificationCenter:center willPresentNotification:notification willShowSystemForegroundAlert:YES];
        completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound)
    }
    
    @end
    class AppDelegate: UIResponder, UIApplicationDelegate {
        let notificationDelegate = NotificationDelegate()
        
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            BatchMessaging.setAutomaticMode(on: false)
            UNUserNotificationCenter.current().delegate = notificationDelegate
        }
    }
    @interface AppDelegate ()
    {
        NotificationDelegate *notificationDelegate;
    }
    @end
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        [BatchMessaging setAutomaticMode:NO];
        if ([UNUserNotificationCenter class]) {
            notificationDelegate = [NotificationDelegate new];
            [[UNUserNotificationCenter currentNotificationCenter] setDelegate:notificationDelegate];
        }
    }
    
    @end
    AppDelegate.swift
    static func tryShowBatchMessage(userInfo: [NSObject : AnyObject]) {
        
        // Put the display code in this if block if you don't want the messaging to show when the user is already using the app
        // if UIApplication.shared.applicationState == .inactive {
        // }
        
        guard let message = BatchMessaging.message(fromPushPayload: userInfo) else {
            // No message from push payload
            return
        }
        
        guard let vc = try? BatchMessaging.loadViewController(for:message) else {
            print("An error occurred while loading Batch's messaging view")
            return
        }
        // Let Batch present it itself
        BatchMessaging.present(vc)
        
        
        // Or,
        // if you want to display the message yourself, you will need to check if the VC should be presented in
        // its own window, to allow user interaction around the message if needed. Banners require this, for example.
        guard let batchVC = vc as? BatchMessagingViewController else {
            print("The loaded VC does not satisfy the BatchMessagingViewController protocol like it should")
            return
        }
        
        if (batchVC.shouldDisplayInSeparateWindow) {
            // Display in your own UIWindow
        } else {
            var targetVC = UIApplication.shared.keyWindow?.rootViewController
            if let presentedVC = targetVC?.presentedViewController {
                targetVC = presentedVC
            }
            targetVC?.present(vc, animated: true, completion: nil)
        }
    }
    AppDelegate.m
    + (void)tryShowBatchMessage:(NSDictionary *)userInfo
    {
        if (!userInfo) {
            return;
        }
        // Put the display code in this if block if you don't want the messaging to show when the user is already using the app
        /*
        if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateInactive) {
        }
        */
        
        BatchMessage *message = [BatchMessaging messageFromPushPayload:userInfo];
        if (message) {
            // You can show a loading view in the meantime for a better user experience
            NSError *err = nil;
            UIViewController *vc = [BatchMessaging loadViewControllerForMessage:message error:&err];
            
            if (err) {
                NSLog(@"An error occurred while loading Batch's messaging view: %@", [err localizedDescription]);
            } else if (vc) {
                // Let Batch present it itself
                [BatchMessaging presentMessagingViewController:vc];
                
                // Or,
                // if you want to display the message yourself, you will need to check if the VC should be presented in
                // its own window, to allow user interaction around the message if needed. Banners require this, for example.
                if ([vc conformsToProtocol:@protocol(BatchMessagingViewController)]) {
                    if (((id<BatchMessagingViewController>)vc).shouldDisplayInSeparateWindow) {
                        // Show this VC in your own UIWindow
                    } else {
                        UIViewController *targetVC = [[[UIApplication sharedApplication] keyWindow] rootViewController];
                        UIViewController *presentedVC = targetVC.presentedViewController;
                        if (presentedVC) {
                            targetVC = presentedVC;
                        }
                        [targetVC presentViewController:vc animated:YES completion:nil];
                    }
                }
                
            }
        }
    }
    
    BatchMessaging.doNotDisturb = true
    BatchMessaging.doNotDisturb = YES;
    func splashScreenDidDisappear() {
      BatchMessaging.doNotDisturb = false
      BatchMessaging.showPendingMessage()
    }
    - (void)splashScreenDidDisappear {
      BatchMessaging.doNotDisturb = NO;
      [BatchMessaging showPendingMessage];
    }
    
    var messagingDelegate: SampleBatchMessagingDelegate?
    
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
      [...]
      
      messagingDelegate = SampleBatchMessagingDelegate()
      BatchMessaging.delegate = messagingDelegate
      
      [...]
    }
    // Header file
    @property (strong, nonatomic) SampleBatchMessagingDelegate *messagingDelegate;
    
    // Implementation
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [...]
        
        // Delegates are weak so be sure to keep a reference to it
        self.messagingDelegate = [SampleBatchMessagingDelegate new];
        [BatchMessaging setDelegate:self.messagingDelegate];
        
        [...]
    }
    import Foundation
    import Batch.Messaging
    
    public class SampleBatchMessagingDelegate: NSObject, BatchMessagingDelegate {
        
        public func batchMessageDidAppear(messageIdentifier: String?) {
            print("SampleBatchMessagingDelegate - batchMessageDidAppear: \(messageIdentifier)")
        }
        
        public func batchMessageDidTriggerAction(_ action: BatchMessageAction, messageIdentifier identifier: String?, actionIndex index: Int) {
            // A button or global tap action has been triggered
    
            // If the action is a CTA (button), you can fetch the label
            if let cta = action as? BatchMessageCTA {
                let label = cta.label
                // [...]
            }
    
            // CTAs are allowed to simply be a "dismiss" action, in which case they
            // will not have any associated action name and arguments
            if !action.isDismissAction() {
                let actionName = action.action // not null
    
                // [...]
            }
        }
        
        public func batchMessageDidDisappear(_ messageIdentifier: String?, reason: BatchMessagingCloseReason) {
            print("SampleBatchMessagingDelegate - batchMessageDidDisappear: \(messageIdentifier) with reason: \(reason)"
        }
    }
    // Header file (.h)
    @import Foundation;
    @import Batch.Messaging;
    
    @interface SampleBatchMessagingDelegate : NSObject <BatchMessagingDelegate>
    
    @end
    
    // Implementation file (.m)
    #import "SampleBatchMessagingDelegate.h"
    
    @implementation SampleBatchMessagingDelegate
    
    - (void)batchMessageDidAppear:(NSString* _Nullable)messageIdentifier
    {
        NSLog(@"SampleBatchMessagingDelegate - batchMessageDidAppear: %@", messageIdentifier);
    }
    
    - (void)batchMessageDidDisappear:(NSString* _Nullable)messageIdentifier
    {
        NSLog(@"SampleBatchMessagingDelegate - batchMessageDidDisappear: %@", messageIdentifier);
    }
    
    @end
    // Set a custom font
    let font = UIFont(name: "MyFont", size: 10)
    let boldFont = UIFont(name: "MyFont-Bold", size: 10)
    BatchMessaging.setFontOverride(font, boldFont: boldFont)
    // or variant with italic and boldItalic
    // BatchMessaging.setFontOverride(UIFont?, boldFont: UIFont?, italicFont: UIFont?, boldItalicFont: UIFont?)
    
    // Clear the custom font, and use the system one
    BatchMessaging.setFontOverride(nil, boldFont: nil)
    // Set a custom font
    UIFont* font = [UIFont fontWithName:@"MyFont" size: 10];
    UIFont* boldFont = [UIFont fontWithName:@"MyFont-Bold" size: 10];
    [BatchMessaging setFontOverride:font boldFont:boldFont];
    
    // Clear the custom font, and use the system one
    [BatchMessaging setFontOverride:nil boldFont:nil];
    An error occured while making a NSURL for the following link: '<your deeplink>', ignoring deeplink action.
    The action 'ACTION NAME' couldn't be found. Did you forget to register it?

    Update

    post

    Updates an existing catalog.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    Identifier of the catalog to update.

    Example: products
    Responses
    202

    Request accepted for asynchronous processing

    application/json
    Responseobject
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /catalogs/update

    Remove

    post

    Delete an audience.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    The name of the existing audience you want this operation to be applied to.

    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an indexing token. Once you get your indexing token, you can use it to check the indexing state with the view action.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /audiences/remove

    View

    get

    Get information about an existing catalog.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    namestringRequired

    Catalog identifier to retrieve.

    indexing_tokenstringOptional

    Optional token used for indexing state tracking.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    Successfully retrieved the catalog metadata.

    application/json
    404

    Not found

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /catalogs/view

    Delete

    post

    Deletes an existing campaign

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    idstringRequired

    The campaign id of the campaign to delete

    Responses
    200

    Request successful, campaign deleted

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /campaigns/delete

    Download

    get

    Download the extraction file of an export request. Status of the export must be SUCCESS to call this API. See view export API to get the current status of your export. The link to the JSON file that you can found under the Location section of the response header will expire after 20 minutes. You will need to call this API again to generate a new file.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    idstringRequired

    ID of the file to be downloaded.

    Example: file_063bc4w4x8e363yem6wfnxc5c13c0n46
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    307

    The resource requested can be found under the Location section of the response header.

    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    409

    Conflict

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /exports/download

    Update

    post

    Add or delete users from an audience.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    The name of the existing audience you want this operation to be applied to.

    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an indexing token. Once you get your indexing token, you can use it to check the indexing state with the view action.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /audiences/update

    View

    get

    Get information about an audience.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    namestringRequired

    The name of the existing audience you want to view.

    indexing_tokenstringOptional

    The indexing token returned by the create, replace, update or remove routes.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audience.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /audiences/view

    List

    get

    List catalogs

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    fromstringOptional

    A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_from value returned in a previous response to request subsequent results.

    limitinteger · min: 1 · max: 100Optional

    To change the page size of results.

    Default: 10Example: 20
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    Successfully listed all catalogs.

    application/json
    get
    /catalogs/list

    Create

    post

    Creates a new catalog.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    Unique identifier of the catalog.

    Example: products
    Responses
    201

    Resource created successfully

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /catalogs/create

    Remove

    post

    Remove a catalog.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    Identifier of the catalog to remove.

    Example: products
    Responses
    202

    Request accepted for asynchronous processing

    application/json
    Responseobject
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /catalogs/remove

    Mass Update

    post

    Update one or multiple profile's data and track events

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Bodyobject[]
    Responses
    202

    Request accepted, will be processed asynchronously

    application/json
    Responseone of
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /profiles/mass-update

    Update

    post

    Update one or multiple profile's data and track events

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Bodyobject[]

    Edit multiple profiles at once. You can specify at most 200 operations or the API call will be rejected.

    post
    /profiles/update

    Replace

    post

    Replace all audience users. It removes all previously added users and adds the given ones.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    The name of the existing audience you want this operation to be applied to.

    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an indexing token. Once you get your indexing token, you can use it to check the indexing state with the view action.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /audiences/replace

    Update

    post

    Update an existing campaign

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    Responses
    200

    Request successful, campaign udpated

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /campaigns/update

    List

    get

    List export requests created.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    fromstringOptional

    A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_from value returned in a previous response to request subsequent results.

    limitinteger · min: 1 · max: 100Optional

    To change the page size of results.

    Default: 10Example: 20
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your export requests. This information is an array of all requests we currently know of for your project. The output contains requests created in the last 4 months.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /exports/list

    Create

    post

    Create an audience.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestring · max: 255Required

    The audience name value must be a string that only contains letters (a-z, A-Z), numbers (0-9) or the following characters : _, -. Audience names can be up to 255 characters long. They are case sensitive.

    typestring · enumRequiredPossible values:
    display_namestringOptional
    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an indexing token. Once you get your indexing token, you can use it to check the indexing state with the view action.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /audiences/create

    List

    get

    List orchestrations.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    fromstringOptional

    A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_from value returned in a previous response to request subsequent results.

    Example: eW9kYSBVRAMjAyNS0wNS0xNFQxNDo1cGRhdGUgc2FtcGxlIEFuZHJvaWMzo1NFo=
    limitinteger · max: 100Optional

    A limit on the number of objects to be returned.

    Default: 10Example: 10
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    Successful response with a list of orchestrations.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /orchestrations/list

    View

    get

    Get information about an export request.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    idstringRequired

    Export request id received when creating an export request.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your export request.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    404

    Not found

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /exports/view

    Stats

    get

    Get statistics about an orchestration.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    orchestration_idstringRequired

    The id of the orchestration to fetch statistics from.

    Example: orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q
    fromstring · dateRequired

    Statistics starting date in a yyyy-MM-dd format. Cannot be earlier than 6 months ago.

    Example: 2025-01-13
    tostring · dateRequired

    Statistics ending date in a yyyy-MM-dd format.

    Example: 2025-02-12
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    Successful response with statistics about an orchestration.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /orchestrations/stats

    List

    get

    List audiences.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Query parameters
    fromstringOptional

    A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_from value returned in a previous response to request subsequent results.

    limitinteger · max: 100Optional

    A limit on the number of objects to be returned.

    Default: 10Example: 20
    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Responses
    200

    If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information about your audiences.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    get
    /audiences/list

    Items Edit

    post

    Adds, updates or removes catalog items by ID.

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    Name of the catalog.

    Example: products
    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an indexing token. Once you get your indexing token, you can use it to check the indexing state with the view action.

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /catalogs/items/edit

    Create

    post

    Create a new campaign

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    namestringRequired

    Display name of the campaign on the dashboard

    statestring · enumRequired

    State of the campaign to create. Draft campaigns are not sent until they are started (updated to RUNNING). Stopped campaigns are paused and can be resumed by updating them to RUNNING.

    Possible values:
    send_rateinteger · min: 1000 · max: 1000000Optional

    Determines the maximum number of messages to be sent per minute.

    labelsstring[]Optional

    An array of labels to assign to the campaign for organizational and capping purposes. Limited at 5 labels per campaign.

    Responses
    201

    Request successful, campaign created

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /campaigns/create

    Update

    post

    Update one or multiple profile's data and track events

    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Bodyobject[]

    Edit multiple profiles at once. You can specify at most 200 operations or the API call will be rejected.

    post
    /profiles/update

    No content

    200

    Successfully listed all catalogs.

    Edit multiple profiles at once. You can specify at most 10 000 operations or the API call will be rejected.

    idstringRequired

    Campaign id received from the create API

    {}
    POST /2.8/catalogs/update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 78
    
    {
      "name": "products",
      "fields": [
        {
          "action": "add",
          "name": "price",
          "type": "string"
        }
      ]
    }
    {
      "indexing_token": "text"
    }
    POST /2.8/audiences/remove HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 24
    
    {
      "name": "AUDIENCE_NAME"
    }
    {
      "name": "products",
      "fields": [
        {
          "name": "price",
          "type": "float"
        }
      ],
      "items": 42,
      "size": 4882372,
      "created": "2025-12-09T13:27:11.778Z",
      "updated": "2025-12-09T13:27:11.778Z",
      "indexing_state": "APPLIED"
    }
    GET /2.8/catalogs/view?name=text HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {}
    POST /2.8/campaigns/delete HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 55
    
    {
      "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1f"
    }
    GET /2.8/exports/download?id=text HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "indexing_token": "text"
    }
    POST /2.8/audiences/update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 229
    
    {
      "name": "AUDIENCE_NAME",
      "ids": [
        {
          "action": "add",
          "id": "CUSTOM-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2023-08-12T22:30:05Z",
            "url(att20)": "https://example.com/image.jpg"
          }
        },
        {
          "action": "remove",
          "id": "CUSTOM-ID-2"
        }
      ]
    }
    {
      "name": "text",
      "display_name": "text",
      "type": "CUSTOM_ID",
      "nb_ids": 1,
      "indexing_state": "APPLIED",
      "created": "2023-08-12T22:30:05Z",
      "updated": "2023-08-12T22:30:05Z"
    }
    GET /2.8/audiences/view?name=text HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "catalogs": [
        {
          "name": "products",
          "fields": [
            {
              "name": "price",
              "type": "float"
            }
          ],
          "items": 42,
          "size": 4882372,
          "created": "2025-12-09T13:27:11.778Z",
          "updated": "2025-12-09T13:27:11.778Z",
          "indexing_state": "APPLIED"
        }
      ],
      "count": 5,
      "has_more": false,
      "next_from": "text"
    }
    GET /2.8/catalogs/list HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {}
    POST /2.8/catalogs/create HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 62
    
    {
      "name": "products",
      "fields": [
        {
          "name": "price",
          "type": "float"
        }
      ]
    }
    {}
    POST /2.8/catalogs/remove HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 19
    
    {
      "name": "products"
    }
    {
      "code": "SUCCESS"
    }
    POST /2.8/profiles/mass-update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 546
    
    [
      {
        "identifiers": {
          "custom_id": "jane.doe@demobatch.com"
        },
        "attributes": {
          "$email_address": "jane.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$phone_number": "+33182837140",
          "$sms_marketing": "unsubscribed",
          "$language": "en",
          "$region": "FR",
          "$timezone": "Europe/Paris",
          "firstname": "Jane",
          "date(birthdate)": "1989-07-20T00:00:00Z",
          "interests": [
            "bikes",
            "cinema"
          ],
          "reward_programs": {
            "$add": [
              "premium_customer"
            ]
          }
        },
        "events": [
          {
            "name": "added_to_cart",
            "attributes": {
              "$label": "pumpkin",
              "quantity": 5,
              "unit_price": 3.99,
              "$tags": [
                "fruits",
                "organic",
                "on_sale"
              ]
            }
          }
        ]
      }
    ]
    POST /2.8/profiles/update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 546
    
    [
      {
        "identifiers": {
          "custom_id": "jane.doe@demobatch.com"
        },
        "attributes": {
          "$email_address": "jane.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$phone_number": "+33182837140",
          "$sms_marketing": "unsubscribed",
          "$language": "en",
          "$region": "FR",
          "$timezone": "Europe/Paris",
          "firstname": "Jane",
          "date(birthdate)": "1989-07-20T00:00:00Z",
          "interests": [
            "bikes",
            "cinema"
          ],
          "reward_programs": {
            "$add": [
              "premium_customer"
            ]
          }
        },
        "events": [
          {
            "name": "added_to_cart",
            "attributes": {
              "$label": "pumpkin",
              "quantity": 5,
              "unit_price": 3.99,
              "$tags": [
                "fruits",
                "organic",
                "on_sale"
              ]
            }
          }
        ]
      }
    ]
    {
      "indexing_token": "text"
    }
    POST /2.8/audiences/replace HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 318
    
    {
      "name": "AUDIENCE_NAME",
      "ids": [
        {
          "id": "CUSTOM-ID-1",
          "attributes": {
            "att1": 3,
            "att2": "string",
            "date(att15)": "2023-08-12T22:30:05Z",
            "url(att20)": "https://example.com/image.jpg"
          }
        },
        {
          "id": "CUSTOM-ID-2",
          "attributes": {
            "att1": 2,
            "att2": "string",
            "date(att15)": "2023-08-12T22:30:05Z",
            "url(att20)": "https://example.com/image.jpg"
          }
        }
      ]
    }
    {}
    POST /2.8/campaigns/update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 471
    
    {
      "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
      "campaign": {
        "name": "The campaign name",
        "state": "RUNNING",
        "send_rate": 100000,
        "when": {
          "local_time": false,
          "start_time": "2024-01-24T10:22:00Z"
        },
        "targeting": {
          "languages": [
            "fr"
          ],
          "regions": [
            "FR"
          ],
          "query": {
            "firstname": {
              "$eq": "Jane"
            }
          }
        },
        "messages": [
          {
            "channel_type": "email",
            "subject": "The campaign subject",
            "sender_identity_id": "4012",
            "reply_to": {
              "email_address": "jane.doe@demobatch.com"
            },
            "html": "The campaign HTML content"
          }
        ]
      }
    }
    {
      "exports": [
        {
          "id": "export_063bc4w4x8e363yem6wfnxc5c13c0n46",
          "request_date": "2023-08-12T22:30:05Z",
          "completion_date": "2023-08-12T22:30:05Z",
          "start_date": "2023-08-12T22:30:05Z",
          "scope": "PROFILE_ATTRIBUTES",
          "status": "CREATED",
          "files": [
            {
              "id": "file_wbgjapsjscryqah0bcwrg1w5kv0dcfkj",
              "part": 1,
              "size": 2048,
              "url": "https://api.batch.com/2.4/exports/download?id=file_wbgjapsjscryqah0bcwrg1w5kv0dcfkj"
            }
          ],
          "request": {
            "export_type": "ATTRIBUTES",
            "attributes": [
              "$email_address",
              "$email_marketing",
              "$sms_marketing",
              "firstname",
              "is_premium"
            ],
            "identifiers": [
              "custom_id",
              "installation_ids"
            ],
            "filter": {
              "segment": "MY-SEGMENT-CODE"
            }
          }
        }
      ],
      "count": 25,
      "has_more": true,
      "next_from": "MjAyNC0wMS0wMVQwMDowMDowMFo="
    }
    GET /2.8/exports/list HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "indexing_token": "text"
    }
    POST /2.8/audiences/create HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 86
    
    {
      "name": "AUDIENCE_NAME",
      "display_name": "The audience description",
      "type": "custom_ids"
    }
    {
      "orchestrations": [
        {
          "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
          "type": "campaign",
          "channels": [
            "push"
          ],
          "platforms": [
            "ios",
            "android"
          ],
          "source": "dashboard",
          "created_date": "2017-03-02T09:43:17",
          "name": "Test Campaign 1",
          "labels": [
            "LABEL1",
            "LABEL2"
          ],
          "status": "running",
          "start_time": "2017-07-06T14:09:18"
        }
      ],
      "count": 132,
      "has_more": true,
      "next_from": "eW9kYSBVRAMjAyNS0wNS0xNFQxNDo1cGRhdGUgc2FtcGxlIEFuZHJvaWMzo1NFo="
    }
    GET /2.8/orchestrations/list HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "id": "export_063bc4w4x8e363yem6wfnxc5c13c0n46",
      "request_date": "2023-08-12T22:30:05Z",
      "completion_date": "2023-08-12T22:30:05Z",
      "start_date": "2023-08-12T22:30:05Z",
      "scope": "PROFILE_ATTRIBUTES",
      "status": "CREATED",
      "files": [
        {
          "id": "file_wbgjapsjscryqah0bcwrg1w5kv0dcfkj",
          "part": 1,
          "size": 2048,
          "url": "https://api.batch.com/2.4/exports/download?id=file_wbgjapsjscryqah0bcwrg1w5kv0dcfkj"
        }
      ],
      "request": {
        "export_type": "ATTRIBUTES",
        "attributes": [
          "$email_address",
          "$email_marketing",
          "$sms_marketing",
          "firstname",
          "is_premium"
        ],
        "identifiers": [
          "custom_id",
          "installation_ids"
        ],
        "filter": {
          "segment": "MY-SEGMENT-CODE"
        }
      }
    }
    GET /2.8/exports/view?id=text HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
      "details": [
        {
          "date": "2025-03-18",
          "sent": 972,
          "delivered": 847,
          "unique_open": 214,
          "total_open": 259,
          "unique_machine_open": 126,
          "unique_click": 37,
          "total_click": 41,
          "spam": 4,
          "unsubscribe": 13,
          "total_bounce": 14,
          "skipped": 15,
          "versions": [
            {
              "version": "a",
              "sent": 530,
              "delivered": 465,
              "unique_open": 139,
              "total_open": 161,
              "unique_machine_open": 37,
              "unique_click": 14,
              "total_click": 16,
              "spam": 3,
              "unsubscribe": 10,
              "total_bounce": 4,
              "skipped": 10
            },
            {
              "version": "b",
              "sent": 442,
              "delivered": 382,
              "unique_open": 75,
              "total_open": 98,
              "unique_machine_open": 89,
              "unique_click": 23,
              "total_click": 25,
              "spam": 1,
              "unsubscribe": 3,
              "total_bounce": 10,
              "skipped": 5
            }
          ]
        }
      ]
    }
    GET /2.8/orchestrations/stats?orchestration_id=text&from=2025-12-09&to=2025-12-09 HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "audiences": [
        {
          "name": "text",
          "display_name": "text",
          "type": "CUSTOM_ID",
          "nb_ids": 1,
          "indexing_state": "APPLIED",
          "created": "2023-08-12T22:30:05Z",
          "updated": "2023-08-12T22:30:05Z"
        }
      ],
      "count": 4012,
      "has_more": true,
      "next_from": "text"
    }
    GET /2.8/audiences/list HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Accept: */*
    
    {
      "indexing_token": "eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5f"
    }
    POST /2.8/catalogs/items/edit HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 252
    
    {
      "name": "products",
      "items": [
        {
          "id": "CATALOG_ITEM_ID",
          "action": "add",
          "attributes": {
            "product_name": "Sample Product",
            "price": 19.99,
            "tags": [
              "summer",
              "sale"
            ],
            "date(launch_date)": "2023-08-01T12:00:00Z",
            "available": true,
            "url(website)": "https://example.com"
          }
        }
      ]
    }
    {
      "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q"
    }
    POST /2.8/campaigns/create HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 416
    
    {
      "name": "The campaign name",
      "state": "RUNNING",
      "send_rate": 100000,
      "when": {
        "local_time": false,
        "start_time": "now"
      },
      "targeting": {
        "languages": [
          "fr"
        ],
        "regions": [
          "FR"
        ],
        "query": {
          "firstname": {
            "$eq": "Jane"
          }
        }
      },
      "labels": [
        "promo",
        "holiday"
      ],
      "messages": [
        {
          "channel_type": "email",
          "subject": "The campaign subject",
          "sender_identity_id": "4012",
          "reply_to": {
            "email_address": "jane.doe@demobatch.com"
          },
          "html": "The campaign HTML content"
        }
      ]
    }
    POST /2.8/profiles/update HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 546
    
    [
      {
        "identifiers": {
          "custom_id": "jane.doe@demobatch.com"
        },
        "attributes": {
          "$email_address": "jane.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$phone_number": "+33182837140",
          "$sms_marketing": "unsubscribed",
          "$language": "en",
          "$region": "FR",
          "$timezone": "Europe/Paris",
          "firstname": "Jane",
          "date(birthdate)": "1989-07-20T00:00:00Z",
          "interests": [
            "bikes",
            "cinema"
          ],
          "reward_programs": {
            "$add": [
              "premium_customer"
            ]
          }
        },
        "events": [
          {
            "name": "added_to_cart",
            "attributes": {
              "$label": "pumpkin",
              "quantity": 5,
              "unit_price": 3.99,
              "$tags": [
                "fruits",
                "organic",
                "on_sale"
              ]
            }
          }
        ]
      }
    ]

    POST - Send

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

    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.

    Request Structure

    Route

    The Transactional API exposes a POST send endpoint: https://api.batch.com/1.1/BATCH_API_KEY/transactional/send.

    Here is a valid cURL example:

    There are two keys you will need to use when calling the API:

    Key
    Description

    You will find both keys in your dashboard settings:

    Please note Batch manages each platform separately, so you will have to call the API twice with a different Dev/Live API key if you want to target iOS and Android.

    Insufficient privileges issue: You may see that error in the REST API key field. This happens because the REST API key is only visible to managers. Make sure the managers of the account share that key with you or ask them to grant you access through the team manager.

    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.

    Post Data

    The body of the request must contain a valid JSON payload with all the parameters you chose to add: Targeting, recurrence and more.

    Let's see the parameters in detail.

    Id
    Description

    Here is how a minimal and valid JSON payload looks like:

    The Landing Message Object

    Id
    Description

    Note If your theme contains the close button, the actions array is not strictly required.

    Each action in the landing message must be defined as follows.

    Each action in the landing message must be defined as follows.

    Id
    Description

    Important note: You will find here a list of all the built-in actions you can use in your Mobile Landing to dismiss the In-App message, use a deeplink, and more : / .

    Here is how a valid JSON payload looks like with a Mobile Landing:

    Sending Localized Notifications

    If you don't know your users' language, you can rely on Batch language detection and include localized versions of your message in your call to the Transactional API.

    Batch will pick the appropriate version of the message for each user, based on the language detected by the SDK or the language your users selected in your app or on your website.

    Here are the modifications you will need to make to add localized versions of your message:

    Localizing the Notification

    The messages object is a collection of messages in different languages. It conflicts with the message object and cannot be used with tokens recipients.

    You will need to set a fallback version of your message. It will be sent to users whose language doesn't match any of the translated versions available. for more details about message localization rules.

    Id
    Description

    Here is a valid example. The first message will be sent to french speaking recipients, the second one to spanish speaking recipients. If none of the sent messages match the recipient's language, the last message will be used.

    Localizing the Mobile Landing

    You can also localize the content of the Mobile Landing attached to your push notification.

    contents is an array of objects. Use it in the landing object. You will also need to set a fallback version of your message that will be sent to users whose language doesn't match any of the translated versions available. for more details about message localization rules.

    Here is a valid example:

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 201 confirmation and a unique token representing the transaction.

    Please keep this token: It will be useful to see the list of push tokens you targeted in the debug tool and it will also help in getting faster support.

    If you don't receive the notification after a successful POST, make sure your app is not opened in the foreground (iOS) and check again your integration.

    Failure

    If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at 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)

    Debug

    Batch provides a simple debug tool that lets the list of all the targeted push tokens for any given API call. Go to ⚙️ Settings → Debug and input the token generated by the API on each successful call.

    The advanced analytics view gives you detailed information for a specific transactional push:

    • SENT: The total amount of sent push notifications.

    • NOT FOUND: Number of Custom User ID or installation ID are not linked to any push token.

    • UNDELIVERABLE: Number of push tokens that were flagged as invalid by Apple/Google. Your app may have been uninstalled.

    • ERRORS: Number of APNS/FCM/WNS errors.

    Troubleshooting

    Can I do a single API request for both iOS and Android?

    Batch manages iOS and Android notifications separately to take advantage of the features that each OS has (e.g. silent push notifications, collapse key, etc). This is why you will need to call the Transactional API once per OS.

    Our APIs are asynchronous and respond very fast. Batch will send a push notification, provided that a valid device token is tied to the custom user ID you are targeting. However, if the custom user ID does not exist for the app you targeted, the call will fail silently.

    My device doesn't seem to receive any notifications

    Here are some suggestions in case your device doesn't receive any notifications:

    • Invalid token: Make sure the device token you are targeting is still valid using the Debug tool.

    • Wrong environment: On iOS, try adding {"sandbox":true} to your json payload.

    • Invalid custom user ID: Make sure the custom user ID ( / ) was registered by Batch for the OS you are targeting using the Debug tool.

    If you are still having issues receiving notifications, please take a look at our troubleshooting sections.

    Boolean - Optional Batch performs a HEAD request on your media URL to prevent you from sending invalid images, or ones too big. Checks include but are not limited to a valid Content-Type and Content-Length. If your server doesn't support this, you can disable these checks by setting this option to true. Acceptable values include: true or false. Default: false E.g.{"skip_media_check":"true"}

    recipients

    Object - Required An object containing who you want to push, by tokens or Custom IDs. Supports up to 10,000 push tokens /custom IDs/Install IDs. At least one of the three parameters must be included.

    tokens

    Array of strings - An array containing the push tokens to push. E.g.{"tokens":["USER_PUSH_TOKEN"]}

    custom_ids

    Array of strings - An array containing the custom user IDs to push. Custom user IDs are case and whitespace sensitive. Batch will select the 10 most recent installs with a token matching each custom user ID targeted in your call. E.g.{"custom_ids":["USER_CUSTOM_ID"]}

    install_ids

    Array of strings - An array containing the installation IDs to push. It should be the unmodified installation ID given by the SDK's user module. E.g.{"install_ids":["USER_INSTALL_ID"]}

    advertising_ids

    Array of strings - An array containing the advertising IDs to push, IDFA on iOS and GAID on Android. It should be the unmodified advertising ID collected from the device. Batch will select the 10 most recent installs with a token matching each advertising ID targeted in your call. E.g.{"advertising_ids":["USER_ADVERTISING_ID"]}

    message

    Object - Required, conflicts with `messages`. Disallowed when push_type is `background` An object containing the message to be delivered. You can send the message in multiple languages by using the messages object described further below

    title

    String - Optional (except for web push) - Supports message personalization Title of the push notification. E.g.{"title":"Don't give up!"}

    body

    String - Required - Supports message personalization Body text of the push notification. E.g.{"body":"Just keep training, you'll get better"}

    messages

    Object - Required, conflicts with `message`. Disallowed when push_type is `background`. The `messages` object is a collection of messages in different languages. .

    media

    Object - Optional - Disallowed when push_type is 'background' An object containing an icon, a picture, an audio or a video file's URL. E.g.{"media":{"icon":"http://mydomain.com/icon.png","picture":"http://mydomain.com/pic.png"}}

    deeplink

    String - Optional, conflicts with 'landing' - Supports message personalization A URL that points to a specific part of your app (i.e. The news you mention in your notification, etc) . The deeplink URL is usually a link based on a URL scheme that you specify within your app, but can be a relative one if you decide to read it manually. E.g.{"deeplink":"recipe-app://recipes/desserts/peach-pie"}

    sandbox

    Boolean - Optional Flag specifying whether the APNS sandbox should be used. No effect for Android applications or Custom IDs. Default: false. E.g.{"sandbox":true}

    wp_template

    String - Optional Flag specifying what Windows Toast template should be used. Use "legacy" if you push Windows 8.1 or Windows Phone 8.1, "generic" for UWP (Windows 10). Default: "legacy". E.g.{"wp_template":"generic"}

    custom_payload

    String - Optional (only available on paid plans) - Supports message personalization A JSON string that can contain additional parameters that your application can handle when receiving push notifications if configured to do so. Some keys cannot be overriden and will be dropped. This includes com.batch on all platforms, but Android comes with . Format is {\"x\":\"y\"} .

    landing

    Object - Optional An object describing the landing message. This will display a landing view allowing you to have complex interactions following a push notification. You will find more information below, under "The landing message object".

    String - Optional - Supports message personalization The text of the title E.g.{"title":"Update to the latest version!"}

    body

    String - Optional - Supports message personalization The text of the body E.g.{"body":"Lots of bug and security fixes"}

    actions

    Array of objects - Required A list of actions available in the landing message. The action object will be described further below

    MISSING_PARAMETER (Http status code: 400, Error code: 30)
  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • 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.

  • batch_rest_api_key

    Your company REST API key. It identifies your account and gives you access to our APIs. You can find it in ⚙ Settings → General.

    batch_api_key

    Your app's API key. It allows you to choose the app you want to push. Each app has a different API key. You can find it in ⚙ Settings → General.

    group_id

    String - Required Name of your campaign, useful for analytics purposes (see Analytics → Notifications → Transactional) . The group_id shouldn't be unique, it's a key to group your transactional push analytics. You can use the letters a-z, A-Z, the numbers 0-9, underscores and hyphens. E.g.{"group_id":"Welcome_campaign"}

    labels

    Array of Strings - Optional - Max. 3 labels An array containing the label codes you want to attach to your notification. You can use labels to implement frequency capping: make sure that you create the labels before using them and that you fill the "CODE" field when setting them up. Labels are NOT supported for token recipients. E.g.{"labels":["label1","label2"]}

    priority

    String - Optional Defines the priority of your message on iOS (APNS) and Android (FCM) . Acceptable values include: normal or high . Default value on iOS is high. Default value on Android is normal. On Android, use the high priority if you have a messaging/voip app and if you notice delivery issues due to native (Doze) or constructor related (Samsung Smart Manager, etc) energy saving features. High priority Android notifications can drain your user's battery faster since they 'wake up' the device and open a network connection. E.g.{"priority":"high"}

    time_to_live

    Integer - Optional - iOS / Android only Time, in seconds, after which the notification will be considered as invalid and should not be delivered after attempting to send it at least once, in any case. There is no default value: ommitting this parameter will use default behaviours of the underlying services, which is often to store notifications for a while. The value must be greater than 0. Maximum: 28 days. E.g.{"time_to_live":3600}

    gcm_collapse_key

    Object - Optional - Android only Defines how notifications are managed when an offline device goes online (enabled by default) . If enabled, the device will only show the most recent notification. If disabled, it will show all the notifications received when the device was offline. You should disable the collapse key if all your notifications matter (E.g. messages, etc) . You can use up to 3 different collapse keys if you want users to get only one notification of each kind when coming online (E.g. marketing messages, alert, etc) . E.g.{"enabled":true,"key":"default"}

    push_type

    String - Optional - Android/iOS. Default: 'alert' Defines whether notifications should show an alert or be silent to trigger a background action. Acceptable values are alert and background . Setting this to 'background' will disable the message and media keys: you will need to remove them from your call. iOS 13 will ignore silent notifications that don't define a background push_type, even though their custom payload defines a silent push. On iOS, {"aps":{"content-available":1}} will automatically be appended to the final payload to wake up the app in the background and the priority will be forced to `normal`. E.g.{"push_type":"alert"}

    theme

    String - Required The code of the theme to use for your landing view E.g.{"theme":"dark_base_theme"}

    webview_url

    String - Optional The URL to load in the Webview. Does nothing on non webview themes. E.g.{"webview_url":"https://batch.com"}

    image

    String - Optional - Supports message personalization The url of the image to use if the theme contains one E.g.{"image":"https://d1v3v59tzaau1a.cloudfront.net/medias/img/landing-samples/fly.15569dd6.jpg"}

    image_description

    String - Optional The description of the image used for accessibility purposes E.g.{"image_description":"Boeing 747"}

    tracking_id

    String - Optional A tracking ID that you will receive in your application if set E.g.{"tracking_id":"OPEA20161005"}

    header

    String - Optional - Supports message personalization The text of the header E.g.{"header":"News"}

    action

    String - Required The action name. Must match with the actions you register in your mobile application. Not strictly required, if null the close action will be used E.g.{"action":"show_article"}

    label

    String - Required The label of the call to action E.g.{"label":"Show"}

    args

    Object - Optional An object containing arbitrary data that will be passed to your action as is E.g.{"args":{"id":4,"category":"sports"}}

    messages

    Object - Required, conflicts with `message`. Disallowed when push_type is `background` An array containing the messages to be delivered. One and only one message without language must be defined, which will be the fallback message. Messages are not supported for token recipients.

    language

    String - Optional Two letter language code as listed here . E.g.{"language":"en"}

    title

    String - Optional (except for web push) - Supports message personalization Title of the push notification. E.g.{"title":"Don't give up!"}

    body

    String - Required - Supports message personalization Body text of the push notification. E.g.{"body":"Just keep training, you'll get better"}

    iOS
    Android
    See here
    See here
    support@batch.com
    iOS
    Android

    skip_media_check

    title

    curl -H "Content-Type: application/json" -H "X-Authorization: batch_rest_api_key" -X POST -d "@payload.json" "https://api.batch.com/1.1/batch_api_key/transactional/send"
    {
    	"group_id": "order_confirmed",
    	"recipients": {
    		"custom_ids": ["USER_ID"]
    	},
    	"message": {
    		"title": "Your order is confirmed!",
    		"body": "We will send you a shipping confirmation alert as soon as your order ships."
    	}
    }
    {
    	"group_id": "order_confirmed",
    	"recipients": {
    		"custom_ids": ["USER_ID"]
    	},
    	"message": {
    		"title": "Your order is confirmed!",
    		"body": "We will send you a shipping confirmation alert as soon as your order ships."
    	},
    	"landing": {
    		"theme": "MODAL-WITH-IMAGE",
    		"image": "https://batch-store.com/img/sunglasses.jpg",
    		"tracking_id": "order confirmation",
    		"image_description": "Item preview",
    		"header": "Thank you!",
    		"title": "Your order has been confirmed!",
    		"body": "Check the status of your order now or keep shopping.",
    		"actions": [
          {
    				"action": "batch.deeplink",
    				"label": "Check Status",
    				"args": {
    					"l": "https://batch-store.com/order-status"
    				}
    			},
    			{
    				"action": "batch.dismiss",
    				"label": "Later"
    			}
    		]
    	}
    }
    {
    	"group_id": "order_confirmed",
    	"recipients": {
    		"custom_ids": ["USER_ID"]
    	},
    	"messages": [
    		{
    			"language": "fr",
    			"title": "Votre commande est confirmée !",
    			"body": "Nous vous enverrons une alerte dès qu'elle sera expédiée."
    		},
    		{
    			"language": "es",
    			"title": "¡Tu pedido está confirmado!",
    			"body": "Te enviaremos una alerta cuando tu pedido sea enviado."
    		},
    		{
    			"title": "Your order is confirmed!",
    			"body": "We will send you a shipping confirmation alert as soon as your order ships."
    		}
    	]
    }
    {
    	"group_id": "order_confirmed",
    	"recipients": {
    		"custom_ids": ["USER_ID"]
    	},
    	"messages": [
    		{
    			"language": "fr",
    			"title": "Votre commande est confirmée !",
    			"body": "Nous vous enverrons une alerte dès qu'elle sera expédiée."
    		},
    		{
    			"language": "es",
    			"title": "¡Tu pedido está confirmado!",
    			"body": "Te enviaremos una alerta cuando tu pedido sea enviado."
    		},
    		{
    			"title": "Your order is confirmed!",
    			"body": "We will send you a shipping confirmation alert as soon as your order ships."
    		}
    	],
    	"landing": {
    		"theme": "MODAL-WITH-IMAGE",
    		"image": "https://batch-store.com/img/sunglasses.jpg",
    		"tracking_id": "order confirmation",
    		"contents": [{
    				"language": "fr",
    				"header": "Merci !",
    				"title": "Votre commande est confirmée",
    				"body": "Vérifiez le statut de votre commande ou continuez vos achats.",
    				"image_description": "Aperçu article",
    				"actions": [{
    						"action": "batch.deeplink",
    						"label": "Vérifier le statut",
    						"args": {
    							"l": "https://batch-store.com/order-status"
    						}
    					},
    					{
    						"action": "batch.dismiss",
    						"label": "Plus tard"
    					}
    				]
    			},
    			{
    				"language": "es",
    				"header": "¡Gracias!",
    				"title": "Tu pedido está confirmado",
    				"body": "Revisa el estado de tu pedido o sigue comprando.",
    				"image_description": "Vista previa del artículo",
    				"actions": [{
    						"action": "batch.deeplink",
    						"label": "Revisar el estado",
    						"args": {
    							"l": "https://batch-store.com/order-status"
    						}
    					},
    					{
    						"action": "batch.dismiss",
    						"label": "Más tarde"
    					}
    				]
    			},
    			{
    				"header": "Thank you!",
    				"title": "Your order has been confirmed!",
    				"body": "Check the status of your order now or keep shopping.",
    				"image_description": "Item preview",
    				"actions": [{
    						"action": "batch.deeplink",
    						"label": "Check Status",
    						"args": {
    							"l": "https://batch-store.com/order-status"
    						}
    					},
    					{
    						"action": "batch.dismiss",
    						"label": "Later"
    					}
    				]
    			}
    		]
    	}
    }
    {"token":"110e8400-e29b-11d4-b543-446655440000"}

    icon

    String - Supports message personalization Android / Windows 10 - URL of the icon file. The file must be a PNG or JPG square image, at least 192px side and must be hosted on an HTTPS server that responds to HEAD requests. It must not be larger than 5MB.

    picture

    String - Supports message personalization iOS 10+ / Android / Windows 10 - URL of the picture file. The file must be a PNG or JPG image with a minimum width and height of 200px. It must be hosted on an HTTPS server that correctly responds to HEAD requests and must not be larger than 5MB. Note: On iOS, make sure your server complies to App Transport Security or that you’ve added the appropriate exceptions in your app and app extension.

    audio

    String - Supports message personalization iOS 10+ - URL of the audio file. The file must be a MP3 file hosted on an HTTPS server that responds to HEAD requests. It must not be larger than 10MB.

    video

    String - Supports message personalization iOS 10+ - URL of the video file. The file must be a MPEG-4 file hosted on an HTTPS server that responds to HEAD requests. It must not be larger than 30MB.

    See more here
    additional forbidden keys due to FCM limitations

    Parameters

    Parameters list

    Basic parameters

    Id
    Description

    name

    String - Min. 3 chars - Required Readable name of the campaign. E.g.{"name":"My Engagement Campaign"}

    live

    Boolean - Required Value that sets the campaign to live. A false value will save the campaign as a draft but not activate it E.g.{"live":true}

    labels

    Array of Strings - Optional - Max. 3 labels An array containing the label names you want to attach to your campaign. You can use labels to filter the list of campaigns that appears on Batch's dashboard. Notice that related cappings are only applied to push Campaigns, but not on In-App Campaigns. E.g.{"labels":["label1","label2"]}

    Timing and delivery

    Two timezone parameters can be specified: start_date and end_date, and their counterparts local_start_date and local_end_date. If none of these parameters are specified, the In-App campaign will start now without any end date.

    Id
    Description

    start_date

    String - Optional - Conflicts with local_start_date Time that the In-App campaign will be activated GMT (UTC+0000). Format is yyyy-MM-ddTHH:mm:ss or now to activate the campaign immediately. E.g.{"local_start_date":"2015-12-01T14:25:00"}

    local_start_date

    String - Optional - Conflicts with push_time A value that defines the campaign activation time in terms of the user's device. The In-App campaign will be activated at the selected time for each time zone. Format is yyyy-MM-ddTHH:mm:ss E.g.{"local_start_date":"2015-12-01T14:25:00"}

    end_date

    String - Optional - Conflicts with local_end_date Time that the In-App campaign will end GMT (UTC+0000). Format is yyyy-MM-ddTHH:mm:ss . E.g.{"end_date":"2015-12-01T14:25:00"}

    local_end_date

    String - Optional - Conflicts with end_date A value that defines the campaign end time in terms of the user's device. The In-App campaign will end at the selected time for each time zone. Format is yyyy-MM-ddTHH:mm:ss E.g.{"local_end_date":"2015-12-01T14:25:00"}

    Trigger

    Id
    Description

    trigger

    Object - Required An object describing when the In-App message will be triggered and displayed.

    Grace period

    The grace period avoids the In-App message to be displayed multiple times in a short time range.

    Id
    Description

    grace_period

    Object - Optional An object describing the grace period duration. E.g.{"grace_period":{"every":2,"unit":"DAYS"}}

    When

    Id
    Description

    when

    Object or String - Optional A string ( NOW or NEXT_SESSION ) or an object (if the trigger is an event) describing when the In-App message should be triggered. E.g.{"when":{"event":"e.event_name","label":"event_label"}}

    User targeting

    targeting

    Object - Optional An object containing the targeting property of the campaign. If omitted, all users will be targeted.

    Landing message

    This will display a landing view using the theme and content of your choosing, allowing you to have complex interactions.

    The landing message is defined under the landing key at the root of the payload and the following fields are allowed.

    Id
    Description

    theme

    String - Required The code of the theme to use for your landing view E.g.{"theme":"dark_base_theme"}

    tracking_id

    String - Optional A tracking ID that you will receive in your application if set E.g.{"tracking_id":"OPEA20161005"}

    contents

    Array of Objects - Required The contents of the landing message. for message localization rules and valid language codes.

    Note If your theme contains the close button, the actions array is not strictly required.

    The action object

    Each action in the landing message must be defined as follows.

    Id
    Description

    action

    String - Required The action name. Must match with the actions you register in your mobile application. Not strictly required, if null the close action will be used E.g.{"action":"show_article"}

    label

    String - Required The label of the call to action E.g.{"label":"Show"}

    args

    Object - Optional An object containing arbitrary data that will be passed to your action as is E.g.{"args":{"id":4,"category":"sports"}}

    Important note: You will find here a list of all the built-in actions you can use in your Mobile Landing to dismiss the In-App message, use a deeplink, and more : iOS / Android.

    The query object

    For advanced usage, you can pass a query object to the targeting. This is a homemade syntax, inspired by MongoDB. This feature is available to Pro and Enterprise users for native and custom attributes.

    Native attributes

    Native attributes allow you to target users based on their OS and app version, their device type or the number of days since they installed your app.

    Native attributes must be added in query, as a targeting property.

    Id
    Description

    b.os_version

    String - The Android or iOS version.The expected format is X.Y.Z. The OS version cannot contain any letter. E.g.{"b.os_version":"5.1.1"}

    b.app_version

    String - Your app version. The expected format is X.Y.Z. E.g.{"b.app_version":"2.A.3"}

    b.device_type

    String - The device type / model. Make sure you choose a value in the model column. E.g.{"b.device_type":"iPhone8,1"}

    b.carrier_code

    Integer - Your user's carrier. The code provided by Batch is a combination of the Mobile country code (MCC) and the Mobile network code (MNC) . The full list of MCC and MNC codes is . Not supported on iOS 16.4 and higher. E.g.{"b.carrier_code":20815}

    age(b.install_date)

    Duration - Number of days elapsed since the install (install: the first time Batch SDK sees the user) . The days are counted in sections of 24 hours from the hour of install. E.g.{"age(b.install_date)":1}

    age(b.last_visit_date)

    Duration - Number of days elapsed since your users' last session. The days are counted in sections of 24 hours from the last session. E.g.{"age(b.install_date)":1}

    By default, a Duration object is an Integer that represents a number of days. This object can be in any other time unit if it is given a String with the value and the unit. For instance "12h" represents a number of hours. E.g.{"age(b.last_push_date)": “12h”}

    Instead of age(), you can also use date() on date attributes. This function will return a UTC timestamp Integer.

    RECOMMENDED

    • Users coming from an older version of your app and upgrading to a version with Batch's SDK (after a first release or a token import) are considered as new installs.

    • If you are planning to use this attribute to send 1-3-7 days post-install notifications, we recommend that you wait at least 7 days to make sure you only target your new users.

    Custom user data

    You can send custom user data from your app or using the Custom Data API.

    Attributes

    Custom attributes are prefixed with c. or u. if they are sent from the Custom Data API, and are simple key/value data. You can use them to collect a:

    • String

    • Number / Decimal

    • Boolean

    • Date

    Tags collections

    Tags are prefixed with t. or ut. if they are sent from the Custom Data API, and are sets of tags.

    Events

    Events are prefixed with e. and have a key, an occurence date, an optional label, and an optional data object.

    Recommended Take a look at this guide to know more on custom data and learn how to tag your app.

    Operators

    • $eq Equal to. This is the default and thus can be ommited.

    • $lt Lower than <

    • $lte Lower or equal than <=

    • $gt Greater than >

    • $gte Greater or equal than >

    • $contains Checks if the tag collection has one of the requested tag

    • $containsAll Checks if the tag collection has all of the requested tag

    Basic examples

    Targets to all users who live in Paris :

    As explained above, $eq is the default so we can ommit it:

    All users with app version 1.0.1

    Users who installed your app 1 day ago and use an iPhone 6.

    When you need multiple conditions, the first level of your query needs to be an $and, with an array of conditions.

    Functions and advanced example

    Date attribute needs a function to be queried; that's why we showed you age(b.install_date) before.

    We plan to introduce more functions to our API to enable events querying in the upcoming weeks.

    From now on, we will only show the query. Just remember it goes in targeting.query.

    Users intersted by Rugby or Football, who installed in the last 10 days, and subscribed to your paid offer.

    Users who installed your app since at least 10 days, living in Paris, at least Android 5.0, using the version 3.1.1 of your app, and subscribed to both France & Sport categories

    Please note that the Imported segment won't be selected if you target users based on custom user data (attributes, tags or events).

    cURL example

    Here is an example of a valid cURL CLI request syntax:

    where payload.json:

    The above example will start a recurring campaign on June 1, 2015 at 14:00 (2PM), sending to users based on their device time.

    • It is set as "live": true so will begin at the designated time, versus resting as a draft requiring further action before sending.

    • The optional targeting object has been included to specify the device language, region, and targeted segments. If this object were not included, all users would be targeted. In this case, we used the native attribute age(b.install_date) to target users who installed the app one day ago.

    • Within the landing object each targeted language has been given a message. It's worth noting that you must have a message object for the default language of your app, as set within the Batch dashboard.

    • This campaign trigger here means that :

      • The message will be display 3 times to each user at the most

      • The message cannot be displayed more than one time in one day (24h)

      • The message will be displayed at the next session. It means that once the message is received by the device, it will be displayed the next time the user will open the app.

    • This campaign uses the recurrence optional object to have the campaign repeat every day at the originally defined time of 14:00 until June 6, 2015 at 00:00.

    A/B Testing

    A/B tested campaigns work a little bit differently than standard ones.

    Landings

    You can A/B test your landing message. To do that, you simply need to define two keys a and b under the landing key. Each key must contain a valid landing message object, as described above.

    Here's a quick example of an A/B tested in-app campaign:

    Note Custom Payloads are not A/B testable.

    Export profile data

    Profiles centralize data and events from multiple sources (Apps, Websites, APIs) in a single place based on the Custom ID.

    The Profiles API allows you to export profiles data. Use this endpoint to:

    • Export profile native attributes

    • Export profile custom attributes

    • Export profile identifiers

    • Export profile events

    API Description

    Lookback

    Some kind of exports are logs of detailed events that happened. Those raw events are not kept forever and will stop being available to export after a while: this is documented in the "Lookback" duration for each event kind. Providing a from parameter older than the lookback period will result in an error.

    Exports that represent a snapshot of data (such as Profile Attributes) do not have this limitation.

    Route

    The Profile API exposes a POST endpoint that allows to create an export request:

    /profiles/export

    Headers and authentication

    See .

    Profile Attributes

    Use this to export custom and native attributes as well as the identifiers of your profiles.

    Request structure

    The body of the request must contain a valid JSON payload describing the export request to be executed.

    Here is a how a complete JSON payload looks like:

    You must specify at least one of attributes, identifiers or both in your export request.

    The filter parameter is optional. Currently, you can only filter by segment. Specify the segment by providing the segment code* you want to use for this export.

    *The segment code is available in two places within the Dashboard on the Segments page:

    • Either via the "Copy segment code" option in the dropdown menu.

    • Or by clicking the copy icon on the right-hand side of the modal for the specific segment.

    Rate limiting with filter parameter

    Please note: when the filter parameter is being passed, we apply a rate limiting of 5 requests per hour (1 new request authorised every 12 minutes), with a maximum authorised burst of 10 requests.

    Export file structure

    The export will contain a list of attributes. Each attribute is composed of an attribute object and an identifiers object.

    Field
    Description
    Type
    Required

    Attribute Object

    Representation of an attribute object.

    Field
    Description
    Type
    Required

    Identifiers object

    Represents the identifiers of the profile concerned by the event.

    Field
    Description
    Type
    Required

    Export file sample

    This is a sample of the content of the export file you will receive.

    Example

    Profile Events

    Use this to export events associated with your profiles.

    Lookback

    90 days

    Request structure

    The body of the request must contain a valid JSON payload describing the export request to be executed.

    Here is a how a complete JSON payload looks like:

    Export file structure

    This export will contain a list of events with it fields and an identifiers object.

    Event fields

    Field
    Description
    Type
    Required

    Identifiers object

    Represents the identifiers of the profile concerned by the event.

    Field
    Description
    Type
    Required

    Event type

    Exhaustive list of type for the event.

    • email_sent: Triggered when the email is sent.

    • email_delivered: Triggered when the email is successfully accepted by the recipient's email server.

    • email_open: Triggered when the recipient opens the email.

    Export file sample

    This is a sample of the content of the export file you will receive.

    Example

    Profile Reachability Events

    Use this to export the reachability events of your profiles.

    Lookback

    Reachability events are available since October 10, 2024. No events are available prior to this date. Lookback period will be 90 days.

    Request structure

    The body of the request must contain a valid JSON payload describing the export request to be executed.

    Here is a how a complete JSON payload looks like:

    Export file structure

    The export will contain a list of reachability events. Each event is composed of an event object and an identifiers object.

    Field
    Description
    Type
    Required

    Event Object

    Representation of an reachability event object. It also describes a part of the profile state at the time of the event.

    Field
    Description
    Type
    Required

    Identifiers object

    Represents the identifiers of the profile concerned by the event.

    Field
    Description
    Type
    Required

    Event reasons

    Exhaustive list of reasons for the event.

    • SUBSCRIBED_TO_SMS_MARKETING: The profile subscribed to SMS marketing.

    • UNSUBSCRIBED_FROM_SMS_MARKETING: The profile unsubscribed from SMS marketing.

    • PHONE_NUMBER_ADDED: The profile added a phone number.

    Export file sample

    This is a sample of the content of the export file you will receive.

    Example

    Responses

    Success

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an export ID. This ID can be used to get status information about your export request using the endpoints.

    Failure

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

    See the list of potential failures in the API Description.

    {
      "targeting": {
        "query": {
          "c.city": {
            "$eq": "Paris"
          }
        }
      }
    }
    {
      "targeting": {
        "query": {
          "c.city": "Paris"
        }
      }
    }
    {
      "targeting": {
        "query": {
          "b.app_version": {
            "$gte": "1.0.1"
          }
        }
      }
    }
    {
      "targeting": {
        "query": {
          "$and": [
            {
              "age(b.install_date)": 1
            },
            {
              "b.device_type": {
                "$gt": "iPhone7,2"
              }
            }
          ]
        }
      }
    }
    {
      "$and": [
        {
          "t.interest": {
            "$contains": ["Rugby", "Football"]
          }
        },
        {
          "age(b.install_date)": {
            "$lte": 10
          }
        },
        {
          "c.paidSubscriber": true
        }
      ]
    }
    {
      "$and": [
        {
          "age(b.install_date)": {
            "$gte": 10
          }
        },
        {
          "c.city": "Paris"
        },
        {
          "b.os_version": {
            "$gte": "5.0"
          }
        },
        {
          "b.app_version": "3.1.1"
        },
        {
          "t.push_optin": {
            "$containsAll": ["France", "Sport"]
          }
        }
      ]
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH-PUSH-API-TOKEN" -X POST -d
    "@payload.json" "https://api.batch.com/API_VERSION_NUMBER/BATCH_API_KEY/in-app-campaigns/create"
    {
      "name": "Test Campaign",
      "local_start_date": "2017-06-01T14:00:00",
      "live": true,
      "targeting": {
        "languages": ["it"],
        "regions": ["FR", "US"],
        "segments": ["ONE_TIME", "ENGAGED", "NEW"],
        "query": {
          "age(b.install_date)": 1
        }
      },
      "trigger": {
        "capping": 3,
        "grace_period": {
          "every": 1,
          "unit": "DAYS"
        },
        "when": "NEXT_SESSION"
      },
      "landing": {
        "theme": "HELLO_THEME",
        "contents": [
          {
            "language": "en",
            "header": "Welcome",
            "title": "Hello!",
            "body": "How is it going?",
            "image": "https://static.batch.com/documentation/logo_batch_192.png",
            "actions": [
              {
                "label": "Continue",
                "action": "continue",
                "args": {
                  "id": "1054"
                }
              }
            ]
          },
          {
            "language": "fr",
            "header": "Bienvenue",
            "title": "Salut!",
            "body": "Comment ça va ?",
            "image": "https://static.batch.com/documentation/logo_batch_192.png",
            "actions": [
              {
                "label": "Continuer",
                "action": "continue",
                "args": {
                  "id": "1054"
                }
              }
            ]
          }
        ]
      }
    }
    {
      "landing": {
        "a": {
          "theme": "my-theme-1",
          "contents": [
            {
              "language": "fr",
              "title": "Salut!",
              "body": "Comment vas-tu?",
              "actions": [
                {
                  "action": "batch.dismiss",
                  "args": {},
                  "label": "Annuler"
                },
                {
                  "action": "batch.deeplink",
                  "args": {
                    "l": "https://google.fr/"
                  },
                  "label": "Rechercher"
                }
              ]
            },
            {
              "language": "en",
              "title": "Hey!",
              "body": "How are you?",
              "actions": [
                {
                  "action": "batch.dismiss",
                  "args": {},
                  "label": "Cancel"
                },
                {
                  "action": "batch.deeplink",
                  "args": {
                    "l": "https://google.com/"
                  },
                  "label": "Search"
                }
              ]
            }
          ]
        },
        "b": {
          "theme": "my-theme-2",
          "contents": [
            {
              "language": "fr",
              "title": "Bonjour!",
              "body": "Tu vas bien?",
              "image": "https://mydomain.com/myimage-1.png",
              "actions": [
                {
                  "action": "batch.dismiss",
                  "args": {},
                  "label": "Annuler"
                },
                {
                  "action": "batch.deeplink",
                  "args": {
                    "l": "https://google.fr/"
                  },
                  "label": "Rechercher"
                }
              ]
            },
            {
              "language": "en",
              "title": "Hi!",
              "body": "How is it going?",
              "image": "https://mydomain.com/myimage-2.png",
              "actions": [
                {
                  "action": "batch.dismiss",
                  "args": {},
                  "label": "Cancel"
                },
                {
                  "action": "batch.deeplink",
                  "args": {
                    "l": "https://google.com/"
                  },
                  "label": "Search"
                }
              ]
            }
          ]
        }
      }
    }

    actions

    Array of objects - Required A list of actions available in the landing message. The action object will be described further below

    webview_url

    String - Required, WebView theme only URL that WebView format should display

    link_open_target

    String - Required, WebView theme only

    Valid values: IN_APP, BROWSER

    b.has_custom_id

    Boolean - True if the user posesses a Custom User ID in our Userbase. E.g.{"b.has_custom_id":true}

    b.transaction_tracked

    Boolean - True if a transaction have been detected from the user. E.g.{"b.transaction_tracked":true}

    b.city_code

    Integer - You user's city detected by Batch using IP geolocation. E.g.{"b.city_code":2988507}

    age(b.last_push_date)

    Duration - Number of days elapsed since the last time you sent your user a push via the dashboard or the Campaigns API. E.g.{"age(b.last_push_date)":2}

    isNear(int latitude, int longitude, string radius, duration time)

    Boolean - True if the last collected user's location is within the given radius around the coordinates during the last X hours. Batch SDK must be allowed to collect geolocation to enable this query. E.g.{"isNear(48.8407578796295,2.351546582031233,5000m,12h)":true}

    b.is_push_optin

    Boolean - True if the install is opt-in to push, meaning that it can receive and display push notifications. E.g.{"b.is_push_optin":false}

    capping

    Integer - Optional The maximum number of time a given user can receive the In-App message E.g.{"capping":1}

    priority

    String - Optional - A value among STANDARD , IMPORTANT and CRITICAL If multiple campaigns should be displayed at the same time, the priority determines which one to display before the others. STANDARD is the default and lowest priority, IMPORTANT has a higher priority and CRITICAL is the highest one. E.g.{"priority":"CRITICAL"}

    grace_period

    Object - Optional See below section Grace period

    when

    Object or String - Required See below section When

    every

    Integer - The grace period duration value E.g.{"every":2}

    unit

    String - Required The grace period duration unit. Acceptable values include: HOURS and DAY E.g.{"unit":"DAYS"}

    event

    String - Required Event name. Custom events must be prefixed by 'e.'. E.g.{"event":"e.event_name"}

    label

    String - Optional Even label E.g.{"label":"event_label"}

    languages

    Array of Strings - An array containing all device languages to be targeted. All language codes in this array must be contained in the messages object. See here for matching rules and valid language codes. E.g.{"languages":["it","fr"]}

    regions

    Array of Strings - An array containing all the geographical regions codes to be targeted. See here for all valid region codes. E.g.{"regions":["FR","US"]}

    segments

    Array of Strings - An array containing the smart segments to be targeted. Acceptable values include: NEW , ONE_TIME , ENGAGED , DORMANT and IMPORTED . If you ommit this field or pass [], all users, included imported ones, will be targeted. E.g.{"segments":["ENGAGED","NEW"]}

    query

    Object - A mongo inspired query object containing filters & operators, based on native attributes (app version, OS version, etc) and custom users data (attributes, tags & events defined by you in the SDK) .

    custom_audiences

    Array of Strings - An array containing all the custom audiences that should be targeted.

    just_in_time

    lean - Optional Whether the targeting should be checked right before displaying the landing message. If true , the SDK will check, before displaying the message, if the user matches the targeting. If false (the default), the targeting will be checked only when the campaign is sent.

    language

    String - Required The language of the message E.g.{"language":"en"}

    header

    String - Optional - Supports message personalization The text of the header E.g.{"header":"News"}

    title

    String - Optional - Supports message personalization The text of the title E.g.{"title":"Update to the latest version!"}

    body

    String - Optional - Supports message personalization The text of the body E.g.{"body":"Lots of bug and security fixes"}

    image

    String - Optional - Supports message personalization The url of the image to use if the theme contains one E.g.{"image":"https://static.batch.com/medias/img/landing-samples/fly.15569dd6.jpg"}

    image_description

    See here
    available here

    String - Optional The description of the image used for accessibility purposes E.g.{"image_description":"Boeing 747"}

    language

    Profile's language E.g.{"language":"en"}

    string

    last_activity

    Profile's last activity E.g.{"last_activity":"2025-06-30T14:25:56Z"}

    date

    last_email_marketing_click

    Profile's last marketing email click E.g.{"last_email_marketing_click":"2025-06-30T14:25:56Z"}

    date

    last_email_marketing_open

    Profile's last marketing email open E.g.{"last_email_marketing_open":"2025-06-30T14:25:56Z"}

    date

    last_email_transactional_click

    Profile's last transactional email click E.g.{"last_email_transactional_click":"2025-06-30T14:25:56Z"}

    date

    last_email_transactional_open

    Profile's last transactional email open E.g.{"last_email_transactional_open":"2025-06-30T14:25:56Z"}

    date

    last_visit_date

    Profile's last visite date E.g.{"last_visit_date":"2025-06-30T14:25:56Z"}

    date

    phone_number

    Profile's phone number E.g.{"phone_number":"+33182837140"}

    string

    push_subscriptions

    Profile's push subscriptions. E.g.

    array

    region

    Profile's region E.g.{"region":"FR"}

    string

    sms_marketing

    Profile's marketing SMS subscription E.g.{"sms_marketing":"subscribed"}

    string

    timezone

    Profile's timezone E.g.{"timezone":"Europe/Paris"}

    string

    api_key

    Application's API Key E.g.{"api_key":"6B29A8F1E7CD4B93AC1D0F52C4A19BE7"}

    string

    bounce_code

    Event's bounce code E.g.{"bounce_code":"invalid_recipient"}

    string

    bounce_type

    Event's bounce type E.g.{"bounce_type":"hard"}

    string

    click_url

    Event's click url E.g.{"click_url":"https://www.batch.com"}

    string

    click_url_name

    Event's click url name E.g.{"click_url_name":"Batch"}

    string

    email_address

    Profile's email address E.g.{"email_address":"jane.doe@demobatch.com"}

    string

    event_date

    Event's date E.g.{"event_date":"2025-09-08T16:21:44Z"}

    string

    event_type

    Event's type E.g.{"event_type":"push_sent"}

    string

    machine_open

    Indicates whether the email open was likely triggered by an automated system rather than a real user E.g.{"machin_open":true}

    boolean

    mailbox_provider

    Profile's mailbox provider E.g.{"mailbox_provider":"Gsuite"}

    string

    is_push_opt_in

    Indicates whether the profile has opted in to push notifications E.g.{"is_push_opt_in":true}

    boolean

    message_language

    Message's language E.g.{"message language":"fr"}

    string

    open_type

    Indicates whether the push open was direct (triggered from the notification) or influenced (the app was opened within 3 hours without interacting with the notification)

    E.g.{"open_type":"direct"}

    string

    orchestration_id

    Orchestration's identifier E.g.{"orchestration_id":"orchestration_0fuy7ah8kqtmvd3jcp2x96ge5n1rwxbq"}

    string

    orchestration_name

    Orchestration's name E.g.{"orchestration_name":"Welcome Batch"}

    string

    phone_country

    Profile's phone country E.g.{"phone_country":"fr"}

    string

    phone_number

    Profile's phone number E.g.{"phone_number":"+33182837140"}

    string

    platform

    Installation platform E.g.{"platform":"IOS"}

    string

    sent_id

    Event's sent identifier E.g.{"sent_id":"9f3c1024-b238-11f0-89ea-5e9dcf083d3f"}

    string

    sms_parts

    Number of message parts in the sent SMS E.g.{"sms_parts":1}

    integer

    step_id

    Step's identifier E.g.{"step_id":"MESSAGE__t9HwKzL"}

    string

    step_name

    Step's name E.g.{"step_name":"Welcome step"}

    string
    email_click: Triggered when the recipient clicks a link in the email.
  • email_unsubscribed: Triggered when the recipient unsubscribes from emails.

  • email_bounced: Triggered when an email fails to deliver.

  • email_spam_complaint: Triggered when the recipient marks the email as spam.

  • sms_sent: Triggered when an SMS is sent.

  • sms_delivered: Triggered when the SMS is successfully delivered.

  • sms_click: Triggered when the recipient clicks a link in the SMS.

  • sms_unsubscribed: Triggered when the recipient unsubscribes from SMS.

  • sms_bounced: Triggered when an SMS fails to deliver.

  • push_sent: Triggered when a push notification is sent.

  • push_open: Triggered when the user opens the app via the push notification.

  • push_bounced: Triggered when the push fails (e.g., invalid token).

  • in_app_delivered : Triggered when the In-App was successfully displayed to the recipient.

  • in_app_click : Triggered when the recipient clicks on a button, excluding buttons configured with a "Dismiss" action.

  • in_app_dismissed : Triggered when the recipient dismisses the in-app (e.g: by clicking on a "Dismiss" button, the top-right 'X' button or swiping).

  • mobile_landing_delivered : Triggered when the Mobile Landing is successfully delivered.

  • mobile_landing_click : Triggered when the recipient clicks a link in the Mobile Landing.

  • mobile_landing_dismissed : Triggered when the recipient taps the dismiss button on the Mobile Landing.

  • reasons

    Reasons why an event has been triggered. See "" E.g.{"reasons":["SUBSCRIBED_TO_SMS_MARKETING","PHONE_NUMBER_ADDED"]}

    array

    has_phone_number

    Only for SMS channel, means the profile has a phone number E.g.{"has_phone_number":true}

    boolean

    has_email_address

    Profile's marketing email subscription E.g.{"has_email_address":true}

    boolean

    sms_marketing

    Profile's marketing SMS subscription E.g.{"sms_marketing":"subscribed"}

    string

    email_marketing

    Profile's marketing emails subscription E.g.{"email_marketing":"subscribed"}

    string

    is_optin

    Installation's notification system opt-in state E.g.{"is_optin":false}

    boolean

    platform

    Platform of the installation (iOS/Android/Webpush). Only available on PUSH channels E.g.{"platform":"iOS"}

    string
    PHONE_NUMBER_REMOVED: The profile removed a phone number.
  • PHONE_NUMBER_UPDATED: The profile updated a phone number.

  • SUBSCRIBED_TO_EMAIL_MARKETING: The profile subscribed to email marketing.

  • UNSUBSCRIBED_FROM_EMAIL_MARKETING: The profile unsubscribed from email marketing.

  • EMAIL_ADDRESS_ADDED: The profile added an email address.

  • EMAIL_ADDRESS_REMOVED: The profile removed an email address.

  • EMAIL_ADDRESS_UPDATED: The profile updated an email address.

  • SUBSCRIBED_TO_PUSH: The profile got an optin install.

  • UNSUBSCRIBED_FROM_PUSH: The profile unsubscribed from push notifications.

  • PUSH_TOKEN_ADDED: The profile added a push token.

  • Export

    post

    Create a request to export profile data.

    attribute

    Representation of an attribute object

    object

    identifiers

    Representation of an identifiers object

    object

    creation_date

    Profile's creation date E.g.{"creation_date":"2025-06-30T11:55:17Z"}

    date

    email_address

    Profile's email address E.g.{"email_address":"jane.doe@demobatch.com"}

    string

    email_marketing

    Profile's marketing emails subscription E.g.{"email_marketing":"subscribed"}

    string

    profile_id

    Unique identifier of the profile E.g.{"profile_id":"profile_063kxgw384nn7k3wxgsa0xfbd0pgmd9v"}

    string

    custom_id

    Custom identifier of the profile E.g.{"custom_id":"User1"}

    string

    installation_ids

    Installation identifier of the profile. Only available on PUSH channels E.g.{"installation_ids": ["828A7D76-3D5E-49DC-A863-2465070184C9"]}

    string

    ab_testing_status

    Orchestration's A/B testing status E.g.{"ab_testing_status":"ONGOING"}

    string

    ab_testing_variant

    Event's A/B testing variant E.g.{"ab_testing_variant":"A"}

    string

    action

    Indicates the action triggered when the user interacted with the message (mobile landing or in-app). This can be a standard Batch action or a custom one defined

    Possible values include:

    • batch.dismiss: The message was dismissed by the user.

    • batch.redirect_settings: The user was redirected to app settings.

    • batch.smart_reoptin: A re-opt-in prompt was displayed (e.g., for push permissions).

    • batch.rating: A rating prompt was triggered.

    • batch.redirect: The user was redirected to a URL.

    E.g.{"action":"batch.dismiss"}

    string

    profile_id

    Unique identifier of the profile. E.g.{"profile_id":"profile_063kxgw384nn7k3wxgsa0xfbd0pgmd9v"}

    string

    custom_id

    Custom identifier of the profile E.g.{"custom_id":"User1"}

    string

    installation_id

    Installation identifier of the profile. Available on push & in-app channels E.g.{"installation_id":"828A7D76-3D5E-49DC-A863-2465070184C9"}

    string

    event

    Representation of a reachability event object

    object

    identifiers

    Representation of an identifiers object

    object

    channel

    Channel where the event happened E.g.{"channel":"SMS"}

    string

    id

    Unique identifier of the event E.g.{"id":"6156b060574cb223e8c4ed47c5df1855"}

    string

    timestamp

    UTC date in a RFC 3339 format E.g.{"timestamp":"2024-01-01T00:00:00Z"}

    string

    profile_id

    Unique identifier of the profile. E.g.{"profile_id":"profile_063kxgw384nn7k3wxgsa0xfbd0pgmd9v"}

    string

    custom_id

    Custom identifier of the profile E.g.{"custom_id":"User1"}

    string

    installation_id

    Installation identifier of the profile. Only available on PUSH channels E.g.{"installation_id":"828A7D76-3D5E-49DC-A863-2465070184C9"}

    string
    Overview → Using Project APIs
    Project Export API
    support@batch.com
    {
        "export_type": "ATTRIBUTES",
        "attributes": [
            "$creation_date",
            "$email_address",
            "$email_marketing",
            "$language",
            "$last_activity",
            "$last_email_marketing_click",
            "$last_email_marketing_open",
            "$last_email_transactional_click",
            "$last_email_transactional_open",
            "$last_visit_date",
            "$phone_number",
            "$push_subscriptions",
            "$region",
            "$sms_marketing",
            "$timezone"
        ],
        "identifiers": [
            "custom_id",
            "installation_ids"
        ],
        "filter": {
            "segment": "MY-SEGMENT-CODE"
        }
    }
    [
      {
        "attributes": {
          "$email_address": "jane.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$language": "fr",
          "$phone_number": null,
          "$region": "FR",
          "$sms_marketing": "unsubscribed",
          "$timezone": "Europe/Paris"
        },
        "identifiers": {
          "custom_id": "User1",
          "installation_ids": ["828A7D76-3D5E-49DC-A863-2465070184C9"],
          "profile_id": "profile_1m9yqztq4w5gxs2pbkqkn8rt1agv0p9n"
        }
      },
      {
        "attributes": {
          "$email_address": "john.doe@demobatch.com",
          "$email_marketing": "subscribed",
          "$language": "fr",
          "$phone_number": null,
          "$region": "FR",
          "$sms_marketing": "unsubscribed",
          "$timezone": "Europe/Paris"
        },
        "identifiers": {
          "custom_id": "User2",
          "profile_id": "profile_3r1vczm73kzq8ebfyt72cp4nm9qd2jk6"
        }
      },
      {
        "attributes": {
          "$email_address": null,
          "$email_marketing": "unsubscribed",
          "$language": "fr",
          "$phone_number": "+33182837140",
          "$region": "FR",
          "$sms_marketing": "subscribed",
          "$timezone": "Europe/Paris"
        },
        "identifiers": {
          "profile_id": "profile_0vnyhjdkt9bs0fx1znp5a4ew8mcz21td"
        }
      }
    ]
    {
        "export_type": "EVENTS",
        "from": "2024-01-01T00:00:00Z",
        "to": "now",
        "events": [
            "email_sent",
            "email_delivered",
            "email_open",
            "email_click",
            "email_unsubscribed",
            "email_bounced",
            "email_spam_complaint",
            "sms_sent",
            "sms_delivered",
            "sms_click"
            "sms_unsubscribed",
            "sms_bounced",
            "push_sent",
            "push_open",
            "push_bounced",
            "in_app_delivered",
            "in_app_click",
            "in_app_dismissed",
            "mobile_landing_delivered",
            "mobile_landing_click",
            "mobile_landing_dismissed"
        ],
        "identifiers": [
            "custom_id"
        ]
    }
    [
      {
          "ab_testing_status": null,
          "ab_testing_variant": null,
          "api_key": "6B29A8F1E7CD4B93AC1D0F52C4A19BE7",
          "event_date": "2025-08-29T13:05:55Z",
          "event_type": "push_sent",
          "identifiers": {
            "custom_id": "User1",
            "profile_id": "profile_1m9yqztq4w5gxs2pbkqkn8rt1agv0p9n",
            "installation_id": "5420388A-D2EF-4397-AC9A-999231DA50D5"
          },
          "is_push_opt_in": true,
          "message_language": "default",
          "orchestration_id": "orchestration_0fuy7ah8kqtmvd3jcp2x96ge5n1rwxbq",
          "orchestration_name": "Batch welcome orchestration",
          "platform": "IOS",
          "sent_id": "9f3c1024-b238-11f0-89ea-5e9dcf083d3f",
          "step_id": "MESSAGE__t9HwKzL",
          "step_name": "Welcome push"
        },
        {
        "ab_testing_status": null,
        "ab_testing_variant": null,
        "event_date": "2025-09-02T15:10:24Z",
        "event_type": "sms_sent",
        "identifiers": {
          "custom_id": "User2",
          "profile_id": "profile_3r1vczm73kzq8ebfyt72cp4nm9qd2jk6"
        },
        "message_language": "default",
        "orchestration_id": "orchestration_0fuy7ah8kqtmvd3jcp2x96ge5n1rwxbq",
        "orchestration_name": "Batch welcome orchestration",
        "phone_country": "fr",
        "phone_number": "+33182837140",
        "sent_id": "sms_1b5uvrk84g3xmk2ze7w9tdapf6q1js0y",
        "sms_parts": 1,
        "step_id": "MESSAGE__pX7dQKz",
        "step_name": "Welcome sms"
      },
      {
        "ab_testing_status": null,
        "ab_testing_variant": null,
        "email_address": "jane.doe@demobatch.com",
        "event_date": "2025-09-03T13:34:51Z",
        "event_type": "email_sent",
        "identifiers": {
          "custom_id": "",
          "profile_id": "profile_0vnyhjdkt9bs0fx1znp5a4ew8mcz21td"
        },
        "mailbox_provider": "Gsuite",
        "message_language": "default",
        "orchestration_id": "orchestration_1q3cymdz0npk8g4xv67whjkb25r9emtc",
        "orchestration_name": "Email Marketing Campaign",
        "sent_id": "email_1vyqn54j0exu38wdg2tsmk7rz9ba4kyh",
        "step_id": "MESSAGE__Aq9KdLm",
        "step_name": null
      },
      {
          "ab_testing_status": null,
          "ab_testing_variant": null,
          "api_key": "6B29A8F1E7CD4B93AC1D0F52C4A19BE7",
          "event_date": "2025-08-29T18:05:55Z",
          "event_type": "in_app_deliverd",
          "identifiers": {
            "custom_id": "User1",
            "profile_id": "profile_1m9yqztq4w5gxs2pbkqkn8rt1agv0p9n",
            "installation_id": "5420388A-D2EF-4397-AC9A-999231DA50D5"
          },
          "message_language": "default",
          "orchestration_id": "orchestration_0fuy7ah8kqtmvd3jcp2x96ge5n1rwxbq",
          "orchestration_name": "Batch welcome orchestration",
          "platform": "IOS",
          "sent_id": "c7a4b9e2-3d51-4f8a-9c7e-2b5d8fa13c6b",
          "step_id": "MESSAGE__7yLjSgc",
          "step_name": "Welcome In-App"
        }
    ]
    {
      "export_type": "REACHABILITY",
      "from": "2024-01-01T00:00:00Z",
      "to": "now",
      "channels": [
        "push",
        "email",
        "sms"
      ],
      "identifiers": [
        "custom_id",
        "installation_id"
      ]
    }
    [
      {
        "event": {
          "channel": "SMS",
          "id": "6156b060574cb223e8c4ed47c5df1855",
          "timestamp": "2024-01-01T00:00:00Z",
          "reasons": [
            "PHONE_NUMBER_ADDED",
            "SUBSCRIBED_TO_SMS_MARKETING"
          ],
          "has_phone_number": true,
          "sms_marketing": "subscribed"
        },
        "identifiers": {
          "profile_id": "profile_063kxgw384nn7k3wxgsa0xfbd0pgmd9v",
          "custom_id": "User1",
          "installation_id": "5420388A-D2EF-4397-AC9A-999231DA50D5"
        }
      },
      {
        "event": {
          "channel": "EMAIL",
          "id": "6156b060574cb223e8c4ed47c5df1855",
          "timestamp": "2024-01-01T00:00:00Z",
          "reasons": [
            "SUBSCRIBED_TO_EMAIL_MARKETING"
          ],
          "has_email_address": true,
          "email_marketing": "subscribed"
        },
        "identifiers": {
          "profile_id": "profile_f8e9w2vnfdpg1pcqwp0cjkpjd3a3pfgt",
          "custom_id": "User2",
          "installation_id": "643B366B-A643-415B-9E60-3E525A11EF88"
        }
      },
      {
        "event": {
          "channel": "PUSH",
          "id": "6156b060574cb223e8c4ed47c5df1856",
          "timestamp": "2024-01-01T00:00:00Z",
          "reasons": [
            "SUBSCRIBED_TO_PUSH"
          ],
          "is_optin": true,
          "platform": "iOS"
        },
        "identifiers": {
          "profile_id": "profile_063kxgw384nn7k3wxgsa0xfbd0pgmd9v",
          "installation_id": "828A7D76-3D5E-49DC-A863-2465070184C9"
        }
      }
    ]
    {
        "id": "export_nvctr8tgdjf7bppacxxt2aeemnjehfmw"
    }
    Authorizations
    AuthorizationstringRequired

    API Key Authentication

    Authentication is required in order to interact with Batch's APIs.

    Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.

    Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.

    How to authenticate

    In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.

    Header parameters
    X-Batch-ProjectstringRequired

    The unique project key, identifying a project on the Batch platform

    Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
    Body
    anyOptional
    or
    or
    Responses
    202

    If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and a request id. Once you get your request id, you can use it to check the export request status with the export view API endpoint.

    application/json
    400

    The request is malformed

    application/json
    401

    The Rest API Key is not valid for this project

    application/json
    429

    Too Many Requests

    application/json
    500

    Unexpected error

    application/json
    503

    Batch's services are under maintenance. Please try again later

    application/json
    post
    /profiles/export
    Event Reasons

    Parameters

    Parameters list

    Basic parameters

    Id
    POST /2.8/profiles/export HTTP/1.1
    Host: api.batch.com
    Authorization: Bearer YOUR_SECRET_TOKEN
    X-Batch-Project: text
    Content-Type: application/json
    Accept: */*
    Content-Length: 183
    
    {
      "export_type": "ATTRIBUTES",
      "attributes": [
        "$email_address",
        "$language",
        "firstname",
        "is_premium"
      ],
      "identifiers": [
        "custom_id",
        "installation_ids"
      ],
      "filter": {
        "segment": "MY-SEGMENT-CODE"
      }
    }
      
    {
      "push_subscriptions":  [
        {
          "installation_id": "0105958C-3A45-4945-B6EE-0A55F682BA55",
          "is_subscribed": true,
          "platform": "IOS"
        }
      ]
    }
    {
      "id": "export_063bc4w4x8e363yem6wfnxc5c13c0n46"
    }
    Description

    name

    String - Min. 3 chars - Required Readable name of the campaign. E.g.{"name":"My Engagement Campaign"}

    live

    Boolean - Required Value that sets the campaign to live. A false value will save the campaign as a draft but not activate it E.g.{"live":true}

    labels

    Array of Strings - Optional - Max. 3 labels An array containing the label codes you want to attach to your campaign. You can use labels to filter the list of campaigns that appears on Batch's dashboard and manage global capping: make sure that you fill the "CODE" field when setting them up. E.g.{"labels":["label1","label2"]}

    Message options

    Id
    Description

    priority

    String - Optional Defines the priority of your message on iOS (APNS) and Android (FCM) . Default value on iOS and Android is high. Acceptable values include: normal or high . On Android, use the high priority if you have a messaging/voip app and if you notice delivery issues due to native (Doze) or constructor related (Samsung Smart Manager, etc) energy saving features. High priority Android notifications can drain your user's battery faster since they 'wake up' the device and open a network connection. Switch to Normal priority if your notifications are not time-sensitive. Note: On iOS, if you set 'push_type' to 'background', this value is ignored and set to 'normal'. E.g.{"priority":"normal"}

    time_to_live

    Integer - Optional Android/Web only. Time, in seconds, after which the notification will be considered as invalid and should not be delivered after attempting to send it at least once, in any case. There is no default value: ommitting this parameter will use default behaviours of the underlying services, which is often to store notifications for a while. A time_to_live of zero results in attempting to deliver the notification once, and will discard it if the device was offline. The value must be greater than 0. Maximum: 28 days. E.g.{"time_to_live":3600}

    gcm_collapse_key

    Object - Optional - Android only Defines how notifications are managed when an offline device goes online (enabled by default) . If enabled, the device will only show the most recent notification. If disabled, it will show all the notifications received when the device was offline. You should disable the collapse key if all your notifications matter (E.g. messages, etc) . You can use up to 3 different collapse keys if you want users to get only one notification of each kind when coming online (E.g. marketing messages, alert, etc) . E.g.{"enabled":true,"key":"default"}

    push_type

    String - Optional - Android/iOS. Default: 'alert' Defines whether notifications should show an alert or be silent to trigger a background action. Acceptable values are alert and background . Setting this to 'background' will disable the messages and media keys: you will need to remove them from your call. iOS 13 will ignore silent notifications that don't define a background push_type, even though their custom payload defines a silent push. On iOS, {"aps":{"content-available":1}} will automatically be appended to the final payload to wake up the app in the background and the priority will be forced to `normal`. E.g.{"push_type":"alert"}

    Timing and delivery

    There are two timezone parameters to choose from: local_push_time and push_time. One of the two timezone parameters must be included.

    Id
    Description

    push_time

    String - Required - Conflicts with local_push_time Time that Batch servers will start sending push notifications GMT (UTC+0000). Format is yyyy-MM-ddTHH:mm:ss or now to activate and send the campaign immediately. E.g.{"push_time":"2015-12-01T14:25:00"}

    local_push_time

    String - Required - Conflicts with push_time A value that defines the campaign send time in terms of the user's device. Batch servers will send push notifications at the selected time for each time zone. The campaign will take 24 hours to complete if users exist in all time zones (only for the Live API key). Format is yyyy-MM-ddTHH:mm:ss E.g.{"local_push_time":"2015-12-01T14:25:00"}

    recurrence

    Object - Optional An object containing parameters to define the recurrency of the campaign.

    capping

    Integer - Optional The maximum number of time a given user can receive the campaign E.g.{"capping":1}

    User targeting

    Id
    Description

    targeting

    Object - Optional An object containing the targeting property of the campaign. If omitted, all users will be targeted.

    Message editions

    Id
    Description

    messages

    Array of Objects - Required, disallowed when push_type is 'background' An object containing the messages to be delivered for each device language targeted in the targeting object. for message localization rules and valid language codes. The title and body of your notification can contain emojis. E.g.[{"language":"en","body":"Today's challenge starts in 5 minutes!"},{"language":"fr","body":"Le défi du jour commence dans 5 minutes !"}]

    media

    Object - Optional - Disallowed when push_type is 'background' An object containing an icon, a picture, an audio or a video file's URL. E.g.{"media":{"icon":"http://mydomain.com/icon.png","picture":"http://mydomain.com/pic.png"}}

    deeplink

    String - Max. 255 chars - Optional, conflicts with 'landing' - A URL that points to a specific part of your app (i.e. The news you mention in your notification, etc). The deeplink URL is usually based on a URL scheme that you specify within your app, but can be a relative one if you decide to read it manually. If you decide to use an external URL in your campaign, Batch won't show the open rate. Deeplinks can also be set on each of the campaign.

    custom_payload

    String - must be valid JSON - Optional (only available on paid plans) - A JSON string that can contain additional parameters that your application can handle when receiving push notifications if configured to do so. Some keys cannot be overriden and will be dropped. This includes com.batch on all platforms, but Android comes with . Format is {\"x\":\"y\"} .

    Landing message

    On iOS and Android, you have the ability to add a landing message to your push campaign. This will display a landing view using the theme and content of your choosing, allowing you to have complex interactions following a push notification.

    The landing message is defined under the landing key at the root of the payload and the following fields are allowed. landing conflicts with deeplink.

    Id
    Description

    theme

    String - Required The code of the theme to use for your landing view E.g.{"theme":"dark_base_theme"}

    image

    String - Optional - The url of the image to use if the theme contains one E.g.{"image":"https://d1v3v59tzaau1a.cloudfront.net/medias/img/landing-samples/fly.15569dd6.jpg"}

    tracking_id

    String - Optional A tracking ID that you will receive in your application if set E.g.{"tracking_id":"OPEA20161005"}

    contents

    Array of Objects - Required The contents of the landing message. Per language messages can be defined. for message localization rules and valid language codes.

    Note If your theme contains the close button, the actions array is not strictly required.

    Each action in the landing message must be defined as follows.

    Id
    Description

    action

    String - Required The action name. Must match with the actions you register in your mobile application. Not strictly required, if null the close action will be used E.g.{"action":"show_article"}

    label

    String - Required The label of the call to action E.g.{"label":"Show"}

    args

    Object - Optional An object containing arbitrary data that will be passed to your action as is E.g.{"args":{"id":4,"category":"sports"}}

    Important note: You will find here a list of all the built-in actions you can use in your Mobile Landing to dismiss the In-App message, use a deeplink, and more : iOS / Android.

    Here is a valid example:

    The query object

    For advanced usage, you can pass a query object to the targeting. This is a homemade syntax, inspired by MongoDB. This feature is available on paid plans for native and custom attributes.

    Native attributes

    Native attributes allow you to target users based on their OS and app version, their device type or the number of days since they installed your app.

    Native attributes must be added in query, as a targeting property.

    Id
    Description

    b.os_version

    String - The Android or iOS version.The expected format is X.Y.Z. The OS version cannot contain any letter. E.g.{"b.os_version":"5.1.1"}

    b.app_version

    String - Your app version. The expected format is X.Y.Z. E.g.{"b.app_version":"2.A.3"}

    b.device_type

    String - The device type / model. The full list of Apple model names is and a list of all the Android devices supported by the Play Store is . Make sure you choose a value in the model column. E.g.{"b.device_type":"iPhone8,1"}

    b.carrier_code

    Integer - Your user's carrier. The code provided by Batch is a combination of the Mobile country code (MCC) and the Mobile network code (MNC) . The full list of MCC and MNC codes is . E.g.{"b.carrier_code":20815}

    age(b.install_date)

    Duration - Number of days elapsed since the install (install: the first time Batch SDK sees the user) . The days are counted in sections of 24 hours from the hour of install. E.g.{"age(b.install_date)":1}

    age(b.last_visit_date)

    Duration - Number of days elapsed since your users' last session. The days are counted in sections of 24 hours from the last session. E.g.{"age(b.install_date)":1}

    By default, a Duration object is an Integer that represents a number of days. This object can be in any other time unit if it is given a String with the value and the unit. For instance "12h" represents a number of hours. E.g.{"age(b.last_push_date)": “12h”}

    Instead of age(), you can also use date() on date attributes. This function will return a UTC timestamp Integer.

    RECOMMENDED: Users coming from an older version of your app and upgrading to a version with Batch's SDK (after a first release or a token import) are considered as new installs. If you are planning to use this attribute to send 1-3-7 days post-install notifications, we recommend that you wait at least 7 days to make sure you only target your new users.

    Custom user data

    You can send custom user data from your app (iOS / Android) or using the Custom Data API.

    Attributes

    Custom attributes are prefixed with c. or u. if they are sent from the Custom Data API, and are simple key/value data. You can use them to collect a:

    • String

    • Number / Decimal

    • Boolean

    • Date

    Tags collections

    Tags are prefixed with t. or ut. if they are sent from the Custom Data API, and are sets of tags.

    Events

    Events are prefixed with e. and have a key, an occurence date, an optional label, and an optional data object.

    Recommended Take a look at this guide to know more on custom data and learn how to tag your app.

    Operators

    • $eq Equal to. This is the default and thus can be ommited.

    • $lt Lower than <

    • $lte Lower or equal than <=

    • $gt Greater than >

    • $gte Greater or equal than >

    • $contains Checks if the tag collection has one of the requested tag

    • $containsAll Checks if the tag collection has all of the requested tag

    Basic examples

    Send a push to all users who live in Paris :

    As explained above, $eq is the default so we can ommit it:

    All users with app version 1.0.1

    Users who installed your app 1 day ago and use an iPhone 6.

    When you need multiple conditions, the first level of your query needs to be an $and, with an array of conditions.

    Functions and advanced example

    Date attribute needs a function to be queried; that's why we showed you age(b.install_date) before.

    We plan to introduce more functions to our API to enable events querying in the upcoming weeks.

    From now on, we will only show the query. Just remember it goes in targeting.query.

    Users intersted by Rugby or Football, who installed in the last 10 days, and subscribed to your paid offer.

    Users who installed your app since at least 10 days, living in Paris, at least Android 5.0, using the version 3.1.1 of your app, and subscribed to both France & Sport push notifications

    Imported users: Push tokens stored in the "imported" segment (e.g. users who haven't updated to a version of your app containing Batch SDK), can only be segmented based on data provided in the initial import file.

    A/B Testing

    A/B tested marketing campaigns work a little bit differently than standard ones.

    Messages

    You will need to change what you put in the messages key. It should become an object, rather than an array.

    In that object, you need to have have two keys: "a" and "b". You've guessed it, these are your A and B messages. Their content works exactly like messages does for standard campaigns: they're an array of messages objects, with all of your translations.

    Here's a quick example of a A/B tested campaign, implying you still have all the other keys:

    Landing messages

    Same as standard messages, you can A/B test your landing messages. To do that, you simply need to define two keys a and b under the landing key. Each key must contain a valid landing message object, as described above.

    Note Custom Payloads are not A/B testable. Also, A/B Testing is only available starting from the Developer plan.

    cURL example

    Here is an example of a valid cURL CLI request syntax:

    where payload.json:

    The above example will start a recurring campaign on June 1, 2015 at 14:00 (2PM), sending to users based on their device time.

    • It is set as "live": true so will begin at the designated time, versus resting as a draft requiring further action before sending.

    • The optional targeting object has been included to specify the device language, region, and targeted segments. If this object were not included, all users would be targeted. In this case, we used the native attribute age(b.install_date) to target users who installed the app one day ago.

    • Within the messages object each targeted language has been given a message. It's worth noting two things here:

      • title is optional but recommended.

      • You must have a message object for the default language of your app, as set within the Batch dashboard.

    • This campaign uses the recurrence optional object to have the campaign repeat every day at the originally defined time of 14:00 until June 6, 2015 at 00:00.

    • The custom_payload here implies that the app being pushed to can handle a dictionary string of "tag" with a value of "wake up push" and "landing_screen" with "greeting". These are not required but can be added if desired.

    {
      "name": "Airport Information",
      "live": false,
      "push_time": "now",
      "messages": [
        {
        "language": "fr",
        "title": "Bienvenue à l'aéroport Charles de Gaulle",
        "body": "Boutiques, restaurants, zones de relaxation, correspondances vers Paris... Retrouvez toutes les informations utiles !"
      },
      {
        "language": "en",
        "title": "Welcome to Charles de Gaulle Airport!",
        "body": "Shops, restaurants, relaxation areas, transfers to Paris city center\u2026 See our practical information!"
      }],
      "landing": {
        "theme": "MODAL-WITH-IMAGE",
        "image": "https://batch-flights.com/img/airport.jpg",
        "tracking_id": "welcome message",
        "contents": [
          {
          "language": "en",
          "header": "Welcome",
          "title": "Find your way in Charles de Gaulle airport",
          "body": "Shops, transfers, restaurants: Everything you need to know about Paris' airport.",
          "image_description": "Airport",
          "actions": [{
            "action": "batch.deeplink",
            "label": "Know More",
            "args": {
              "l": "https://batch-flights.com/en/travelguide"
            }
          }, {
            "action": "batch.dismiss",
            "label": "Later"
          }]
        },
        {
          "language": "fr",
          "header": "Bienvenue",
          "title": "Votre passage à Charles de Gaulle",
          "body": "Retrouvez toutes les informations utiles pour faire votre check-in et attendre votre avion en toute tranquilité.",
          "image_description": "Aéroport",
          "actions": [{
            "action": "batch.deeplink",
            "label": "Consulter le guide",
            "args": {
              "l": "https://batch-flights.com/fr/guidevoyageur"
            }
          }, {
            "action": "batch.dismiss",
            "label": "Plus tard"
          }]
        }]
      }
    }
    {
      "targeting": {
        "query": {
          "c.city": {
            "$eq": "Paris"
          }
        }
      }
    }
    {
      "targeting": {
        "query": {
          "c.city": "Paris"
        }
      }
    }
    {
      "targeting": {
        "query": {
          "b.app_version": {
            "$gte": "1.0.1"
          }
        }
      }
    }
    {
      "targeting": {
        "query": {
          "$and": [
            {
              "age(b.install_date)": 1
            },
            {
              "b.device_type": {
                "$gt": "iPhone7,2"
              }
            }
          ]
        }
      }
    }
    {
      "$and": [
        {
          "t.interest": {
            "$contains": [
              "Rugby",
              "Football"
            ]
          }
        },
        {
          "age(b.install_date)": {
            "$lte": 10
          }
        },
        {
          "c.paidSubscriber": true
        }
      ]
    }
    {
      "$and": [
        {
          "age(b.install_date)": {
            "$gte": 10
          }
        },
        {
          "c.city": "Paris"
        },
        {
          "b.os_version": {
            "$gte": "5.0"
          }
        },
        {
          "b.app_version": "3.1.1"
        },
        {
          "t.push_optin": {
            "$containsAll": [
              "France",
              "Sport"
            ]
          }
        }
      ]
    }
    {
      "messages": {
        "a": [
          {
            "language": "en",
            "title": "Hello!",
            "body": "How is it going?"
          },
          {
            "language": "fr",
            "title": "Salut!",
            "body": "Ça va?"
          }
        ],
        "b": [
          {
            "language": "en",
            "title": "Hey!",
            "body": "How are you?"
          },
          {
            "language": "fr",
            "title": "Coucou!",
            "body": "Tu vas bien?"
          }
        ]
      }
    }
    {
      "landing": {
        "a": {
          "theme": "dark-theme",
          "tracking_id": "article_1054",
          "contents": [
            {
              "language": "en",
              "header": "Latest news",
              "title": "ESA's Hera Mission files near Mars",
              "body": "The flyby is a significant milestone in Hera’s journey to the binary asteroid system Didymos",
              "actions": [
                {
                  "label": "Show",
                  "action": "show_article",
                  "args": {
                    "id": "1054",
                    "category": "space"
                  }
                }
              ]
            }
          ]
        },
        "b": {
          "theme": "light-theme",
          "tracking_id": "article_1054",
          "contents": [
            {
              "language": "en",
              "header": "Latest news",
              "title": "Hera flies by Mars",
              "body": "The flyby is a significant milestone in Hera’s journey to the binary asteroid system Didymos",
              "actions": [
                {
                  "label": "Show",
                  "action": "show_article",
                  "args": {
                    "id": "1054",
                    "category": "space"
                  }
                }
              ]
            }
          ]
        }
      }
    }
    curl -H "Content-Type: application/json" -H "X-Authorization: BATCH-PUSH-API-TOKEN" -X POST -d
    "@payload.json" "https://api.batch.com/API_VERSION_NUMBER/BATCH_API_KEY/campaigns/create"
    {
      "name": "Test Campaign",
      "local_push_time": "2015-06-01T14:00:00",
      "live": true,
      "targeting": {
        "languages": [
          "it"
        ],
        "regions": [
          "FR",
          "US"
        ],
        "segments": [
          "ONE_TIME",
          "ENGAGED",
          "NEW"
        ],
        "query": {
          "age(b.install_date)": 1
        }
      },
      "messages": [
        {
          "language": "en",
          "title": "Hello!",
          "body": "How is it going?"
        },
        {
          "language": "fr",
          "title": "Salut!",
          "body": "Ça va?"
        }
      ],
      "recurrence": {
        "end_date": "2015-06-30T00:00:00",
        "repeat_unit": "DAILY",
        "repeat_frequency": 1
      },
      "capping": 1,
      "images": {
        "icon": "https://static.batch.com/documentation/logo_batch_192.png"
      },
      "custom_payload": "{\"tag\":\"wake up push\", \"landing_screen\":\"greeting\"}"
    }

    Object - Optional Please see the media object bellow. Messages without media (explicitely set to null or omitted) will inherit the campaign-level one(s), if set. If medias are set both at message-level and campaign-level, the former will take priority over the later.

    b.has_custom_id

    Boolean - True if the user posesses a Custom User ID in our Userbase. E.g.{"b.has_custom_id":true}

    b.transaction_tracked

    Boolean - True if a transaction have been detected from the user. E.g.{"b.transaction_tracked":true}

    b.city_code

    Integer - You user's city detected by Batch using IP geolocation. E.g.{"b.city_code":2988507}

    age(b.last_push_date)

    Duration - Number of days elapsed since the last time you sent your user a push via the dashboard or the Campaigns API. E.g.{"age(b.last_push_date)":2}

    isNear(int latitude, int longitude, string radius, duration time)

    Boolean - True if the last collected user's location is within the given radius around the coordinates during the last X hours. Batch SDK must be allowed to collect geolocation to enable this query. E.g.{"isNear(48.8407578796295,2.351546582031233,5000m,12h)":true}

    b.is_push_optin

    Boolean - True if the install is opt-in to push, meaning that it can receive and display push notifications. E.g.{"b.is_push_optin":false}

    b.os_model

    String - Web push only The OS model as indicated by the browser’s User-Agent. E.g.{"b.os_model":"Windows"}

    b.browser_model

    String - Web push only The browser model as indicated by the browser’s User-Agent. E.g.{"b.browser_model":"Chrome"}

    b.device_category

    String - Web push only Allows you to target users depending on their device category (as indicated by the browser's User-Agent): mobile or desktop. Note: Tablets belong to the mobile category. E.g.{"b.device_category":"mobile"}

    end_date

    String - Time that the recurring campaign will stop sending. Format is yyyy-MM-ddTHH:mm:ss . Optional E.g.{"end_date":"2015-12-03T14:25:00"}

    repeat_unit

    String - Sets the unit of how often the campaign will recur. Acceptable values include: DAILY , WEEKLY , and MONTHLY . E.g.{"repeat_unit":"WEEKLY"}

    repeat_frequency

    Integer - Sets the frequency of campaign repetition. Uses the above repeat_unit parameter to determine units. E.g.{"repeat_frequency":2}

    languages

    Array of Strings - An array containing all device languages to be targeted. All language codes in this array must be contained in the messages object. See here for matching rules and valid language codes. E.g.{"languages":["it","fr"]}

    regions

    Array of Strings - An array containing all the geographical regions codes to be targeted. See here for all valid region codes. E.g.{"regions":["FR","US"]}

    segments

    Array of Strings - An array containing the smart segments to be targeted. Acceptable values include: NEW , ONE_TIME , ENGAGED , DORMANT and IMPORTED . If you ommit this field or pass [], all users, included imported ones, will be targeted. E.g.{"segments":["ENGAGED","NEW"]}

    query

    Object - A mongo inspired query object containing filters & operators, based on native attributes (app version, OS version, etc) and custom users data (attributes, tags & events defined by you in the SDK) .

    custom_audiences

    Array of Strings - An array containing all the custom audiences that should be targeted.

    language

    String - Optional Language of this message. If null or missing, this message will be for the application's default language. E.g.{"language":"en"}

    title

    String - Optional (except for web push) - Supports message personalization Title of the push notification. On iOS , the title will only appear on the Apple Watch or in the notification center (since iOS 8) . E.g.{"title":"Don't give up!"}

    body

    String - Required - Supports message personalization Body text of the push notification. E.g.{"body":"Just keep training, you'll get better."}

    deeplink

    String - Max. 255 chars - Optional - Supports message personalization A URL that points to a specific part of your app (i.e. The news you mention in your notification, etc). The deeplink URL is usually based on a URL scheme that you specify within your app, but can be a relative one if you decide to read it manually. If you decide to use an external URL in your campaign, Batch won't show the open rate. Messages without a deeplink (explicitely set to null or omitted) will inherit the campaign-level one, if set. If deeplinks are set both at message-level and campaign-level, the former will take priority over the later.

    icon

    String - Supports message personalization Android / Windows 10 / Web - URL of the icon file. The file must be a PNG or JPG square image, at least 192px side.

    picture

    String - Supports message personalization iOS 10+ / Android / Windows 10 / Web - URL of the picture file. The file must be a PNG or JPG image with a minimum width and height of 300px. Note: On iOS, make sure your server complies to App Transport Security or that you’ve added the appropriate exceptions in your app and app extension.

    audio

    String - Supports message personalization iOS 10+ - URL of the audio file. The file must be a MP3 file hosted on an HTTPS server that responds to HEAD requests. It must not be larger than 10MB.

    video

    String - Supports message personalization iOS 10+ - URL of the video file. The file must be a MPEG-4 file hosted on an HTTPS server that responds to HEAD requests. It must not be larger than 30MB.

    language

    String - Required The language of the message E.g.{"language":"en"}

    header

    String - Optional - Supports message personalization The text of the header E.g.{"header":"News"}

    title

    String - Optional - Supports message personalization The text of the title E.g.{"title":"Update to the latest version!"}

    body

    String - Optional - Supports message personalization The text of the body E.g.{"body":"Lots of bug and security fixes"}

    image_description

    String - Optional The description of the image used for accessibility purposes E.g.{"image_description":"Boeing 747"}

    actions

    See here
    Supports message personalization
    message
    Supports message personalization
    additional forbidden keys due to FCM limitations
    Supports message personalization
    See here
    available here
    available here
    available here

    media

    Array of objects - Required A list of actions available in the landing message. The action object will be described further below

    Advanced

    Android

    The full list of Android devices supported by the PlayStore is available here.

    Make sure you chose a value in the "model" column (e.g. SM-G900H).

    iPhone

    Identifier
    Description

    iPad

    Identifier
    Description

    iPod

    Identifier
    Description

    Language and country codes

    Here is a non-exhaustive list of language and country codes you can use in your requests. Batch accepts country codes and a subset of .

    Valid language codes

    Code
    Description

    Language matching rules

    Batch also supports more specific languages, like Portuguese Brazil (pt-BR) and Portuguese Portugal (pt-PT) which are sub languages of pt. A campaign using pt in its targeting, will target users with pt-BR or pt-PT language. A campaign using pt-BR will only target users with pt-BR language.

    A device which language is pt is considered as being Portuguese Portugal (pt-PT).

    Push & landing message localization rules

    The Push Campaigns and Transactional Pushes both support localization, meaning that several messages can be defined for different languages. If several message match the user language, the message with the most specific language will be used.

    Ex: a message A is defined for pt-BR, a message B is defined for pt. A user with language pt-BR (which matches pt and pt-BR) will receive the message A because pt-BR is more specific than pt.

    Valid country codes

    Code
    Description

    iPhone5,3 iPhone5,4

    iPhone 5c

    iPhone6,1 iPhone6,2

    iPhone 5s

    iPhone7,2

    iPhone 6

    iPhone7,1

    iPhone 6 Plus

    iPhone8,1

    iPhone 6s

    iPhone8,2

    iPhone 6s Plus

    iPhone8,4

    iPhone SE

    iPhone9,1 iPhone9,3

    iPhone 7

    iPhone9,2 iPhone9,4

    iPhone 7 Plus

    iPhone10,1 iPhone10,4

    iPhone 8

    iPhone10,2 iPhone10,5

    iPhone 8 Plus

    iPhone10,3 iPhone10,6

    iPhone X

    iPhone11,8

    iPhone XR

    iPhone11,2

    iPhone XS

    iPhone11,6 iPhone11,4

    iPhone XS Max

    iPhone12,1

    iPhone 11

    iPhone12,3

    iPhone 11 Pro

    iPhone12,5

    iPhone 11 Pro Max

    iPhone12,8

    iPhone SE 2

    iPhone13,2

    iPhone 12

    iPhone13,1

    iPhone 12 Mini

    iPhone13,3

    iPhone 12 Pro

    iPhone13,4

    iPhone 12 Pro Max

    iPhone14,5

    iPhone 13

    iPhone14,4

    iPhone 13 Mini

    iPhone14,2

    iPhone 13 Pro

    iPhone14,3

    iPhone 13 Pro Max

    iPad7,11 iPad7,12

    iPad (7th gen)

    iPad11,6 iPad11,7

    iPad (8th gen)

    iPad12,1 iPad12,2

    iPad (9th gen)

    iPad4,1 iPad4,2 iPad4,3

    iPad Air (1st gen)

    iPad5,3

    iPad Air (2nd gen)

    iPad11,3 iPad11,4

    iPad Air (3rd gen)

    iPad13,1 iPad13,2

    iPad Air (4th gen)

    iPad6,3 iPad6,4

    iPad Pro 9.7 inch

    iPad7,3 iPad7,4

    iPad Pro 10.5 inch

    iPad8,1 iPad8,2 iPad8,3 iPad8,4

    iPad Pro 11 inch (1st gen)

    iPad8,9 iPad8,10

    iPad Pro 11 inch (2nd gen)

    iPad13,4 iPad13,5 iPad13,6 iPad13,7

    iPad Pro 11 inch (3rd gen)

    iPad6,7 iPad6,8

    iPad Pro 12.9 inch (1st gen)

    iPad7,1 iPad7,2

    iPad Pro 12.9 inch (2nd gen)

    iPad8,5 iPad8,6 iPad8,7 iPad8,8

    iPad Pro 12.9 inch (3rd gen)

    iPad8,11 iPad8,12

    iPad Pro 12.9 inch (4th gen)

    iPad13,8 iPad13,9 iPad13,10 iPad13,11

    iPad Pro 12.9 inch (5th gen)

    iPad2,5 iPad2, 6iPad2,7

    iPad Mini (1st gen)

    iPad4,4 iPad4,5 iPad4,6

    iPad Mini (2nd gen)

    iPad4,7 iPad4,8 iPad4,9

    iPad Mini (3rd gen)

    iPad5,1 iPad5,2

    iPad Mini (4th gen)

    iPad11,1 iPad11,2

    iPad Mini (5th gen)

    iPad14,1 iPad14,2

    iPad Mini (6th gen)

    iPod9,1

    iPod Touch (7th gen)

    cs

    Czech

    da

    Danish

    de

    German

    el

    Greek

    en

    English

    es

    Spanish

    et

    Estonian

    fa

    Persian

    fi

    Finnish

    fr

    French

    he

    Hebrew

    hi

    Hindi

    hr

    Croatian

    hu

    Hungarian

    id

    Indonesian

    it

    Italian

    ja

    Japanese

    ka

    Georgian

    km

    Khmer

    ko

    Korean

    lt

    Lithuanian

    lv

    Latvian

    ms

    Malay

    mk

    Macedonian

    my

    Burmese

    nb

    Bokmål

    nl

    Dutch

    no

    Norwegian

    pl

    Polish

    pt

    Portuguese (All)

    pt-BR

    Portuguese (Brazil)

    pt-PT

    Portuguese (Portugal)

    ro

    Romanian

    ru

    Russian

    sk

    Slovak

    sl

    Slovenian

    sr

    Serbian

    sv

    Swedish

    th

    Thai

    tr

    Turkish

    uk

    Ukrainian

    vi

    Vietnamese

    zh

    Chinese (Simplified)

    AM

    Armenia

    AN

    Netherlands Antilles

    AO

    Angola

    AQ

    Antarctica

    AR

    Argentina

    AS

    Samoa (American)

    AT

    Austria

    AU

    Austria

    AW

    Aruba

    AX

    Aaland Islands

    AZ

    Azerbaijan

    BA

    Bosnia & Herzegovina

    BB

    Barbados

    BD

    Bangladesh

    BE

    Belgium

    BF

    Burkina Faso

    BG

    Bulgaria

    BH

    Bahrain

    BI

    Burundi

    BJ

    Benin

    BL

    St Barthelemy

    BM

    Bermuda

    BN

    Brunei

    BO

    Bolivia

    BR

    Brazil

    BS

    Bahamas

    BT

    Bhutan

    BV

    Bouvet Island

    BW

    Botswana

    BY

    Belarus

    BZ

    Belize

    CA

    Canada

    CC

    Cocos (Keeling) Islands

    CD

    Congo (Dem. Rep.)

    CF

    Central African Rep.

    CG

    Congo (Rep.)

    CH

    Switzerland

    CI

    Cote d'Ivoire

    CK

    Cook Islands

    CL

    Chile

    CM

    Cameroon

    CN

    China

    CO

    Colombia

    CR

    Costa Rica

    CU

    Cuba

    CV

    Cape Verde

    CW

    Curacao

    CX

    Christmas Island

    CY

    Cyprus

    CZ

    Czech Republic

    DE

    Germany

    DJ

    Djibouti

    DK

    Denmark

    DM

    Dominica

    DO

    Dominican Republic

    DZ

    Algeria

    EC

    Ecuador

    EE

    Estonia

    EG

    Egypt

    EH

    Western Sahara

    ER

    Eritrea

    ES

    Spain

    ET

    Ethiopia

    FI

    Finland

    FJ

    Fiji

    FK

    Falkland Islands

    FM

    Micronesia

    FO

    Faroe Islands

    FR

    France

    GA

    Gabon

    GB

    Britain (UK)

    GD

    Grenada

    GE

    Georgia

    GF

    French Guiana

    GG

    Guernsey

    GH

    Ghana

    GI

    Gibraltar

    GL

    Greenland

    GM

    Gambia

    GN

    Guinea

    GP

    Guadeloupe

    GQ

    Equatorial Guinea

    GR

    Greece

    GS

    South Georgia & the South Sandwich Islands

    GT

    Guatemala

    GU

    Guam

    GW

    Guinea-Bissau

    GY

    Guyana

    HK

    Hong Kong

    HM

    Heard Island & McDonald Islands

    HN

    Honduras

    HR

    Croatia

    HT

    Haiti

    HU

    Hungary

    ID

    Indonesia

    IE

    Ireland

    IL

    Israel

    IM

    Isle of Man

    IN

    India

    IO

    British Indian Ocean Territory

    IQ

    Iraq

    IR

    Iran

    IS

    Iceland

    IT

    Italy

    JE

    Jersey

    JM

    Jamaica

    JO

    Jordan

    JP

    Japan

    KE

    Kenya

    KG

    Kyrgyzstan

    KH

    Cambodia

    KI

    Kiribati

    KM

    Comoros

    KN

    St Kitts & Nevis

    KP

    Korea (North)

    KR

    Korea (South)

    KW

    Kuwait

    KY

    Cayman Islands

    KZ

    Kazakhstan

    LA

    Laos

    LB

    Lebanon

    LC

    St Lucia

    LI

    Liechtenstein

    LK

    Sri Lanka

    LR

    Liberia

    LS

    Lesotho

    LT

    Lithuania

    LU

    Luxembourg

    LV

    Latvia

    LY

    Libya

    MA

    Morocco

    MC

    Monaco

    MD

    Moldova

    ME

    Montenegro

    MF

    St Martin (French part)

    MG

    Madagascar

    MH

    Marshall Islands

    MK

    Macedonia

    ML

    Mali

    MM

    Myanmar (Burma)

    MN

    Mongolia

    MO

    Macau

    MP

    Northern Mariana Islands

    MQ

    Martinique

    MR

    Mauritania

    MS

    Montserrat

    MT

    Malta

    MU

    Mauritius

    MV

    Maldives

    MW

    Malawi

    MX

    Mexico

    MY

    Malaysia

    MZ

    Mozambique

    NA

    Namibia

    NC

    New Caledonia

    NE

    Niger

    NF

    Norfolk Island

    NG

    Nigeria

    NI

    Nicaragua

    NL

    Netherlands

    NO

    Norway

    NP

    Nepal

    NR

    Nauru

    NU

    Niue

    NZ

    New Zealand

    OM

    Oman

    PA

    Panama

    PE

    Peru

    PF

    French Polynesia

    PG

    Papua New Guinea

    PH

    Philippines

    PK

    Pakistan

    PL

    Poland

    PM

    St Pierre & Miquelon

    PN

    Pitcairn

    PR

    Puerto Rico

    PS

    Palestine

    PT

    Portugal

    PW

    Palau

    PY

    Paraguay

    QA

    Qatar

    RE

    Reunion

    RO

    Romania

    RS

    Serbia

    RU

    Russia

    RW

    Rwanda

    SA

    Saudi Arabia

    SB

    Solomon Islands

    SC

    Seychelles

    SD

    Sudan

    SE

    Sweden

    SG

    Singapore

    SH

    St Helena

    SI

    Slovenia

    SJ

    Svalbard & Jan Mayen

    SK

    Slovakia

    SL

    Sierra Leone

    SM

    San Marino

    SN

    Senegal

    SO

    Somalia

    SR

    Suriname

    SS

    South Sudan

    ST

    Sao Tome & Principe

    SV

    El Salvador

    SX

    St Maarten (Dutch part)

    SY

    Syria

    SZ

    Swaziland

    TC

    Turks & Caicos Is

    TD

    Chad

    TF

    French Southern & Antarctic Lands

    TG

    Togo

    TH

    Thailand

    TJ

    Tajikistan

    TK

    Tokelau

    TL

    East Timor

    TM

    Turkmenistan

    TN

    Tunisia

    TO

    Tonga

    TR

    Turkey

    TT

    Trinidad & Tobago

    TV

    Tuvalu

    TW

    Taiwan

    TZ

    Tanzania

    UA

    Ukraine

    UG

    Uganda

    UM

    US minor outlying islands

    US

    United States

    UY

    Uruguay

    UZ

    Uzbekistan

    VA

    Vatican City

    VC

    St Vincent

    VE

    Venezuela

    VG

    Virgin Islands (UK)

    VI

    Virgin Islands (US)

    VN

    Vietnam

    VU

    Vanuatu

    WF

    Wallis & Futuna

    WS

    Samoa

    YE

    Yemen

    YT

    Mayotte

    ZA

    South Africa

    ZM

    Zambia

    ZW

    Zimbabwe

    iPhone1,1

    iPhone

    iPhone1,2

    iPhone 3G

    iPhone2,1

    iPhone 3GS

    iPhone3,1 iPhone3,2 iPhone3,3

    iPhone 4

    iPhone4,1

    iPhone 4S

    iPhone5,1 iPhone5,2

    iPhone 5

    iPad1,1

    iPad (1st gen)

    iPad2,1 iPad2,2 iPad2,3 iPad2,4

    iPad (2nd gen)

    iPad3,1 iPad3,2 iPad3,3

    iPad (3rd gen)

    iPad3,4 iPad3,5 iPad3,6

    iPad (4th gen)

    iPad6,11 iPad6,12

    iPad (5th gen)

    iPad7,5 iPad7,6

    iPad (6th gen)

    iPod1,1

    iPod Touch

    iPod2,1

    iPod Touch (2nd gen)

    iPod3,1

    iPod Touch (3rd gen)

    iPod4,1

    iPod Touch (4th gen)

    iPod5,1

    iPod Touch (5th gen)

    iPod7,1

    iPod Touch (6th gen)

    ar

    Arabic

    az

    Azerbaijani

    be

    Belarus

    bg

    Bulgarian

    bs

    Bosnian

    ca

    Catalan

    AD

    Andorra

    AE

    United Arab Emirates

    AF

    Afghanistan

    AG

    Antigua & Barbuda

    AI

    Anguilla

    AL

    Albania

    ISO 3166-1 alpha-2
    BCP 47 language tags