Audience API

POST accounts/:account_id/tailored_audiences/:tailored_audience_id/users

This endpoint will allow partners to add, update and remove users from a given tailored_audience_id. The endpoint will also accept multiple user identifier types per user as well.

All data being provided in the users field of the request must be hashed using SHA256 and normalized.

Batch Requests

  • The current maximum batch size is 2500 for this endpoint. The batch size is determined by the number of entries in the users field, regardless of the operation_type
  • All parameters are sent in the request body and a Content-Type of application/json is required.
  • Batch requests fail or succeed together as a group and all API responses for both error and success preserve the item order of the initial request.

Batch Responses

The response returned by the Ads API contains two fields, a success_count and a total_count. These values must always be equal, and they are a count of the number of records in the request that have been processed by the backend. A situation where the number of records sent in the request body is not equal the success_count and total_count should be treated as an error condition, requiring a retry.

Batch Errors

  • Request-level errors (eg. max batch size exceeded) are shown in the response under the errors object.
  • Item-level errors (eg. missing required parameters) are show in the response under the operation_errors object.
  • The index of the error in the operation_errors refers to the index in the input item, with the corresponding error message

Resource URL

https://ads-api.twitter.com/4/accounts/:account_id/tailored_audiences/:tailored_audience_id/users

Parameters

Name Description
operation_type
required

The per users group operation type being performed.

Type: enum

Possible values: Update, Delete

params
required

A JSON object containing the users array, the effective_at and expires_at timestamps.

Type: JSON

users
required

An array of JSON objects containing all params for an individual user.

Type: JSON

effective_at
optional

The UTC time at which the tailored audience association(s) should take effect. Expressed in ISO 8601. Defaults to the current date and time.

Type: string

Example: 2017-07-05T07:00:00Z

expires_at
optional

The UTC time at which the tailored audience association(s) should expire. The specified time must be later than the value of effective_at. Expressed in ISO 8601. Defaults to your configured default expiration period (typically 30 days or 720 hours from effective_at).

Type: string

Example: 2017-07-05T07:00:00Z

Given the mutil-key approach to the users object, each element of this object is documented below:

Name Description
email
optional

Email address(es) for the user.

Type: Array[String]

phone
optional

Phone number(s) for the user.

Type: Array[String]

device_id
optional

IDFA/AdID/Android ID

Type: Array[String]

twitter_handle
optional

The @handle(s) belonging to the user

Type: Array[String]

twitter_id
optional

The Twitter ID belonging to the user

Type: Array[String]

Example Request

POST https://ads-api.twitter.com/4/accounts/18ce54d4x5t/tailored_audiences/1nmth/users

[
  {
    "operation_type": "Update",
    "params": {
      "effective_at": "2018-05-15T00:00:00Z",
      "expires_at": "2019-01-01T07:00:00Z",
      "users": [
        {
          "email": [
            "abc@twitter.com"
          ],
          "phone_number": [
            "9255551212",
            "4255551212"
          ]
        },
        {
          "email": [
            "edf@twitter.com"
          ],
          "phone_number": [
            "9255551212",
            "4255551212"
          ]
        }
      ]
    }
  },
  {
    "operation_type": "Delete",
    "params": {
      "effective_at": "2018-05-15T00:00:00Z",
      "expires_at": "2019-01-01T07:00:00Z",
      "users": [
        {
          "device_id": [
            "123456"
          ],
          "email": [
            "abc@twitter.com"
          ],
          "handle": [
            "123333"
          ],
          "phone_number": [
            "9255551212",
            "4255551212"
          ],
          "twitter_id": [
            "12346"
          ]
        },
        {
          "email": [
            "edf@twitter.com"
          ],
          "phone_number": [
            "9255551212",
            "4255551212"
          ]
        }
      ]
    }
  }
]

Example Response

{
  "request": {
    "params": {
      "account_id": "18ce54d4x5t",
      "tailored_audience_id": "1nmth"
    }
  },
  "data": {
    "success_count": 4,
    "total_count": 4
  }
}