Links

Facebook Page

Options for posting via the API to a Facebook Page

Facebook Page API Endpoint

Overview

Posting to Facebook via the API requires connecting a Facebook Page. Facebook does not allow personal accounts to be connected.
JSON for a basic post with a link and image to a Facebook page:
{
"post": "The best FB post ever #best https://www.facebook.com",
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"],
"platforms": ["facebook"]
}
Facebook will automatically preview the link in the post unless there is an image or video included. In the above example the image will show. Removing the image will cause the link preview to show.
If your video doesn't end in a known video extension such as mp4, please use the isVideo parameter. See the /post endpoint for details.
Post Facebook Carousel images through Ayrshare's API with the carousel body parameter.
{
"faceBookOptions": {
"carousel": {
"link": "URL of See More At...", // The URL of the "See More At" button
"items": [ // 2 min, 10 max elements in the array
{
"name": "Image name",
"link": "URL when image clicked",
"picture": "URL of image"
},
{
"name": "Image name",
"link": "URL when image clicked",
"picture": "URL of image"
}
]
}
}
}
  • The top-level link parameter is the URL at the end of the carousel.
  • The items is an array of object containing the following values. Minimum 2 elements and max 10 elements in the items array.
    • picture - URL of the carousel image.
    • link - URL when the image is clicked.
    • name - image displayed in each image card.
Note: Do not use the media_urls with carousel. If media_urls is used, carousels will be ignored.
Please see our Facebook Carousel Blog Post for more information.

Facebook Reels

You can post a video to Facebook Reels API with the following facebookOptions.
{
"post": "The description of the video",
"mediaUrls": "https://img.ayrshare.com/012/reel.mp4",
{
"faceBookOptions": {
"reels": true,
"title": "Super title for the Reel" // optional
}
}
}
  • reels: Set to true to post the video to Reels.
  • title: .The title of the video. Optional.
Please see the Reels API video requirements or an example of using the Facebook Reels API.

Media Captions

Set a caption for each Facebook media image posted.
Accepts an array of string caption text. Each array must correspond to a media url. E.g. ["This is my best pic", "😃 here is the next one"] refers to the 1st and 2nd urls in mediaUrls.
{
"faceBookOptions": {
"mediaCaptions": ["This is my best pic", "😃 here is the next one"]
}
}

Alternative Text

Add alternative text, also known as alt text, to a Facebook image or video. Facebook alt text is an accessibility feature used for additional user info and screen readers.
Use the altText in the faceBookOptions object.
"faceBookOptions": {
"altText": ["This is my best pic", "😃 here is the next one"] // Array of Alt Texts
}
Each alt text must correspond to an image or video in the mediaUrls array. The alt text will be applies to each image in order.

Video Thumbnail

Set a thumbnail for a video. Send a remote URL of a PNG or JPG file that is the same dimensions as the video and less than 10 MB. URL should end in .png or .jpg.
{
"faceBookOptions": {
"thumbNail": "https://octodex.github.com/images/Fintechtocat.png"
}
}

Video Title

Add a title to the video with the title parameter.
{
"faceBookOptions": {
"title": "The best video ever!"
}
}

Animated GIFs

Only one URL is allowed with a Facebook animated GIF. If the media URL does not end in ".gif" or ".GIF", set the isVideo field to true.
{
"randomPost": true,
"platforms": [
"facebook"
],
"isVideo": true, // Set to true if the mediaURL does not end in .gif or .GIF
"mediaUrls": ["https://img.ayrshare.com/012/cat.gif"]
}

Facebook Page Mentions

You can mention another Facebook Page, also known as Facebook Tagging, by including the Facebook Page name or Page ID in the post text. Facebook does not allow mentions or tags of personal profiles.
Note: Premium or Business Plan required for mentions.
Include a mention with the following @mention:
@page-name or @[page-id]

Mention with Page Name

An example post text with a Page name. You can find the Page name from the Facebook URL, e.g. https://www.facebook.com/Ayrshare
"post": "This is the best social media api by @Ayrshare"
Ayrshare will make a best attempt to find the matching Page based on the name, but sometimes a match can not be found. A more reliable method is using a Page ID.

Mention with Page ID

An example post text with a Page ID, note the use of []. Please see below on how to find the Page ID.
"post": "This is the best social media api by @[738681876342836]"
The Facebook Page ID will resolve to the matching page and notify the Page mentioned.
Use Page mentioning with caution by only mentioning Pages you are associated with and never spam.
When you mention a Page, the owner of the Page will be notified via an alert and email. If several Pages complain about you mentioning them, Facebook could possibly ban your account. Please be sure to only tag Pages that you have an established relationship.
The Facebook Page being mentioned must allow other Pages to mention/tag their Page. Mentions can be enabled in the Page's general settings under "Others Tag this Page".

Find a Facebook Page ID

  1. 1.
    From News Feed, click Pages in the left side menu.
  2. 2.
    Click your Page name to go to your Page.
  3. 3.
    Click About at the top of your Page. If you don't see it, click More
    .
  4. 4.
    Scroll down to find your Page ID below MORE INFO.
or if you want to find the ID of a page your don't own:
  • If the Facebook Page has a URL such ashttps://www.facebook.com/ayrshare-1234567890 then the ID is 1234567890.
  • If the Facebook Page has a URL such as:
    https://www.facebook.com/pages/ayrshare/123466789203 then the Page ID is the number at the end, such as 123466789203.
You can test that the Page ID is correct by going to https://facebook.com/page-id and it will resolve to the Page.
You can also try a 3rd party Facebook Page look up tool, which is not supported by Ayrshare, such as: https://lookup-id.com/
If all other methods fail, you can go to the Facebook page in a browser and view the page source. In Chrome, right click to select "View Source". Then search for either owning_profile_id or profile_id to find the Page ID.
A Facebook post will automatically create a link preview of a link in the post body. However, if you want to specify either a different link or force the link preview, use the link parameter with URL of the link.
"faceBookOptions": {
"link": "https://www.ayrshare.com/instagram-hashtag-guide/"
}

FAQ

How do I add line breaks or rich text to a Facebook post?

Facebook line breaks can be added to a post with a special new line character.
Rich text, such as bold or italic lettering, can be added to a Facebook post with a few html elements.

Why do I see "Published by Ayrshare" on a post?

Don't worry, it only shows in the admin view. Please see the troubleshooting guide for more information.

Can I post Facebook Stories or Reels?

Facebook Stories posting is not yet supported by Facebook's official API integration. However Facebook Reels and Instagram Reels can be posted via Ayrshare's API.