Marketing API Version

Ad Set

An ad set is a group of ads that share the same daily or lifetime budget, schedule, bid type, bid info, and targeting data. Ad sets enable you to group ads according to your criteria, and you can retrieve the ad-related statistics that apply to a set. See Optimized CPM and Promoted Object.

The week of September 10, 2017, we removed more than 3 million self-reported terms related to education and employment as targeting options in our ads interfaces. We did this after discovering a small percentage of people had entered offensive responses, in violation of our policies. After a thorough review, we are making additional changes to improve our policies, enforcement practices, and also adding back ~5,000 commonly used targeting terms that meet our Community Standards. For more information see Ads Developer Blog, Update to Self-Reported Profile Targeting Options.

For example, create an ad set with a daily budget:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Targeting;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
  AdSetFields::NAME => 'My Ad Set',
  AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
  AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
  AdSetFields::BID_AMOUNT => 2,
  AdSetFields::DAILY_BUDGET => 1000,
  AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
  AdSetFields::TARGETING => (new Targeting())->setData(array(
    TargetingFields::GEO_LOCATIONS => array(
      'countries' => array('US'),
    ),
  )),
));
$adset->create(array(
  AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
));
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting

ad_account = AdAccount(fbid='act_<AD_ACCOUNT_ID>')

params = {
    AdSet.Field.name: 'My Ad Set',
    AdSet.Field.campaign_id: <CAMPAIGN_ID>,
    AdSet.Field.daily_budget: 1000,
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
    AdSet.Field.bid_amount: 2,
    AdSet.Field.targeting: {
        Targeting.Field.geo_locations: {
            'countries': ['US'],
        },
    },
    AdSet.Field.status: AdSet.Status.active,
}
adset = ad_account.create_ad_set(params=params)
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
  .setName("My Ad Set")
  .setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
  .setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
  .setBidAmount(2L)
  .setDailyBudget(1000L)
  .setCampaignId(<CAMPAIGN_ID>)
  .setTargeting(
    new Targeting()
      .setFieldGeoLocations(
        new TargetingGeoLocation()
          .setFieldCountries(Arrays.asList("US"))
      )
  )
  .setStatus(AdSet.EnumStatus.VALUE_PAUSED)
  .execute();
String ad_set_id = adSet.getId();
curl \
  -F 'name=My Ad Set' \
  -F 'optimization_goal=REACH' \
  -F 'billing_event=IMPRESSIONS' \
  -F 'bid_amount=2' \
  -F 'daily_budget=1000' \
  -F 'campaign_id=<CAMPAIGN_ID>' \
  -F 'targeting={"geo_locations":{"countries":["US"]}}' \
  -F 'status=PAUSED' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets

Create an ad set with a lifetime budget

curl \
  -F 'name=LifetimeBudgetSet' \
  -F 'lifetime_budget=100000' \
  -F 'optimization_goal=POST_ENGAGEMENT' \
  -F 'billing_event=IMPRESSIONS' \
  -F 'bid_amount=1500' \
  -F 'targeting={"geo_locations":{"countries":["US"]}}' \
  -F 'campaign_id=<CAMPAIGN_ID>' \
  -F 'end_time=2017-09-21T15:41:30+0000' \
  -F 'status=PAUSED' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/VERSION/act_<AD_ACCOUNT_ID>/adsets

Limits

The following are the limits on ad sets

LimitValue

Maximum number of ad sets per regular ad account

5000 non-deleted ad sets

Maximum number of ad sets per bulk ad account

10000 non-deleted ad sets

Maximum number of ads per ad set

50 non-archived ads

Reading

An ad set is a group of ads that share the same daily or lifetime budget, schedule, bid type, bid info, and targeting data. Ad sets enable you to group ads according to your criteria, and you can retrieve the ad-related statistics that apply to a set.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_read
Page management Apps
No data
Other Apps
No data

Examples

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;

$adset = new AdSet(<AD_SET_ID>);
$adset->read(array(
  AdSetFields::NAME,
  AdSetFields::CONFIGURED_STATUS,
  AdSetFields::EFFECTIVE_STATUS,
));

echo $adset->{AdSetFields::NAME}.PHP_EOL;
echo $adset->{AdSetFields::CONFIGURED_STATUS}.PHP_EOL;
echo $adset->{AdSetFields::EFFECTIVE_STATUS}.PHP_EOL;
from facebookads.adobjects.adset import AdSet

adset = AdSet(fbid=<AD_SET_ID>)
fields = [
    AdSet.Field.name,
    AdSet.Field.configured_status,
    AdSet.Field.effective_status,
]
adset.remote_read(fields=fields)
print(adset[AdSet.Field.name])
print(adset[AdSet.Field.configured_status])
print(adset[AdSet.Field.effective_status])
AdSet adSet2 = new AdSet(<AD_SET_ID>, context).get()
  .requestNameField()
  .requestConfiguredStatusField()
  .requestEffectiveStatusField()
  .execute();
curl -G \
  -d 'fields=name,configured_status,effective_status' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/<AD_SET_ID>

To retrieve date-time related fields in a UNIX timestamp format, use the date_format parameter:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;

$adset = new AdSet(<AD_SET_ID>);
$params = array(
  'date_format' => 'U',
);
$adset->read(array(
  AdSetFields::START_TIME,
  AdSetFields::END_TIME,
  AdSetFields::CONFIGURED_STATUS,
  AdSetFields::EFFECTIVE_STATUS,
  AdSetFields::CAMPAIGN_ID,
), $params);

echo $adset->{AdSetFields::EFFECTIVE_STATUS}.PHP_EOL;
from facebookads.adobjects.adset import AdSet

adset = AdSet(fbid=<AD_SET_ID>)
fields = [
    AdSet.Field.start_time,
    AdSet.Field.end_time,
    AdSet.Field.configured_status,
    AdSet.Field.effective_status,
    AdSet.Field.campaign_id,
]
params = {
    'date_format': 'U',
}
adset.remote_read(fields=fields, params=params)

print(adset[AdSet.Field.effective_status])
AdSet adSet2 = new AdSet(<AD_SET_ID>, context).get()
  .setParam("date_format", "U")
  .requestStartTimeField()
  .requestEndTimeField()
  .requestConfiguredStatusField()
  .requestEffectiveStatusField()
  .requestCampaignIdField()
  .execute();
curl -G \
  -d 'date_format=U' \
  -d 'fields=start_time,end_time,configured_status,effective_status,campaign_id' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/<AD_SET_ID>

To retrieve information for multiple ad sets:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;

$ad_set_ids = array(<AD_SET_1_ID>, <AD_SET_2_ID>, <AD_SET_3_ID>);
$fields = array(
  AdSetFields::NAME,
  AdSetFields::CONFIGURED_STATUS,
  AdSetFields::EFFECTIVE_STATUS,
);
$adsets = AdSet::readIds($ad_set_ids, $fields);

foreach ($adsets as $adset) {
  echo $adset->{AdSetFields::NAME}.PHP_EOL;
}
curl -G \
  -d 'fields=name,configured_status,effective_status' \
  -d 'ids=1000002,1000002,1000002' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/

To read all ad sets from one ad account:

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Fields\AdSetFields;

$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$adsets = $account->getAdSets(array(
  AdSetFields::NAME,
  AdSetFields::CONFIGURED_STATUS,
  AdSetFields::EFFECTIVE_STATUS,
));

foreach ($adsets as $adset) {
  echo $adset->{AdSetFields::NAME}.PHP_EOL;
}
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adset import AdSet

account = AdAccount('act_<AD_ACCOUNT_ID>')
adsets = account.get_ad_sets(fields=[AdSet.Field.name])

for adset in adsets:
    print(adset[AdSet.Field.name])
APINodeList<AdSet> adSets = new AdAccount(act_<AD_ACCOUNT_ID>, context).getAdSets()
  .requestNameField()
  .requestConfiguredStatusField()
  .requestEffectiveStatusField()
  .execute();
curl -G \
  -d 'fields=name,configured_status,effective_status' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets

To read the names of ad sets with status paused in an ad account

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;

$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$adsets = $account->getAdSets(
  array(),
  array(
    AdSetFields::EFFECTIVE_STATUS => array(
      AdSet::STATUS_PAUSED,
    ),
  ));

foreach ($adsets as $adset) {
  echo $adset->{AdSetFields::NAME}.PHP_EOL;
}
APINodeList<AdSet> adSets = new AdAccount(act_<AD_ACCOUNT_ID>, context).getAdSets()
  .setEffectiveStatus("[\"PAUSED\"]")
  .execute();
curl -G \
  -d 'effective_status=["PAUSED"]' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets

To read the end_time of multiple ad sets.

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;

$adsets = AdSet::readIds(
  array($ad_set_1_id, $ad_set_2_id),
  array(AdSetFields::END_TIME));

foreach ($adsets as $adset) {
  echo $adset->{AdSetFields::END_TIME}.PHP_EOL;
}
curl -G \
  -d 'fields=end_time' \
  -d 'ids=1000002,1000002' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/

Parameters

This endpoint doesn't have any parameters.

Fields

FieldDescription
id
numeric string

Ad set ID

account_id
numeric string

Ad Account ID

adlabels

Ad Labels associated with this ad set

adset_schedule

Ad set schedule, representing a delivery schedule for a single day

attribution_spec
list<AttributionSpec>

Conversion attribution spec used for attributing conversions for optimization. Supported window lengths differ by optimization goal and campaign objective. See Validation, Attribution Spec.

bid_amount
unsigned int32

Bid cap or target cost for this ad set. The bid cap used in a lowest cost bid strategy is defined as the maximum bid you want to pay for a result based on your optimization_goal. The target cost used in a target cost bid strategy lets Facebook bid on your behalf to meet your target on average and keep costs stable as you raise budget. This field is not returned if is_autobid is true. The bid amount's unit is cents for currencies like USD, EUR, and the basic unit for currencies like JPY, KRW. The bid amount for ads with IMPRESSION or REACH as billing_event is per 1,000 occurrences of that event, and the bid amount for ads with other billing_events is for each occurrence.

bid_info
map<string, unsigned int32>

Map of bid objective to bid value. This field is not available if is_autobid is true.

billing_event
enum {APP_INSTALLS, CLICKS, IMPRESSIONS, LINK_CLICKS, NONE, OFFER_CLAIMS, PAGE_LIKES, POST_ENGAGEMENT, VIDEO_VIEWS}

The billing event for this ad set:
APP_INSTALLS: Pay when people install your app.
CLICKS: Pay when people click anywhere in the ad.
IMPRESSIONS: Pay when the ads are shown to people.
LINK_CLICKS: Pay when people click on the link of the ad.
OFFER_CLAIMS: Pay when people claim the offer.
PAGE_LIKES: Pay when people like your page.
POST_ENGAGEMENT: Pay when people engage with your post.
VIDEO_VIEWS: Pay when people watch videos.

budget_remaining
numeric string

Remaining budget

campaign

The campaign that contains this ad set

campaign_id
numeric string

Campaign ID

configured_status
enum {ACTIVE, PAUSED, DELETED, ARCHIVED}

The status set at the ad set level. It can be different from the effective status due to its parent campaign. Prefer using 'status' instead of this.

created_time
datetime

Created time

creative_sequence
list<numeric string>

Order of the adgroup sequence to be shown to users

daily_budget
numeric string

The daily budget of the set defined in your account currency.

effective_status
enum {ACTIVE, PAUSED, DELETED, PENDING_REVIEW, DISAPPROVED, PREAPPROVED, PENDING_BILLING_INFO, CAMPAIGN_PAUSED, ARCHIVED, ADSET_PAUSED}

The effective status of the ad set, which can be either its own status or caused by its parent campaign.

end_time
datetime

End time, in UTC UNIX timestamp

frequency_control_specs

An array of frequency control specs for this ad set. As there is only one event type currently supported, this array has no more than one element. Writes to this field are only available in ad sets where REACH is the objective.

instagram_actor_id
numeric string

Represents your Instagram account id, used for ads, including dynamic creative ads on Instagram.

is_autobid
bool

Whether the advertiser expresses the intent for Facebook to automatically bid on their behalf. The main goal of automatic bidding is achieving lowest cost for your ad set. We try to get you the lowest cost results, based on your selected optimization_goal for ad delivery, and bid more as needed to spend your budget. You can provide a bid cap using the same lowest cost bid strategy by setting bid_amount and not setting is_autobid=true instead. Learn more in Ads Help Center, About bid strategies: Lowest cost

is_average_price_pacing
bool

Whether the advertiser expresses the intent to set an average cost per result based on their optimization_goal, and wants to maintain a stable average cost as they raise their budget. Average price pacing is also described as target cost. The main benefit of this is maintaining a stable average cost as advertisers raise their budget. Learn more in Ads Help Center, About bid strategies: Target cost

lifetime_budget
numeric string

The lifetime budget of the set defined in your account currency.

lifetime_imps
int32

Lifetime impressions. Available only for campaigns with buying_type=FIXED_CPM

name
string

Name of ad set

optimization_goal
enum {NONE, APP_INSTALLS, BRAND_AWARENESS, AD_RECALL_LIFT, CLICKS, ENGAGED_USERS, EVENT_RESPONSES, IMPRESSIONS, LEAD_GENERATION, LINK_CLICKS, OFFER_CLAIMS, OFFSITE_CONVERSIONS, PAGE_ENGAGEMENT, PAGE_LIKES, POST_ENGAGEMENT, REACH, SOCIAL_IMPRESSIONS, VIDEO_VIEWS, APP_DOWNLOADS, LANDING_PAGE_VIEWS, VALUE, REPLIES}

Which optimization goal this ad set is using:
NONE: Only available in read mode for campaigns created pre v2.4.
APP_INSTALLS: Optimize for people more likely to install your app.
BRAND_AWARENESS: Optimize to reach the most number of users who are likely to spend at least a minimum amount of time on the image or video.
AD_RECALL_LIFT: Optimize for people more likely to remember seeing your ads.
CLICKS: Deprecated. Only available in read mode.
ENGAGED_USERS: Optimize for people more likely to take a particular action in your app.
EVENT_RESPONSES: Optimize for people more likely to attend your event.
IMPRESSIONS: Show the ads as many times as possible.
LEAD_GENERATION: Optimize for people more likely to fill out a lead generation form.
LINK_CLICKS: Optimize for people more likely to click in the link of the ad.
OFFER_CLAIMS: Optimize for people more likely to claim the offer.
OFFSITE_CONVERSIONS: Optimize for people more likely to make a conversion in the site
PAGE_ENGAGEMENT: Optimize for people more likely to engage with your page.
PAGE_LIKES: Optimize for people more likely to like your page.
POST_ENGAGEMENT: Optimize for people more likely to engage with your post.
REACH: Optimize to reach the most unique users of each day or interval specified in frequency_control_specs.
SOCIAL_IMPRESSIONS: Increase the number of impressions with social context. I.e. with the names of one or more of the user's friends attached to the ad who have already liked the page or installed the app.
VIDEO_VIEWS: Optimize for people more likely to watch videos.
VALUE: Optimize for maximum total purchase value within the specified attribution window.
REPLIES: REPLIES optimization will direct ads to people more likely to have a conversation with the business.

pacing_type
list<string>

Defines the pacing type, standard or using ad scheduling

promoted_object

The object this ad set is promoting across all its ads.

recommendations

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

recurring_budget_semantics
bool

If this field is true, your daily spend may be more than your daily budget while your weekly spend will not exceed 7 times your daily budget. More details explained in the Ad Set Budget document. If this is false, your amount spent daily will not exceed the daily budget. This field is not applicable for lifetime budgets.

rf_prediction_id
id

Reach and frequency prediction ID

rtb_flag
bool

Whether this ad set is using RTB or not

source_adset

The source ad set that this ad set was copied from

source_adset_id
numeric string

The source ad set id that this ad set was copied from

start_time
datetime

Start time, in UTC UNIX timestamp

status
enum {ACTIVE, PAUSED, DELETED, ARCHIVED}

The status set at the ad set level. It can be different from the effective status due to its parent campaign. The field returns the same value as 'configured_status', and is the suggested one to use.

targeting

Targeting

time_based_ad_rotation_id_blocks
list<list<integer>>

Specify ad creative that displays at custom date ranges in a campaign as an array. A list of Adgroup IDs. The list of ads to display for each time range in a given schedule. For example display first ad in Adgroup for first date range, second ad for second date range, and so on. You can display more than one ad per date range by providing more than one ad ID per array. For example set time_based_ad_rotation_id_blocks to [[1], [2, 3], [1, 4]]. On the first date range show ad 1, on the second date range show ad 2 and ad 3 and on the last date range show ad 1 and ad 4. Use with time_based_ad_rotation_intervals to specify date ranges.

time_based_ad_rotation_intervals
list<unsigned int32>

Date range when specific ad creative displays during a campaign. Provide date ranges in an array of UNIX timestamps where each timestamp represents the start time for each date range. For example a 3-day campaign from May 9 12am to May 11 11:59PM PST can have three date ranges, the first date range starts from May 9 12:00AM to May 9 11:59PM, second date range starts from May 10 12:00AM to May 10 11:59PM and last starts from May 11 12:00AM to May 11 11:59PM. The first timestamp should match the campaign start time. The last timestamp should be at least 1 hour before the campaign end time. You must provide at least two date ranges. All date ranges must cover the whole campaign length, so any date range cannot exceed campaign length. Use with time_based_ad_rotation_id_blocks to specify ad creative for each date range.

updated_time
datetime

Updated time

use_new_app_click
bool

If set, allows Mobile App Engagement ads to optimize for LINK_CLICKS

Edges

EdgeDescription

activities

The activities of this ad set

adcreatives

The creatives of this ad set

ads

The ads under this ad set

asyncadrequests

Async ad requests for this ad set

copies

The copies of this ad set

delivery_estimate

The delivery estimate for this ad set

insights

Insights on advertising performance of this ad set

targetingsentencelines

The targeting description sentence for this ad set

conversions

Reference document for using Facebook Marketing APIs to get conversion stats on your Facebook ads, ad sets, and accounts.

stats

Reference document for using Facebook Marketing APIs to get ad statistics on impressions, clicks, performance, and more

Validation Rules

ErrorDescription
100Invalid parameter
275Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.
278Reading advertisements requires an access token with the extended permission ads_read
274The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API
270This Ads API request is not allowed for apps with development access level (Development access is by default for all apps, please request for upgrade). Make sure that the access token belongs to a user that is both admin of the app and admin of the ad account
200Permissions error
272This Ads API call requires the user to be admin of the application
273This Ads API call requires the user to be admin of the ad account

Creating

Examples

Validate an ad set with a daily budget where campaign objective is set to APP_INSTALLS

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Targeting;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
  AdSetFields::NAME => 'Mobile App Installs Ad Set',
  AdSetFields::PROMOTED_OBJECT => array(
    'application_id' => <APP_ID>,
    'object_store_url' => '<APP_STORE_URL>',
  ),
  AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::APP_INSTALLS,
  AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
  AdSetFields::BID_AMOUNT => 2,
  AdSetFields::DAILY_BUDGET => 1000,
  AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
  AdSetFields::TARGETING => (new Targeting())->setData(array(
    TargetingFields::GEO_LOCATIONS => array(
      'countries' => array('US'),
    ),
    TargetingFields::PUBLISHER_PLATFORMS => array(
      'facebook',
      'audience_network',
    ),
    TargetingFields::DEVICE_PLATFORMS => array('mobile'),
    TargetingFields::USER_OS => array(
      'IOS',
    )
  )),
));
$adset->create();
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting

ad_account = AdAccount(fbid='act_<AD_ACCOUNT_ID>')

params = {
    AdSet.Field.name: 'Mobile App Installs Ad Set',
    AdSet.Field.promoted_object: {
        'application_id': <APP_ID>,
        'object_store_url': '<APP_STORE_URL>',
    },
    AdSet.Field.campaign_id: <CAMPAIGN_ID>,
    AdSet.Field.daily_budget: 1000,
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.app_installs,
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.bid_amount: 2,
    AdSet.Field.targeting: {
        Targeting.Field.geo_locations: {
            'countries': ['US'],
        },
        Targeting.Field.publisher_platforms: ['facebook', 'audience_network'],
        Targeting.Field.device_platforms: ['mobile'],
        Targeting.Field.user_os: [
            'IOS',
        ],
    },
    AdSet.Field.status: AdSet.Status.active,
}
adset = ad_account.create_ad_set(params=params)
curl \
  -F 'name=Mobile App Installs Ad Set' \
  -F 'promoted_object={"application_id":"<APP_ID>","object_store_url":"<APP_STORE_URL>"}' \
  -F 'optimization_goal=APP_INSTALLS' \
  -F 'billing_event=IMPRESSIONS' \
  -F 'bid_amount=2' \
  -F 'daily_budget=1000' \
  -F 'campaign_id=<CAMPAIGN_ID>' \
  -F 'targeting={ 
    "device_platforms": ["mobile"], 
    "geo_locations": {"countries":["US"]}, 
    "publisher_platforms": ["facebook","audience_network"], 
    "user_os": ["IOS"] 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/adsets

Considerations

Bid/Budget Validations

When creating an ad set, from v2.4 and on, there will be a minimum budget for different billing events (clicks, impressions, actions). Minimum values are defined in terms of the daily budget but apply to lifetime budgets as well. For example, if the minimum daily budget is $5, a campaign lasting 5 days will need at least $25 for budget. All values in this section are in US Dollars. Differenct currency has different minimum daily budget limit.

If is_autobid is set to true in the ad set:

Billing EventMinimum Daily BudgetNotes

Impressions

$0.50

Clicks/Likes/Video Views

$2.50

Low-frequency Actions

$40

Low-frequency actions include mobile app installs, offer claims or canvas app installs. Important: This minimum daily budget is the same for all countries.

If is_autobid is set to false in the ad set:

Billing EventMinimum Daily Budget

Impressions

At least the bid_amount. For example, if the bid amount is $10, then $10 will be the minimum budget required.

Clicks/Actions

5x the bid_amount for a Click or Action. For example, if the bid amount is $5 per click/action, then $25 will be the minimum budget required.

Budgets in other non-USD currencies will be converted and validated upon time of ad set creation.

For ads belonging to ad accounts from countries in the list below, the minimum values are 2x the ones in the tables. For example if billing event is an impression, minimum daily budget is $0.50 but in the the following countries minimum would be $1.00. The only exception to this rule are low-frequency actions when is_autobid is true (e.g mobile app install campaings):

Australia, Austria, Belgium, Canada, Denmark, Finland, France, Germany, Greece, Hong Kong, Israel, Italy, Japan, Netherlands, New Zealand, Norway, Singapore, South Korea, Spain, Sweden, Switzerland, Taiwan, United Kingdom, United States of America.

Locale targeted page post If you promote a Page post which has been targeted by locale the ad set targeting must include the same, or a subset of, locale targeting as the Page post.

E.g. if the Page post is targeted at locales 6 (US English) and 24 (UK English), then the ad set must be targeted at one or more of the same locales.

Mobile App Ads Mobile app ad sets should

  • be used in conjunction with targeting spec fields user_device and user_os
  • have a MOBILE_APP_* objective on the campaign

Desktop App Ads Desktop app ad sets must

  • include a targeting spec of either
    • 'page_types':['desktopfeed'] or
    • 'page_types':['rightcolumn'] or
    • 'page_types':['desktop'] along with the other targeting options you have selected.
  • include a CANVAS_APP_* objective
You can make a POST request to adsets edge from the following paths:
When posting to this edge, an AdSet will be created.

Example

Graph API Explorer
POST /v2.12/act_{ad-account-id}/adsets HTTP/1.1
Host: graph.facebook.com

name=My+Reach+Ad+Set&optimization_goal=REACH&billing_event=IMPRESSIONS&bid_amount=2&daily_budget=1000&campaign_id=%7Bad-campaign-id%7D&targeting=%7B%22geo_locations%22%3A%7B%22countries%22%3A%5B%22US%22%5D%7D%7D&status=PAUSED&promoted_object=%7B%22page_id%22%3A%22%7Bpage-id%7D%22%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/act_{ad-account-id}/adsets',
    array (
      'name' => 'My Reach Ad Set',
      'optimization_goal' => 'REACH',
      'billing_event' => 'IMPRESSIONS',
      'bid_amount' => '2',
      'daily_budget' => '1000',
      'campaign_id' => '{ad-campaign-id}',
      'targeting' => '{"geo_locations":{"countries":["US"]}}',
      'status' => 'PAUSED',
      'promoted_object' => '{"page_id":"{page-id}"}',
    ),
    '{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}/adsets",
    "POST",
    {
        "name": "My Reach Ad Set",
        "optimization_goal": "REACH",
        "billing_event": "IMPRESSIONS",
        "bid_amount": "2",
        "daily_budget": "1000",
        "campaign_id": "{ad-campaign-id}",
        "targeting": "{\"geo_locations\":{\"countries\":[\"US\"]}}",
        "status": "PAUSED",
        "promoted_object": "{\"page_id\":\"{page-id}\"}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("name", "My Reach Ad Set");
params.putString("optimization_goal", "REACH");
params.putString("billing_event", "IMPRESSIONS");
params.putString("bid_amount", "2");
params.putString("daily_budget", "1000");
params.putString("campaign_id", "{ad-campaign-id}");
params.putString("targeting", "{\"geo_locations\":{\"countries\":[\"US\"]}}");
params.putString("status", "PAUSED");
params.putString("promoted_object", "{\"page_id\":\"{page-id}\"}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/act_{ad-account-id}/adsets",
    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 Reach Ad Set",
  @"optimization_goal": @"REACH",
  @"billing_event": @"IMPRESSIONS",
  @"bid_amount": @"2",
  @"daily_budget": @"1000",
  @"campaign_id": @"{ad-campaign-id}",
  @"targeting": @"{\"geo_locations\":{\"countries\":[\"US\"]}}",
  @"status": @"PAUSED",
  @"promoted_object": @"{\"page_id\":\"{page-id}\"}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/act_{ad-account-id}/adsets"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
curl -X POST \
     -d "name=My+Reach+Ad+Set" \
     -d "optimization_goal=REACH" \
     -d "billing_event=IMPRESSIONS" \
     -d "bid_amount=2" \
     -d "daily_budget=1000" \
     -d "campaign_id=%7Bad-campaign-id%7D" \
     -d "targeting=%7B%22geo_locations%22%3A%7B%22countries%22%3A%5B%22US%22%5D%7D%7D" \
     -d "status=PAUSED" \
     -d "promoted_object=%7B%22page_id%22%3A%22%7Bpage-id%7D%22%7D" \
        https://graph.facebook.com/v2.12/act_{ad-account-id}/adsets
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

NameDescription
adlabels
list<Object>

Specifies list of labels to be associated with this object. This field is optional

adset_schedule
list<Object>

Ad set schedule, representing a delivery schedule for a single day

start_minute
int64

A 0 based minute of the day representing when the schedule starts

Required
end_minute
int64

A 0 based minute of the day representing when the schedule ends

Required
days
list<int64>

Array of ints representing which days the schedule is active. Valid values are 0-6 with 0 representing Sunday, 1 representing Monday, ... and 6 representing Saturday.

Required
attribution_spec
list<JSON object>

Conversion attribution spec used for attributing conversions for optimization. Supported window lengths differ by optimization goal and campaign objective. See Validation, Attribution Spec.

event_type
enum {CLICK_THROUGH, VIEW_THROUGH}
Required
window_days
int64
Required
bid_amount
integer

Bid cap or target cost for this ad set. The bid cap used in a lowest cost bid strategy is defined as the maximum bid you want to pay for a result based on your optimization_goal. The target cost used in a target cost bid strategy lets Facebook bid to meet your target on average and keep costs stable as you spend. If an ad level bid_amount is specified, updating this value will overwrite the previous ad level bid. Either bid_amount or is_autobid is required unless you are using Reach and Frequency buying for your ad sets. The bid amount's unit is cents for currencies like USD, EUR, and the basic unit for currencies like JPY, KRW. The bid amount for ads with IMPRESSION or REACH as billing_event is per 1,000 occurrences, and has to be at least 2 US cents or more. For ads with other billing_events, the bid amount is for each occurrence, and has a minimum value 1 US cents. The minimum bid amounts of other currencies are of similar value to the US Dollar values provided.

billing_event
enum{APP_INSTALLS, CLICKS, IMPRESSIONS, LINK_CLICKS, NONE, OFFER_CLAIMS, PAGE_LIKES, POST_ENGAGEMENT, VIDEO_VIEWS}

The billing event that this ad set is using:
APP_INSTALLS: Pay when people install your app.
CLICKS: Deprecated.
IMPRESSIONS: Pay when the ads are shown to people.
LINK_CLICKS: Pay when people click on the link of the ad.
OFFER_CLAIMS: Pay when people claim the offer.
PAGE_LIKES: Pay when people like your page.
POST_ENGAGEMENT: Pay when people engage with your post.
VIDEO_VIEWS: Pay when people watch videos.

campaign_id
numeric string or integer

The ad campaign you wish to add this ad set to.

campaign_spec
Campaign spec

Provide name, objective and buying_type for a campaign you want to create. Otherwise you need to provide campaign_id for an existing ad campaign. For example:
-F 'campaign_spec={
  "name": "Inline created campaign",
  "objective": "CONVERSIONS",
  "buying_type": "AUCTION"
}'

creative_sequence
list<numeric string or integer>

Order of the adgroup sequence to be shown to users

daily_budget
int64

The daily budget defined in your account currency, allowed only for ad sets with a duration (difference between end_time and start_time) longer than 24 hours.
Either daily_budget or lifetime_budget must be greater than 0.

daily_imps
int64

Daily impressions. Available only for campaigns with buying_type=FIXED_CPM

end_time
datetime

End time, required when lifetime_budget is specified. e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. When creating a set with a daily budget, specify end_time=0 to set the set to be ongoing and have no end date. UTC UNIX timestamp

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.

frequency_control_specs
list<Object>

An array of frequency control specs for this ad set. As there is only one event type currently supported, this array has no more than one element. Writes to this field are only available in ad sets where REACH is the objective.

event
enum{IMPRESSIONS, VIDEO_VIEWS, VIDEO_VIEWS_2S}

Event name, only IMPRESSIONS currently.

Required
interval_days
integer

Interval period in days, between 1 and 90 (inclusive)

Required
max_frequency
integer

The maximum frequency, between 1 and 90 (inclusive)

Required
is_autobid
boolean

If autobid is set. With is_autobid=true, Facebook bids automatically on your behalf. This bid strategy is designed to provide you the lowest cost ad set. We try to get you the lowest cost results, based on your optimization_goal for ad delivery, and bid more as needed to spend your budget. You can provide a bid cap using the same lowest cost bid strategy by setting bid_amount and not setting is_autobid=true. Either bid_amount or is_autobid is required except if you are using Reach and Frequency buying. You cannot use this when billing_event=APP_INSTALLS or MOBILE_APP_INSTALLS. Learn more in Ads Help Center, About bid strategies: Lowest cost

is_average_price_pacing
boolean

Specifies whether average price pacing is enabled or not. This type of bid strategy is also described as a target cost bid strategy. You should provide a target so Facebook can bid to meet your target costs, on average. This also helps you keep costs stable as you spend with bid_amount and is_average_prcie_pacing=true. Default value false. Learn more in Ads Help Center, About bid strategies: Target cost

lifetime_budget
int64

Lifetime budget, defined in your account currency. If specified, you must also specify an end_time.
Either daily_budget or lifetime_budget must be greater than 0.

lifetime_imps
int64

Lifetime impressions. Available only for campaigns with buying_type=FIXED_CPM

name
string

Ad set name, max length of 400 characters.

Required
optimization_goal
enum{NONE, APP_INSTALLS, BRAND_AWARENESS, AD_RECALL_LIFT, CLICKS, ENGAGED_USERS, EVENT_RESPONSES, IMPRESSIONS, LEAD_GENERATION, LINK_CLICKS, OFFER_CLAIMS, OFFSITE_CONVERSIONS, PAGE_ENGAGEMENT, PAGE_LIKES, POST_ENGAGEMENT, REACH, SOCIAL_IMPRESSIONS, VIDEO_VIEWS, APP_DOWNLOADS, LANDING_PAGE_VIEWS, VALUE, REPLIES}

What the ad set is optimizing for.
APP_INSTALLS: Will optimize for people more likely to install your app.
AD_RECALL_LIFT: Optimize for people more likely to remember seeing your ads. You cannot set bid_amount, and is_autobid must be true if this goal is used.
ENGAGED_USERS: Will optimize for people more likely to take a particular action in your app.
EVENT_RESPONSES: Will optimize for people more likely to attend your event.
IMPRESSIONS: Will show the ads as many times as possible.
LEAD_GENERATION: Will optimize for people more likely to fill out a lead generation form.
LINK_CLICKS: Will optimize for people more likely to click in the link of the ad.
OFFER_CLAIMS: Will optimize for people more likely to claim the offer.
OFFSITE_CONVERSIONS: Will optimize for people more likely to make a conversion in the site
PAGE_ENGAGEMENT: Will optimize for people more likely to engage with your page.
PAGE_LIKES: Will optimize for people more likely to like your page.
POST_ENGAGEMENT: Will optimize for people more likely to engage with your post.
REACH: Optimize to reach the most unique users of each day or interval specified in frequency_control_specs.
SOCIAL_IMPRESSIONS: Increase the number of impressions with social context. I.e. with the names of one or more of the user's friends attached to the ad who have already liked the page or installed the app.
VIDEO_VIEWS: Will optimize for people more likely to watch videos.
VALUE: Will optimize for maximum total purchase value within the specified attribution window.

pacing_type
list<string>

Defines the pacing type, standard by default or using ad scheduling

promoted_object
Object

The object this ad set is promoting across all its ads. Required with certain campaign objectives.
CONVERSIONS

  • pixel_id (Conversion pixel ID)
  • pixel_id (Facebook pixel ID) and custom_event_type
  • pixel_id (Facebook pixel ID) and pixel_rule and custom_event_type
  • event_id (Facebook event ID) and custom_event_type
  • application_id, object_store_url, and custom_event_type for mobile app events
PAGE_LIKES
page_id
OFFER_CLAIMS
page_id
LINK_CLICKS
application_id and object_store_url for mobile app or Canvas app engagement link clicks
APP_INSTALLS
application_id and object_store_url
or application_id, object_store_url, and custom_event_type if the optimization_goal is OFFSITE_CONVERSIONS
PRODUCT_CATALOG_SALES
product_set_id,
or product_set_id and custom_event_type

When optimization_goal is LEAD_GENERATION, page_id needs to be passed as promoted_object.
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, ADD_TO_CART, ADD_TO_WISHLIST, INITIATED_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE, LEAD, COMPLETE_REGISTRATION, CONTENT_VIEW, SEARCH, LEVEL_ACHIEVED, ACHIEVEMENT_UNLOCKED, SPENT_CREDITS, OTHER}

The event from an App Event of a mobile app, or tag of an conversion pixel.

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

redownload
boolean

Allows you to specify that you would like to retrieve all fields of the set in your response. Default value: false.

rf_prediction_id
numeric string or integer

Reach and frequency prediction ID

start_time
datetime

The start time of the set, e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. UTC UNIX timestamp

status
enum{ACTIVE, PAUSED, DELETED, ARCHIVED}

Only ACTIVE and PAUSED are valid for creation. The other statuses can be used for update. If it is set to PAUSED, all its active ads will be paused and have an effective status ADSET_PAUSED.

targeting
Targeting object

An ad set's targeting structure. "countries" is required. See targeting.

time_based_ad_rotation_id_blocks
list<list<int64>>

Specify ad creative that displays at custom date ranges in a campaign as an array. A list of Adgroup IDs. The list of ads to display for each time range in a given schedule. For example display first ad in Adgroup for first date range, second ad for second date range, and so on. You can display more than one ad per date range by providing more than one ad ID per array. For example set time_based_ad_rotation_id_blocks to [[1], [2, 3], [1, 4]]. On the first date range show ad 1, on the second date range show ad 2 and ad 3 and on the last date range show ad 1 and ad 4. Use with time_based_ad_rotation_intervals to specify date ranges.

time_based_ad_rotation_intervals
list<int64>

Date range when specific ad creative displays during a campaign. Provide date ranges in an array of UNIX timestamps where each timestamp represents the start time for each date range. For example a 3-day campaign from May 9 12am to May 11 11:59PM PST can have three date ranges, the first date range starts from May 9 12:00AM to May 9 11:59PM, second date range starts from May 10 12:00AM to May 10 11:59PM and last starts from May 11 12:00AM to May 11 11:59PM. The first timestamp should match the campaign start time. The last timestamp should be at least 1 hour before the campaign end time. You must provide at least two date ranges. All date ranges must cover the whole campaign length, so any date range cannot exceed campaign length. Use with time_based_ad_rotation_id_blocks to specify ad creative for each date range.

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,
}
You can make a POST request to copies edge from the following paths:
When posting to this edge, an AdSet will be created.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
  • manage_pages
  • pages_show_list
Page management Apps
No data
Other Apps
No data

Parameters

NameDescription
campaign_id
numeric string or integer

Single ID of a campaign to make parent of the copy. The copy inherits all campaign settings, such as budget from the parent.Ignore if you want to keep the copy under the original campaign parent.

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

The end time of the set, 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 adset 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_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

The start time of the set, 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 adset will inherit the start time from the original set

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

ACTIVE: the copied adset will have active status. PAUSED: the copied adset will have paused status. INHERITED_FROM_SOURCE: the copied adset will have the status from the original set.

Return Type

This endpoint supports read-after-write and will read the node represented by copied_adset_id in the return type.
Struct {
copied_adset_id: numeric string,
ad_object_ids: List [
Struct {
ad_object_type: enum {unique_adcreative, ad, ad_set, campaign, topline, ad_account},
source_id: numeric string,
copied_id: numeric string,
}
],
}
You may perform a POST request to the following edge from this node:

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
294Managing advertisements requires an access token with the extended permission for ads_management
2625The request for a reach frequency campaign is invalid.
800Unknown data store API error
273This Ads API call requires the user to be admin of the ad account
331Your picture is too tall or too wide. Try to pick something closer to a square.
272This Ads API call requires the user to be admin of the application
384The video you tried to upload is too long. Please try again with a shorter video.

Updating

Examples

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;

$adset = new AdSet(<AD_SET_ID>, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
  AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
  AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::LINK_CLICKS,
  AdSetFields::BID_AMOUNT => 200,
));

$adset->update();
from facebookads.adobjects.adset import AdSet

adset = AdSet(fbid=<AD_SET_ID>, parent_id='act_<AD_ACCOUNT_ID>')
adset.update({
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.link_clicks,
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.bid_amount: 200,
})
adset.remote_update()
new AdSet(<AD_SET_ID>, context).update()
  .setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
  .setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_LINK_CLICKS)
  .setBidAmount(200L)
  .execute();
curl \
  -F 'billing_event=IMPRESSIONS' \
  -F 'optimization_goal=LINK_CLICKS' \
  -F 'bid_amount=200' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/<AD_SET_ID>

To update the end_time of an ad set, using ISO-8601 date-time format

use FacebookAds\Object\AdSet;

$adset = new AdSet('<AD_SET_ID>');
$adset->end_time = '2013-10-02T00:00:00-0700';
$adset->update();
from facebookads.objects import AdSet

adset = AdSet('<AD_SET_ID>')
adset[AdSet.Field.end_time] = '2013-10-02T00:00:00-0700'
adset.remote_update()
curl \
-F "end_time=2013-10-02T00:00:00-0700" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_SET_ID>"

To update the status of an ad set to paused

use FacebookAds\Object\AdSet;

$adset = new AdSet('<AD_SET_ID>');
$adset->campaign_status = AdSet::STATUS_PAUSED;
$adset->update();
from facebookads.objects import AdSet

adset = AdSet('<AD_SET_ID>')
adset[AdSet.Field.status] = AdSet.Status.paused
adset.remote_update()
curl \
-F "campaign_status=PAUSED" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_SET_ID>"

Remarks

An archived ad set can only update two fields: name and campaign_status. The campaign_status field can only be changed to DELETED.

A deleted ad set can only change its name.

There are two considerations to take into account when adjusting an ad set's budget value or budget type:

  • When updating a set's lifetime or daily budget to a lower value, the new value must be at least 10% greater than the current amount spent already. For example: if an ad set has a $1000 lifetime budget and has spend $300 so far, the lowest new lifetime budget would be $330.
  • Since v2.4, ad sets have a minimum required budget. Any update must take that into consideration. Check the details at the Create Considerations section from this page.
You can update an AdSet by making a POST request to /{ad_set_id}.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
Page management Apps
No data
Other Apps
No data

Parameters

NameDescription
account_id
numeric string

Ad Account ID

adlabels
list<Object>

Specifies list of labels to be associated with this object. This field is optional

adset_schedule
list<Object>

Ad set schedule, representing a delivery schedule for a single day

start_minute
int64

A 0 based minute of the day representing when the schedule starts

Required
end_minute
int64

A 0 based minute of the day representing when the schedule ends

Required
days
list<int64>

Array of ints representing which days the schedule is active. Valid values are 0-6 with 0 representing Sunday, 1 representing Monday, ... and 6 representing Saturday.

Required
attribution_spec
list<JSON object>

Conversion attribution spec used for attributing conversions for optimization. Supported window lengths differ by optimization goal and campaign objective. See Validation, Attribution Spec.

event_type
enum {CLICK_THROUGH, VIEW_THROUGH}
Required
window_days
int64
Required
bid_amount
integer

Bid cap or target cost for this ad set. The bid cap used in a lowest cost bid strategy is defined as the maximum bid you want to pay for a result based on your optimization_goal. The target cost used in a target cost bid strategy lets Facebook bid to meet your target on average and keep costs stable as you spend. If an ad level bid_amount is specified, updating this value will overwrite the previous ad level bid. Either bid_amount or is_autobid is required unless you are using Reach and Frequency buying for your ad sets. The bid amount's unit is cents for currencies like USD, EUR, and the basic unit for currencies like JPY, KRW. The bid amount for ads with IMPRESSION or REACH as billing_event is per 1,000 occurrences, and has to be at least 2 US cents or more. For ads with other billing_events, the bid amount is for each occurrence, and has a minimum value 1 US cents. The minimum bid amounts of other currencies are of similar value to the US Dollar values provided.

billing_event
enum{APP_INSTALLS, CLICKS, IMPRESSIONS, LINK_CLICKS, NONE, OFFER_CLAIMS, PAGE_LIKES, POST_ENGAGEMENT, VIDEO_VIEWS}

The billing event that this ad set is using:
APP_INSTALLS: Pay when people install your app.
CLICKS: Deprecated.
IMPRESSIONS: Pay when the ads are shown to people.
LINK_CLICKS: Pay when people click on the link of the ad.
OFFER_CLAIMS: Pay when people claim the offer.
PAGE_LIKES: Pay when people like your page.
POST_ENGAGEMENT: Pay when people engage with your post.
VIDEO_VIEWS: Pay when people watch videos.

creative_sequence
list<numeric string or integer>

Order of the adgroup sequence to be shown to users

daily_budget
int64

The daily budget defined in your account currency, allowed only for ad sets with a duration (difference between end_time and start_time) longer than 24 hours.
Either daily_budget or lifetime_budget must be greater than 0.

daily_imps
int64

Daily impressions. Available only for campaigns with buying_type=FIXED_CPM

end_time
datetime

End time, required when lifetime_budget is specified. e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. When creating a set with a daily budget, specify end_time=0 to set the set to be ongoing and have no end date. UTC UNIX timestamp

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_autobid
boolean

If autobid is set. With is_autobid=true, Facebook bids automatically on your behalf. This bid strategy is designed to provide you the lowest cost ad set. We try to get you the lowest cost results, based on your optimization_goal for ad delivery, and bid more as needed to spend your budget. You can provide a bid cap using the same lowest cost bid strategy by setting bid_amount and not setting is_autobid=true. Either bid_amount or is_autobid is required except if you are using Reach and Frequency buying. You cannot use this when billing_event=APP_INSTALLS or MOBILE_APP_INSTALLS. Learn more in Ads Help Center, About bid strategies: Lowest cost

is_average_price_pacing
boolean

Specifies whether average price pacing is enabled or not. This type of bid strategy is also described as a target cost bid strategy. You should provide a target so Facebook can bid to meet your target costs, on average. This also helps you keep costs stable as you spend with bid_amount and is_average_prcie_pacing=true. Default value false. Learn more in Ads Help Center, About bid strategies: Target cost

lifetime_budget
int64

Lifetime budget, defined in your account currency. If specified, you must also specify an end_time.
Either daily_budget or lifetime_budget must be greater than 0.

lifetime_imps
int64

Lifetime impressions. Available only for campaigns with buying_type=FIXED_CPM

name
string

Ad set name, max length of 400 characters.

optimization_goal
enum{NONE, APP_INSTALLS, BRAND_AWARENESS, AD_RECALL_LIFT, CLICKS, ENGAGED_USERS, EVENT_RESPONSES, IMPRESSIONS, LEAD_GENERATION, LINK_CLICKS, OFFER_CLAIMS, OFFSITE_CONVERSIONS, PAGE_ENGAGEMENT, PAGE_LIKES, POST_ENGAGEMENT, REACH, SOCIAL_IMPRESSIONS, VIDEO_VIEWS, APP_DOWNLOADS, LANDING_PAGE_VIEWS, VALUE, REPLIES}

What the ad set is optimizing for.
APP_INSTALLS: Will optimize for people more likely to install your app.
AD_RECALL_LIFT: Optimize for people more likely to remember seeing your ads. You cannot set bid_amount, and is_autobid must be true if this goal is used.
ENGAGED_USERS: Will optimize for people more likely to take a particular action in your app.
EVENT_RESPONSES: Will optimize for people more likely to attend your event.
IMPRESSIONS: Will show the ads as many times as possible.
LEAD_GENERATION: Will optimize for people more likely to fill out a lead generation form.
LINK_CLICKS: Will optimize for people more likely to click in the link of the ad.
OFFER_CLAIMS: Will optimize for people more likely to claim the offer.
OFFSITE_CONVERSIONS: Will optimize for people more likely to make a conversion in the site
PAGE_ENGAGEMENT: Will optimize for people more likely to engage with your page.
PAGE_LIKES: Will optimize for people more likely to like your page.
POST_ENGAGEMENT: Will optimize for people more likely to engage with your post.
REACH: Optimize to reach the most unique users of each day or interval specified in frequency_control_specs.
SOCIAL_IMPRESSIONS: Increase the number of impressions with social context. I.e. with the names of one or more of the user's friends attached to the ad who have already liked the page or installed the app.
VIDEO_VIEWS: Will optimize for people more likely to watch videos.
VALUE: Will optimize for maximum total purchase value within the specified attribution window.

pacing_type
list<string>

Defines the pacing type, standard by default or using ad scheduling

promoted_object
Object

The object this ad set is promoting across all its ads. Required with certain campaign objectives.
CONVERSIONS

  • pixel_id (Conversion pixel ID)
  • pixel_id (Facebook pixel ID) and custom_event_type
  • pixel_id (Facebook pixel ID) and pixel_rule and custom_event_type
  • event_id (Facebook event ID) and custom_event_type
  • application_id, object_store_url, and custom_event_type for mobile app events
PAGE_LIKES
page_id
OFFER_CLAIMS
page_id
LINK_CLICKS
application_id and object_store_url for mobile app or Canvas app engagement link clicks
APP_INSTALLS
application_id and object_store_url
or application_id, object_store_url, and custom_event_type if the optimization_goal is OFFSITE_CONVERSIONS
PRODUCT_CATALOG_SALES
product_set_id,
or product_set_id and custom_event_type

When optimization_goal is LEAD_GENERATION, page_id needs to be passed as promoted_object.
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, ADD_TO_CART, ADD_TO_WISHLIST, INITIATED_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE, LEAD, COMPLETE_REGISTRATION, CONTENT_VIEW, SEARCH, LEVEL_ACHIEVED, ACHIEVEMENT_UNLOCKED, SPENT_CREDITS, OTHER}

The event from an App Event of a mobile app, or tag of an conversion pixel.

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

redownload
boolean

Allows you to specify that you would like to retrieve all fields of the set in your response. Default value: false.

rf_prediction_id
numeric string or integer

Reach and frequency prediction ID

start_time
datetime

The start time of the set, e.g. 2015-03-12 23:59:59-07:00 or 2015-03-12 23:59:59 PDT. UTC UNIX timestamp

status
enum{ACTIVE, PAUSED, DELETED, ARCHIVED}

Only ACTIVE and PAUSED are valid for creation. The other statuses can be used for update. If it is set to PAUSED, all its active ads will be paused and have an effective status ADSET_PAUSED.

targeting
Targeting object

An ad set's targeting structure. "countries" is required. See targeting.

time_based_ad_rotation_id_blocks
list<list<int64>>

Specify ad creative that displays at custom date ranges in a campaign as an array. A list of Adgroup IDs. The list of ads to display for each time range in a given schedule. For example display first ad in Adgroup for first date range, second ad for second date range, and so on. You can display more than one ad per date range by providing more than one ad ID per array. For example set time_based_ad_rotation_id_blocks to [[1], [2, 3], [1, 4]]. On the first date range show ad 1, on the second date range show ad 2 and ad 3 and on the last date range show ad 1 and ad 4. Use with time_based_ad_rotation_intervals to specify date ranges.

time_based_ad_rotation_intervals
list<int64>

Date range when specific ad creative displays during a campaign. Provide date ranges in an array of UNIX timestamps where each timestamp represents the start time for each date range. For example a 3-day campaign from May 9 12am to May 11 11:59PM PST can have three date ranges, the first date range starts from May 9 12:00AM to May 9 11:59PM, second date range starts from May 10 12:00AM to May 10 11:59PM and last starts from May 11 12:00AM to May 11 11:59PM. The first timestamp should match the campaign start time. The last timestamp should be at least 1 hour before the campaign end time. You must provide at least two date ranges. All date ranges must cover the whole campaign length, so any date range cannot exceed campaign length. Use with time_based_ad_rotation_id_blocks to specify ad creative for each date range.

Return Type

This endpoint supports read-after-write and will read the node to which you POSTed.
Struct {
success: bool,
}
You may perform a POST request to the following edge from this node:

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
294Managing advertisements requires an access token with the extended permission for ads_management
2625The request for a reach frequency campaign is invalid.
800Unknown data store API error
273This Ads API call requires the user to be admin of the ad account
331Your picture is too tall or too wide. Try to pick something closer to a square.
272This Ads API call requires the user to be admin of the application
384The video you tried to upload is too long. Please try again with a shorter video.

Deleting

Examples

use FacebookAds\Object\AdSet;

$adset = new AdSet(<AD_SET_ID>);
$adset->deleteSelf();
from facebookads.adobjects.adset import AdSet

adset = AdSet(<AD_SET_ID>)
adset.remote_delete()
new AdSet(<AD_SET_ID>, context).update()
  .setStatus(AdSet.EnumStatus.VALUE_DELETED)
  .execute();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/<AD_SET_ID>/
You can delete an AdSet by making a DELETE request to /{ad_set_id}.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
Page management Apps
No data
Other Apps
No data

Parameters

This endpoint doesn't have any parameters.

Return Type

Struct {
success: bool,
}
You may perform a DELETE request to the following edge from this node:

Validation Rules

ErrorDescription
100Invalid parameter