Campaign Management
Line Items¶
GET accounts/:account_id/line_items¶
Retrieve details for some or all line items associated with the current account.
Resource URL¶
https://ads-api.twitter.com/4/accounts/:account_id/line_items
Parameters¶
Name | Description |
---|---|
account_id
required
|
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests excluding GET accounts. The specified account must be associated with the authenticated user. Type: string Example: |
campaign_ids
optional
|
Scope the response to just the line items under specific campaigns by specifying a comma-separated list of identifiers. Up to 200 IDs may be provided. Type: string Example: |
count
optional
|
Specifies the number of records to try and retrieve per distinct request. Type: int Default:
200 Min, Max:
1 , 1000 |
cursor
optional
|
Specifies a cursor to get the next page of results. See Pagination for more information. Type: string Example: |
draft_only
optional
|
Scope the response to just draft line items. Type: boolean Default:
false Possible values:
true , false |
funding_instrument_ids
optional
|
Scope the response to just the line items under specific funding instruments by specifying a comma-separated list of identifiers. Up to 200 IDs may be provided. Type: string Example: |
line_item_ids
optional
|
Scope the response to just the desired line items by specifying a comma-separated list of identifiers. Up to 200 IDs may be provided. Type: string Example: |
sort_by
optional
|
Sorts by supported attribute in ascending or descending order. See Sorting for more information. Type: string Example: |
with_deleted
optional
|
Include deleted results in your request. Type: boolean Default:
false Possible values:
true , false |
with_total_count
optional
|
Include the Note: This parameter will be ignored if Note: Requests which include Type: boolean Default:
false Possible values:
true , false |
Example Request¶
GET https://ads-api.twitter.com/4/accounts/18ce54d4x5t/line_items?line_item_ids=8v7jo
Example Response¶
{
"request": {
"params": {
"line_item_ids": [
"8v7jo"
],
"account_id": "18ce54d4x5t"
}
},
"next_cursor": null,
"data": [
{
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [
"ALL_ON_TWITTER"
],
"start_time": null,
"bid_amount_local_micro": 100000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": null,
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "8v7jo",
"entity_status": "ACTIVE",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-05-27T08:04:00Z",
"tracking_tags": [],
"updated_at": "2017-05-27T08:06:25Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "8gdx6",
"creative_source": "MANUAL",
"deleted": false
}
]
}
GET accounts/:account_id/line_items/:line_item_id¶
Retrieve a specific line item associated with the current account.
Resource URL¶
https://ads-api.twitter.com/4/accounts/:account_id/line_items/:line_item_id
Parameters¶
Name | Description |
---|---|
account_id
required
|
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests excluding GET accounts. The specified account must be associated with the authenticated user. Type: string Example: |
line_item_id
required
|
A reference to the line item you are operating with in the request. Type: string Example: |
with_deleted
optional
|
Include deleted results in your request. Type: boolean Default:
false Possible values:
true , false |
Example Request¶
GET https://ads-api.twitter.com/4/accounts/18ce54d4x5t/line_items/8v7jo
Example Response¶
{
"request": {
"params": {
"line_item_id": "8v7jo",
"account_id": "18ce54d4x5t"
}
},
"data": {
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [
"ALL_ON_TWITTER"
],
"start_time": null,
"bid_amount_local_micro": 100000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": null,
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "8v7jo",
"entity_status": "ACTIVE",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-05-27T08:04:00Z",
"tracking_tags": [],
"updated_at": "2017-05-27T08:06:25Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "8gdx6",
"creative_source": "MANUAL",
"deleted": false
}
}
POST accounts/:account_id/line_items¶
Create a line item associated with the specified campaign belonging to the current account.
All line items within a campaign must be of the same product_type
and
objective
.
When using the PROMOTED_ACCOUNT
product type, associating a Tweet with
the line_item
will add timeline placements on mobile in addition to the
standard PROMOTED_ACCOUNT
placement.
Note: There is a limit of 100 line items per campaign and 8,000 active line items across all campaigns.
Resource URL¶
https://ads-api.twitter.com/4/accounts/:account_id/line_items
Parameters¶
Name | Description |
---|---|
account_id
required
|
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests excluding GET accounts. The specified account must be associated with the authenticated user. Type: string Example: |
campaign_id
required
|
The identifier for the campaign to create the line item under. Type: string Example: |
objective
required
|
The campaign objective for this line item. Type: enum Possible values: |
placements
required
|
The placement location(s) for this line item to display in. Specify a comma-separated list of placement values. Type: enum Possible values: |
product_type
required
|
The type of promoted product that this line item will contain. Type: enum Possible values: |
advertiser_domain
sometimes required
|
The website domain for this advertiser, without the protocol specification. Note: Required when the line item’s placement is set to
Type: string Example: |
bid_amount_local_micro
sometimes required
|
The bid amount to be associated with this line item. The currency associated with the specified funding instrument will be used. For USD, $5.50 is represented as 5500000. Note: Required if Note: Only values greater than zero are accepted. Type: long Example: |
categories
sometimes required
|
The relevant IAB categories for this advertiser. See GET iab_categories. Note: Required when the line item’s placement is set to
Type: string Example: |
advertiser_user_id
optional
|
The Twitter user identifier for the handle promoting a Type: long Example: |
automatically_select_bid
optional
|
Automatically optimize bidding based on daily budget and campaign flight dates. If set to Note: Cannot be set in the same request as Type: boolean Possible values: |
bid_type
optional
|
The bidding mechanism.
Note: If set to Note: Cannot be set in the same request as Note: Default based on objective. Type: enum Possible values: |
bid_unit
optional
|
The bid unit for this line item. This setting is available for line items using
the Note: For other objectives, the bid unit is automatically set. Type: enum Possible values: |
charge_by
optional
|
The unit to charge this line item by. This setting is only available for line
items using the Note: For other objectives, Type: enum Possible values: |
end_time
optional
|
The time, expressed in ISO 8601, that the line item will stop serving. Type: string Example: |
entity_status
optional
|
The line item status. Type: enum Default:
ACTIVE Possible values:
ACTIVE , DRAFT , PAUSED |
include_sentiment
optional
|
Allows the line item to be targeted to Tweets with positive or with both positive and negative sentiment. Note: Only valid for the Type: enum Default:
POSITIVE_ONLY Possible values:
ALL , POSITIVE_ONLY |
lookalike_expansion
optional
|
Used to expand the reach of campaigns by targeting users similar to those already targeted. Use of this parameter is restricted to whitelisted advertisers only. Note: By default, no expansion will be applied. Type: enum Possible values: |
name
optional
|
The name for the line item. Type: string Example: |
optimization
optional
|
The optimization setting to use with this line item. Type: enum Default:
DEFAULT Possible values:
DEFAULT , ENGAGEMENTS , WEBSITE_CONVERSIONS |
primary_web_event_tag
optional
|
The identifier of the primary web event tag. Allows more accurate tracking of engagements for the campaign pertaining to this line item. Type: string Example: |
start_time
optional
|
The time, expressed in ISO 8601, that the line item will begin serving. Type: string Example: |
total_budget_amount_local_micro
optional
|
The total budget amount to be allocated to the line item. The currency associated with the specified funding instrument will be used. For USD, $37.50 is represented as 37500000. Type: long Example: |
tracking_tags
optional
|
The tracking partner enum and the tracking tag url provided by the tracking partner, separated by a dash. Type: string Example: |
Example Request¶
POST https://ads-api.twitter.com/4/accounts/18ce54d4x5t/line_items?campaign_id=8slvg&objective=TWEET_ENGAGEMENTS&product_type=PROMOTED_TWEETS&placements=ALL_ON_TWITTER&bid_amount_local_micro=3210000&entity_status=PAUSED
Example Response¶
{
"data": {
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [
"ALL_ON_TWITTER"
],
"start_time": null,
"bid_amount_local_micro": 3210000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": null,
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "95lya",
"entity_status": "PAUSED",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-06-23T01:59:22Z",
"tracking_tags": [],
"updated_at": "2017-06-23T01:59:22Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "8slvg",
"creative_source": "MANUAL",
"deleted": false
},
"request": {
"params": {
"placements": [
"ALL_ON_TWITTER"
],
"bid_amount_local_micro": 3210000,
"product_type": "PROMOTED_TWEETS",
"objective": "TWEET_ENGAGEMENTS",
"entity_status": "PAUSED",
"account_id": "18ce54d4x5t",
"campaign_id": "8slvg"
}
}
}
POST batch/accounts/:account_id/line_items¶
Allows the batch creation of new line items with a single request.
Batch Requests
- The current maximum batch size is 20.
- All parameters are sent in the request body and a
Content-Type
ofapplication/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
Batch API responses return an ordered collection of items. Otherwise, they are identical in structure to their corresponding single-item endpoints.
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 line item parameter) are shown in the
response under the
operation_errors
object.
Resource URL¶
https://ads-api.twitter.com/4/batch/accounts/:account_id/line_items
Parameters¶
Name | Description |
---|---|
operation_type
required
|
The per item operation type being performed. Type: enum Possible values: |
params
required
|
A JSON object containing all the parameters for the line item objects. For a list of required and optional line item parameters, see here. |
Example Request¶
POST 'Content-Type: application/json' https://ads-api.twitter.com/4/batch/accounts/18ce54d4x5t/line_items
[
{
"operation_type":"Create",
"params":{
"campaign_id":"8yn7m",
"objective":"TWEET_ENGAGEMENTS",
"product_type":"PROMOTED_TWEETS",
"placements":"ALL_ON_TWITTER",
"bid_amount_local_micro":3210000,
"entity_status":"PAUSED"
}
}
]
Example Response¶
{
"data": [
{
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [
"ALL_ON_TWITTER"
],
"start_time": null,
"bid_amount_local_micro": 3210000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": null,
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "9cqi0",
"entity_status": "PAUSED",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-07-07T17:42:20Z",
"tracking_tags": [],
"updated_at": "2017-07-07T17:42:20Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "8yn7m",
"creative_source": "MANUAL",
"deleted": false
}
],
"request": [
{
"params": {
"placements": [
"ALL_ON_TWITTER"
],
"bid_amount_local_micro": 3210000,
"product_type": "PROMOTED_TWEETS",
"objective": "TWEET_ENGAGEMENTS",
"entity_status": "PAUSED",
"account_id": "18ce54d4x5t",
"campaign_id": "8yn7m"
},
"operation_type": "Create"
}
]
}
PUT accounts/:account_id/line_items/:line_item_id¶
Update the specified line item associated with the current account.
Resource URL¶
https://ads-api.twitter.com/4/accounts/:account_id/line_items/:line_item_id
Parameters¶
Name | Description |
---|---|
account_id
required
|
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests excluding GET accounts. The specified account must be associated with the authenticated user. Type: string Example: |
line_item_id
required
|
A reference to the line item you are operating with in the request. Type: string Example: |
advertiser_domain
optional
|
The website domain for this advertiser, without the protocol specification. Note: Required when the line item’s placement is set to
Type: string Example: |
advertiser_user_id
optional
|
The Twitter user identifier for the handle promoting a Type: long Example: |
automatically_select_bid
optional
|
Automatically optimize bidding based on daily budget and campaign flight dates. If set to Note: Cannot be set in the same request as Type: boolean Possible values: |
bid_amount_local_micro
optional
|
The bid amount to be associated with this line item. The currency associated with the specified funding instrument will be used. For USD, $5.50 is represented as 5500000. Note: Required if Note: Only values greater than zero are accepted. Type: long Example: |
bid_type
optional
|
The bidding mechanism.
Note: If set to Note: Cannot be set in the same request as Note: Default based on objective. Type: enum Possible values: |
categories
optional
|
The relevant IAB categories for this advertiser. See GET iab_categories. Note: Required when the line item’s placement is set to
Type: string Example: |
end_time
optional
|
The time, expressed in ISO 8601, that the line item will stop serving. Type: string Example: |
entity_status
optional
|
The line item status. Type: enum Possible values: |
include_sentiment
optional
|
Allows the line item to be targeted to Tweets with positive or with both positive and negative sentiment. Note: Only valid for the Type: enum Possible values: |
lookalike_expansion
optional
|
Used to expand the reach of campaigns by targeting users similar to those already targeted. Use of this parameter is restricted to whitelisted advertisers only. Type: enum Possible values: |
name
optional
|
The name for the line item. Type: string Example: |
optimization
optional
|
The optimization setting to use with this line item. Type: enum Possible values: |
start_time
optional
|
The time, expressed in ISO 8601, that the line item will begin serving. Type: string Example: |
total_budget_amount_local_micro
optional
|
The total budget amount to be allocated to the line item. The currency associated with the specified funding instrument will be used. For USD, $37.50 is represented as 37500000. Type: long Example: |
tracking_tags
optional
|
The tracking partner enum and the tracking tag url provided by the tracking partner, separated by a dash. Type: string Example: |
Example Request¶
PUT https://ads-api.twitter.com/4/accounts/18ce54d4x5t/line_items/8v7jo?bid_amount_local_micro=140000
Example Response¶
{
"data": {
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [
"ALL_ON_TWITTER"
],
"start_time": null,
"bid_amount_local_micro": 140000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": null,
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "8v7jo",
"entity_status": "ACTIVE",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-05-27T08:04:00Z",
"tracking_tags": [],
"updated_at": "2017-07-04T22:01:28Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "8gdx6",
"creative_source": "MANUAL",
"deleted": false
},
"request": {
"params": {
"line_item_id": "8v7jo",
"bid_amount_local_micro": 140000,
"account_id": "18ce54d4x5t"
}
}
}
DELETE accounts/:account_id/line_items/:line_item_id¶
Delete the specified line item belonging to the current account.
Note: Deleting a line item is not reversible and subsequent attempts to delete the resource will return HTTP 404.
Resource URL¶
https://ads-api.twitter.com/4/accounts/:account_id/line_items/:line_item_id
Parameters¶
Name | Description |
---|---|
account_id
required
|
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests excluding GET accounts. The specified account must be associated with the authenticated user. Type: string Example: |
line_item_id
required
|
A reference to the line item you are operating with in the request. Type: string Exampple: |
Example Request¶
DELETE https://ads-api.twitter.com/4/accounts/18ce54d4x5t/line_items/9f2ix
Example Response¶
{
"data": {
"bid_type": "MAX",
"advertiser_user_id": 756201191646691328,
"name": "Untitled",
"placements": [],
"start_time": null,
"bid_amount_local_micro": 100000,
"automatically_select_bid": false,
"advertiser_domain": null,
"target_cpa_local_micro": null,
"primary_web_event_tag": null,
"charge_by": "ENGAGEMENT",
"product_type": "PROMOTED_TWEETS",
"end_time": "2017-07-21T00:00:00Z",
"bid_unit": "ENGAGEMENT",
"total_budget_amount_local_micro": null,
"objective": "TWEET_ENGAGEMENTS",
"id": "9f2ix",
"entity_status": "ACTIVE",
"account_id": "18ce54d4x5t",
"optimization": "DEFAULT",
"categories": [],
"currency": "USD",
"created_at": "2017-07-14T00:01:50Z",
"tracking_tags": [],
"updated_at": "2017-08-09T07:41:08Z",
"include_sentiment": "POSITIVE_ONLY",
"campaign_id": "90r8n",
"creative_source": "MANUAL",
"deleted": true
},
"request": {
"params": {
"line_item_id": "9f2ix",
"account_id": "18ce54d4x5t"
}
}
}