Member-only story

Publish media to Instagram via the Instagram Graph API

Stefan Pöltl
3 min readMar 2, 2023

Instagram supports to publish different kind of contents to a business account programmatically, but to get everything working you have to do some preperation. I focus to avoid any SDK or dependencies, simple cURL commands are enough and can be implemented in any programming language.

3 steps to get started

Content publishing via the Graph API needs the following 3 step setup:

1. Business Instagram account(Creator accounts aren’t supported)

Profile -> Edit profile -> Switch to professional account

2. A Facebook page linking to the Instagram account

3. A Facebook App with the business login and Instagram API added

Long live the token :)

Once this is done you can start retrieving a long lived access token to work for 60 days before refreshing it. The simplest method is to use the Graph API explorer:

  1. Head to the Graph API explorer: https://developers.facebook.com/tools/explorer/
  2. Select your Meta App, User Token and add the following permissions:

Click generate access token and you get a basic short lived access token. To gather a 60 day long lived token run the following cURL command:

curl -i -X GET "https://graph.facebook.com/v16.0/oauth/access_token?  
grant_type=fb_exchange_token&
client_id={app-id}&
client_secret={app-secret}&
fb_exchange_token={your-access-token}"

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Stefan Pöltl
Stefan Pöltl

Responses (3)

Write a response

So I'm trying to generate my token via Graph API explorer but there is no permission for instagram_basic, any ideas?

Does this publish to the facebook page also? or just the Instagram account?

Thanks for the help