Instagram API guide: posting, DMs and webhooks (2026)
By Natnael Girma · Published
The Instagram API is Meta's official API for Instagram Business and Creator accounts. It lets your app publish posts, Reels, carousels and Stories, read and reply to comments, send and receive DMs, and get insights. There is no API key. Each account owner signs in through Meta, and your app gets an access token for that account. Personal accounts can't use it, and the old Basic Display API stopped working on December 4, 2024.
Everything below is from Meta's Instagram Platform docs as of December 2026. The current Graph API version is v27.0, released November 4, 2026, per the changelog.
Which Instagram API setup to use
Meta now offers three setups. They share most endpoints but differ in how people log in, which token you get and which host you call.
| Unified Login | Instagram Login | Facebook Login for Business | |
|---|---|---|---|
| Users log in with | Instagram or Facebook | ||
| Facebook Page needed | No | No | Yes, linked to the account |
| Business portfolio needed | Yes | No | Depends on configuration |
| Token | Business Integration System User token | Instagram User token | Facebook User or Page token |
| Host | graph.facebook.com | graph.instagram.com | graph.facebook.com |
| Messaging | Built in | Built in | Through the Messenger Platform |
| Hashtag search, product tagging, partnership ads | Yes | No | Yes |
Meta recommends Unified Login for new integrations and says new Instagram API features ship only for that setup. Its token belongs to the client's business portfolio, so it keeps working if the person who logged in leaves the business. Instagram Login is the simplest to start with, and it's what the curl examples below use. For Unified Login or Facebook Login, swap the host to graph.facebook.com and use that setup's token.
What the API can and can't do
It can:
- Publish images, Reels, carousels and Stories to the account
- Read comments on the account's media, reply, hide and delete them
- Send DMs to people who messaged the account first, and send one private reply to a commenter
- Read insights and mentions, and receive webhooks for comments and messages
It can't:
- Reach personal accounts
- Follow accounts or like posts. Meta's reference has no endpoints for either.
- Start a DM conversation with someone who hasn't messaged the account
- Apply filters, add shopping tags (per the publishing guide), or add Story stickers such as links, polls or locations
Getting access: app, permissions and App Review
- Create an app at developers.facebook.com and add the Instagram use case.
- Pick your login setup and request only the permissions you use. For Instagram Login those are
instagram_business_basic(required for everything),instagram_business_content_publish,instagram_business_manage_commentsandinstagram_business_manage_messages. - Build and test with Standard Access. It covers accounts you own or manage and have added to the app, with no review.
- Request Advanced Access through App Review before serving accounts you don't own or manage. Meta's overview says Advanced Access also needs Business Verification.
For App Review, Meta asks for step-by-step test instructions, test credentials if reviewers need them, and a separate screencast for each permission showing how your app uses it. Some permissions need at least one successful API call before you can request them. Requests for permissions your app doesn't use get rejected.
Get an access token (Instagram Login)
The Business Login flow has three steps.
1. Send the user to authorize.
https://www.instagram.com/oauth/authorize?client_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=instagram_business_basic,instagram_business_content_publish,instagram_business_manage_comments,instagram_business_manage_messages&state=RANDOM
The user comes back with a code. It's valid for one hour and works once. Strip the #_ Meta sometimes appends to the redirect.
2. Exchange the code for a short-lived token.
curl -X POST https://api.instagram.com/oauth/access_token \
-F client_id=YOUR_APP_ID \
-F client_secret=YOUR_APP_SECRET \
-F grant_type=authorization_code \
-F redirect_uri=YOUR_REDIRECT_URI \
-F code=AUTH_CODE
The response has access_token, user_id and permissions.
3. Exchange it for a long-lived token (60 days). Do this on your server, because it uses the app secret.
curl "https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret=YOUR_APP_SECRET&access_token=SHORT_LIVED_TOKEN"
To refresh, call refresh_access_token with grant_type=ig_refresh_token. The token must be at least 24 hours old and not yet expired. A token that expires can't be refreshed, and the user has to log in again. Run a scheduled refresh job well before day 60.
curl "https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=LONG_LIVED_TOKEN"
Publish a photo
Publishing is container first, then publish. Meta downloads your media from a public URL, so the file has to be reachable when you call.
# 1. Create a container
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/media" \
-d "image_url=https://example.com/photo.jpg" \
--data-urlencode "caption=Fresh batch out of the oven #bakery" \
-d "access_token=$TOKEN"
# -> {"id":"CONTAINER_ID"}
# 2. Check it is ready
curl "https://graph.instagram.com/v27.0/CONTAINER_ID?fields=status_code&access_token=$TOKEN"
# -> {"status_code":"FINISHED","id":"CONTAINER_ID"}
# 3. Publish
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/media_publish" \
-d "creation_id=CONTAINER_ID" \
-d "access_token=$TOKEN"
# -> {"id":"MEDIA_ID"}
status_code can be IN_PROGRESS, FINISHED, PUBLISHED, ERROR or EXPIRED. Meta suggests checking once a minute for up to five minutes. Containers expire if you don't publish them within 24 hours.
Images must be JPEG, up to 8 MB, with an aspect ratio between 4:5 and 1.91:1. Captions allow 2,200 characters, 30 hashtags and 20 @ tags. The full spec list is in the media reference.
Reels, carousels and Stories
Reels use media_type=REELS and video_url. Optional fields include share_to_feed, cover_url, thumb_offset (milliseconds), collaborators (up to 3 usernames) and trial_params for trial Reels. Videos must be MP4 or MOV, 3 seconds to 15 minutes, up to 300 MB.
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/media" \
-d "media_type=REELS" \
-d "video_url=https://example.com/reel.mp4" \
-d "share_to_feed=true" \
--data-urlencode "caption=Behind the counter" \
-d "access_token=$TOKEN"
Carousels take one container per item with is_carousel_item=true (videos use media_type=VIDEO), then a parent container with media_type=CAROUSEL and the child IDs. The caption goes on the parent. Reels can't go inside a carousel, and every image is cropped to the first image's aspect ratio.
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/media" \
-d "media_type=CAROUSEL" \
-d "children=CHILD_ID_1,CHILD_ID_2,CHILD_ID_3" \
--data-urlencode "caption=Three new flavors" \
-d "access_token=$TOKEN"
Stories use media_type=STORIES with an image_url or video_url. Story videos run 3 to 60 seconds and up to 100 MB. A published Story reports media_type as IMAGE or VIDEO, so check media_product_type to tell it apart from a feed post.
Rate limits and publishing quotas
| Limit | Value | Source |
|---|---|---|
| API-published posts | 100 per account per rolling 24 hours (carousel counts as one) | Publishing guide |
quota_total returned by the limit endpoint |
50 per 86,400 seconds | Reference |
| Media containers | 400 per account per rolling 24 hours | Media reference |
| Most other calls | 4,800 × the account's impressions, per 24 hours | Overview |
| Send API (text, links, reactions, stickers) | 100 calls per second per account | Overview |
| Send API (audio, video) | 10 calls per second per account | Overview |
| Private replies to post and Reel comments | 750 calls per hour per account | Overview |
| Private replies to Live comments | 100 calls per second per account | Overview |
| Conversations API | 2 calls per second per account | Overview |
The two publishing figures disagree in Meta's own docs. Ask the account directly:
curl "https://graph.instagram.com/v27.0/$IG_ID/content_publishing_limit?fields=quota_usage,config&access_token=$TOKEN"
Send DMs with the Instagram messaging API
The messaging API works only after a person messages the account. You then have 24 hours to reply freely. A reply sent by a person on your team can be tagged to use a separate 7-day human agent window. Text must be 1,000 bytes or less.
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/messages" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"recipient":{"id":"IGSID"},"message":{"text":"Thanks for reaching out. Here is our menu: https://example.com/menu"}}'
You can also send images, video, audio, PDFs, stickers, reactions and templates. Images can be up to 8 MB, and audio, video and PDF files up to 25 MB.
Private replies are how comment-to-DM works. Put the comment ID in the recipient instead of a user ID:
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/messages" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"recipient":{"comment_id":"COMMENT_ID"},"message":{"text":"Here is the guide you asked for: https://example.com/guide"}}'
Meta's rules: one private reply per comment, sent within 7 days of the comment (Live comments only while the broadcast is live). You can message again only if the person replies, within 24 hours of their reply. The 750-an-hour cap sounds tight, but the 7-day window holds 168 hours, so one account can send up to 126,000 private replies (750 × 168) before the oldest comment ages out. A burst of 3,000 keyword comments takes at least four hours to answer, well inside the window.
One setting trips up almost everyone. Meta's messaging setup says each account must turn on Settings, Messages and story replies, Message controls, Connected Tools, Allow Access to Messages. Without it, nothing arrives.
Comments
Reply to a comment with POST /{comment-id}/replies and a message. Hide one with POST /{comment-id} and hide=true, or delete it with DELETE /{comment-id}. To add a comment to your own post (a "first comment"), use POST /{media-id}/comments. Meta's comment moderation guide recommends webhooks over polling to stay under rate limits.
Webhooks
- Create an HTTPS endpoint. Meta verifies it with a GET request containing
hub.mode=subscribe,hub.challengeandhub.verify_token. Check the token matches yours and echo backhub.challenge. - Validate every event. Meta signs payloads in the
X-Hub-Signature-256header assha256=plus an HMAC-SHA256 of the body using your app secret. - Subscribe the fields in the App Dashboard, then enable them for each account:
curl -X POST "https://graph.instagram.com/v27.0/$IG_ID/subscribed_apps" \
-d "subscribed_fields=comments,messages" \
-d "access_token=$TOKEN"
# -> {"success":true}
The setup guide lists three requirements: your app must be Live to receive notifications for app users, comments and live_comments need Advanced Access, and comment and mention notifications only fire for public accounts.
Common errors
From Meta's error code reference:
| Subcode | Meaning | Fix |
|---|---|---|
| 2207052 | Media could not be fetched from the URL | Use a public, direct file URL |
| 2207027 | Media is not ready for publishing | Wait for FINISHED before media_publish |
| 2207008 | Creation ID doesn't exist or expired | Retry after 30 seconds to 2 minutes, then create a new container |
| 2207042 | Daily publishing limit reached | Wait for the 24-hour window to roll |
| 2207004 | Image too large | Keep images under 8 MB |
| 2207009 | Aspect ratio not accepted | Use 4:5 to 1.91:1 |
| 2207010 | Caption too long | 2,200 characters, 30 hashtags, 20 @ tags |
| 2207026 | Unsupported video format | Use MP4 or MOV |
| 2207050 | Account is restricted | The owner must fix it in the Instagram app |
| 2207051 | Activity restricted as possible spam | Slow down, and appeal if it isn't spam |
The error table still says carousels need 2 to 10 items (2207028), while the publishing guide says up to 20. Test with your own account before promising 20.
What we ran into building this
Taskwind's Instagram connector uses Unified Login on graph.facebook.com/v27.0. Some things the docs don't spell out:
- The token isn't the Instagram account. A Unified Login token belongs to a system user, so
/medoesn't return the Instagram account. We list accounts withGET /me/assigned_instagram_accountsand name the account ID in every call. - Your own portfolio is invisible. That endpoint returned nothing when the login came from the business portfolio that owns our Meta app, even though the token worked on those accounts. We check those account IDs individually.
- DM webhooks wait for the toggle. With
messagessubscribed, nothing arrives until the account turns on Allow Access to Messages. When DM webhooks are silent, check that setting before you debug your code. - Comment webhooks need Advanced Access. Until your app has it, read comments on a timer instead. Test with comments written by accounts that have no role on your app, because those are the comments your users will actually get.
Skip the Meta app: use a unified API
If you only need Instagram, building on Meta's API directly is reasonable. It gets heavier when you also need TikTok, LinkedIn or YouTube, each with its own app, review and token rules.
Taskwind runs the Meta app for you. Your users connect through Meta's sign-in in the Taskwind dashboard, and your code makes one call. Upload media, then post:
curl -X POST https://taskwind.ai/v1/media \
-H "Authorization: Bearer $TASKWIND_API_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @photo.jpg
# -> {"id":"med_...","url":"...","content_type":"image/jpeg"}
curl -X POST https://taskwind.ai/v1/posts \
-H "Authorization: Bearer $TASKWIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content":"Fresh batch out of the oven #bakery","account_ids":["acc_..."],"media_ids":["med_..."],"scheduled_at":1798000000}'
Taskwind handles the containers, polling and token storage, and it applies the 24-hour and 7-day messaging rules to DMs and comment-to-DM automations. It posts photos, Reels and carousels of up to 10 items. It doesn't publish Stories and has no analytics yet. Plans start at $49 a month for 5 accounts (pricing, API docs). For a wider look at multi-network APIs, see social media posting APIs.
Questions
Is the Instagram API free?
Meta doesn't publish a price for it. Your costs are hosting, engineering time and the work of passing App Review.
Can I get an Instagram API key?
No. Instagram has no project-level API key. You get an app ID and secret, and each account owner grants your app a token through OAuth.
Can I schedule posts with the Instagram API?
Not directly. There is no publish-at parameter, so your own job has to create and publish the container at the right time. Our guide to automating Instagram posts compares the ways to do that.