How to post content (image or video) to Instagram using the Instagram Graph API

CK CK 3788 
Created at
Updated at  
6,390 0 0

Note

❗ Personal Instagram accounts cannot use the Instagram Graph API for publishing content. 

🧭 How to switch to a Creator Account

  1. Open the Instagram App on your phone.
  2. Go to your Profile (bottom right icon).
  3. Tap the three lines (☰) in the top right corner.
  4. Tap Settings and activity.
  5. Scroll to Account type and tools.
  6. Tap Switch to professional account.
  7. Select Creator when prompted.
  8. Choose your category (e.g., Artist, Blogger, Public Figure).
  9. Review your contact info (you can keep it private).
  10. Connect to a Facebook Page (optional, but required for API use).

If you become a creator, here's a basic example of how to post content (image or video) to Instagram using the Instagram Graph API. This requires you to have:

  1. A Facebook Developer Account.
  2. An Instagram Business or Creator Account.
  3. A Facebook Page connected to the Instagram Account.
  4. A Facebook App with the required permissions.
  5. An Access Token with instagram_content_publish scope.

Step 1: Get an Access Token

You need a long-lived access token from the Facebook Graph API. Generate it via the Facebook Graph Explorer with the instagram_basic, instagram_content_publish, and pages_read_engagement permissions.


Step 2: Get the Instagram Business Account ID

Run this Graph API request:

GET https://graph.facebook.com/v19.0/me/accounts?access_token=YOUR_ACCESS_TOKEN

This returns a list of pages. Get the Page ID associated with your Instagram account.

Next, fetch the Instagram Business Account ID:

GET https://graph.facebook.com/v19.0/PAGE_ID?fields=instagram_business_account&access_token=YOUR_ACCESS_TOKEN

Step 3: Upload an Image to Instagram

Use the Instagram Business Account ID to create a post.

Python Example

import requests

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
INSTAGRAM_ACCOUNT_ID = "YOUR_INSTAGRAM_BUSINESS_ACCOUNT_ID"
IMAGE_URL = "https://your-image-url.com/image.jpg"
CAPTION = "Hello from Instagram API!"

# Step 1: Upload Image
url = f"https://graph.facebook.com/v19.0/{INSTAGRAM_ACCOUNT_ID}/media"
payload = {
    "image_url": IMAGE_URL,
    "caption": CAPTION,
    "access_token": ACCESS_TOKEN
}
response = requests.post(url, data=payload)
result = response.json()

if "id" in result:
    creation_id = result["id"]

    # Step 2: Publish Image
    publish_url = f"https://graph.facebook.com/v19.0/{INSTAGRAM_ACCOUNT_ID}/media_publish"
    publish_payload = {
        "creation_id": creation_id,
        "access_token": ACCESS_TOKEN
    }
    publish_response = requests.post(publish_url, data=publish_payload)
    print(publish_response.json())
else:
    print("Error:", result)

Step 4: Upload a Video to Instagram

For video, you need to use video_url instead of image_url.

VIDEO_URL = "https://your-video-url.com/video.mp4"

# Step 1: Upload Video
video_payload = {
    "video_url": VIDEO_URL,
    "caption": "My video post",
    "access_token": ACCESS_TOKEN
}
video_response = requests.post(url, data=video_payload)
video_result = video_response.json()

if "id" in video_result:
    video_creation_id = video_result["id"]

    # Step 2: Publish Video
    video_publish_payload = {
        "creation_id": video_creation_id,
        "access_token": ACCESS_TOKEN
    }
    video_publish_response = requests.post(publish_url, data=video_publish_payload)
    print(video_publish_response.json())
else:
    print("Error:", video_result)

Step 5: Verify Post

Check if the post is published by running:

GET https://graph.facebook.com/v19.0/{MEDIA_ID}?fields=permalink&access_token=YOUR_ACCESS_TOKEN

It returns a permalink to the Instagram post.

Tags Instagram API Instagram Account Instagram Business Account Instagram Creator Account Facebook X
Comments 0
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Tailwind CSS and shadcn/ui for React App with Charts and Graphs
    1,039
  3. HTML NoIndex: Keep Pages Off Search
    1,488
  4. JavaScript to disable Screen Saver or Power Saving Mode
    497
  5. Improving SEO with image-sitemap
    1,175
  6. Making HTML Tables Responsive on Mobile: Addressing Text Overflow
    771
  7. How do we make better SEO with schema.org?
    420
  8. A Javascript code that returns Monthly Mortgage Payment and Tax
    1,251
  9. A simple JavaScript snippet to copy a string to the clipboard
    1,049
  10. Dynamic JSON Editor based in HTML/JavaScript
    507
  11. Font name correctly having the same width space
    1,210
  12. JavaScript Algorithms
    716
  13. GraphQL Tutorial on CentOS 7: From Installation to Deployment
    555
  14. Capture all browser console logs including errors for debugging
    2,167
  15. Simple asynchronous/synchronous $.ajax() example using jQuery to make an HTTP GET request
    840
  16. JavaScript Code to Get Page Keywords
    344
  17. What is OpenGraph?
    364
  18. What is Twitter Cards?
    399
  19. Code to Extract the Site Thumbnail Image for Twitter or Facebook
    389
  20. JavaScript Code to Get the Page Title
    331
  21. JavaScript Code to Get Meta Description from HTML
    393
  22. Javascript code to extract favicon URL
    395
  23. RSS to Array in JavaScript
    2,138
  24. Javascript function to convert sitemap.xml to array
    595
  25. Understanding Elasticsearch from Installation to Trouble Shooting
    909
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,736
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    218
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    86
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    198
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    234
  17. The Concept of Scaffolding in AI Agents
    222
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    576
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    253
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    328
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    198
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252