
There is no such thing as an Instagram API key. Instagram's official API, run by Meta, authenticates every request with an access token that belongs to one Instagram professional account, and you get that token through an OAuth login flow backed by a Meta app's app ID and app secret. If you only need to call the API for your own account, you can generate a 60-day token in the Meta App Dashboard in a few minutes; if you serve other people's accounts, you need OAuth, App Review and Business Verification.
TL;DR
- Instagram has no static API key. You need a Meta app (app ID + app secret) and an access token per Instagram account.
- Only Business and Creator (professional) accounts can use the API. Personal accounts get nothing since Basic Display was shut down in December 2024.
- Meta now has three setups: Instagram Login (
graph.instagram.com), Facebook Login (graph.facebook.com, needs a linked Page) and the newer Unified Login, which Meta recommends for new integrations. - With Instagram Login, the login flow gives a 1-hour token. Exchange it for a 60-day token and refresh it before day 60, or the user has to log in again.
- Error
190means the token is expired or revoked. Error10or200-299means a missing permission. - Never put the app secret in a browser, mobile app or repo. Token exchanges happen server-side.
- If you just want to post, read comments or reply to DMs, a unified API like Outstand gives you one API key and handles the Meta app, tokens and refresh for you.
Does Instagram have an API?
Yes. Meta calls it the Instagram Platform: a set of APIs for Instagram professional accounts covering content publishing (images, videos, Reels, carousels, Stories), comment moderation, insights, mentions and messaging. For a full tour of the endpoints see our Instagram Graph API guide, and for what it costs see Instagram API pricing.
What it does not have is a key you paste into a header forever. Some guides still describe "Instagram API with Instagram Login" as a read-only consumer API. That is out of date: per Meta's platform overview, it supports publishing, comment moderation, insights and messaging for professional accounts, without a Facebook Page.
What you get instead of an Instagram API key
Credential | What it is | Where it lives | Secret? |
|---|---|---|---|
App ID | Identifies your Meta app in OAuth URLs | App Dashboard | No |
App secret | Proves requests come from your app during token exchange | App Dashboard | Yes, server only |
Authorization code | One-time code returned to your redirect URI, valid 1 hour | Query string | Short-lived |
Short-lived access token | Instagram User token from the code exchange, valid 1 hour | Your server | Yes |
Long-lived access token | 60-day token you actually call the API with | Your database | Yes |
One detail that trips people up: with Instagram Login, the app ID and secret you need are the Instagram app ID and Instagram app secret shown under Instagram > API setup with Instagram login > Business login settings, not the Meta app ID at the top of the dashboard. Facebook Login and Unified Login use the Meta app ID and secret. Mixing them up gives you an "invalid client" error on the code exchange.
Instagram Login vs Facebook Login vs Unified Login
Meta's overview currently lists three setups. Pick one before you write any code, because the token type, host and permission names all differ.
Instagram Login | Facebook Login | Unified Login | |
|---|---|---|---|
User logs in with | Instagram or Facebook | ||
Token you receive | Instagram User access token | Facebook User or Page access token | Business Integration System User token |
API host |
|
|
|
Facebook Page | Not required | Required | Not required |
Permission family |
|
|
|
Meta's recommendation | Existing integrations | Existing Page-linked integrations | New integrations |
Unified Login is built on Facebook Login for Business. Its token belongs to the client's business portfolio rather than the person who logged in, and whether it expires depends on the configuration you create in the dashboard (Meta: Unified Login authentication). Facebook Login tokens follow the Page token model, which we cover in depth in long-lived Page access tokens.
The rest of this guide walks through Instagram Login, because it is the setup most developers search for when they type "instagram access token", it needs no Facebook Page, and it is what Outstand uses in production today.
Permissions (scopes) for Instagram Login
Scope | What it unlocks |
|---|---|
| Profile fields, media list. Required to refresh tokens. |
| Publishing posts, carousels, Reels and Stories |
| Reading, replying to, hiding and deleting comments |
| Account and media insights |
| Reading and sending direct messages |
The older business_basic, business_content_publish and similar scope values were deprecated on January 27, 2025 (Meta: Business Login for Instagram). Code copied from a 2024 tutorial that still sends them will fail.
Access levels matter as much as scopes. Standard Access is the default and is enough if your app only serves accounts you own or manage. To serve accounts you do not own, you need Advanced Access, which requires App Review and Business Verification (Meta overview). Our approval guide by platform covers what reviewers want to see; in our experience, plan for at least two weeks from app creation to a fully approved integration.
Fastest path: a token for your own account
If you only need to automate your own Instagram professional account, skip OAuth entirely.
- Create an app at developers.facebook.com/apps and add the Instagram product.
- Open Instagram > API setup with Instagram login.
- Under Generate access tokens, add your Instagram account. Meta requires the account to be public.
- Click Generate token next to the account, log in, and copy the token.
Tokens generated in the App Dashboard are long-lived and valid for 60 days (Meta: Get started with Instagram Login). Test it:
1curl -s "https://graph.instagram.com/v27.0/me?fields=user_id,username,account_type,followers_count&access_token=$IG_TOKEN"If that returns your username and account type, you have a working token. You can also paste it into Meta's Access Token Debugger to see its scopes and expiry.
Step by step: get an Instagram access token with OAuth
This is the flow you need when other people connect their accounts to your product. All four endpoints come from Meta's Business Login for Instagram docs.
1. Send the user to the authorize URL
1https://www.instagram.com/oauth/authorize?client_id=YOUR_INSTAGRAM_APP_ID&redirect_uri=https://yourapp.com/ig/callback&response_type=code&state=RANDOM_CSRF_VALUE&scope=instagram_business_basic,instagram_business_content_publish,instagram_business_manage_comments,instagram_business_manage_insightsThe redirect_uri must exactly match one of the OAuth redirect URIs in your Business login settings. Meta notes the dashboard may add a trailing slash, so check the stored value. Always send and verify state.
2. Exchange the code for a short-lived token
The user comes back to https://yourapp.com/ig/callback?code=...#_. Strip the trailing #_, which is not part of the code. The code is valid for one hour and works once.
1curl -X POST https://api.instagram.com/oauth/access_token \
2 -F "client_id=$IG_APP_ID" \
3 -F "client_secret=$IG_APP_SECRET" \
4 -F "grant_type=authorization_code" \
5 -F "redirect_uri=https://yourapp.com/ig/callback" \
6 -F "code=$CODE"The response carries a short-lived access_token (valid for one hour), the Instagram-scoped user_id, and the permissions the user actually granted. Reusing a code returns Matching code was not found or was already used.
3. Exchange it for a long-lived token
1curl -s "https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret=$IG_APP_SECRET&access_token=$SHORT_TOKEN"1{
2 "access_token": "EAACEdEose0...",
3 "token_type": "bearer",
4 "expires_in": 5183944
5}expires_in is in seconds, roughly 60 days. Store now + expires_in next to the token.
4. Refresh before day 60
1curl -s "https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=$LONG_TOKEN"There is no separate refresh token: you refresh with the current long-lived token. Meta only allows it when the token is at least 24 hours old, not yet expired, and the user granted instagram_business_basic. Miss the window and the token is dead; the user has to go through the login flow again.
Gotchas we hit running this in production
These come from Outstand's own Instagram connection code, not from the docs.
user_idoverflows JavaScript numbers. The code exchange returnsuser_idas a JSON number larger than 2^53.JSON.parsesilently rounds it, so you store the wrong ID. We parse that response with a custom transformer that keeps the ID as a string.user_idis sometimes missing. Some exchange responses come back without it. Fall back to calling/mewith the new token, whoseidmatches.permissionsis an array, not a string. Meta's docs show a comma-separated string; in practice we receive an array. Handle both, and store what was actually granted, because users can untick scopes.- Encode the scope list with literal commas.
URLSearchParamsencodes commas as%2C. That works on the normal login path, but when Instagram interrupts the flow with a checkpoint (an OTP challenge) it resumes from a stored redirect that is decoded one fewer time, and the whole list arrives as one invalid scope. Appendscopelast, with raw commas. - Connecting a second account reconnects the first. Instagram happily reuses the browser's logged-in session. Pass
force_reauth=trueon the authorize URL so the user is asked for credentials, which is also how they pick a different account. - Refresh on a schedule, not on failure. Waiting for a
190to refresh is too late: an expired token cannot be refreshed. Our token refresher runs daily and refreshes any token within seven days of expiry, so each token gets several attempts before it lapses.
Common Instagram API token errors
Graph API errors share one shape, documented in Meta's error handling guide:
1{
2 "error": {
3 "message": "Error validating access token: Session has expired",
4 "type": "OAuthException",
5 "code": 190,
6 "error_subcode": 463,
7 "fbtrace_id": "EJplcsCHuLu"
8 }
9}Code | Meaning | What to do |
|---|---|---|
| Token expired, revoked or invalid | Send the user through login again. Subcode |
| Permission not granted or removed | Check granted scopes, re-request the missing one |
| Permission error for a specific permission | Same as |
| Throttled | Back off and retry |
| Code reused, expired, or | Restart the flow; compare redirect URIs byte for byte |
Treat 190 as "this account needs reconnecting" and tell the user, rather than retrying.
Security: where the secret and tokens must live
- The app secret goes into server-side environment variables or a secrets manager, never into frontend bundles, mobile binaries or git. Meta's docs say the same: long-lived token requests must be made server-side because they include the secret.
- Treat access tokens like passwords. Encrypt them at rest, keep them out of logs, URLs and analytics events, and never return them from your own API by default.
- Use
stateon every authorize request to stop CSRF on the callback. - Register a deauthorize callback and a data deletion callback in Business login settings, and actually delete the tokens when they fire.
Or skip all of it: one Outstand API key
Everything above is per network. Repeat it for TikTok, LinkedIn and YouTube and you maintain a stack of OAuth flows and refresh jobs. Outstand is a unified social media API: one API key, sent as Authorization: Bearer, covers all 12 networks we support, including Instagram.
For Instagram, Outstand ships Managed Keys: your subscription includes Outstand's own Meta app, so you can connect Instagram Business or Creator accounts without creating a Meta app or going through App Review yourself. If you want your own brand on the consent screen, you can bring your own Meta app instead (Instagram configuration).
Connect an account by sending the user to Outstand's authorize URL. Outstand runs the Instagram Login flow, exchanges the code, upgrades to a 60-day token and stores it:
1https://www.outstand.so/app/api/socials/instagram/{orgId}?redirect_uri=https://yourapp.com/callbackThe user lands back on your redirect_uri with success, account_id, network_unique_id and username. Then publish with the account ID:
1curl -X POST https://api.outstand.so/v1/posts/ \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "containers": [
6 {
7 "content": "New drop is live",
8 "media": [{ "url": "https://media.outstand.so/your-upload/launch.jpg", "filename": "launch.jpg" }]
9 }
10 ],
11 "accounts": ["YOUR_INSTAGRAM_ACCOUNT_ID"]
12 }'Outstand refreshes Instagram tokens daily before they expire, and if a refresh fails it sends an account.token_expired webhook so you can ask the user to reconnect. Direct messages are opt-in via the instagram_business_manage_messages scope (Instagram docs). See also the Instagram API page, getting Instagram posts and Reels and Stories.
FAQ
Does Instagram have an API key?
No. Instagram authenticates with OAuth access tokens issued per Instagram professional account. The closest thing to a key is your Meta app's app ID (public) and app secret (private), which you use to obtain tokens, never to call the API directly.
How do I get an Instagram access token?
For your own account, generate one in the Meta App Dashboard under Instagram > API setup with Instagram login; it lasts 60 days. For other users' accounts, implement Business Login for Instagram: authorize URL, code exchange at api.instagram.com/oauth/access_token, then exchange for a long-lived token at graph.instagram.com/access_token.
How long does an Instagram access token last?
Short-lived tokens from the login flow last one hour. Long-lived tokens last 60 days and can be refreshed for another 60 days once they are at least 24 hours old. Unified Login tokens expire according to the configuration you choose.
Is there an Instagram access token generator?
Meta's App Dashboard has a Generate token button for accounts added to your app, and the Graph API Explorer can mint test tokens for Facebook Login. Avoid third-party "token generator" websites: they ask you to log in with your Instagram credentials and get a token that controls your account.
Can I use the Instagram API with a personal account?
No. The Basic Display API, which served personal accounts, was shut down in December 2024. You need a Business or Creator account. See Instagram Creator vs Business account for which one to pick.
What does Instagram API error 190 mean?
The access token is expired, revoked or otherwise invalid. Check error_subcode: 463 is expired, 460 means the user changed their password. Expired tokens cannot be refreshed, so the user must log in again.
Rather build product than babysit Meta tokens? Get an Outstand API key and connect your first Instagram account in about half an hour.