Posting Instagram Reels via Instagram/Facebook Graph API

Greg Vonf @ Business Automated
6 min readAug 9, 2022

Recently Meta has enabled general availability of API that allows posting Reels to IG, here is a short documentation how you can implement it with your favorite no-code or code tool.

Photo by Alexander Shatov on Unsplash

In our case we are using Make.com (formerly known as Integromat) and Airtable to build automated social media calendar, but you could replicate below scenario also with other tools. The core for posting reels via API is setting up OAuth connection to Facebook and the API calls described below.

You can followed detailed description in the video below:

Step 1: Setting up FB Developer account

Go to https://developers.facebook.com/ create a developer account and create a new app.

The app should be “Business” since it contains the permissions that are needed to post a Reel to Instagram. It is also important to link the app to your Business Account that is owning the IG page to which you want to post reels. It is necessary to be using Business Account for IG reels and images posting.

Next step is to add 2 “products” to your app. This will be “Facebook Login” and “Instagram Graph API”

The core is really adding them to the app, without need for full set up. Only the Facebook Login settings need to be slightly customized.

Step 2: Setting up OAuth connection to Facebook Graph API with Make/Integromat

Inside of “Facebook Login” / Settings you will need to add mandatory Redirect URI. In our case since we are using Make.com (formerly Integromat), we are using their redirect URI:

https://www.integromat.com/oauth/cb/oauth2

As the next step, inside the app settings you will need to find your App ID and App secret. You will need to copy paste them for authentication.

To establish connection you will need to know 3 more data points

Authorize URI: https://www.facebook.com/v14.0/dialog/oauth

Token URI: https://graph.facebook.com/v14.0/oauth/access_token

Authorization scopes:

business_management
instagram_basic
instagram_content_publish
pages_show_list

Scopes listed above are necessary to have all the API permissions to post Instagram Reels ( and also Instagram posts).

Having all that you can connect Make/Integromat OAuth module here:

Clicking on the Save button will initiate a connection where you need to log in to Facebook (if you are not logged in already) and approve the permissions that we are granting for this connection.

If you are the sole user of this app, there is no need to submit it for any review.

Step 2b: Setting up OAuth connection to Facebook Graph API with code or other clients

If you are setting up connection to Facebook via code or other client you will need to establish connection via direct API calls.

The first call provides us with an authentication code:

GET https://www.facebook.com/v14.0/dialog/oauth?
client_id={app-id}
&redirect_uri={redirect-uri}

In the second stage you will need to exchange the code from the step above for an Access Token:

GET https://graph.facebook.com/v14.0/oauth/access_token?
client_id={app-id}
&redirect_uri={redirect-uri}
&client_secret={app-secret}
&code={code-parameter}

Above endpoint will return Access Token which can be used for accessing Facebook Graph API — please see more details in the references at the end of the article.

Step 3: Testing connection to Facebook

To confirm that our connection to IG is working correctly try testing making a following call:

https://graph.facebook.com/v14.0/me

As a response you should see response status 200 (code for successful response) and your own Facebook user name and your personal Facebook ID.

Step 4: Finding the page ID

Next stage is to find the ID of your Instagram page. There might be a better solution than described here, if you know of one let me know in the comments.

Log in to Instagram with the page you want to use for posting the reels. Open the developer tools — right click -> Inspect -> Console

Inside the Console windows type the below code

window._sharedData.config.viewer.fbid

It will display your page FB ID, we will use it in the next step.

me/accounts

Step 5: Posting Reels to Instagram

The first step is to make a POST request to a media endpoint containing your Instagram page ID:
https://graph.facebook.com/v14.0/<PageID>/media

The full HTTP request syntax is below:

POST: https://graph.facebook.com/v14.0/<PageID>/media?media_type=REELS&video_url=<video URL>&caption=<URL encoded caption>

As a response from the above request you will receive a “container ID”, this ID will be needed to finalize the posting. The container ID will be returned almost immediately, but the actual video file will be processing on Instagram servers for some time depending on the fine size.

If the next call “media_publish” is made too early, it will result in an error (request will return 400 error) and you will need to try repeating the “media_publish” call after a while.

The “media_publish” call is being made as a POST request to https://graph.facebook.com/v14.0/17841437033504540/media_publish

POST: https://graph.facebook.com/v14.0/17841437033504540/media_publish?creation_id=<creation ID>

If this call is successful, it will return the ID of successfully published post.

This is it! Your video is posted on Instagram!

Specification for IG content.

Image Specifications

  • Format: JPEG
  • File size: 8 MB maximum.
  • Aspect ratio: Must be within a 4:5 to 1.91:1 range
  • Minimum width: 320 (will be scaled up to the minimum if necessary)
  • Maximum width: 1440 (will be scaled down to the maximum if necessary)
  • Height: Varies, depending on width and aspect ratio
  • Color Space: sRGB. Images using other color spaces will have their color spaces converted to sRGB.

Video Specifications

  • Container: MOV or MP4 (MPEG-4 Part 14), no edit lists, moov atom at the front of the file.
  • Audio codec: AAC, 48khz sample rate maximum, 1 or 2 channels (mono or stereo).
  • Video codec: HEVC or H264, progressive scan, closed GOP, 4:2:0 chroma subsampling.
  • Frame rate: 23–60 FPS.
  • Picture size:
  • Maximum columns (horizontal pixels): 1920
  • Minimum aspect ratio [cols / rows]: 4 / 5
  • Maximum aspect ratio [cols / rows]: 16 / 9
  • Video bitrate: VBR, 5Mbps maximum
  • Audio bitrate: 128kbps
  • Duration: 60 seconds maximum, 3 seconds minimum
  • File size: 100MB maximum

Reel Specifications

  • Container: MOV or MP4 (MPEG-4 Part 14), no edit lists, moov atom at the front of the file.
  • Audio codec: AAC, 48khz sample rate maximum, 1 or 2 channels (mono or stereo).
  • Video codec: HEVC or H264, progressive scan, closed GOP, 4:2:0 chroma subsampling.
  • Frame rate: 23–60 FPS.
  • Picture size:
  • Maximum columns (horizontal pixels): 1920
  • Required aspect ratio is between 0.01:1 and 10:1 but we recommend 9:16 to avoid cropping or blank spaces.
  • Video bitrate: VBR, 5Mbps maximum
  • Audio bitrate: 128kbps
  • Duration: 15 mins maximum, 3 seconds minimum
  • File size: 100MB maximum

Reels Tab Eligibility

Although you can publish reels with longer durations and different aspect ratios, only reels with durations between 5 and 90 seconds and aspect ratios of 9:16 are eligible to appear in the Reels tab.

References:

  1. Getting started with Instagram API — https://developers.facebook.com/docs/instagram-api/getting-started
  2. Details of setting up manual OAuth on Facebook — https://developers.facebook.com/docs/facebook-login/guides/advanced/manual-flow
  3. Publishing single posts via Instagram API — https://developers.facebook.com/docs/instagram-api/guides/content-publishing/#single-media-posts
  4. Reels specification — https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#reel-specifications
  5. Trouble shooting for any potential errors — https://developers.facebook.com/docs/instagram-api/guides/content-publishing/#troubleshooting

--

--

Greg Vonf @ Business Automated

Greg is the founder of Business Automated, an agency helping small businesses streamline and simplify their processes. For more visit www.business-automated.com