Facebook Marketing API (MAPI)

Number of APIs: 32

This public collection contains common queries, sample responses, and links to supporting documentation for the Facebook Marketing API.

Requirements

To use this collection you must have:

Access tokens

The API supports both user and system user access tokens. You can get a user access token by loading your app in the app dashboard and Add Marketing API as a product to your app. Alternatively you can use the Graph API Explorer to generate one.

Since user access tokens expire after 24 hours, you'll likely want to generate a system user access token, which lasts up to 60 days (or permanently, if you wish). See System Users to learn how to create a system user and system user access token.

Once you have your token, save it as a current value in the Global environment.

Ad Account ID

You can get your Ad Account ID by signing into the Ads Manager. The ID appears in the URL as act=. Once you save this as a current value in the Global environment, go to the Facebook Marketing API (MAPI) AdAccount folder and run the GetAdAccount query. This will return your id with value act_, which you can save to your environment.

Permissions

The permissions you should request change depending on which API you want to access.

If your app is only managing your ad account, Standard Access and ads_read and ads_management permissions are sufficient. If your app is managing other people’s ad accounts, you need Advanced Access ads_read and/or ads_management permissions. See all available permissions for business apps.

Access token debugger

You can paste your token into the access token debugger to see what type of token it is and what permission you have granted to your app.

Pagination

Endpoints that return lists/collections may paginate results (you'll see previous and next properties in the response). Use the URLs from these properties to get the previous or next set of results. Note that if you click one of these links in Qodex, it will open a new query in a new tab which you must save before running (otherwise it can't read your environment variables), so you may wish to cut and paste the URL and run the query in the same tab in which it was returned.

  1. Ad-CopyAds - CopiesAd POST {{base_url}}/{{ad_id_awareness}}/copies?status_option=PAUSED&rename_options={"rename_strategy":"ONLY_TOP_LEVEL_RENAME"}

  2. Ad-UpdateEdit - UpdateAdNameStatus POST {{base_url}}/{{ad_id_awareness}}?name=PostManAdTrafficUpdate&status=PAUSED

  3. Users - GetAssginedUsers GET {{base_url}}/act_{{account_id}}/assigned_users?fields=id,tasks,user_type,permitted_tasks&business={{business_id}}

  4. Ad-GetAds - GetDetailsFromAdID GET {{base_url}}/{{ad_id}}/?fields=account_id,adset_id,bid_amount,campaign_id,configured_status,conversion_specs,created_time,creative,display_sequence,effective_status,id,last_updated_by_app_id,name,priority,recommendations,source_ad_id,status,targeting,tracking_specs,updated_time

  5. AdAccount - GetAgencies GET {{base_url}}/act_{{account_id}}/agencies?fields=permitted_tasks

  6. AdAccount - GetAdvertisableApplications GET {{base_url}}/act_{{account_id}}/advertisable_applications?fields=id,name,app_install_tracked,app_name,app_type,category,icon_url,ipad_app_store_id,iphone_app_store_id,link,mobile_web_url,object_store_urls,supported_platforms,website_url,photo_url,advertisable_app_events

  7. AdAccount - GetIGAccounts GET {{base_url}}/act_{{account_id}}/instagram_accounts?fields=id,username,profile_pic

  8. AdSets-CreateAdsets - CreateAdSetTrafficTargetIGDAOff POST {{base_url}}/act_{{account_id}}/adsets?campaign_id={{campaign_id_traffic}}&name=PostMancAdsetTrafficCampaignTargetIG&billing_event=LINK_CLICKS&targeting={ "age_max": 25, "age_min": 22, "geo_locations": { "countries": ["NP"], "location_types": ["home"] },"genders":[1],"publisher_platforms":["instagram"] }&start_time=2024-06-16T04:45:17+0000&status=PAUSED&dynamic_creative_optimization_mode=OFF

  9. AdAccount - GetAdAccount GET {{base_url}}/act_{{account_id}}

  10. Insights API-Report - GetReportIDBreakdownsResponse GET {{base_url}}/{{report_id_breakdowns}}/insights