Boosting Facebook Posts with the Marketing API

Have you ever published a Facebook post and seen that blue “Boost post” button? It often shows on Facebook company page posts and allows you to create an ad out of the organic post. It is a quick and easy way to create a paid post that nets you more engagement, clicks, and impressions.

Facebook Boost Post
Facebook Boost Post

While the “Boost post” button on Facebook lets you create paid posts, it’s time-consuming, a manual process, and requires visiting the Facebook website. For a better solution that integrates with your platform or web app, you can use the Facebook Ads API. This allows your users to create ads directly from your application and provides metrics like impression count, click count, and ad spend.

In this integration guide we’ll review how to implement the Ayrshare Facebook Ads API, also known as the Facebook Marketing API, so your app can allow users to create paid ads from organic posts and retrieve ad analytics and metrics.

Why Boost a Post?

A Boosted Post is a type of paid Meta ad, specifically for Facebook and Instagram, that starts as an ordinary post, i.e. organic post, on your Facebook page. When you “boost” it, you’re paying Facebook to show it to a wider or more targeted audience beyond your current followers and beyond the standard algorithm. It’s one of the simplest ways to advertise on Facebook to increase engagement and clicks, and it’s often the first step businesses take when dipping their toes into digital advertising.

The Facebook API for Ads lets you integrate this capability into your platform.

Increased Visibility Organic reach on Facebook has dropped significantly in recent years. Boosting helps cut through the noise, ensuring your content gets seen by more people, especially those who are likely to engage with your brand.
Audience Targeting You can choose who sees your boosted post based on demographics like location, age, and interests.
Get Quick Engagement Boosted posts are great for promoting time-sensitive content like a sale, an event, a product launch, or a limited offer. A small budget can lead to quick spikes in likes, comments, shares, and link clicks, which are all valuable social proof.
Ease of Use Unlike more complex ad campaigns, boosted posts are simple and user-friendly. You don’t need to navigate Ads Manager or set up complicated ad sets. Just choose a post, set your audience, budget, and duration and you’re off.

Boosted posts are perfect when you want to:

  • Amplify an already high-performing post.
  • Promote blog content, events, or announcements.
  • Build brand awareness on a budget.

Understanding Ayrshare’s Ads API

Ayrshare is the leading social media management API offering. Using simple API calls, you can add social media management to your platform for all your users including posting, scheduling, analytics, messaging, and much more.

Ayrshare now offers the ability to convert a Facebook post into an ad using the Faceook Ads API, called a boosted post.

There are five endpoints available to ensure that you have full control over the entire lifecycle of managing an ad on Facebook.

Facebook Ads API Endpoints
Ayrshare Facebook Ads Endpoints

Guide to Boosting a Facebook Post

Before you start the implementation, ensure that you have an Ayrshare Premium or Business Plan account and that you have enabled the Ads add-on in the web dashboard on the Account page. You also need to have an active Facebook Ad account with billing details configured.

The general flow that your user will follow for the Facebook Advertising API is as follows:

  1. Choose the Facebook Ad account that has the relevant billing details.
  2. Select the post that will be boosted. You can either choose a post you sent via Ayrshare or one directly published on Facebook.
  3. Set the required and optional parameters including the goal, audience, budget, and duration.
  4. Submit the Ad to Facebook for approval.
  5. Monitor the ad spend and performance.
Facebook Ad API Creation Flow

API Calls for Boosting a Post with Facebook

Let’s step through the individual FB Ads API calls required to complete this flow.

Choose the Facebook Ad Account

Call the Ads Account endpoint to get a list of Accounts to choose from – these are the ads account you have created at Facebook with billing setup.

const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/facebook/accounts", {
      method: "GET",
      headers: {
        "Authorization": `Bearer ${API_KEY}`
      }
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);

The response will list the accounts. The user should pick an account with a status of active and note down the accountId – this will be used in the subsequent Facebook Market API calls.

{
    "status": "success",
    "adAccounts": [
        {
            "accountId": "274948345",
            "ageInDays": 2870.86,
            "amountSpent": 191.33,
            "balance": 7.84,
            "budgetRemaining": 1,
            "business": {
                "name": "Fun Fun Fun",
                "city": "New York",
                "country": "US",
                "state": "NY",
                "street": "178 Columbus Ave",
                "zip": "10023"
            },
            "created": "2012-01-05T03:11:31-0800",
            "currency": "USD",
            "disableReason": null,
            "fundingSource": {
                "id": "13157487252022",
                "type": "Credit Card"
            },
            "hasNotificationsEnabled": true,
            "isPersonal": false,
            "isPrepayAccount": false,
            "metrics": {
                "spend": 191.33,
                "impressions": 24994,
                "reach": 20410,
                "clicks": 622,
                "ctr": 2.488597,
                "cpm": 7.655037,
                "cpp": 9.374326,
                "frequency": 1.224596,
                "uniqueClicks": 432,
                "uniqueCtr": 2.11661,
                "costPerUniqueClick": 0.442894,
                "inlineLinkClicks": 538,
                "costPerInlineLinkClick": 0.355632,
                "outboundClicks": 468,
                "costPerOutboundClick": 0.408825,
                "websiteCtr": [
                    {
                        "action_type": "link_click",
                        "value": "2.152517"
                    }
                ],
                "accountCurrency": "USD",
                "accountName": "John Smith",
                "accountId": "274948321"
            },
            "minDailyBudget": 1,
            "name": "John Smith",
            "owner": "3205611418413",
            "spendCap": 0,
            "status": "Active",
            "tax": {
                "id": "824087134",
                "type": "Business Tax ID (EIN/SSN)",
                "status": "Pending",
                "isRequired": false
            },
            "timezoneName": "America/Los_Angeles",
            "tosAccepted": {
                "webCustomAudienceTos": true,
                "customAudienceTos": true
            }
        }
    ],
    "count": 1,
    "lastUpdated": "2025-03-26T19:33:51.571Z",
    "nextUpdate": "2025-03-26T19:44:51.571Z"
}

Choose the Facebook Post

Next, you’ll want to choose the post to boost as an ad. You can either choose a post done through Ayrshare or one already existing at Facebook.com.

Start with the history endpoints, which return a list of Facebook posts.

For example, the history endpoint to return the list of posts sent via Ayrshare. Or use the history-platform endpoint to get posts that were not published via Ayrshare.

Depending on which endpoint you use, you will need to capture either the Ayrshare post ID or the Facebook post ID to use when creating the ad.

Boost the Post

Next, we’ll call the Boost a Post endpoint to create a paid post.

You will need the accountId and postId from the prior two calls. In addition there are other required parameters including the budget, bid amount, goal, and locations. There are some optional parameters including interests. The goals are explained in more detail in the docs and let the user choose what kind of optimization the algorithm should choose, such as maximizing the engagement, interactions, or views.

const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/facebook/boost", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${API_KEY}`
  },
  body: JSON.stringify({
    postId: "1234567890",
    accountId: "1234567890",
    adName: "My Ad",
    status: "active",
    goal: "engagement",
    minAge: 18,
    maxAge: 65,
    location: "US",
    budget: 100,
    bidAmount: 1,
    startDate: "2025-03-01T00:00:00Z",
    endDate: "2025-03-07T23:59:59Z",
    interests: [1234567890, 1234567891]
  })
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);

To let the user select interests, you send in an array of interest IDs. These interests can be accessed using the Ad Interests endpoint.

const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", {
      method: "GET",
      headers: {
        "Authorization": `Bearer ${API_KEY}`
      }
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);

This interests endpoint takes in a search term and returns the related interests with the id.

{
    "status": "success",
    "interests": [
        {
            "id": "6003195554098",
            "name": "Rhythm and blues music",
            "topic": "News and entertainment",
            "audienceSizeLowerBound": 669180255,
            "audienceSizeUpperBound": 786955980
        },
        {
            "id": "6003470511564",
            "name": "Do it yourself (DIY)",
            "topic": "Hobbies and activities",
            "audienceSizeLowerBound": 418387661,  // Lower bound of audience size
            "audienceSizeUpperBound": 492023890  // Upper bound of audience size
        },
        {
            "id": "6002926036121",
            "name": "Italy",
            "topic": "Travel, places and events",
            "audienceSizeLowerBound": 279313350,  // Lower bound of audience size
            "audienceSizeUpperBound": 328472500  // Upper bound of audience size
        }
    ],
    "count": 3,
    "lastUpdated": "2025-03-27T01:01:38.547Z",
    "nextUpdate": "2025-03-27T01:12:38.547Z"
}

The response from the /boost endpoint will return the adId and additional data with the success status.

{
    "status": "success",
    "adId": "120217670757750410",
    "adName": "API Post - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
    "adStatus": "active",
    "bidAmount": 10,
    "budget": 100,
    "endDate": "2026-03-28T22:30:00Z",
    "goal": {
        "title": "Get More Engagement",
        "description": "This goal seeks to increase engagement...",
        "type": "engagement"
    },
    "interests": [
        "6003195554098"
    ],
    "location": "US",
    "maxAge": 65,
    "minAge": 18,
    "postId": "DE6gpw8kxlonHy2b7Lo",
    "startDate": "2026-03-26T22:30:00Z"
}

Monitor the Ads

There are two endpoints to get analytics, metrics, and spend data on active and historical ads.

  • The Boosted Ads endpoint returns a specific ad or ads based on sending in a Facebook Account ID, Facebook Post ID, Ayrshare Ad ID, or Ayrshare Post ID. This endpoint is useful to review the current spend, metrics (click through rate, cost per click, and impressions), and details about the ad (bid amount, budget).
  • The Ads History endpoint returns a daily history for a Facebook Account ID, Facebook Post ID, Ayrshare Ad ID, or Ayrshare Post ID. This is great to see your daily spend and daily analytics.

For example, the results from the /ads/facebook/history endpoint returns detailed spend and analytics data for each day that the ad was live.

{
    "status": "success",
    "history": [
        {
            "adId": "6683876017501",
            "adName": "API Post 1 - DE6gpw8kxlonHy6eb7L1 - 2025-03-30T17:11:26",
            "budgetDaily": 4,
            "budgetType": "daily",
            "deliveryStatus": "ACTIVE",
            "goal": {
                "description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
                "title": "Get More Engagement",
                "type": "engagement"
            },
            "isActive": true,
            "isComplete": false,
            "metrics": {
                "clicks": 3,
                "impressions": 1035,
                "reach": 1026,
                "frequency": 0,
                "ctr": 0,
                "cpm": 1.53,
                "cpp": 1.54,
                "cpc": 0
            },
            "network": "facebook",
            "postId": "DE6gpw8kxlonHy6eb7L1",
            "spend": 1.58,
            "spendDate": "2025-04-02T00:00:00.000Z",
            "status": "ACTIVE"
        },
        {
            "adId": "120218167147110411",
            "adName": "API Post 2 - DE6gpw8kxlonHy6eb7L1 - 2025-03-30T16:41:15",
            "budgetDaily": 4,
            "budgetType": "daily",
            "deliveryStatus": "ACTIVE",
            "goal": {
                "description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
                "title": "Get More Engagement",
                "type": "engagement"
            },
            "isActive": true,
            "isComplete": false,
            "metrics": {
                "clicks": 4,
                "impressions": 1036,
                "reach": 1011,
                "frequency": 0,
                "ctr": 0,
                "cpm": 1.61,
                "cpp": 1.65,
                "cpc": 0
            },
            "network": "facebook",
            "postId": "DE6gpw8kxlonHy6eb7L1",
            "spend": 1.67,
            "spendDate": "2025-04-02T00:00:00.000Z",
            "status": "ACTIVE"
        }
    ],
    "dateRange": {
        "start": "2025-02-24T20:02:34.613Z",
        "end": "2025-03-26T20:02:34.613Z",
        "postId": "eSNkaAiFZVin6wm6f"
    },
    "metrics": {
        "totalSpend": 3.25,
        "totalClicks": 7,
        "totalImpressions": 2071,
        "totalReach": 2052,
        "averageCTR": 0.1,
        "averageFrequency": 0,
        "cpm": 0.79,
        "cpp": 0.85,
        "cpc": 0.2,
        "costPerResult": 1.2,
        "byGoalType": {
            "engagement": {
                "spend": 7.62,
                "impressions": 9332,
                "clicks": 0,
                "reach": 8502,
                "count": 8,
                "ctr": 0,
                "cpm": 0.8165452207458208,
                "cpp": 0.8962597035991532,
                "cpc": 0
            }
        },
        "byGoalTitle": {
            "Get More Engagement": {
                "spend": 3.25,
                "impressions": 2071,
                "clicks": 7,
                "reach": 2052,
                "count": 1,
                "type": "engagement",
                "ctr": 0.1,
                "cpm": 0.79,
                "cpp": 0.85,
                "cpc": 0.2
            }
        },
        "goalPerformance": {
            "bestPerformingGoalType": {
                "type": "engagement",
                "clicks": 7,
                "spend": 3.25,
                "ctr": 0.1
            },
            "mostEfficientGoalType": {
                "type": "engagement",
                "cpc": 0.2,
                "spend": 3.25
            }
        },
        "count": 2,
        "firstDay": "2025-03-17T00:00:00.000Z",
        "lastDay": "2025-03-23T00:00:00.000Z"
    }
}

Updating an Ad

When you create an ad can choose to have it either active or paused, meaning it is currently showing or not showing to users. The Update an Ad endpoint allows you to toggle the ad between two states:

const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/facebook/ads", {
      method: "PUT",
      headers: {
        "Authorization": `Bearer ${API_KEY}`
      },
      body: JSON.stringify({ adId: 1234567890, status: "active" })
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);

Frequently Asked Questions

What kind of data can I retrieve from the API for reporting?

Getting detailed data on ads is an important component of managing your Facebook Ads. You can get comprehensive data on ads using the /ads/facebook/history endpoint returns spend, clicks, impressions, reach, frequency, CTR (Click-Through Rate), CPM (Cost Per 1,000 Impressions), CPP (Cost Per Purchase), and CPC (Cost Per Click).

How much should I spend on Facebook Boosted Posts?

You can set a custom budget for each Facebook Boosted Post. Facebook requires a minimum bid of $1.00 per click and the ad must run for at least 30 hours.

Do I need to use Facebook Ads Manager or manage Facebook Ad Campaigns?

Ads created and updated via Ayrshare Facebook Market API can always be found in the Facebook Ads Manager. Ayrshare handles all of the settings at the ad, ad set, and campaign levels. There is never a need to manually edit any of the settings directly in the Facebook Ads Manager.

What do the different statuses mean for Facebook ads?

Here’s what each of those Facebook Ads statuses means:

Active: The ad is running and being served to people. You’re being charged based on the ad’s delivery and objectives.

Paused: The ad has been stopped. It’s not delivering and you’re not being charged. It can be restarted at any time.

Deleted: The ad has been permanently removed. It still appears in reports for historical performance, but can’t be recovered.

Archived: Similar to deleted, but typically used for organizational purposes. Ads are no longer active, can’t be edited or reactivated, but they’re kept in the account for record-keeping or reporting.

How do I preview the ad?

After creating the ad you can call do a GET call on the boost ads endpoint to retrieve the preview link. The previewLink URL allows you share the preview ad with your colleagues, so that they will see the ad for 24-hours across the various Facebook formats. Your colleagues’ views of the ad will not be counted towards your ad spend.

How do I learn more about Facebook Ads?

You can learn more about Facebook Marketing API at the Meta API docs.


Using Facebook’s Advertising API is an easy way for your users to increase their reach, impressions, and clicks through targeted ads directly from your app. This approach can help your businesses cut through social media noise by precisely reaching your users’ desired customer demographics. Additionally, if your business model includes taking a percentage of customer ad spend, implementing Facebook ads can create a valuable new revenue stream.

Leave a Comment