Как стать счастливее и уверенно идти к своим целям? Все ответы — в книге «Сам себе государство. Как совершить революцию в жизни». Купить Ad Campaign - Documentation - Facebook for Developers
Graph API Version

Campaign

A campaign is the highest level organizational structure within an ad account and should represent a single objective for an advertiser, for example, to drive page post engagement. Setting objective of the campaign will enforce validation on any ads added to the campaign to ensure they also have the correct objective.

Facebook will no longer be able to aggregate non-inline conversion metric values across iOS 14 and non-iOS 14 campaigns due to differences in attribution logic. Querying across iOS 14 and non-iOS 14 campaigns will result in no data getting returned for non-inline conversion metrics such as app installs and purchases. Inline event metrics like impressions, link clicks, and video views, however, can still be aggregated. Please visit our changelog for more information.

Ad campaigns that target iOS 14 must set the new is_skadnetwork_attribution field to true.

The date_preset = lifetime parameter is disabled in Graph API v10.0 and replaced with date_preset = maximum, which returns a maximum of 37 months of data. For v9.0 and below, date_preset = maximum will be enabled on May 25, 2021, and any lifetime calls will default to maximum and return only 37 months of data.

Limits

New Required Field for All Campaigns

All businesses using the Marketing API must identify whether or not new and edited campaigns belong to a Special Ad Category. Current available categories are: housing, employment, credit, or issues, elections, and politics. Businesses whose ads do not belong to a Special Ad Category must indicate NONE or send an empty array in the special_ad_categories field.

Businesses running housing, employment, or credit ads must comply with targeting and audience restrictions. Targeting for ads about social issues, elections or politics are not affected by the special_ad_categories label.

As of Marketing API 7.0, the special_ad_category parameter on the POST /act_<ad_account_id>/campaigns endpoint has been deprecated and replaced with a new special_ad_categories parameter. The new special_ad_categories parameter is required and accepts an array.

If you use the special_ad_category parameter, it will still return a string, but you should use GET /{campaign-id}?fields=special_ad_categories to get an array back. Refer to Special Ad Category for additional information.

Reading

A campaign is a grouping of ad sets which are organized by the same business objective. Each campaign has an objective that must be valid across the ad sets within that campaign.

After your ads begin delivering, you can query stats for ad campaigns. The statistics returned will be unique stats, deduped across the ad sets. You can also get reports and statistics for all ad sets and ads in an campaign simultaneously.

Example

Graph API Explorer
GET v10.0/...?fields={fieldname_of_type_Campaign} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '...?fields={fieldname_of_type_Campaign}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "...?fields={fieldname_of_type_Campaign}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "...?fields={fieldname_of_type_Campaign}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"...?fields={fieldname_of_type_Campaign}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

ParameterDescription
date_preset
enum{today, yesterday, this_month, last_month, this_quarter, maximum, last_3d, last_7d, last_14d, last_28d, last_30d, last_90d, last_week_mon_sun, last_week_sun_sat, last_quarter, last_year, this_week_mon_today, this_week_sun_today, this_year}

Date Preset

time_range
{'since':YYYY-MM-DD,'until':YYYY-MM-DD}

Time Range. Note if time range is invalid, it will be ignored.

since
datetime

A date in the format of "YYYY-MM-DD", which means from the beginning midnight of that day.

until
datetime

A date in the format of "YYYY-MM-DD", which means to the beginning midnight of the following day.

Fields

FieldDescription
id
numeric string

Campaign's ID

account_id
numeric string

ID of the ad account that owns this campaign

ad_strategy_id
numeric string

Ad Strategy ID

adlabels

Ad Labels associated with this campaign

bid_strategy
enum {LOWEST_COST_WITHOUT_CAP, LOWEST_COST_WITH_BID_CAP, COST_CAP}

Bid strategy for this campaign when you enable campaign budget optimization and when you use AUCTION as your buying type:
LOWEST_COST_WITHOUT_CAP: Designed to get the most results for your budget based on your ad set optimization_goal without limiting your bid amount. This is the best strategy to select if you care most about cost efficiency. However, note that it may be harder to get stable average costs as you spend. Note: this strategy is also known as automatic bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.
LOWEST_COST_WITH_BID_CAP: Designed to get the most results for your budget based on your ad set optimization_goal while limiting actual bid to a specified amount. Get specified bid cap in the bid_amount field for each ad set in this ad campaign. This strategy is known as manual maximum-cost bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.
COST_CAP: Designed to get the most results for your budget based on your ad set optimization_goal while limiting actual average cost per optimization event to a specified amount. Get specified cost cap in the bid_amount field for each ad set in this ad campaign. Learn more in Ads Help Center, About bid strategies: Cost Cap.
Notes:

  • If you do not enable campaign budget optimization, you should get bid_strategy at the ad set level.
  • TARGET_COST bidding strategy has been deprecated with Marketing API v9.
boosted_object_id
numeric string

The Boosted Object this campaign has associated, if any

brand_lift_studies

Automated Brand Lift V2 studies for this ad set.

budget_rebalance_flag
bool

Whether to automatically rebalance budgets daily for all the adsets under this campaign. This has been deprecated on Marketing API V7.0.

budget_remaining
numeric string

Remaining budget

buying_type
string

Buying type, possible values are:
AUCTION: default
RESERVED: for reach and frequency ads.
Reach and Frequency is disabled for housing, employment and credit ads.

can_create_brand_lift_study
bool

If we can create a new automated brand lift study for the ad set.

can_use_spend_cap
bool

Whether the campaign can set the spend cap

configured_status
enum {ACTIVE, PAUSED, DELETED, ARCHIVED}

If this status is PAUSED, all its active ad sets and ads will be paused and have an effective status CAMPAIGN_PAUSED. Prefer using 'status' instead of this.

created_time
datetime

Created Time

daily_budget
numeric string

The daily budget of the campaign

effective_status
enum {ACTIVE, PAUSED, DELETED, ARCHIVED, IN_PROCESS, WITH_ISSUES}

IN_PROCESS is available for version 4.0 or higher

is_skadnetwork_attribution
bool

When set to true Indicates that the campaign will include SKAdNetwork, iOS 14+.

issues_info

Issues for this campaign that prevented it from deliverying

last_budget_toggling_time
datetime

Last budget toggling time

lifetime_budget
numeric string

The lifetime budget of the campaign

name
string

Campaign's name

objective
string

Campaign's objective

pacing_type
list<string>

Defines pacing type of the campaign. The value is an array of options: "standard".

promoted_object

The object this campaign is promoting across all its ads

recommendations

If there are recommendations for this campaign, this field includes them. Otherwise, will not be included in the response. (This field is not included in redownload mode.)

smart_promotion_type
enum

Smart Promotion Type. guided_creation or smart_app_promotion(the choice under APP_INSTALLS objective).

source_campaign

The source campaign that this campaign is copied from

source_campaign_id
numeric string

The source campaign id that this campaign is copied from

special_ad_categories
list<enum>

special ad categories

special_ad_category
enum

The campaign's Special Ad Category. One of HOUSING, EMPLOYMENT, CREDIT, or NONE.

special_ad_category_country
list<enum>

Country field for Special Ad Category.

spend_cap
numeric string

A spend cap for the campaign, such that it will not spend more than this cap. Expressed as integer value of the subunit in your currency.

start_time
datetime

Merging of start_times for the ad sets belonging to this campaign. At the campaign level, start_time is a read only field. You can setup start_time at the ad set level.

status
enum {ACTIVE, PAUSED, DELETED, ARCHIVED}

If this status is PAUSED, all its active ad sets and ads will be paused and have an effective status CAMPAIGN_PAUSED. The field returns the same value as 'configured_status', and is the suggested one to use.

stop_time
datetime

Merging of stop_times for the ad sets belonging to this campaign, if available. At the campaign level, stop_time is a read only field. You can setup stop_time at the ad set level.

topline_id
numeric string

Topline ID

updated_time
datetime

Updated Time. If you update spend_cap, this will not automatically update this field.

Edges

EdgeDescription

The ad studies containing this campaign

Ad rules that govern this campaign - by default, this only returns rules that either directly mention the campaign by id or indirectly through the set entity_type

Ads under this campaign

The ad sets under this campaign

The copies of this campaign

Validation Rules

ErrorDescription
100Invalid parameter
80004There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
200Permissions error
368The action attempted has been deemed abusive or is otherwise disallowed
190Invalid OAuth 2.0 Access Token
275Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.

Creating

You can make a POST request to async_batch_requests edge from the following paths:
When posting to this edge, a Campaign will be created.

Parameters

ParameterDescription
adbatch
list<Object>

JSON encoded batch reqeust

Required
name
string

Required
relative_url
string

Required
body
UTF-8 encoded string

Required
name
UTF-8 encoded string

Name of the batch request for tracking purposes.

Required

Return Type

This endpoint supports read-after-write and will read the node represented by id in the return type.
Struct {
id: numeric string,
}

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
You can make a POST request to copies edge from the following paths:
When posting to this edge, a Campaign will be created.

Parameters

ParameterDescription
deep_copy
boolean
Default value: false

Whether to copy all the child ads. Limits: the total number of children ads to copy should not exceed 3 for a synchronous call and 51 for an asynchronous call.

end_time
datetime

For deep copy, the end time of the sets under the copied campaign, e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. UTC UNIX timestamp. When creating a set with a daily budget, specify end_time=0 to set the set to be ongoing without end date. If not set, the copied sets will inherit the end time from the original set

rename_options
JSON or object-like arrays

Rename options

rename_strategy
enum {DEEP_RENAME, ONLY_TOP_LEVEL_RENAME, NO_RENAME}
Default value: ONLY_TOP_LEVEL_RENAME

DEEP_RENAME: will change this object's name and children's names in the copied object. ONLY_TOP_LEVEL_RENAME: will change the this object's name but won't change the children's name in the copied object. NO_RENAME: will change no name in the copied object

rename_prefix
string

A prefix to copy names. Defaults to null if not provided.

rename_suffix
string

A suffix to copy names. Defaults to null if not provided and appends a localized string of - Copy based on the ad account locale.

start_time
datetime

For deep copy, the start time of the sets under the copied campaign, e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. UTC UNIX timestamp. If not set, the copied sets will inherit the start time from the original set

status_option
enum {ACTIVE, PAUSED, INHERITED_FROM_SOURCE}
Default value: PAUSED

ACTIVE: the copied campaign will have active status. PAUSED: the copied campaign will have paused status. INHERITED_FROM_SOURCE: the copied campaign will have the parent status.

Return Type

This endpoint supports read-after-write and will read the node represented by copied_campaign_id in the return type.
Struct {
copied_campaign_id: numeric string,
ad_object_ids: List [
Struct {
ad_object_type: enum {unique_adcreative, ad, ad_set, campaign, opportunities, privacy_info_center, topline, ad_account},
source_id: numeric string,
copied_id: numeric string,
}
],
}

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
500Message contains banned content
80004There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
You can make a POST request to campaigns edge from the following paths:
When posting to this edge, a Campaign will be created.

Example

Graph API Explorer
POST /v10.0/act_<AD_ACCOUNT_ID>/campaigns HTTP/1.1
Host: graph.facebook.com

name=My+campaign&objective=LINK_CLICKS&status=PAUSED&special_ad_categories=%5B%5D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/act_<AD_ACCOUNT_ID>/campaigns',
    array (
      'name' => 'My campaign',
      'objective' => 'LINK_CLICKS',
      'status' => 'PAUSED',
      'special_ad_categories' => '[]',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/act_<AD_ACCOUNT_ID>/campaigns",
    "POST",
    {
        "name": "My campaign",
        "objective": "LINK_CLICKS",
        "status": "PAUSED",
        "special_ad_categories": "[]"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("name", "My campaign");
params.putString("objective", "LINK_CLICKS");
params.putString("status", "PAUSED");
params.putString("special_ad_categories", "[]");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/act_<AD_ACCOUNT_ID>/campaigns",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
  @"name": @"My campaign",
  @"objective": @"LINK_CLICKS",
  @"status": @"PAUSED",
  @"special_ad_categories": @"[]",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/act_<AD_ACCOUNT_ID>/campaigns"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
curl -X POST \
  -F 'name="My campaign"' \
  -F 'objective="LINK_CLICKS"' \
  -F 'status="PAUSED"' \
  -F 'special_ad_categories=[]' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v10.0/act_<AD_ACCOUNT_ID>/campaigns
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

ParameterDescription
adlabels
list<Object>

Ad Labels associated with this campaign

bid_strategy
enum{LOWEST_COST_WITHOUT_CAP, LOWEST_COST_WITH_BID_CAP, COST_CAP}

Choose bid strategy for this campaign to suit your specific business goals. Each strategy has tradeoffs and may be available for certain optimization_goals:
LOWEST_COST_WITHOUT_CAP: Designed to get the most results for your budget based on your ad set optimization_goal without limiting your bid amount. This is the best strategy if you care most about cost efficiency. However with this strategy it may be harder to get stable average costs as you spend. This strategy is also known as automatic bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.
LOWEST_COST_WITH_BID_CAP: Designed to get the most results for your budget based on your ad set optimization_goal while limiting actual bid to your specified amount. With a bid cap you have more control over your cost per actual optimization event. However if you set a limit which is too low you may get less ads delivery. If you select this, you must provide a bid cap in the bid_amount field for each ad set in this ad campaign. Note: during creation this is the default bid strategy if you don't specify. This strategy is also known as manual maximum-cost bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.

Notes:

  • If you do not enable campaign budget optimization, you should set bid_strategy at ad set level.
  • TARGET_COST bidding strategy has been deprecated with Marketing API v9.
buying_type
string
Default value: AUCTION

This field will help Facebook make optimizations to delivery, pricing, and limits. All ad sets in this campaign must match the buying type. Possible values are:
AUCTION (default)
RESERVED (for reach and frequency ads).

campaign_optimization_type
enum{NONE, ICO_ONLY}

campaign_optimization_type

daily_budget
int64

Daily budget of this campaign. All adsets under this campaign will share this budget. You can either set budget at the campaign level or at the adset level, not both.

execution_options
list<enum{validate_only, include_recommendations}>
Default value: Set

An execution setting
validate_only: when this option is specified, the API call will not perform the mutation but will run through the validation rules against values of each field.
include_recommendations: this option cannot be used by itself. When this option is used, recommendations for ad object's configuration will be included. A separate section recommendations will be included in the response, but only if recommendations for this specification exist.
If the call passes validation or review, response will be {"success": true}. If the call does not pass, an error will be returned with more details. These options can be used to improve any UI to display errors to the user much sooner, e.g. as soon as a new value is typed into any field corresponding to this ad object, rather than at the upload/save stage, or after review.

is_skadnetwork_attribution
boolean

To create an iOS 14 campaign, enable SKAdNetwork attribution for this campaign.

iterative_split_test_configs
list<Object>

Array of Iterative Split Test Configs created under this campaign .

lifetime_budget
int64

Lifetime budget of this campaign. All adsets under this campaign will share this budget. You can either set budget at the campaign level or at the adset level, not both.

name
string

Name for this campaign

Supports Emoji
objective
enum{APP_INSTALLS, BRAND_AWARENESS, CONVERSIONS, EVENT_RESPONSES, LEAD_GENERATION, LINK_CLICKS, LOCAL_AWARENESS, MESSAGES, OFFER_CLAIMS, PAGE_LIKES, POST_ENGAGEMENT, PRODUCT_CATALOG_SALES, REACH, STORE_VISITS, VIDEO_VIEWS}

Campaign's objective. If it is specified the API will validate that any ads created under the campaign match that objective.
Currently, with BRAND_AWARENESS objective, all creatives should be either only images or only videos, not mixed.

promoted_object
Object

The object this campaign is promoting across all its ads. Only product_catalog_id is used at the ad set level.

application_id
int

The ID of a Facebook Application. Usually related to mobile or canvas games being promoted on Facebook for installs or engagement

pixel_id
numeric string or integer

The ID of a Facebook conversion pixel. Used with offsite conversion campaigns.

custom_event_type
enum{RATE, TUTORIAL_COMPLETION, CONTACT, CUSTOMIZE_PRODUCT, DONATE, FIND_LOCATION, SCHEDULE, START_TRIAL, SUBMIT_APPLICATION, SUBSCRIBE, ADD_TO_CART, ADD_TO_WISHLIST, INITIATED_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE, LEAD, COMPLETE_REGISTRATION, CONTENT_VIEW, SEARCH, SERVICE_BOOKING_REQUEST, MESSAGING_CONVERSATION_STARTED_7D, LEVEL_ACHIEVED, ACHIEVEMENT_UNLOCKED, SPENT_CREDITS, LISTING_INTERACTION, D2_RETENTION, D7_RETENTION, OTHER}

The event from an App Event of a mobile app, not in the standard event list.

object_store_url
URL

The uri of the mobile / digital store where an application can be bought / downloaded. This is platform specific. When combined with the "application_id" this uniquely specifies an object which can be the subject of a Facebook advertising campaign.

offer_id
numeric string or integer

The ID of an Offer from a Facebook Page.

page_id
Page ID

The ID of a Facebook Page

product_catalog_id
numeric string or integer

The ID of a Product Catalog. Used with Dynamic Product Ads.

product_item_id
numeric string or integer

The ID of the product item.

instagram_profile_id
numeric string or integer

The ID of the instagram profile id.

product_set_id
numeric string or integer

The ID of a Product Set within an Ad Set level Product Catalog. Used with Dynamic Product Ads.

event_id
numeric string or integer

The ID of a Facebook Event

offline_conversion_data_set_id
numeric string or integer

The ID of the offline dataset.

fundraiser_campaign_id
numeric string or integer

The ID of the fundraiser campaign.

custom_event_str
string

The event from an App Event of a mobile app, not in the standard event list.

omnichannel_object
Object

app
array<JSON object>

pixel
array<JSON object>

Required
onsite
array<JSON object>

source_campaign_id
numeric string or integer

Used if a campaign has been copied. The ID from the original campaign that was copied.

special_ad_categories
array<enum {NONE, EMPLOYMENT, HOUSING, CREDIT, ISSUES_ELECTIONS_POLITICS}>

special_ad_categories

Required
special_ad_category_country
array<enum {AD, AE, AF, AG, AI, AL, AM, AN, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MH, MK, ML, MM, MN, MO, MP, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, XK, YE, YT, ZA, ZM, ZW}>

special_ad_category_country

spend_cap
int64

A spend cap for the campaign, such that it will not spend more than this cap. Defined as integer value of subunit in your currency with a minimum value of $100 USD (or approximate local equivalent). Set the value to 922337203685478 to remove the spend cap. Not available for Reach and Frequency or Premium Self Serve campaigns

status
enum{ACTIVE, PAUSED, DELETED, ARCHIVED}

Only ACTIVE and PAUSED are valid during creation. Other statuses can be used for update. If it is set to PAUSED, its active child objects will be paused and have an effective status CAMPAIGN_PAUSED.

topline_id
numeric string or integer

Topline ID

upstream_events
dictionary { string : <dictionary { string : <string> }> }

Upstream events

Return Type

This endpoint supports read-after-write and will read the node represented by id in the return type.
Struct {
id: numeric string,
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter
80004There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
200Permissions error
300Edit failure
294Managing advertisements requires an access token with the extended permission for ads_management
368The action attempted has been deemed abusive or is otherwise disallowed
2615Invalid call to update this adaccount
900No such application exists.

Updating

You can update a Campaign by making a POST request to /{campaign_id}.

Parameters

ParameterDescription
adlabels
list<Object>

Ad Labels associated with this campaign

adset_bid_amounts
JSON object {adset ID : int64}

A map of child adset IDs to their respective bid amounts required in the process of toggling campaign from autobid to manual bid

adset_budgets
array<JSON object>

An array of maps containing all the non-deleted child adset IDs and either daily_budget or lifetime_budget, required in the process of toggling between campaign budget and adset budget

adset_id
adset ID

adset_id

Required
daily_budget
int64

daily_budget

lifetime_budget
int64

lifetime_budget

bid_strategy
enum{LOWEST_COST_WITHOUT_CAP, LOWEST_COST_WITH_BID_CAP, COST_CAP}

Choose bid strategy for this campaign to suit your specific business goals. Each strategy has tradeoffs and may be available for certain optimization_goals:
LOWEST_COST_WITHOUT_CAP: Designed to get the most results for your budget based on your ad set optimization_goal without limiting your bid amount. This is the best strategy if you care most about cost efficiency. However with this strategy it may be harder to get stable average costs as you spend. This strategy is also known as automatic bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.
LOWEST_COST_WITH_BID_CAP: Designed to get the most results for your budget based on your ad set optimization_goal while limiting actual bid to your specified amount. With a bid cap you have more control over your cost per actual optimization event. However if you set a limit which is too low you may get less ads delivery. If you select this, you must provide a bid cap in the bid_amount field for each ad set in this ad campaign. Note: during creation this is the default bid strategy if you don't specify. This strategy is also known as manual maximum-cost bidding. Learn more in Ads Help Center, About bid strategies: Lowest cost.
COST_CAP: Designed to get the most results for your budget based on your ad set optimization_goal while limiting actual average cost per optimization event to a specified amount. Get specified cost cap in the bid_amount field for each ad set in this ad campaign. Learn more in Ads Help Center, About bid strategies: Cost Cap.

Notes:

  • If you do not enable campaign budget optimization, you should set bid_strategy at ad set level.
  • TARGET_COST bidding strategy has been deprecated with Marketing API v9.
budget_rebalance_flag
boolean

Whether to automatically rebalance budgets daily for all the adsets under this campaign.

campaign_optimization_type
enum{NONE, ICO_ONLY}

campaign_optimization_type

daily_budget
int64

Daily budget of this campaign. All adsets under this campaign will share this budget. You can either set budget at the campaign level or at the adset level, not both.

execution_options
list<enum{validate_only, include_recommendations}>
Default value: Set

An execution setting
validate_only: when this option is specified, the API call will not perform the mutation but will run through the validation rules against values of each field.
include_recommendations: this option cannot be used by itself. When this option is used, recommendations for ad object's configuration will be included. A separate section recommendations will be included in the response, but only if recommendations for this specification exist.
If the call passes validation or review, response will be {"success": true}. If the call does not pass, an error will be returned with more details. These options can be used to improve any UI to display errors to the user much sooner, e.g. as soon as a new value is typed into any field corresponding to this ad object, rather than at the upload/save stage, or after review.

is_skadnetwork_attribution
boolean

Flag to indicate that the campaign will be using SKAdNetwork, which also means that it will only be targeting iOS 14.x and above

iterative_split_test_configs
list<Object>

Array of Iterative Split Test Configs created under this campaign .

lifetime_budget
int64

Lifetime budget of this campaign. All adsets under this campaign will share this budget. You can either set budget at the campaign level or at the adset level, not both.

name
string

Name for this campaign

Supports Emoji
objective
enum{APP_INSTALLS, BRAND_AWARENESS, CONVERSIONS, EVENT_RESPONSES, LEAD_GENERATION, LINK_CLICKS, LOCAL_AWARENESS, MESSAGES, OFFER_CLAIMS, PAGE_LIKES, POST_ENGAGEMENT, PRODUCT_CATALOG_SALES, REACH, STORE_VISITS, VIDEO_VIEWS}

Campaign's objective. If it is specified the API will validate that any ads created under the campaign match that objective.
Currently, with BRAND_AWARENESS objective, all creatives should be either only images or only videos, not mixed.

promoted_object
Object

The object this campaign is promoting across all its ads. Only product_catalog_id is used at the ad set level.

application_id
int

The ID of a Facebook Application. Usually related to mobile or canvas games being promoted on Facebook for installs or engagement

pixel_id
numeric string or integer

The ID of a Facebook conversion pixel. Used with offsite conversion campaigns.

custom_event_type
enum{RATE, TUTORIAL_COMPLETION, CONTACT, CUSTOMIZE_PRODUCT, DONATE, FIND_LOCATION, SCHEDULE, START_TRIAL, SUBMIT_APPLICATION, SUBSCRIBE, ADD_TO_CART, ADD_TO_WISHLIST, INITIATED_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE, LEAD, COMPLETE_REGISTRATION, CONTENT_VIEW, SEARCH, SERVICE_BOOKING_REQUEST, MESSAGING_CONVERSATION_STARTED_7D, LEVEL_ACHIEVED, ACHIEVEMENT_UNLOCKED, SPENT_CREDITS, LISTING_INTERACTION, D2_RETENTION, D7_RETENTION, OTHER}

The event from an App Event of a mobile app, not in the standard event list.

object_store_url
URL

The uri of the mobile / digital store where an application can be bought / downloaded. This is platform specific. When combined with the "application_id" this uniquely specifies an object which can be the subject of a Facebook advertising campaign.

offer_id
numeric string or integer

The ID of an Offer from a Facebook Page.

page_id
Page ID

The ID of a Facebook Page

product_catalog_id
numeric string or integer

The ID of a Product Catalog. Used with Dynamic Product Ads.

product_item_id
numeric string or integer

The ID of the product item.

instagram_profile_id
numeric string or integer

The ID of the instagram profile id.

product_set_id
numeric string or integer

The ID of a Product Set within an Ad Set level Product Catalog. Used with Dynamic Product Ads.

event_id
numeric string or integer

The ID of a Facebook Event

offline_conversion_data_set_id
numeric string or integer

The ID of the offline dataset.

fundraiser_campaign_id
numeric string or integer

The ID of the fundraiser campaign.

custom_event_str
string

The event from an App Event of a mobile app, not in the standard event list.

omnichannel_object
Object

app
array<JSON object>

pixel
array<JSON object>

Required
onsite
array<JSON object>

smart_promotion_type
enum{GUIDED_CREATION, SMART_APP_PROMOTION}

smart_promotion_type

special_ad_categories
array<enum {NONE, EMPLOYMENT, HOUSING, CREDIT, ISSUES_ELECTIONS_POLITICS}>

special_ad_categories

special_ad_category
enum{NONE, EMPLOYMENT, HOUSING, CREDIT, ISSUES_ELECTIONS_POLITICS}

special_ad_category

special_ad_category_country
array<enum {AD, AE, AF, AG, AI, AL, AM, AN, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MH, MK, ML, MM, MN, MO, MP, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, XK, YE, YT, ZA, ZM, ZW}>

special_ad_category_country

spend_cap
int64

A spend cap for the campaign, such that it will not spend more than this cap. Defined as integer value of subunit in your currency with a minimum value of $100 USD (or approximate local equivalent). Set the value to 922337203685478 to remove the spend cap. Not available for Reach and Frequency or Premium Self Serve campaigns

status
enum{ACTIVE, PAUSED, DELETED, ARCHIVED}

Only ACTIVE and PAUSED are valid during creation. Other statuses can be used for update. If it is set to PAUSED, its active child objects will be paused and have an effective status CAMPAIGN_PAUSED.

upstream_events
dictionary { string : <dictionary { string : <string> }> }

Upstream events

Return Type

This endpoint supports read-after-write and will read the node to which you POSTed.
Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
2625The request for a reach frequency campaign is invalid.
80004There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
294Managing advertisements requires an access token with the extended permission for ads_management
190Invalid OAuth 2.0 Access Token

Deleting

You can delete a Campaign by making a DELETE request to /{campaign_id}.

Parameters

This endpoint doesn't have any parameters.

Return Type

Struct {
success: bool,
}

Validation Rules

ErrorDescription
200Permissions error
100Invalid parameter
80004There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
You can dissociate a Campaign from an AdAccount by making a DELETE request to /act_{ad_account_id}/campaigns.

Parameters

ParameterDescription
before_date
datetime

Set a before date to delete campaigns before this date

delete_strategy
enum{DELETE_ANY, DELETE_OLDEST, DELETE_ARCHIVED_BEFORE}

Delete strategy

Required
object_count
integer

Object count

Return Type

Struct {
objects_left_to_delete_count: unsigned int32,
deleted_object_ids: List [
numeric string
],
}

Validation Rules

ErrorDescription
100Invalid parameter

Objective Validation

Your campaign objective choice can limit the settings available to you.

Optimization Goals

Certain campaign objectives support only certain ad set optimization_goals. See Bidding Overview, Validation.

Compatible Ad Types

ObjectiveCompatible Ad Types

APP_INSTALLS

BRAND_AWARENESS

CONVERSIONS

EVENT_RESPONSES

LEAD_GENERATION

LINK_CLICKS

MESSAGES

POST_ENGAGEMENT

PRODUCT_CATALOG_SALES

REACH

STORE_VISITS

VIDEO_VIEWS

Objectives and Creative Fields

See our ads guide for a list of creatives supported per objective. In the API, the objective determines which ad creatives are valid.

ObjectiveCreative Fields

APP_INSTALLS

object_story_id or object_story_spec

CONVERSIONS

object_story_id or object_story_spec


Notes:

  • If you are creating link ads not connected to a page, use the following creative fields: title, body, object_url, and image_file or image_hash.
  • Creative cannot include link ads pointing to an app store.

EVENT_RESPONSES

object_story_id or object_story_spec

LEAD_GENERATION

object_story_id or object_story_spec

LINK_CLICKS

object_story_id or object_story_spec


Notes:

  • Creative cannot include link ads pointing to an app store.
  • If you select LINK_CLICKS as both optimization goal and billing event, you must include call_to_action.

MESSAGES

object_story_spec

PAGE_LIKES

object_story_id, object_story_spec, object_id, and body

POST_ENGAGEMENT

object_story_id or object_story_spec


Note: Creative cannot include link ads pointing to an app store.

VIDEO_VIEWS

object_story_id or object_story_spec

Objectives and Tracking Specs

Tracking specs are applied by default based on the objective specified, please see the full list of defaults by objective here.

There are two important scenarios to take into account:

  • Tracking pixels are not applied by default, and you must specify it explicitly when your objective is CONVERSIONS.
  • Mobile app ads will no longer track installs or app events by default. You must explicitly specify to track installs or app events for mobile app ads otherwise your ad will not track.

To specify to track an install or app event, set the following in your ad:

tracking_specs=[{'action.type':['mobile_app_install'],'application':[{your_app_id}]},{'action.type':['app_custom_event'],'application':[{your_app_id}]}]

Certain objectives require the promoted_object to be set in ad sets. See Promoted Object for more information.

ObjectiveRequired promoted_object Fields

APP_INSTALLS

  • application_id and object_store_url
  • If optimization_goal is OFFSITE_CONVERSIONS: application_id, object_store_url, and custom_event_type

CONVERSIONS

  • pixel_id (Conversion pixel ID)
  • pixel_id (Facebook pixel ID) and custom_event_type
  • pixel_id (Facebook pixel ID), pixel_rule, and custom_event_type
  • event_id (Facebook event ID) and custom_event_type
  • For mobile app events: application_id, object_store_url, and custom_event_type
  • For offline conversions: offline_conversion_data_set_id (Offline dataset ID), and custom_event_type

LINK_CLICKS

For mobile app or Instant Experiences app engagement link clicks: application_id and object_store_url.

PRODUCT_CATALOG_SALES

  • product_set_id, or
  • product_set_id and custom_event_type

PAGE_LIKES

page_id

OFFER_CLAIMS

page_id

Objective and Placements

Certain types of ad placements are valid only for specific objectives or creatives. See Business Help Center, Available ad placements for marketing objectives.

The table below shows some placements and their compatible objectives or creatives. You can pick a combination of those compatible placements. Note that:

  • With LEAD_GENERATION, device_platforms: desktop cannot be selected together with publisher_platforms: instagram.
  • If your objective is website traffic, story for facebook_positions does not support destination_type: messenger.
  • If your objective is website traffic, story for messenger_positions does not support destination_type: messenger.
Objective Creative Placement

APP_INSTALLS, promoting an Instant Experiences app

Desktop app ads

device_platforms: desktop

APP_INSTALLS, promoting a mobile app

Photo or video mobile app ads

device_platforms: mobile


publisher_platforms: facebook, feed, instagram, instant_articles, audience_network


facebook_positions: feed, video_feeds, instant articles and story


audience_network_positions: classic, rewarded_video


messenger_positions: story

BRAND_AWARENESS

all

publisher_platforms: facebook, instagram, audience_network.


facebook_positions: feed, video_feeds, instant_article, instream_video and story, which is currently under limited availability


instagram_positions: stream


audience_network_positions: classic, instream_video

CONVERSIONS

Photo or video link ads from a page

We support BRAND_AWARENESS, APP_INSTALL, POST_ENGAGEMENT, VIDEO_VIEWS, REACH, WEBSITE_CONVERSIONS, and TRAFFIC. Also supported: right_hand_column and story for facebook_positions and messenger_positions: messenger_home and story.


facebook_positions: story only supports the objective WEBSITE_CONVERSIONS


messenger_positions: story only supports the objective WEBSITE_CONVERSIONS


Exception: instream_video is not supported for this objective.

CONVERSIONS

Link ads not connected to a page

facebook_positions: right_hand_column

CONVERSIONS (promoting mobile app)

Photo or video mobile app ads

device_platforms: mobile.


facebook_positions: right_hand_column and story. story as a facebook_positions for this objective does not support destination_type: messenger.


messenger_positions: messenger_home


story as a messenger_positions for this objective does not support destination_type: messenger.

EVENT_RESPONSES

Event ads

As of 3.0, you cannot use right_hand_column for facebook_positions

EVENT_RESPONSES

Page post ads

publisher_platforms: facebook.


As of 3.0, you cannot use right_hand_column for facebook_positions

LEAD_GENERATION

Page post ads

device_platforms: mobile, desktop


publisher_platforms: facebook, instagram


facebook_positions: feed and story, which is in limited availability


instagram_positions: stream


As of 3.0, you cannot use right_hand_column for facebook_positions

LINK_CLICKS

Photo or video link ads from a page

All, including right_hand_column and messenger_positions: messenger_home and story.

LINK_CLICKS

Link ads not connected to a page

facebook_positions: right_hand_column

LINK_CLICKS, promoting an Instant Experiences app

Desktop app ads

device_platforms: desktop


facebook_positions: right_hand_column

LINK_CLICKS, promoting a mobile app

Photo or video mobile app ads

device_platforms: mobile, facebook_positions: right_hand_column

PAGE_LIKES

Video creatives

publisher_platforms: facebook


As of 3.0, you cannot use right_hand_column for facebook_positions

POST_ENGAGEMENT

Page post ads with video or photo

publisher_platforms: facebook, instagram


device_platforms: mobile, desktop


As of 3.0, you cannot use right_hand_column for facebook_positions

POST_ENGAGEMENT

Page post ads with text only

publisher_platforms: facebook, instagram


device_platforms: mobile, desktop


As of 3.0, you cannot use right_hand_column for facebook_positions

POST_ENGAGEMENT

New campaign

publisher_platforms: facebook, instagram


As of 3.0, you cannot use right_hand_column for facebook_positions

PRODUCT_CATALOG_SALES

dynamic ads

All, including right_hand_column for facebook_positions.

REACH

Reach ads

All except right_hand_column for facebook_positions as of 3.0.


Includes messenger_positions: story and story for facebook_positions.

STORE_VISITS

store visit ads

publisher_platforms: facebook


As of 3.0, you cannot use right_hand_column for facebook_positions

VIDEO_VIEWS

Video ads

publisher_platforms: facebook, instagram, audience_network, instant_articles.


Includes story for facebook_positions but not with the optimation_goal set to TWO_SECOND_CONTINUOUS_VIDEO_VIEWS.


As of 3.0, you cannot use right_hand_column for facebook_positions

Objective, Optimization Goal and attribution_spec

Use click-through and view-through attribution windows for ad set to track conversions then use for ads delivery optimization. This is different from the attribution window you use for ads reporting. With attribution_spec, select a combination of click-through or view-through windows of 1 day or 7 days. The combinations you can use depend on your ad set's optimization_goal and campaign's objective.

Recommended Default attribution_spec

You may not have provided attribution_spec when you created ads sets optimized for Value Optimization. This is an optimization available for conversions, app installs, and product catalog sales objectives. In the past, we defaulted to a 1-day click through attribution window.

Objective Optimization Goal Allowed Combination

CONVERSIONS, PRODUCT_CATALOG_SALES

OFFSITE_CONVERSIONS

1-day click


7-day click


1-day click and 1-day view


7-day click and 1-day view

APP_INSTALLS, LINK_CLICKS

OFFSITE_CONVERSIONS

1-day click


7-day click (LINK_CLICKS only)

APP_INSTALLS

APP_INSTALLS

1-day click


1-day click and 1-day view

CONVERSIONS

INCREMENTAL_OFFSITE_ CONVERSIONS

Null click, Null view

For all other optimization_goal and objective combinations, you can only use 1-day click for attribution_spec.