Search code examples
facebookfacebook-marketing-api

Accessing Facebook Marketing API


I'm trying to create a Facebook ad using the Facebook Marketing API. I haven't used it before and was wondering how I gain access to the API.

I have an access token with ads_management permission but are any other steps necessary and how would I then access the API?

Thank you for your help.


Solution

  • Along with a access token with the appropriate scope you need a ad account and a Facebook application and to authorize the account as an advertiser for the app. Add the account under Advertising Accounts within Advanced settings of your app. See also the Facebook documentation page on Marketing API access at https://developers.facebook.com/docs/marketing-api/access. For now you should follow the Development access level.

    To get start with the API you'll need to know your Ad Account ID which you should have from the prior step. If not you can find it from https://www.facebook.com/ads/manager

    A simple example of using the API is to make a cURL request for the id and name of your ad account. Replace with your token and with the number ID retrieved from the above step.

    curl -G \
    -d "fields=name" \
    -d "access_token=<ACCESS_TOKEN>" \
    "https://graph.facebook.com/v2.4/act_<AD_ACCOUNT_ID>/
    

    For further API documentation see the getting started guide at https://developers.facebook.com/docs/marketing-api/getting-started and also the API overview at https://developers.facebook.com/docs/marketing-api/using-the-api.