Back

Facebook Ads API Essential Guide

Aug 3, 20246 minute read

What type of API does Facebook Ads provide?

Facebook Ads uses a GraphQL API. Key points:

  1. Facebook created GraphQL to address limitations they were facing with REST APIs when developing their mobile apps, particularly the News Feed feature.

  2. GraphQL was designed to solve some common problems with REST APIs, including over-fetching and under-fetching of data, the need for multiple API endpoints, and difficulties in handling different versions of mobile apps.

  3. GraphQL allows clients to specify exactly what data they need in a single request, which is then returned by the server in the same shape.

  4. Some key advantages of GraphQL include a typed schema that improves discoverability, flexible permissions for exposing certain functions while keeping others private, no need for versioning, and the ability to integrate multiple platforms and legacy systems.

  5. Facebook uses the same version of the GraphQL API across all its applications.

Does the Facebook Ads API have webhooks?

Availability of Webhooks

Yes, the official Facebook Ads API does have webhooks, but they are limited to specific features within the Marketing API.

Types of Events

The search results mention a few specific use cases for Facebook Ads API webhooks:

  1. Lead Ads: You can subscribe to webhooks for retrieving lead information from Lead Ads campaigns.
  2. Ad Approval: There was a question about using webhooks for ad approval events, suggesting that users are interested in such capabilities, although this specific functionality wasn't confirmed.

Key Points to Consider

  • Webhooks for the Facebook Ads API seem to be feature-specific rather than covering all aspects of ad management.
  • The availability of webhooks for Ads API has changed over time. Initially, it was thought that webhooks were only available for Pages and Users, but later it was confirmed that they do exist for certain Marketing API features.
  • The exact list of available webhook events may change over time, so it's always best to refer to the most up-to-date Facebook Developer documentation for the latest information.

Best Practices

  1. Always check the official Facebook Developer documentation for the most current information on webhook capabilities and supported events.
  2. When implementing webhooks, ensure you follow Facebook's security best practices to protect your endpoint and handle the data securely.
  3. Be aware that webhook functionality may be limited or change over time, so design your system to be flexible and adaptable to potential changes in the API.

For the most accurate and comprehensive list of webhook events available for the Facebook Ads API, it's recommended to consult the official Facebook Developer documentation or reach out to Facebook Developer Support.

Rate Limits and other limitations

Here are the key points about the API rate limits for the Facebook Ads API:

Ad Account Level API Limits

  • Rate limiting is applied at the ad account level [1].
  • Each API call is assigned a score (generally 1 point for read calls, 3 points for write calls) [1].
  • There is a maximum score enforced:
    • For apps in the development tier: 60 points, decays in 300 seconds, blocked for 300 seconds when limit reached [1].
    • For apps in the standard tier: 9000 points, decays in 300 seconds, blocked for 60 seconds when limit reached [1].

Business Use Case Rate Limits

  • Different limits apply for specific use cases like custom audiences, ads insights, catalog management, etc. [1]
  • For example, for ads management:
    • Standard tier: 100,000 + (40 * number of active ads) calls per ad account per hour [1]
    • Development tier: 300 + (40 * number of active ads) calls per ad account per hour [1]

Other Limits

  • Ad set budget changes are limited to 4 times per hour per ad set [1].
  • Ad creation is limited based on the daily spend limit of the ad account [1].
  • There are also app-level limits based on total users of an app [1].

Key Considerations

  • The Marketing API has its own rate limiting separate from the Graph API [1].
  • Rate limits depend on whether you have Standard Access or Advanced Access to the Ads Management Standard Access feature [1].
  • Limits can be checked via HTTP headers like X-Ad-Account-Usage and X-Business-Use-Case [1].
  • Implementing strategies like preventing burst traffic, optimizing requests, and using backoff when hitting limits is recommended [1].

Summary

The Facebook Ads API employs a complex system of rate limits at different levels (ad account, app, business use case) that vary based on your access tier and specific API endpoints being used. Carefully monitoring usage and implementing proper throttling strategies is crucial when working with this API.

Latest API Version

The most recent version of the Facebook Ads API (also known as the Marketing API) is v20.0 [2][3][4].

Key points to consider:

  1. Version v20.0 was released on May 21, 2024 [4].

  2. Facebook releases new versions of the Marketing API approximately every four months [1].

  3. Multiple versions of the API can exist simultaneously, with different functionalities in each version [1].

  4. Developers have at least a 90-day grace period to move to a new version after it's released [1].

  5. The currently available Marketing API versions are [3]:

    • v20.0 (introduced May 21, 2024, available until TBD)
    • v19.0 (introduced January 23, 2024, available until February 4, 2025)
    • v18.0 (introduced September 12, 2023, available until August 13, 2024)
  6. Starting May 2024, Facebook introduced an auto-version upgrade feature for Marketing API endpoints that are not affected between versions [1].

Best practices:

  1. Always specify the API version in your requests to ensure consistent behavior [1].

  2. Regularly check the Marketing API Changelog for updates and affected endpoints [1].

  3. Plan to upgrade your integration to the latest version before the deprecation of the version you're currently using [1].

  4. Be aware of upcoming deprecations and plan accordingly [4].

  5. Consider using the Facebook Business SDK for easier API integration [2].

By staying up-to-date with the latest version and following these best practices, you can ensure your integration with the Facebook Ads API remains stable and takes advantage of the latest features and improvements.

How to get a Facebook Ads developer account and API Keys?

To get a developer account for Facebook Ads and create an API integration, you need to follow these steps:

1. Create a Developer App

  • Go to the Facebook for Developers website and click on "My Apps" > "Create App".
  • You can also use an existing app if you already have one.

2. Set Up a Business Manager Account

  • You must be an admin of your Business Manager account.
  • If you don't have a Business Manager account, create one before proceeding.

3. Create a System User

  • It's recommended to use access tokens backed by a system user for accessing the Commerce API.
  • Add your app to your Business Manager if you haven't already done so.
  • Add system users to your Business Manager or use an existing system user in your business.

4. Assign Assets

  • Assign your system user admin access to the following assets in your Business Manager:
    • The app you use for the Commerce API
    • The test commerce account you created
    • The Facebook Page backing your test commerce account
    • The catalog connected to your test commerce account

5. Generate a System User Access Token

  • On the Business Manager > System User page, click "Add Assets" and assign the system user as an admin of your app.
  • Click "Generate Token" to generate an access token.
  • Request the following permissions when generating the access token:
    • pages_read_engagement
    • catalog_management (if you plan to use API to manage catalogs)
    • business_management (if you plan to use API to manage business assets)
  • If you were granted access to the Commerce API after Oct 20, 2020, you also need to request these permissions:
    • commerce_manage_accounts or commerce_account_read_settings
    • commerce_account_manage_orders or commerce_account_read_orders
    • commerce_account_read_reports (to access the Finance Reporting API)

6. Generate a Page Access Token

  • Every commerce account is backed by a Facebook Page. You need a Page access token tied to that page.
  • Learn how to obtain a Page access token using the System User access token.
  • Store this token securely and consider rotating it regularly.

7. Connect Your App to a Commerce Account

  • Make a one-time API call to connect your app to your test commerce account.
  • This step is necessary for connecting your app to any new Commerce account you want to manage.

8. Start Building and Testing

  • Begin managing your orders placed in your test commerce account using the Order Management API.
  • Once you demonstrate your integration on a test account, submit your app for App Review to manage a real commerce account.

What can you do with the Facebook Ads API?

Based on the search results provided, here is a list of key data models you can interact with using the Facebook Ads API, along with what is possible for each:

Ad Account

  • Retrieve all ad accounts associated with a user
  • Access account-level insights and performance data
  • Manage users associated with the account

Campaign

  • Create and manage ad campaigns
  • Access campaign-level insights and performance data
  • Manage ad sets and ads within campaigns

Ad Set

  • Create and manage ad sets
  • Access ad set-level insights and performance data
  • Manage ads within ad sets
  • Create and manage individual ads
  • Access ad-level insights and performance data
  • Retrieve ad creatives and preview ads

Ad Creative

  • Create and manage ad creatives (appearance and content of ads)
  • Access ad creative data
  • Generate ad previews

Custom Audience

  • Create and manage custom audiences for targeting

Insights

  • Retrieve detailed performance data for accounts, campaigns, ad sets, and ads
  • Access over 70 different metrics and dimensions
  • Apply various breakdowns, date ranges, and filters to customize reports

Catalog

  • Manage product catalogs for dynamic ads
  • Upload and update inventory information

Conversions API

  • Connect advertiser's marketing data with Meta's systems
  • Optimize ad targeting and measure results

Business Management

  • Create and maintain a business's organic and paid presence across Meta platforms

Ad Image and Video

  • Manage libraries of images and videos for use in ad creatives

Lead

  • Retrieve lead information associated with Lead Ads

For each of these data models, you can typically perform CRUD operations (Create, Read, Update, Delete) where applicable, as well as access related data and insights. The API allows for programmatic management of all aspects of Facebook advertising campaigns, from creation to optimization and reporting.