📸 How to Set Up Facebook Graph API for Instagram Publishing

Instagram automation for SaaS platforms like GlowFlow requires direct integration with Meta’s Graph API. This guide walks you through the full setup—from account linking to publishing content.

✅ Prerequisites

Before you begin, ensure you have:

  • A Facebook account

  • A Facebook Page (can be for testing)

  • An Instagram Business or Creator account

  • A Meta Developer App

Instagram Graph API only works with Professional accounts (Business or Creator) linked to a Facebook Page.

🧩 Architecture Overview

🔐 Prerequisites

  • Facebook App with pages_manage_posts, instagram_content_publish, pages_show_list, instagram_basic

  • Instagram account must be Business or Creator and linked to a Facebook Page

  • Store page_id, instagram_id, and access_token securely in Supabase Vault or pass via request body 

🛠 Step-by-Step Setup

1. Convert Instagram to Business Account

  • Open Instagram → Settings → Account

  • Tap “Switch to Professional Account”

  • Choose Business, skip contact info

2. Link Instagram to Facebook Page

  • Go to your Facebook Page → Settings → Linked Accounts

  • Click “Connect Instagram”

  • Log in and confirm the link

3. Create a Meta Developer App

  • Visit

  • Click “My Apps” → “Create App”

  • Choose App Type: Business

  • Fill in app name, email, and business account (optional)

4. Add Instagram Graph API Product

  • In your app dashboard, click “Add Product”

  • Select Instagram Graph API

  • Also add Facebook Login, Pages API, and Business Management API

5. Configure Facebook Login

  • Go to Facebook Login → Settings

  • Add your OAuth Redirect URI (e.g. https://yourdomain.com/auth/callback)

  • Enable:

    • Client OAuth Login

    • Web OAuth Login

6. Request App Review for Permissions

Go to App Review → Permissions and Features and request:

  • instagram_basic

  • instagram_content_publish

  • pages_show_list

  • business_management

You’ll need to submit screencasts and descriptions of how your app uses these permissions.

How to Generate Token?

  •  Visit: https://developers.facebook.com/apps/923749834/dashboard/?business_id=98349247
  • go to Tools --> Graph Api Explorer (https://developers.facebook.com/tools/explorer/) 
  • Copy Access Token


  • Extetend Token Expiry from 1 hour to 2 months(max)
  •  visit https://developers.facebook.com/tools/debug/accesstoken/

 Paste token and click on extend


How to get Facebook Page Token and Page id?

From Page Settings

  1. Go to your Page.

  2. Click SettingsPage Transparency or About.

  3. Scroll down to find Page ID listed there.


  4. Facebook Page Access Token

    Step-by-Step via Graph API Explorer

    1. Go to

    2. Select your app from the dropdown.

    3. Click Get TokenGet User Access Token

    4. Select permissions:

      • pages_manage_posts

      • pages_read_engagement

      • pages_show_list

    5. Authorize the token.

    6. Use the token to call:

    7. GET /me/accounts

      Note: These tokens are short-lived (~1 hour). You can exchange them for a long-lived token (valid for 60 days) using Facebook’s Access Token Tool.

7. Authenticate Users via OAuth

Redirect users to Meta’s login:

ts
const redirectToMetaLogin = () => {
  const clientId = 'YOUR_APP_ID';
  const redirectUri = 'https://yourdomain.com/auth/callback';
  const scopes = [
    'instagram_basic',
    'pages_show_list',
    'instagram_content_publish',
    'business_management'
  ].join(',');

  window.location.href = `https://www.facebook.com/v19.0/dialog/oauth
?client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scopes}&response_type=code`;
};

8. Publish Content via Graph API

Use two endpoints:

  1. Create Media Container

http
POST https://graph.facebook.com/v19.0/{ig_user_id}/media

Payload:

json
{
  "image_url": "https://yourdomain.com/image.jpg",
  "caption": "Your caption",
  "access_token": "USER_ACCESS_TOKEN"
}
  1. Publish Media

http
POST https://graph.facebook.com/v19.0/{ig_user_id}/media_publish

Payload:

json
{
  "creation_id": "MEDIA_CONTAINER_ID",
  "access_token": "USER_ACCESS_TOKEN"
}

🧠 Pro Tips

  • Media containers expire in 24 hours—create them just before publishing.

  • Use Supabase or n8n to schedule and trigger publishing.

  • Store access tokens securely and refresh them as needed.