POST - Update

See create to see an introduction about Audience API.

API Description

This API schema is available in the OpenAPI 3.1 format: View it online.

Request structure

Route

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

https://api.batch.com/2.3/audiences/update

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:

{
  "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"
      }
    }
  ]
}

Let's see the parameters in detail.

IdDescription
namestring - Required
Name of the audience.
E.g.{"name":"AUDIENCE_NAME"}
idsArray of Objects - Required
An array of objects describing actions to be applied to the audience.
Supports up to 10,000 elements.
If you need to upload more than 10,000 elements, you can make several calls.

E.g.[{"action":"add","id":"USER_CUSTOM_ID1"}]
actionString - Required
The action to be applied to the audience.
Acceptable values include: add or remove .

E.g.{"action":"add"}
idString - Required
The ID that will be added to or deleted from the audience.
E.g.{"id":"USER_CUSTOM_ID"}
attributesObject - Optional. Only accepted for add action.
An object containing attributes to be attached to the id. They can then be used in message personalization.
following type are supported : String, Number, Float, Date, Url, Array. See the Profile API documentation for more info on attributes
Supports up to 15 elements.

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.

{
  "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.

See the list of potential failures in the specification.

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