Marketing API Version

Ad Account Ads

Ads belonging to this ad account.

Reading

The ads of this ad account

Graph API Explorer
GET /v2.10/{ad-account-id}/ads HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{ad-account-id}/ads'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
/* make the API call */
FB.api(
    "/{ad-account-id}/ads",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{ad-account-id}/ads",
    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:@"/{ad-account-id}/ads"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

Developers usually request these permissions for this endpoint:

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

Parameters

NameDescription
ad_draft_id
numeric string

ad draft id

date_preset
enum{today, yesterday, this_month, last_month, this_quarter, lifetime, 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}

Predefine date range used to aggregate insights metrics

effective_status
list<string>

effective status

include_deleted
boolean

include deleted

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

Date range used to aggregate insights metrics

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.

updated_since
integer

updated since

Fields

Reading from this edge will return a JSON formatted result:

{ "data": [], "paging": {}, "summary": {} }

data

A list of Ad nodes.

paging

For more details about pagination, see the Graph API guide.

summary

Aggregated information about the edge, such as counts. Specify the fields to fetch in the summary param (like summary=insights).

FieldDescription

insights

Analytics summary for all objects

total_count

unsigned int32

Total number of objects

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
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
273This Ads API call requires the user to be admin of the ad account
278Reading advertisements requires an access token with the extended permission ads_read
272This Ads API call requires the user to be admin of the application

Creating

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

Permissions

Developers usually request these permissions for this endpoint:

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

Parameters

NameDescription
adlabels
list<Object>

Ad labels associated with this ad

adset_id
int64

The ID of the ad set, required on creation.

adset_spec
Ad set spec

The ad set spec for this ad. When the spec is provided, adset_id field is not required.

bid_amount
integer

Bid amount for this ad which will be used in auction instead of the ad set bid_amount, if specified. Any updates to the ad set bid_amount will overwrite this value with the new ad set value.

creative
AdCreative

This field is required for create. The ID or creative spec of the ad creative to be used by this ad. You can read more about creatives here. You may supply the ID within an object as follows:

{"creative_id": <CREATIVE_ID>}
or creative spec as follow:

{"creative": {\"name\": \"<NAME>\", \"object_story_spec\": <SPEC>}}

RequiredSupports Emoji
date_format
string

The format of the date.

display_sequence
int64

The sequence of the ad within the same campaign

execution_options
list<enum{validate_only, synchronous_ad_review, 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.
synchronous_ad_review: this option should not be used by itself. It should always be specified with validate_only. When these options are specified, the API call will perform Ads Integrity validations, which include message language checking, image 20% text rule, and so on, as well as the validation logics.
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.

name
string

Name of the ad.

Required
redownload
boolean

Set this value to true and the API will respond with all fields instead of just id.

status
enum{ACTIVE, PAUSED, DELETED, ARCHIVED}

Only ACTIVE and PAUSED are valid during creation. Other statuses can be used for update. When an ad is created, it will first go through ad review, and will have the ad status PENDING_REVIEW before it finishes review and reverts back to your selected status of ACTIVE or PAUSED. During testing, it is recommended to set ads to a PAUSED status so as to not incur accidental spend.

tracking_specs
Object

Tracking specs

Return Type

Struct {
id: numeric string,
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
500Message contains banned content
384The video you tried to upload is too long. Please try again with a shorter video.
2626The request for a reach frequency campaign has failed.
380There was a problem uploading your thumbnail file. Please try again.
331Your picture is too tall or too wide. Try to pick something closer to a square.
192Invalid phone number
800Unknown data store API error
300Edit failure

Updating

You can't perform this operation on this endpoint.

Deleting

You can't perform this operation on this endpoint.