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:

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"

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

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

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:

{
  "type": "install_ids",
  "description": "The audience description"
}

Let's see the parameters in detail.

IdDescription
typestring - Required
Type of the audience.
Only install_ids type is accepted for the moment.

E.g.{"type":"install_ids"}
descriptionstring - Optional
Description of the audience.
E.g.{"description":"The audience description"}

Responses

Success

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

{ "indexing_token": "a0082dc6860938a26280bd3ba927303b" }

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.

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