### Get Started with Conversions API Source: https://developers.facebook.com/docs/marketing-api/conversions-api Guides users through the initial steps required to set up and start using the Conversions API. ```APIDOC ## Get Started with Conversions API ### Description This guide walks you through the essential steps to begin using the Conversions API. It covers prerequisites, obtaining necessary credentials, and making your first API calls. ### Prerequisites - A Facebook Business Manager account. - An Ad Account ID. - A Pixel ID (optional, but recommended for certain features). ### Steps 1. **Obtain Access Token**: Generate an access token with the necessary permissions. 2. **Identify Event Source**: Determine the source of your events (website, app, offline). 3. **Configure API Endpoint**: Set up the correct API endpoint URL. 4. **Construct Event Payload**: Prepare the data for the events you want to send. 5. **Send Events**: Make the API request to send events to Facebook. ``` -------------------------------- ### Install Event Payload with Custom Data Source: https://developers.facebook.com/docs/marketing-api/conversions-api/app-events This example shows the structure of an Install event payload, demonstrating how to include custom user and app data. ```json { "data": [ { "event_name": "MobileAppInstall", "event_time": 1684389252, "action_source": "app", "user_data": { "client_ip_address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "madid": "38400000-8cf0-11bd-b23e-10b96e40000d", "anon_id": "12345340-1234-3456-1234-123456789012" }, "app_data": { "advertiser_tracking_enabled": 1, "application_tracking_enabled": 1, "extinfo": [ "a2", "com.some.app", "771", "Version 7.7.1", "10.1.1", "OnePlus6", "en_US", "GMT-1", "TMobile", "1920", "1080", "2.00", "2", "128", "8", "USA/New York" ] } } ] } ``` -------------------------------- ### Example GET Request for Users Source: https://developers.facebook.com/docs/admin-center/api-reference/account-management-api An example of a GET request to the Users endpoint, including required headers for authorization and user agent. ```http GET /Users/ HTTP/1.1 Host: scim.workplace.com Authorization: Bearer {your access token} User-Agent: {your user agent} ``` -------------------------------- ### Example Budget Schedule Specification Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group Demonstrates how to specify a budget schedule with start and end times, budget value, and budget value type. ```bash -F 'budget_schedule_specs=[ { "time_start":1699081200, "time_end":1699167600, "budget_value":100, "budget_value_type":"ABSOLUTE" } ]' ``` -------------------------------- ### Example Install Referrer Decryption Key Source: https://developers.facebook.com/docs/app-ads/install-referrer This is an example of the decryption key provided by Facebook for your app. Use this key in Step 3 to decrypt the install referrer data. ```text 2575590594a9cd809e5bfacf397f8c1ac730dbc38a3e137ecd1ab66591c8c3c9M ``` -------------------------------- ### Creating an Ad Set Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign This example demonstrates how to create a new ad set with a daily budget, campaign objective, targeting, and other relevant parameters. It validates the setup for a campaign objective set to APP_INSTALLS. ```APIDOC ## Creating an Ad Set ### Description Creates a new ad set with specified parameters, including name, budget, bid, optimization goal, campaign association, targeting, and status. This example specifically validates settings for an App Installs campaign. ### Method POST ### Endpoint `https://graph.facebook.com/v25.0/act_/adsets` ### Parameters #### Form Data Parameters - **name** (string) - Required - The name of the ad set. - **daily_budget** (number) - Required - The daily budget for the ad set in USD. - **bid_amount** (number) - Required - The bid amount for the ad set in USD. - **billing_event** (string) - Required - The billing event for the ad set (e.g., IMPRESSIONS, CLICKS). - **optimization_goal** (string) - Required - The optimization goal for the ad set (e.g., APP_INSTALLS). - **campaign_id** (string) - Required - The ID of the campaign this ad set belongs to. - **promoted_object** (object) - Required - An object containing details of the promoted object, such as application ID and store URL. - **application_id** (string) - Required - The ID of the application being promoted. - **object_store_url** (string) - Required - The URL of the application in the app store. - **targeting** (object) - Required - An object defining the targeting criteria for the ad set. - **device_platforms** (array of strings) - Required - The device platforms to target (e.g., "mobile"). - **facebook_positions** (array of strings) - Required - The Facebook placements to target (e.g., "feed"). - **geo_locations** (object) - Required - The geographic locations to target. - **countries** (array of strings) - Required - The countries to target (e.g., "US"). - **publisher_platforms** (array of strings) - Required - The publisher platforms to target (e.g., "facebook", "audience_network"). - **user_os** (array of strings) - Required - The user operating systems to target (e.g., "IOS"). - **status** (string) - Required - The status of the ad set (e.g., "PAUSED"). - **access_token** (string) - Required - The user's OAuth 2.0 access token. ### Request Example ```json { "name": "Mobile App Installs Ad Set", "daily_budget": 1000, "bid_amount": 2, "billing_event": "IMPRESSIONS", "optimization_goal": "APP_INSTALLS", "campaign_id": "", "promoted_object": { "application_id": "", "object_store_url": "" }, "targeting": { "device_platforms": [ "mobile" ], "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ], "user_os": [ "IOS" ] }, "status": "PAUSED", "access_token": "" } ``` ### Response #### Success Response (200) Details of the created ad set, including its ID and status. #### Response Example ```json { "id": "", "name": "Mobile App Installs Ad Set", "status": "PAUSED" } ``` ``` -------------------------------- ### Create Ad and Get Details Source: https://developers.facebook.com/docs/graph-api/batch-requests This example shows how to create a new ad for a campaign and then retrieve its details in a single batch request, demonstrating URL encoding for the body parameter. ```APIDOC ## POST /batch ### Description Creates a new ad for a campaign and then retrieves the details of the newly created object. ### Method POST ### Endpoint https://graph.facebook.com ### Parameters #### Request Body - **batch** (string) - Required - A JSON array of operations to perform. - **access_token** (string) - Required - The access token for authentication. ### Request Example ```json { "batch": [ { "method": "POST", "name": "create-ad", "relative_url": "11077200629332/ads", "body": "ads=%5B%7B%22name%22%3A%22test_ad%22%2C%22billing_entity_id%22%3A111200774273%7D%5D" }, { "method": "GET", "relative_url": "?ids={result=create-ad:$.data.*.id}" } ] } ``` ### Response #### Success Response (200) An array of results for each operation in the batch. #### Response Example (Response structure will vary based on the operations performed) ``` -------------------------------- ### Create Ad Set with Lifetime Budget Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign This example shows how to create an ad set with a specified lifetime budget, including start and end times, and targeting. ```APIDOC ## Create Ad Set with Lifetime Budget ### Description Creates a new ad set with a lifetime budget, defining budget, schedule, targeting, and campaign association. ### Method POST ### Endpoint https://graph.facebook.com/v25.0/act_/adsets ### Parameters #### Request Body - **name** (string) - Required - The name of the ad set. - **lifetime_budget** (number) - Required - The total lifetime budget for the ad set. - **start_time** (string) - Required - The start time for the ad set's schedule. - **end_time** (string) - Required - The end time for the ad set's schedule. - **campaign_id** (string) - Required - The ID of the campaign this ad set belongs to. - **bid_amount** (number) - Required - The bid amount. - **billing_event** (string) - Required - The event to bill for (e.g., LINK_CLICKS). - **optimization_goal** (string) - Required - The goal to optimize for (e.g., LINK_CLICKS). - **targeting** (object) - Required - Targeting specifications, including publisher platforms and geo_locations. - **status** (string) - Required - The status of the ad set (e.g., PAUSED). - **access_token** (string) - Required - User's access token. ### Request Example ```json { "name": "My First Adset", "lifetime_budget": 20000, "start_time": "2025-12-04T20:32:30-0800", "end_time": "2025-12-14T20:32:30-0800", "campaign_id": "", "bid_amount": 100, "billing_event": "LINK_CLICKS", "optimization_goal": "LINK_CLICKS", "targeting": { "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ] }, "status": "PAUSED", "access_token": "" } ``` ### Response #### Success Response (200) Details about the created ad set. #### Response Example (Response structure not provided in source) ``` -------------------------------- ### Example Key Hash Output Source: https://developers.facebook.com/docs/android/getting-started This is an example of the key hash output that will appear in your logcat after running the modified sample code. ```logcat 12-20 10:47:37.747: D/KeyHash:(936): 478uEnKQV+fMQT8Dy4AKvHkYibo= ``` -------------------------------- ### Create a desktop app install video ad Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads This endpoint allows you to create a video ad for desktop app installs. ```APIDOC ## POST /v25.0//videos ### Description Creates a video ad for desktop app installs. ### Method POST ### Endpoint https://graph.facebook.com/v25.0//videos ### Parameters #### Request Body - **name** (string) - Required - The name of the video. - **message** (string) - Required - The message for the ad. - **thumbnail** (string) - Required - The URL of the thumbnail. - **published** (boolean) - Required - Whether the video should be published immediately. - **call_to_action** (object) - Required - Specifies the call to action type and value. - **type** (string) - Required - The type of call to action (e.g., "PLAY_GAME"). - **value** (object) - Required - The value associated with the call to action. - **link** (string) - Required - The link to the app store. - **source** (file) - Required - The path to the video file. - **access_token** (string) - Required - The access token for the API. ### Request Example ```json { "name": "My Video", "message": "Check out this app!", "thumbnail": "", "published": 0, "call_to_action": {"type":"PLAY_GAME","value":{"link":""}}, "source": "@", "access_token": "" } ``` ### Response #### Success Response (200) Details about the created video ad. #### Response Example ```json { "id": "" } ``` ``` -------------------------------- ### Install Yarn dependencies Source: https://developers.facebook.com/docs/messenger-platform/instagram/sample-experience Install project dependencies using Yarn. ```bash $ yarn install ``` -------------------------------- ### Create Ad and Get Details in Batch Request Source: https://developers.facebook.com/docs/graph-api/batch-requests This example creates a new ad and then retrieves its details using a batch request. Note the URL encoding required for the 'body' parameter when passing complex data structures. ```curl curl \ -F 'access_token=...' \ -F 'batch=[ { "method":"POST", "name":"create-ad", "relative_url":"11077200629332/ads", "body":"ads=%5B%7B%22name%22%3A%22test_ad%22%2C%22billing_entity_id%22%3A111200774273%7D%5D" }, { "method":"GET", "relative_url":"?ids={result=create-ad:$.data.*.id}" }]' \ https://graph.facebook.com ``` -------------------------------- ### Set up .env file Source: https://developers.facebook.com/docs/messenger-platform/instagram/sample-experience Copy the sample environment file to .env and edit it with your app and page values. ```bash $ cp .sample.env .env ``` -------------------------------- ### Search Locales with Facebook Marketing API Source: https://developers.facebook.com/docs/marketing-api/audiences/reference/targeting-search Use the `adlocale` type to search for locales. This example searches for all locales starting with 'en'. To get all locales, leave 'q' blank and set a high limit. ```curl curl -G \ -d 'type=adlocale' \ -d 'q=en' \ -d 'access_token=' \ https://graph.facebook.com/v/search ``` -------------------------------- ### Set up Catalog with Video Support Source: https://developers.facebook.com/docs/marketing-api/dynamic-ads/get-started This XML example demonstrates how to set up a catalog for Advantage+ catalog ads, including adding video assets. The `url` and `tag` fields are supported for video, with currently only one video supported per product. ```xml   Test hotel feed       hotel_1     Test Hotel 1     A very nice hotel     Facebook            180 Hamilton Ave       Palo Alto       12345       California       94301       United States          37.4435997     -122.1615219     Palo Alto     Silicon Valley     8     200.5 USD     +1 650 666-3311     2.5            7.8       tripAdvisor       300                 9.8       Hotels.com       35000                 https://media-cdn.tripadvisor.com/media/photo-o/05/ca/40/af/the-epiphany-a-joie-de.jpg       front view       first image                 http://www.jdvhotels.com/content/uploads/2014/06/72-1200x800.jpg       room       bed          Starwood     http://www.jdvhotels.com/hotels/california/silicon-valley-hotels/the-epiphany-hotel/                *    *    ``` -------------------------------- ### Example Execution Options Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group Shows how to use execution options for validation and including recommendations in API calls. ```bash execution_options=["validate_only", "include_recommendations"] ``` -------------------------------- ### Read Ad Creative Link Data Image Layer Spec (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/ad-creative-link-data-image-layer-spec This PHP SDK example demonstrates how to make a GET request to retrieve the Ad Creative Link Data Image Layer Spec. Ensure you have the Facebook SDK for PHP installed and configured. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '...?fields={fieldname_of_type_AdCreativeLinkDataImageLayerSpec}', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Create a Desktop App Ads for Virtual Goods Image Ad Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads Use this example to create an image ad for desktop apps, specifically for promoting virtual goods. The `BUY_NOW` call to action is utilized. ```bash curl \ -F 'message=Buy coins now!' \ -F 'picture=' \ -F 'link=' \ -F 'published=1' \ -F 'call_to_action={"type":"BUY_NOW","value":{"link":"","product_link":""}}' \ -F 'access_token=' \ https://graph.facebook.com/v25.0//feed ``` -------------------------------- ### Graph API GET Request Example Source: https://developers.facebook.com/docs/graph-api/overview This example shows how to make a GET request to retrieve a Facebook profile picture using cURL. It demonstrates direct browser interaction and cURL command-line usage. ```HTTP https://graph.facebook.com/facebook/picture?redirect=false ``` ```cURL curl -i -X GET "https://graph.facebook.com/facebook/picture?redirect=false" ``` -------------------------------- ### Get Mobile App Install Insights Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads Retrieve aggregated daily insights on app installations. Requires an app access token. ```URL https://graph.facebook.com/v25.0//insights/application_mobile_app_installs?&access_token= ``` -------------------------------- ### Create Legacy Campaign Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group Use this example to create a new campaign with a legacy objective such as APP_INSTALLS. Replace ACCESS_TOKEN and AD_ACCOUNT_ID with your specific values. ```bash curl -X POST \ -F 'name="New Campaign"' \ -F 'objective="APP_INSTALLS"' \ -F 'status="PAUSED"' \ -F 'special_ad_categories=[]' \ -F 'access_token=ACCESS_TOKEN \ https://graph.facebook.com/v11.0/\n act_AD_ACCOUNT_ID/campaigns ``` -------------------------------- ### Initialize All Source: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/all/all.html This snippet shows the basic initialization of the 'All' functionality. ```java All() ``` -------------------------------- ### Get Mobile App Install Insights with Breakdown Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads Break down app installation insights by gender/age, country, or locale. Only one breakdown parameter can be used at a time. ```URL https://graph.facebook.com/v25.0//insights/application_mobile_app_installs?breakdown=gender_age&access_token= ``` ```URL https://graph.facebook.com/v25.0//insights/application_mobile_app_installs?breakdown=country&access_token= ``` ```URL https://graph.facebook.com/v25.0//insights/application_mobile_app_installs?breakdown=locale&access_token= ``` -------------------------------- ### Get Instagram Ice Breakers Source: https://developers.facebook.com/docs/messenger-platform/instagram/features/ice-breakers Use this GET request to retrieve the currently configured ice breakers for your Instagram business. This helps in verifying the setup or fetching existing configurations. ```curl curl -X GET "https://graph.facebook.com/v11.0/me/messenger_profile?fields=ice_breakers&platform=instagram&access_token=" ``` -------------------------------- ### Creating an Ad Set Source: https://developers.facebook.com/docs/marketing-api/adset This example demonstrates how to create a new ad set with a daily budget, specifying campaign objective, targeting, and other relevant parameters. ```APIDOC ## POST /act_/adsets ### Description Creates a new ad set with specified parameters. ### Method POST ### Endpoint https://graph.facebook.com/v25.0/act_/adsets ### Parameters #### Request Body - **name** (string) - Required - The name of the ad set. - **daily_budget** (float) - Required - The daily budget for the ad set. - **bid_amount** (float) - Required - The bid amount for the ad set. - **billing_event** (string) - Required - The billing event for the ad set (e.g., IMPRESSIONS, CLICKS). - **optimization_goal** (string) - Required - The optimization goal for the ad set (e.g., APP_INSTALLS). - **campaign_id** (string) - Required - The ID of the campaign to which this ad set belongs. - **promoted_object** (object) - Required - The object being promoted (e.g., application details). - **application_id** (string) - Required - The ID of the application. - **object_store_url** (string) - Required - The URL of the app in the app store. - **targeting** (object) - Required - The targeting criteria for the ad set. - **device_platforms** (array) - Required - The device platforms to target (e.g., ["mobile"]). - **facebook_positions** (array) - Required - The Facebook placements to target (e.g., ["feed"]). - **geo_locations** (object) - Required - The geographic locations to target. - **countries** (array) - Required - The countries to target (e.g., ["US"]). - **publisher_platforms** (array) - Required - The publisher platforms to target (e.g., ["facebook", "audience_network"]). - **user_os** (array) - Required - The user operating systems to target (e.g., ["IOS"]). - **status** (string) - Optional - The status of the ad set (e.g., "PAUSED"). - **access_token** (string) - Required - The access token for authentication. ### Request Example ```json { "name": "Mobile App Installs Ad Set", "daily_budget": 1000, "bid_amount": 2, "billing_event": "IMPRESSIONS", "optimization_goal": "APP_INSTALLS", "campaign_id": "", "promoted_object": { "application_id": "", "object_store_url": "" }, "targeting": { "device_platforms": [ "mobile" ], "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ], "user_os": [ "IOS" ] }, "status": "PAUSED", "access_token": "" } ``` ### Considerations #### Bid/Budget Validations - All values are in US Dollars. - Minimum daily budget limits vary by currency and billing event. - Minimum budget considers total spent budget. - If `bid_strategy` is `LOWEST_COST_WITHOUT_CAP`: - Impressions: $0.50 - Clicks/Likes/Video Views: $2.50 - Low-frequency Actions: $40 - If `bid_strategy` is `LOWEST_COST_WITH_BID_CAP`: - Impressions: At least the `bid_amount`. - Clicks/Actions: 5x the `bid_amount`. - Budgets in non-USD currencies are converted and validated. - For specific countries (Australia, Austria, Belgium, Canada, Denmark, Finland, France, Germany, Greece, Hong Kong, Israel, Italy, Japan, Netherlands, New Zealand, Norway, Singapore, South Korea, Spain, Sweden, Switzerland, Taiwan, United Kingdom, United States of America), minimum values are 2x the standard, except for Low-Frequency Actions with `LOWEST_COST_WITHOUT_CAP`. ``` -------------------------------- ### getEVENT_NAME_START_TRIAL Source: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/appevents/appeventsconstants.html The start of a free trial of a product or service you offer (example: trial subscription). ```APIDOC ## getEVENT_NAME_START_TRIAL ### Description The start of a free trial of a product or service you offer (example: trial subscription). ### Method Signature ```java final String getEVENT_NAME_START_TRIAL() ``` ``` -------------------------------- ### Create a Mobile App Install Video Ad Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads This snippet demonstrates how to create a video ad to drive mobile app installs. Ensure the `thumbnail` and `source` parameters are correctly set. ```bash curl \ -F 'name=My Video' \ -F 'message=Check out this app!' \ -F 'thumbnail=' \ -F 'published=0' \ -F 'call_to_action={"type":"INSTALL_MOBILE_APP","value":{"link":""}}' \ -F 'source=@' \ -F 'access_token=' \ https://graph.facebook.com/v25.0//videos ``` -------------------------------- ### Get Mobile App Installs Insights Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads Retrieve aggregated daily insights on the demographics of people who installed your app. Insights are available for ads with a promoted object containing the app ID. ```APIDOC ## GET /insights ### Description Retrieves aggregated daily insights on the demographics of people who installed your app. This requires an app access token and an app ID. ### Method GET ### Endpoint `https://graph.facebook.com/v25.0//insights/application_mobile_app_installs` ### Parameters #### Query Parameters - **access_token** (string) - Required - Your app access token. - **breakdown** (string) - Optional - Specifies how to break down the statistics. Accepted values are `gender_age`, `country`, or `locale`. Cannot be combined. ### Request Example ``` https://graph.facebook.com/v25.0//insights/application_mobile_app_installs?breakdown=gender_age&access_token= ``` ### Response #### Success Response (200) Details about the response schema are not provided in the source. ``` -------------------------------- ### Security Audit Logs API Request Example Source: https://developers.facebook.com/docs/admin-center/api-reference/security-log-api Example HTTP GET request to retrieve security audit logs. Ensure you include your access token and user agent in the headers. ```HTTP GET /security_audit_logs/ HTTP/1.1 Host: graph.work.meta.com Authorization: Bearer {your access token} User-Agent: {your user agent} ``` -------------------------------- ### Run the app locally Source: https://developers.facebook.com/docs/messenger-platform/instagram/sample-experience Start the local application server using Node.js. ```bash $ node app.js ``` -------------------------------- ### Create Ad Set with Daily Budget Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign This example demonstrates how to create a new ad set with a specified daily budget, targeting, and optimization goal. ```APIDOC ## Create Ad Set with Daily Budget ### Description Creates a new ad set with a daily budget, specifying targeting options, optimization goals, and campaign association. ### Method POST ### Endpoint https://graph.facebook.com/v25.0/act_/adsets ### Parameters #### Request Body - **name** (string) - Required - The name of the ad set. - **optimization_goal** (string) - Required - The goal to optimize for (e.g., REACH, LINK_CLICKS). - **billing_event** (string) - Required - The event to bill for (e.g., IMPRESSIONS, LINK_CLICKS). - **bid_amount** (number) - Required - The bid amount. - **daily_budget** (number) - Required - The daily budget for the ad set. - **campaign_id** (string) - Required - The ID of the campaign this ad set belongs to. - **targeting** (object) - Required - Targeting specifications, including geo_locations and facebook_positions. - **status** (string) - Required - The status of the ad set (e.g., PAUSED). - **promoted_object** (object) - Required - Information about the object being promoted, including page_id. - **access_token** (string) - Required - User's access token. ### Request Example ```json { "name": "My Reach Ad Set", "optimization_goal": "REACH", "billing_event": "IMPRESSIONS", "bid_amount": 2, "daily_budget": 1000, "campaign_id": "", "targeting": { "geo_locations": { "countries": [ "US" ] }, "facebook_positions": [ "feed" ] }, "status": "PAUSED", "promoted_object": { "page_id": "" }, "access_token": "" } ``` ### Response #### Success Response (200) Details about the created ad set. #### Response Example (Response structure not provided in source) ``` -------------------------------- ### Search Education Majors Source: https://developers.facebook.com/docs/marketing-api/audiences/reference/targeting-search Target majors by an id and name. This example searches for all majors that start with 'ph'. ```APIDOC ## GET /search ### Description Searches for education majors based on a query string. ### Method GET ### Endpoint https://graph.facebook.com/v/search ### Parameters #### Query Parameters - **type** (string) - Required - Specifies the type of data to retrieve. Use 'adeducationmajor' for education majors. - **q** (string) - Required - The string to search for (e.g., 'ph' to find majors starting with 'ph'). - **access_token** (string) - Required - Your Facebook API access token. ### Request Example ```bash curl -G \ -d 'type=adeducationmajor' \ -d 'q=ph' \ -d 'access_token=' \ https://graph.facebook.com/v/search ``` ### Response #### Success Response (200) - **data** (array) - Contains a list of matching education majors. - **name** (string) - The name of the education major. - **id** (integer) - The Facebook ID of the education major. - **coverage** (integer) - Estimated target audience size for this major. #### Response Example ```json { "data": [ { "name": "Photography", "id": 108170975877442, "coverage": 613618 }, { "name": "Physics", "id": 109279729089828, "coverage": 942491 }, { "name": "Philosophy", "id": 108026662559095, "coverage": 701271 } ] } ``` ``` -------------------------------- ### Example Encrypted Referrer Data Structure Source: https://developers.facebook.com/docs/app-ads/install-referrer This example shows the structure of the encrypted data received from the Google Play Install Referrer API. The Facebook ad campaign metadata is appended to the `utm_content` parameter's `source` field. ```json { "utm_content": { "source": { "data": "afe56cf6228c6ea8c79da49186e718e92a579824596ae1d0d4d20d7793dca797bd4034ccf467bfae5c79a3981e7a2968c41949237e2b2db678c1c3d39c9ae564c5cafd52f2b77a3dc77bf1bae063114d0283b97417487207735da31ddc1531d5645a9c3e602c195a0ebf69c272aa5fda3a2d781cb47e117310164715a54c7a5a032740584e2789a7b4e596034c16425139a77e507c492b629c848573c714a03a2e7d25b9459b95842332b460f3682d19c35dbc7d53e3a51e0497ff6a6cbb367e760debc4194ae097498108df7b95eac2fa9bac4320077b510be3b7b823248bfe02ae501d9fe4ba179c7de6733c92bf89d523df9e31238ef497b9db719484cbab7531dbf6c5ea5a8087f95d59f5e4f89050e0f1dc03e464168ad76a64cca64b79", "nonce": "b7203c6a6fb633d16e9cf5c1" }, ... }, ... } ``` -------------------------------- ### Create Ad Set Example Source: https://developers.facebook.com/docs/marketing-api/adset This example demonstrates how to create a new ad set using a POST request to the /adsets edge. It includes parameters for name, budget, schedule, campaign, bid, optimization, targeting, and status. ```cURL POST /v25.0/act_/adsets HTTP/1.1 Host: graph.facebook.com name=My+First+Adset&lifetime_budget=20000&start_time=2026-05-12T10%3A45%3A09-0700&end_time=2026-05-22T10%3A45%3A09-0700&campaign_id=%3CAD_CAMPAIGN_ID%3E&bid_amount=100&billing_event=LINK_CLICKS&optimization_goal=LINK_CLICKS&targeting=%7B%22facebook_positions%22%3A%5B%22feed%22%5D%2C%22geo_locations%22%3A%7B%22countries%22%3A%5B%22US%22%5D%7D%2C%22publisher_platforms%22%3A%5B%22facebook%22%2C%22audience_network%22%5D%7D&status=PAUSED ``` -------------------------------- ### Search Work Employers Source: https://developers.facebook.com/docs/marketing-api/audiences/reference/targeting-search Reference targetable employers by id and name. This example searches for all work employers starting with 'mic'. ```APIDOC ## GET /search ### Description Searches for targetable work employers based on a query string. ### Method GET ### Endpoint https://graph.facebook.com/v/search ### Parameters #### Query Parameters - **type** (string) - Required - Specifies the type of data to retrieve. Use 'adworkemployer' for work employers. - **q** (string) - Required - The string to search for (e.g., 'mic' to find employers starting with 'mic'). - **access_token** (string) - Required - Your Facebook API access token. ### Request Example ```bash curl -G \ -d 'type=adworkemployer' \ -d 'q=mic' \ -d 'access_token=' \ https://graph.facebook.com/v/search ``` ### Response #### Success Response (200) - **data** (array) - Contains a list of matching work employers. - **name** (string) - The name of the work employer. - **id** (integer) - The Facebook ID of the work employer. - **coverage** (integer) - Estimated target audience size for this employer. #### Response Example ```json { "data": [ { "name": "Western Michigan University", "id": 10022826163, "coverage": 24366 }, { "name": "University of Michigan", "id": 21105780752, "coverage": 17357 }, { "name": "Michigan State University - SPARTANS", "id": 8891783019, "coverage": 65853 } ] } ``` ``` -------------------------------- ### Get Campaign Fields Source: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group Retrieve specific fields for a campaign using the Graph API. This example shows how to request campaign fields. ```HTTP GET v25.0/...?fields={fieldname_of_type_Campaign} HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Create Campaign for App Installs Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads This step involves creating a campaign with the 'OUTCOME_APP_PROMOTION' objective to drive app installs. Replace and with your actual values. ```bash curl -X POST \ -F 'name="App Installs Campaign with Dynamic Product Ads"' \ -F 'objective="OUTCOME_APP_PROMOTION"' \ -F 'status="PAUSED"' \ -F 'special_ad_categories=[]' \ -F 'is_adset_budget_sharing_enabled=0' \ -F 'access_token=' \ https://graph.facebook.com/v25.0/act_/campaigns ``` -------------------------------- ### Get Registration Method Parameter Key Source: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/appevents/appeventsconstants.html Retrieve the constant string for the registration method parameter. Examples include 'Facebook', 'email', 'Twitter'. ```java final StringgetEVENT_PARAM_REGISTRATION_METHOD() ``` -------------------------------- ### Create a Desktop App Install Video Ad Source: https://developers.facebook.com/docs/marketing-api/mobile-app-ads This snippet is for creating a video ad to promote desktop app installs. It uses a `PLAY_GAME` call to action, suitable for games or applications. ```bash curl \ -F 'name=My Video' \ -F 'message=Check out this app!' \ -F 'thumbnail=' \ -F 'published=0' \ -F 'call_to_action={"type":"PLAY_GAME","value":{"link":""}}' \ -F 'source=@' \ -F 'access_token=' \ https://graph.facebook.com/v25.0//videos ``` -------------------------------- ### Get Photos Published by a User Source: https://developers.facebook.com/docs/graph-api/overview Retrieve a list of photos published by a specific user. This example uses a cURL request to the Graph API. ```bash curl -i -X GET \ "https://graph.facebook.com/USER-ID/photos?access_token=ACCESS-TOKEN" ``` -------------------------------- ### Get Android Attribution ID Source: https://developers.facebook.com/docs/marketing-api/app-event-api Retrieves the Facebook attribution ID for Android devices using ContentProvider. Ensure the device has the Facebook app installed. ```java public static final Uri ATTRIBUTION_ID_CONTENT_URI = Uri.parse("content://com.facebook.katana.provider.AttributionIdProvider"); public static final String ATTRIBUTION_ID_COLUMN_NAME = "aid"; public static String getAttributionId(ContentResolver contentResolver) { String [] projection = {ATTRIBUTION_ID_COLUMN_NAME}; Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null); if (c == null || !c.moveToFirst()) { return null; } String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME)); c.close(); return attributionId; } ``` -------------------------------- ### App Installs Source: https://developers.facebook.com/docs/marketing-api/mobile-conversions-endpoint Send a POST request to the /{app-id}/activities endpoint to log an app install event. This requires the application_tracking_enabled and advertiser_tracking_enabled parameters, along with the advertiser_id and an app access token. ```APIDOC ## POST /activities ### Description Logs an app install event. ### Method POST ### Endpoint `https://graph.facebook.com/{app-id}/activities` ### Parameters #### Query Parameters - **event** (string) - Required - The event type, should be `MOBILE_APP_INSTALL`. - **application_tracking_enabled** (integer) - Required - Set to 0 or 1. - **advertiser_tracking_enabled** (integer) - Required - Set to 0 or 1. - **advertiser_id** (string) - Required - The advertiser ID from an Android device or the Advertising Identifier (IDFA) from an Apple device. - **{app-access-token}** (string) - Required - An app access token for Facebook authentication. ### Request Example ``` https://graph.facebook.com/{app-id}/activities?event=MOBILE_APP_INSTALL&application_tracking_enabled=0&advertiser_tracking_enabled=0&advertiser_id={advertiser-tracking-id}&{app-access-token} ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the event was logged successfully. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Sample Verification Request URL Source: https://developers.facebook.com/docs/messenger-platform/webhook This is an example of a GET request URL used for webhook verification. It includes mode, verify token, and challenge parameters. ```http GET https://www.your-clever-domain-name.com/webhooks? hub.mode=subscribe& hub.verify_token=mytoken& hub.challenge=1158201444 ``` -------------------------------- ### Initialize Git repository Source: https://developers.facebook.com/docs/messenger-platform/instagram/sample-experience Initialize a new Git repository if one does not exist. ```bash $ git init Initialized empty Git repository in .git/ $ git add . $ git commit -m "My first commit" ``` -------------------------------- ### App Installs Source: https://developers.facebook.com/docs/marketing-api/app-event-api Send a POST request to the /{app-id}/activities endpoint to log an app install event. This requires the event name, application tracking status, advertiser tracking status, advertiser ID, and an app access token. ```APIDOC ## App Installs ### Description Send a POST request from your server to the `/{app-id}/activities` endpoint with the `application_tracking_enabled` and `advertiser_tracking_enabled` parameters to log an app install. ### Method POST ### Endpoint `https://graph.facebook.com/{app-id}/activities` ### Parameters #### Query Parameters - **event** (string) - Required - The event to log, e.g., `MOBILE_APP_INSTALL`. - **application_tracking_enabled** (integer) - Required - Set to 0 or 1. - **advertiser_tracking_enabled** (integer) - Required - Set to 0 or 1. - **advertiser_id** (string) - Required - The advertiser ID from an Android device or the Advertising Identifier (IDFA) from an Apple device. - **{app-access-token}** (string) - Required - Your app access token for Facebook authentication. ### Request Example ```curl -i -X POST "https://graph.facebook.com/{app-id}/activities ?event=MOBILE_APP_INSTALL &application_tracking_enabled=0 &advertiser_tracking_enabled=0 &advertiser_id={advertiser-tracking-id} &{app-access-token}" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the event was logged successfully. #### Response Example ```json { "success": true } ``` #### Caveats - Report only one install per user. Deduplicate IDs on the ID and user levels if possible. ``` -------------------------------- ### Get Ad Type Parameter Key Source: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/appevents/appeventsconstants.html Retrieve the constant string for the ad type parameter. Examples include 'banner', 'interstitial', 'rewarded_video', 'native'. ```java final StringgetEVENT_PARAM_AD_TYPE() ``` -------------------------------- ### startTracking() Source: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/accesstokentracker.html Starts tracking the current access token. ```APIDOC ## startTracking() ### Description Starts tracking the current access token. ### Method startTracking ```