Our POST batch/accounts/:account_id/targeting_criteria endpoint allows targeting criteria for multiple line items to be created or deleted with a single request.
Until now, the maximum number of operations in a batch was 100. Today, we are announcing that we have increased this to 1,000.
Twitter Ads API Team
Request details:
- the
Content-Type: application/json header is required
- parameters are sent in the request body
- batch requests fail or succeed as a group
Response details:
- responses for both errors and successes are preserved in the order of the initial request
Usage example:
$ twurl -H ads-api.twitter.com -X POST -A "Content-Type: application/json" -d '[{"operation_type":"Create","params":{"line_item_id":"6f9an","targeting_type":"LOCATION","targeting_value":"5122804691e5fecc"}},{"operation_type":"Delete","params":{"targeting_criterion_id":"al2rua"}}]' "/1/batch/accounts/18ce54d4x5t/targeting_criteria" | jq
{
"data_type": "targeting_criterion",
"data": [
{
"line_item_id": "6f9an",
"name": "San Francisco-Oakland-San Jose CA, US",
"id": "al7vt2",
"location_type": "CITY",
"operator_type": "EQ",
"created_at": "2016-11-11T22:59:50Z",
"targeting_value": "5122804691e5fecc",
"updated_at": "2016-11-11T22:59:50Z",
"deleted": false,
"targeting_type": "LOCATION"
},
{
"line_item_id": "6keuo",
"name": "accounts",
"id": "al2rua",
"operator_type": "EQ",
"created_at": "2016-11-11T17:50:19Z",
"targeting_value": "accounts",
"updated_at": "2016-11-11T22:59:50Z",
"deleted": true,
"targeting_type": "BROAD_KEYWORD"
}
],
"request": [
{
"params": {
"line_item_id": "6f9an",
"targeting_type": "LOCATION",
"targeting_value": "5122804691e5fecc",
"account_id": "18ce54d4x5t"
},
"operation_type": "Create"
},
{
"params": {
"targeting_criterion_id": "al2rua",
"account_id": "18ce54d4x5t"
},
"operation_type": "Delete"
}
]
}
For readability, the parameter array is shown below.
[
{
"operation_type":"Create",
"params":{
"line_item_id":"6f9an",
"targeting_type":"LOCATION",
"targeting_value":"5122804691e5fecc"
}
},
{
"operation_type":"Delete",
"params":{
"targeting_criterion_id":"al2rua"
}
}
]