So you're looking for an official API to post to Instagram. Yes, there is one: the Instagram Graph API. It's Meta's legitimate way for developers to programmatically publish content, and it replaced the old unreliable workarounds with a stable foundation.
Automating Instagram Content
Meta released the Instagram Graph API in 2018, giving developers a formal gateway to the platform. With over 2.6 billion active users on Instagram, API-driven posting is a critical tool for any serious social media strategy.
The API lets you publish photos, videos, and carousels directly to Instagram Business or Creator accounts. Brands that have adopted it report a 25% increase in content consistency and a 15% boost in engagement compared to manual posting.
Key Advantages of Using an API
- Scalable Content Scheduling: Plan and automate hundreds of posts in advance without someone manually hitting "publish" every day.
- Workflow Integration: Connect Instagram publishing directly into your CMS, DAM, or custom dashboard.
- Enhanced Security: The API uses OAuth 2.0 for authentication, so you never share raw login credentials.
- Rich Functionality: Tag users, add locations, and manage comments from your own application.
As you explore the Graph API, it's also worth looking at the broader ecosystem, including other social media API automation strategies.
Some developers prefer unified APIs, which bundle multiple social platforms into a single integration. This saves a significant amount of development time and ongoing maintenance.
API Posting Methods at a Glance
| Feature | Instagram Graph API | Unified APIs (e.g., Late) |
|---|---|---|
| Integration | Direct, platform-specific integration per social network. | A single, standardized API for all supported platforms. |
| Maintenance | You handle all API updates and changes. | The provider handles all platform-specific updates. |
| Authentication | Manage separate OAuth 2.0 flows for each platform. | A single, simplified authentication process. |
| Media Handling | Requires multi-step processes for media uploads. | Often provides a simpler, one-call media upload endpoint. |
| Best For | Deep, single-platform integrations or large enterprises. | Multi-platform tools, startups, and rapid development. |
If you're building a tool focused solely on Instagram, the Graph API gives you direct control. But if you need to support multiple platforms without the overhead, a unified API is usually the faster route.
Getting API Access and Permissions

Before writing a single line of code, there's some groundwork to cover. The Instagram Graph API only works with Instagram Business or Creator accounts. If you're on a personal profile, switch first. That's not optional.
You'll make this change in the Instagram app's settings. You also need to link your Instagram account to a Facebook Page, which serves as the bridge into Meta's developer ecosystem.
Setting Up Your Facebook App
Head to the Meta for Developers portal and create a new Facebook App. Select "Business" as the app type. This gives you an App ID and an App Secret, which are your main credentials. Keep that App Secret out of any client-side code.
Tip: A common mistake is forgetting to add the "Instagram Graph API" product to your app from the developer dashboard. Miss this step and your app won't know how to request Instagram-specific permissions.
OAuth and Permissions
To post to Instagram via the API, you need the instagram_content_publish scope. Without it, any publish attempt will fail with an OAuthException.
For a basic publishing app, here's what you need:
instagram_basic: Read the user's profile info and media.pages_show_list: Find the Facebook Page linked to their Instagram account.instagram_content_publish: Post photos, videos, and carousels.
For a deeper look at the full authentication and publishing sequence, check out our guide to the Instagram Graph API.
Once the user authenticates, you'll get a short-lived User Access Token. Exchange it for a long-lived one so your app stays connected without constant re-authentication.
The Core Publishing Workflow
Publishing to Instagram via the API isn't a single API call. It's a three-step sequence: create a media container, upload your content, then publish the container.
Creating the Media Container
Hit the /{ig-user-id}/media endpoint first. This doesn't upload your file. It creates a placeholder and returns a container ID.
For a single-image post, the request is straightforward:
curl -i -X POST \
"https://graph.facebook.com/v25.0/17841405822304914/media?image_url=https%3A//www.example.com/my-image.jpg&caption=%23API%20%23ExamplePost&access_token={your-access-token}"
The API responds with the container ID:
{
"id": "17947137973499426"
}
Keep this ID. You'll need it in the next step.
Publishing the Media Container
With your container ID, make a POST request to /{ig-user-id}/media_publish. Pass the container ID and Instagram publishes it to your profile.
Here's the Python version:
import requests
ig_user_id = '17841405822304914'
container_id = '17947137973499426'
access_token = '{your-access-token}'
publish_url = f'https://graph.facebook.com/v25.0/{ig_user_id}/media_publish'
payload = {
'creation_id': container_id,
'access_token': access_token
}
response = requests.post(publish_url, data=payload)
print(response.json())
A successful call returns the ID of the new media object. That's your confirmation the post is live.
Pro Tip: Container creation isn't always instant. If you fire off the publish request too quickly, you'll get an error. Check the container status before publishing.
Handling Carousels and Videos
Videos follow the same flow but use video_url instead of image_url. Make sure your video meets Instagram's encoding requirements.
Carousels are more involved:
- Create Child Containers: Call
/{ig-user-id}/mediafor each item withis_carousel_item=true. - Create the Parent Container: Once you have all child IDs (up to 10), call the same endpoint with
media_type=CAROUSELand pass the child IDs to thechildrenparameter. - Publish the Parent Container: Publish it with
media_publish, same as a single image.
Scheduling Posts
Instead of publishing immediately, add the publish_time parameter during container creation. This is how you build a real content calendar.

Webhooks for Real-Time Events
The API lets you listen for activity in real time using webhooks. Subscribe to events like new comments and Meta sends a payload to your server when they happen. You could build a bot that auto-replies to certain comments, or a dashboard that updates on new engagement. Much better than polling.
Token Management
Short-lived User Access Tokens expire in about an hour. Long-lived tokens last 60 days. You need logic to handle this or you'll hit sudden auth errors in production.
A practical approach:
- Store expiration dates: Save the expiration timestamp alongside every token.
- Refresh proactively: Run a daily cron job to refresh tokens expiring within the next week.
- Handle failures gracefully: Catch token errors, auto-refresh, then retry the original call before giving up.
Complete Instagram API Endpoint Reference
The Instagram Graph API provides several endpoint categories. Here's a comprehensive reference:
Media Publishing Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/{ig-user-id}/media | POST | Create a media container for photos, videos, reels, or carousels |
/{ig-user-id}/media_publish | POST | Publish a prepared media container to the feed |
/{ig-media-id} | GET | Retrieve details about a published media object |
/{ig-container-id} | GET | Check container status before publishing |
Comment Management Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/{ig-media-id}/comments | GET | List all comments on a media object |
/{ig-media-id}/comments | POST | Post a comment (including First Comment) |
/{ig-comment-id}/replies | GET/POST | Get or post replies to comments |
/{ig-comment-id} | DELETE | Delete your own comments |
Analytics Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/{ig-user-id}/insights | GET | Account-level metrics (reach, impressions) |
/{ig-media-id}/insights | GET | Post-level metrics (saves, shares, engagement) |
Other Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/ig_hashtag_search | GET | Search for hashtag IDs |
/{ig-hashtag-id}/top_media | GET | Get top posts for a hashtag |
/{ig-user-id}/mentioned_media | GET | Find posts where you're @mentioned |
| Business Discovery | GET | Get public data about other business accounts |
Note: The hashtag search API limits you to 30 unique hashtags per 7-day rolling window per account.
First Comment API: Automating Engagement
One powerful but often overlooked feature is the ability to post the first comment on your own content immediately after publishing. This is huge for:
- Adding hashtags without cluttering your caption
- Pinning CTAs like "Link in bio" or "DM for details"
- Starting conversations with engagement prompts
Publishing with First Comment
After your media container is published, immediately POST to the comments endpoint:
// Node.js example: Post first comment after publishing
const axios = require('axios');
async function publishWithFirstComment(igUserId, containerCreationId, accessToken, firstComment) {
// Step 1: Publish the media
const publishResponse = await axios.post(
`https://graph.facebook.com/v25.0/${igUserId}/media_publish`,
{
creation_id: containerCreationId,
access_token: accessToken
}
);
const mediaId = publishResponse.data.id;
console.log('Published media:', mediaId);
// Step 2: Post the first comment immediately
const commentResponse = await axios.post(
`https://graph.facebook.com/v25.0/${mediaId}/comments`,
{
message: firstComment,
access_token: accessToken
}
);
console.log('First comment posted:', commentResponse.data.id);
return { mediaId, commentId: commentResponse.data.id };
}
// Usage
publishWithFirstComment(
'17841405822304914',
'17947137973499426',
'{your-access-token}',
'Follow for more tips! #instagram #api #developer #automation'
);
Important: First comment publishing requires the instagram_manage_comments permission in addition to instagram_content_publish.
Platforms That Support First Comment
Not all social platforms support first comment via API. Here's the breakdown:
| Platform | First Comment Supported | Notes |
|---|---|---|
| Instagram (Feed) | ✅ Yes | Requires instagram_manage_comments |
| Instagram (Reels) | ✅ Yes | Same as feed posts |
| ✅ Yes | Via Graph API | |
| ✅ Yes | Via ugcPosts API | |
| YouTube | ✅ Yes | Via Data API comments.insert |
| TikTok | ❌ No | API doesn't support comments |
| X/Twitter | ❌ No | Use quote tweets instead |
Two Ways to Authenticate: Which One to Choose?
The Instagram Graph API supports two authentication flows, each suited for different use cases:
Method 1: Instagram Business Login (Direct)
This is the simpler approach where users authenticate directly through Instagram using OAuth 2.0.
Best for:
- Consumer-facing apps where users connect their own accounts
- Single-account integrations
- Mobile applications
- Scenarios with minimal Facebook infrastructure
Required permissions: instagram_basic, instagram_content_publish
Method 2: Facebook Login for Business (via Page)
This method authenticates through Facebook and accesses Instagram accounts connected to Facebook Pages.
Best for:
- Enterprise platforms managing multiple client accounts
- Integrations with Facebook Business Manager
- Agencies with centralized account management
- Systems that also need Facebook Page data
Required permissions: pages_show_list, business_management, instagram_basic, instagram_content_publish
Quick Comparison
| Factor | Instagram Business Login | Facebook Login for Business |
|---|---|---|
| Setup complexity | Moderate | Higher |
| Token source | Direct from Instagram | Via Facebook Page |
| Best for | Single accounts, user apps | Multi-account, enterprise |
| Account linking | Direct | Through Facebook Page |
| Token lifespan | 60 days (long-lived) | 60 days (long-lived) |
For most developers building scheduling tools or content management platforms, Facebook Login for Business is the standard approach because it integrates with Business Manager and handles multi-account scenarios better.
Stop building social integrations from scratch.
One API call to publish, schedule, and manage posts across 15+ platforms.
Understanding Business Use Case Rate Limits
The Instagram Graph API uses a Business Use Case (BUC) rate limiting system that's more nuanced than simple request caps.
Base Allocation
Every connected Instagram account gets 200 API requests per hour. This limit is per account, not per app. So if your app has 50 connected accounts, your total hourly capacity is 10,000 requests (200 × 50).
What Counts Against Your Limit
- ✅ Successful requests
- ✅ Failed requests (errors still consume quota)
- ✅ Pagination requests (each page = 1 request)
- ❌ Webhook deliveries (these are push, not pull)
Monitoring Your Usage
Parse the X-Business-Use-Case-Usage header from API responses:
{
"ig_api_usage": [{
"acc_id_util_pct": 75,
"reset_time_duration": 1800
}]
}
- acc_id_util_pct: Percentage of hourly limit consumed (0-100)
- reset_time_duration: Seconds until limit resets
Pro tip: Implement exponential backoff when acc_id_util_pct exceeds 80%. Never let it hit 100% or you'll be temporarily blocked.
Realistic Capacity Examples
| Use Case | Requests/Hour | Can You Do It? |
|---|---|---|
| Refresh dashboard for 5 accounts | ~110 | ✅ Yes, 1-2x per hour |
| Monitor comments every 5 minutes | ~48 | ✅ Yes, all day |
| Bulk publish 25 posts | ~75 | ✅ Yes, with margin |
| Scrape 1000 posts from hashtag | ~1000 | ❌ Need 5 accounts |
Why Unified APIs Are a Simpler Option

The Instagram Graph API is powerful, but it's a lot to manage. Multi-step authentication, platform-specific media handling, and the constant risk of undocumented breaking changes add up fast.
Unified APIs wrap all that complexity into a single, clean interface. One set of endpoints for Instagram, Facebook, LinkedIn, and whatever else you need.
How Abstraction Helps
Instead of learning each social network's quirks separately, you learn one API. The provider handles the translation. That three-step container dance for Instagram collapses into a single API call.
Industry reports show that over 40% of digital marketing agencies now rely on third-party APIs for this reason, reporting a 30% reduction in content management time and a 12% boost in average engagement rates.
Workflow Comparison
Direct Graph API:
- Authenticate through the Facebook OAuth 2.0 flow.
- POST to create an Instagram media container.
- Poll the container to check status.
- POST again to publish the container.
- Repeat all of this with different logic for every other platform.
Unified API (like Late):
- Authenticate once for all connected accounts.
- POST to a scheduling endpoint with what to post and where. Done.
This is why many developers opt for a unified social media management API. It frees you from maintaining separate integrations so you can build features your users actually want.
Troubleshooting Common Errors and Rate Limits
Hitting errors is part of the process. Most have straightforward fixes.
OAuthException: Almost always a permissions issue. Check that your app has the instagram_content_publish scope and that your access token is valid.
Content validation failures: Your media doesn't meet Instagram's rules for aspect ratio, resolution, or file format. Validate against their guidelines before uploading.
Rate Limits
The Instagram Graph API caps how many calls your app can make in a given window. Exceed it and you'll get temporarily blocked. Cache data that doesn't change often, use webhooks instead of polling, and implement exponential backoff for failed requests. More on this in our guide on API rate limit best practices.
Common Error Codes
| Error Code | Common Cause | How to Fix |
|---|---|---|
| 100 | Invalid Parameter | Missing or invalid parameter. Check the API docs for the endpoint. |
| 190 | Invalid OAuth 2.0 Access Token | Token is expired, revoked, or malformed. Generate a new token. |
| 200 | Permission Denied | User hasn't granted the necessary permissions. Re-initiate the OAuth flow. |
| 368 | Temporarily Blocked | Posting behavior flagged as spammy. Wait and review your posting frequency. |
| 9004 | Content Not Valid | Media doesn't meet Instagram's specifications (aspect ratio, file type, resolution). |
| 24 | Media ID Not Found | Container doesn't exist or hasn't finished processing. Verify it was created successfully. |
Instagram API Alternatives: Unified APIs vs Direct Integration
When deciding how to integrate Instagram posting into your app, you have two main paths:
Option 1: Direct Graph API Integration
Building directly on Meta's Graph API gives you full control but comes with trade-offs:
Pros:
- No third-party dependency
- Access to all API features as Meta releases them
- No additional costs beyond your development time
Cons:
- Complex OAuth 2.0 setup (Facebook Page + Business/Creator account linking)
- Multi-step media container workflow
- You handle all rate limiting, token refresh, and error recovery
- Each platform requires separate integration (Instagram, TikTok, LinkedIn, etc.)
Option 2: Unified API Providers
Several companies offer abstraction layers over Instagram's API:
| Provider | Starting Price | Key Differentiator |
|---|---|---|
| Late | $29/mo | 12 platforms, 99.97% uptime, first-comment support |
| Ayrshare | $49/mo | Focus on agencies, white-label options |
| Publer | $12/mo | Visual calendar, Canva integration |
| Unipile | Custom | Enterprise focus, messaging APIs |
For developers building scheduling tools, CMS integrations, or multi-platform apps, unified APIs eliminate months of integration work. Late's API, for example, reduces Instagram posting to a single endpoint:
curl -X POST https://api.getlate.dev/posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platforms": ["instagram"],
"content": "Your caption here #api #instagram",
"mediaUrls": ["https://example.com/image.jpg"],
"firstComment": "Link in bio for more!"
}'
This single call handles container creation, media upload, publishing, and first comment. Compare that to the multi-step Graph API workflow shown earlier.
When to Use Which
- Use Direct Graph API if: You only need Instagram, have dedicated API engineering resources, or require features not yet supported by unified APIs.
- Use a Unified API if: You need multiple platforms, want faster time-to-market, or prefer paying for reliability over building it yourself.
Common Questions
Can I Post Stories or Reels with the API?
Yes. The Instagram Content Publishing API supports Reels (video posts) by setting media_type=REELS and providing a video_url when creating the media container. Stories publishing is also available for Business accounts through the API by setting media_type=STORIES. This means you can programmatically publish feed posts, carousels, Reels, and Stories. Refer to the official Meta documentation for the latest details on supported media types and requirements.
How Should I Handle Authentication Securely?
Authentication must happen server-side using the OAuth 2.0 flow. Never expose your App Secret or access tokens in client-side code. Your server should receive the authorization code, exchange it for an access token, and store that token encrypted in your database.
Creator vs. Business Accounts: Does It Matter?
For publishing content, both work. The difference is in analytics and advertising APIs, which are more powerful for Business accounts. If users need deep insights, Business is the right choice. If they're focused purely on content, Creator accounts are fine.
What are Instagram API rate limits?
The Instagram Graph API allows 200 requests per hour per user (Instagram account). Each connected account gets its own limit pool. Pagination requests count separately, and failed requests still consume your limit. To stay within limits, cache responses, use webhooks instead of polling, and implement exponential backoff.
Do I need a Business account to use the Instagram API?
Yes. The Instagram Graph API only works with Business or Creator accounts. Personal accounts cannot use the Content Publishing API. You also need to connect your Instagram account to a Facebook Page for authentication through Meta's OAuth 2.0 flow.
Related Resources
- Instagram Graph API Guide - Deep dive into authentication and endpoints
- Schedule First Comment - How to automate first comments on Instagram
- Instagram API Pricing - Compare costs of different Instagram API solutions
- Social Media API Overview - Multi-platform publishing in one API
Ready to skip the Graph API complexity? Late's unified API lets you post to Instagram plus 11 other platforms with a single integration. First comment support, Reels, carousels, and Stories—all included. Start free at getlate.dev.