Ad Campaign, Ad Set and Ads have one of following status types:
For background see Ads Developer Blog, Deleted versus Archived.
Live ad objects can have the following status:
ACTIVE
PAUSED
PENDING_REVIEW
CREDIT_CARD_NEEDED
PREAPPROVED
DISABLED
PENDING_PROCESS
WITH_ISSUES
Set the ad object to ARCHIVED
by setting status
field to ARCHIVED
. When an object status is set to ARCHIVED
, you can continue to query the details and stats based on the object id. However there is a maximum limit on the number of objects you can archive. So you should respect this limit and change status to DELETED
when you no longer need an object.
An ARCHIVED
object has only 2 fields you can change: name
and status
. You can also only change status
to DELETED
.
Set the ad object to DELETED
by either setting status
field to DELETED
or sending an HTTP DELETE
to that object. Once an object status is set to DELETED
, you cannot set it back to ARCHIVED
.
If you keep the deleted object ID, you can continue to retrieve stats or object details by querying the object ID. However you cannot retrieve the deleted objects as a connection object from a non deleted node or object. For example, <API_VERSION>/<AD_ID>/insights
works for a deleted object but <API_VERSION>/act_<AD_ACCOUNT_ID>/insights?level=ad
does not return stats for the deleted object.
After you delete an ad, it may still track impressions, clicks, and actions for 28 days after the date of last delivery. You can query insights for DELETED
objects using the ad.effective_status
filter.
If you have an ad set with 2 ads in it, and you delete one ad, the following 2 queries do not return the same results:
https://graph.facebook.com/v21.0
/<AD_SET_ID>/insights https://graph.facebook.com/v21.0
/<AD_ID>/insights
The ad set returns stats for both the deleted and the non-deleted ads in it. However when you query for ads in the ad set, you only see one ad:
https://graph.facebook.com/v21.0
/<AD_SET_ID>/ads
To avoid this scenario, you should delete ads 28 days after their last date of delivery to ensure stats no longer change. Also you should store the stats or ids of those objects in your own system before you delete them. This recommendation is optional:
You cannot change any field, except name
, for a DELETED
object.
This is how you typically manage object status:
deleted
state to reduce the limit.The status on ad objects works this way for the hierarchy of ad objects:
with_issues
, paused
, archived
, or deleted
for a campaign, all the objects below it automatically inherit that status. deleted
, you cannot retrieve the ad sets or ads below that campaign without explicitly specifying the IDs.with_issues
, paused
, archived
, or deleted
, the ad set or ad campaign containing that ad keep its original status and is available for retrieval.The following limits apply to ARCHIVED
objects for given ad account:
If you read archived
edges, you must specifically filter for the archived objects since we do not return them by default. If you read stats for an ad object, we include the stats of all children objects, no matter if the child is active
, archived
, or deleted
. Therefore you need no filter for insights on child objects.
Objects with statuses such as ACTIVE
, PAUSED
differ from those with ARCHIVED
status, and DELETED
. Here are the major differences.
Query | Live | ARCHIVED | DELETED |
---|---|---|---|
Exists in database | Yes | Yes | Yes |
Maximum number per ad account | 100,000 | No limit | |
Query as edges without filter | Yes | No | No |
Query as edges with status filter | Yes for objects of status contained in the filter | Yes if status filter contains | No if status filter does not contain |
Query by its own ID | Yes | Yes | Yes |
Stats aggregated in | Yes | Yes | Yes |
Stats included in the result list of | Yes | No | No |
Stats included in the result list of | Yes for objects of status contained in the filter | Yes for objects of status contained in the filter | No |
Insights shown with | Yes | Yes | Yes |
Status can be changed to | Any valid status |
| Cannot change |
To set an ad to be archived:
use FacebookAds\Object\Ad;
$ad = new Ad(<AD_ID>);
$ad->archive();
from facebookads.adobjects.ad import Ad
ad = Ad(ad_id)
ad.remote_archive()
new Ad(<AD_ID>, context).update()
.setStatus(Ad.EnumStatus.VALUE_ARCHIVED)
.execute();
curl \
-F 'status=ARCHIVED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<AD_ID>
To delete an ad:
use FacebookAds\Object\Ad;
$ad = new Ad(<AD_ID>);
$ad->deleteSelf();
from facebookads.adobjects.ad import Ad
ad = Ad(<AD_ID>)
ad.remote_delete()
new Ad(<AD_ID>, context).update()
.setStatus(Ad.EnumStatus.VALUE_DELETED)
.execute();
curl -X DELETE \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<AD_ID>/
To retrieve live subobjects of a live object, for example, all live ads of an ad campaign, not including ARCHIVED
or DELETED
ads:
curl -X GET \
-d 'fields="name"' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v21.0/<AD_CAMPAIGN_ID>/ads
To retrieve ARCHIVED
subobjects of a live object, for example, all ARCHIVED
ads of an ad set, requires the status filter:
curl -X GET \
-d 'effective_status=[
"ARCHIVED"
]' \
-d 'fields="name"' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v21.0/<AD_CAMPAIGN_ID>/ads