Skip to content
Instagram integration · v1

Instagram API for photo and Reels publishing

Instagram publishing is a two-phase asynchronous flow. PostMCP creates the media container, polls it to FINISHED and publishes it — you send a caption and a media URL.

Endpoint
POST /api/tools/create_post
Platform value
"instagram"
Auth
x-api-key or Bearer token
Upstream
graph.instagram.com v26.0
Overview

What the Instagram API gives you

The Instagram content publishing API never publishes in one call. You create a media container, then poll it until status_code reads FINISHED, then publish the container by ID. Get the polling wrong and you either publish an unprocessed asset or hang forever on a video that already failed.

PostMCP runs that loop for you against graph.instagram.com/v26.0 using Instagram Login, so a business or creator account connects directly without a Facebook Page in the middle. Videos and Reels are detected from the file extension and submitted as REELS; everything else goes up as an image.

Photo posts

A public image_url plus your caption becomes a native feed post.

Reels

URLs ending in .mp4 or .mov are detected automatically and submitted with media_type: REELS.

Managed container polling

The engine polls status_code every 3 seconds for up to 60 seconds and raises the real Instagram error message on failure.

Direct Instagram Login

Business and creator accounts connect through instagram.com/oauth/authorize — no Facebook Page linkage required.

Scheduled publication

Queue posts by date and time; the container flow runs at the scheduled slot.

Cross-posting

Publish the same asset to Facebook, Threads and the rest from one request.

Common uses

  • Publish a Reel the moment a video render finishes in your pipeline.
  • Push new product photography from your PIM to Instagram with generated captions.
  • Let an agent write captions and hashtags, then queue them for review.
  • Cross-post an Instagram asset to Facebook and Threads in the same request.
Quickstart

Post to Instagram in three steps

Connect the account once, grab an API key, then send a single request. The same body works from a shell, a server, or an AI agent.

  1. 1

    Connect your Instagram account

    Open the dashboard, choose Instagram and complete the hosted connect flow. Credentials are encrypted into the user vault and never returned to your client.

  2. 2

    Create an API key

    Generate a key from the dashboard. Send it as x-api-key, as an Authorization: Bearer header, or as an apikey query parameter on the MCP transport.

  3. 3

    Send your first post

    POST to /api/tools/create_post with platforms: ["instagram"]. Set publishImmediately to broadcast now, or supply scheduleDate and scheduleTime to queue it.

POST /api/tools/create_post
curl -X POST "https://api.postmcpai.com/api/tools/create_post" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $POSTMCPAI_API_KEY" \
  -d '{"content":"Shipping something new today. Built with PostMCP AI.","platforms":["instagram"],"publishImmediately":true}'
Response — 200 OK
{
  "success": true,
  "message": "Post created and queued successfully",
  "post": {
    "id": "66a50c89e4b019a2b72f",
    "content": "Shipping something new today. Built with PostMCP AI.",
    "platforms": [
      "instagram"
    ],
    "status": "published"
  }
}
Reference

Instagram API endpoints

Every endpoint is a POST against the base URL https://api.postmcpai.com. The same seven operations cover all connected networks — set the platform value to "instagram" to target Instagram.

OperationEndpointWhat it does
preflight_postPOST/api/tools/preflight_postDry-run copy against limits, targets and credits before publishing.
create_postPOST/api/tools/create_postSchedule a post or broadcast it immediately.
publish_post_nowPOST/api/tools/publish_post_nowForce a queued post out ahead of its slot, or retry the profiles that failed.
list_postsPOST/api/tools/list_postsRead the queue — scheduled, published, draft and failed — with counts.
get_postPOST/api/tools/get_postRead one post, with per-profile delivery state and live URLs.
get_post_analyticsPOST/api/tools/get_post_analyticsRead how a post did: views, likes, comments and shares per profile.
get_profile_analyticsPOST/api/tools/get_profile_analyticsRead a profile’s followers, post count and views from its network.
update_postPOST/api/tools/update_postEdit copy, targets, schedule or status before publication.
reschedule_postPOST/api/tools/reschedule_postMove a post to another slot, keeping its copy and targets.
reset_stuck_postPOST/api/tools/reset_stuck_postRelease a post left stuck mid-publish so it can be retried.
delete_postPOST/api/tools/delete_postRemove a scheduled or draft post from the queue.
get_connected_accountsPOST/api/tools/get_connected_accountsList connected profiles, handles and page IDs per platform.
get_account_healthPOST/api/tools/get_account_healthFind connections whose token expired or is about to.
generate_imagePOST/api/tools/generate_imageGenerate a post image and get back a hosted URL for mediaUrl.
list_workspacesPOST/api/tools/list_workspacesList the workspaces on this key, with the id to scope other calls to.
get_user_infoPOST/api/tools/get_user_infoRead plan tier and credit balance.

create_post parameters

FieldTypeRequiredDescription
contentstringYesText body of the post. Truncation rules are enforced by the destination network, not by PostMCP.
targetAccountsarray[object]YesThe profiles that receive the post. Each entry takes platform and profileId (from get_connected_accounts). Only the profiles listed here are posted to.
platformsarray[string]OptionalShorthand for whole networks — linkedin, twitter, facebook, instagram, threads, bluesky, youtube. Each one expands to every connected profile on it, so prefer targetAccounts unless you mean that fan-out. Optional when targetAccounts is given.
publishImmediatelybooleanOptionalWhen true the post is broadcast on receipt. Defaults to false, which queues it.
scheduleDatestringOptionalPublication date as YYYY-MM-DD. Required when publishImmediately is false.
scheduleTimestringOptionalPublication time as HH:MM on a 24-hour clock. Required when publishImmediately is false.
timezonestringOptionalIANA zone the schedule above is written in, e.g. Asia/Kolkata. Omit it and the wall-clock slot resolves as UTC, which is rarely what "10am" meant.
mediaUrlstringOptionalPublicly reachable image or video URL. PostMCP fetches it and re-uploads it in the format the network expects. Required, and must be a video, when the post targets YouTube.
workspaceIdstringOptionalWorkspace to post from, taken from list_workspaces. Omitted, the call resolves to the default workspace on the key.
Authentication

Instagram OAuth and API keys

Two layers of auth sit under every request: the Instagram credential you grant once during connect, and the PostMCP API key your code sends on each call.

Step 1

Open the connect URL

Send the user to /connect/instagram. PostMCP builds an instagram.com/oauth/authorize URL with enable_fb_login=0 and force_authentication=1.

Step 2

Instagram consent screen

The user approves basic profile access and content publishing on their business or creator account.

Step 3

Token exchange

The callback code becomes an Instagram access token tied to the Instagram user ID used in every publish call.

Step 4

Encrypted storage

Tokens are encrypted into the user vault and never exposed to your client.

Scopes requested from Instagram

ScopeWhy it is needed
instagram_business_basicReads the connected business account profile and its Instagram user ID.
instagram_business_content_publishCreates media containers and publishes them to the feed.

Sending your API key

Header (recommended)x-api-key: pmcp_sec_…
Bearer tokenAuthorization: Bearer pmcp_sec_…
Query (MCP SSE)/mcp?apikey=pmcp_sec_…
Under the hood

How PostMCP publishes to Instagram

One request from you becomes this sequence server-side. Knowing the shape helps when you are debugging a failed broadcast.

  1. 1

    Classify the media

    A .mp4 or .mov extension sets media_type: REELS with video_url; anything else uses image_url.

  2. 2

    Create the container

    The caption and media URL are POSTed to /{ig-user-id}/media, returning a creation ID.

  3. 3

    Poll to FINISHED

    Every 3 seconds, up to 20 attempts, the engine reads status_code. An ERROR status raises Instagram's own error message immediately.

  4. 4

    Publish the container

    The creation ID is posted to /media_publish to push it live.

  5. 5

    Time out safely

    If 60 seconds elapse without FINISHED the post is marked failed rather than left in limbo.

Upstream Instagram calls

MethodEndpointPurpose
POSThttps://graph.instagram.com/v26.0/{ig-user-id}/mediaCreates the media container from `image_url` or `video_url` plus a caption.
GEThttps://graph.instagram.com/v26.0/{creation-id}?fields=status_code,statusPolls the container until processing reports FINISHED or ERROR.
POSThttps://graph.instagram.com/v26.0/{ig-user-id}/media_publishPublishes the finished container by `creation_id`.

Direct Instagram API vs PostMCP

AspectCalling Instagram directlyWith PostMCP
Publishing flowCreate container, poll, publish — three phases you orchestrateOne call, orchestration server-side
Polling logicCustom retry loop and error parsingBounded 60s poll with real error surfacing
Reels detectionSet media_type yourself per assetInferred from the media URL
CarouselsOne container per slide, poll each, then a CAROUSEL container listing themOne `mediaUrls` array of 2–10 URLs
Account linkageFacebook Page linkage in most setupsDirect Instagram Login
SchedulingBuild your own queueBuilt in and editable
Constraints

Instagram limits and supported media

These ceilings are set by Instagram, not by PostMCP. Your content field is forwarded unchanged, so the network enforces them rather than silently truncating.

Caption length2,200 characters
Hashtags30 per post
MediaRequired — Instagram has no text-only post type
Carousel2–10 images and/or videos via mediaUrls
Image formatsJPEG (public URL)
Video formatsMP4 and MOV, published as Reels
Account typeBusiness or creator accounts only
Troubleshooting

Common Instagram API errors

Failures are recorded per platform on the post record, so a multi-network broadcast that partially succeeds tells you exactly which leg failed and why.

CodeMessageLikely causeFix
400Instagram Media Container creation failedThe media URL is unreachable, or the aspect ratio and format fall outside Instagram's bounds.Serve a public JPEG within Instagram's supported aspect-ratio range.
ERRORInstagram Media processing failedThe container reported an ERROR status during processing, usually a bad video encode.Re-encode as H.264 MP4 with AAC audio and retry.
TIMEOUTInstagram Media processing timed outProcessing did not reach FINISHED within 60 seconds.Use a smaller or shorter asset; large videos can exceed the window.
190Access token for instagram is missing or invalidThe token expired or the account switched away from a business type.Confirm the account is business or creator and reconnect.
Model Context Protocol

Post to Instagram from an AI agent

The same seven operations are exposed as MCP tools. Point Claude Desktop, Cursor, or any MCP client at the server and your agent can publish to Instagram directly.

claude_desktop_config.json
{
  "mcpServers": {
    "postmcpai": {
      "command": "npx",
      "args": ["-y", "@postmcpai/server"],
      "env": {
        "POSTMCPAI_API_KEY": "pmcp_sec_YOUR_SECRET_KEY",
        "POSTMCPAI_API_URL": "https://api.postmcpai.com"
      }
    }
  }
}

Prompt the agent directly

With the server connected, natural language is enough — the agent picks the tool and fills the arguments:

“Draft a Instagram post about today’s release and schedule it for 9:30am tomorrow.”
FAQ

Instagram API questions

How do I post to Instagram using the API?

POST to https://api.postmcpai.com/api/tools/create_post with platforms: ["instagram"], a content caption and a public mediaUrl. PostMCP creates the media container on graph.instagram.com, polls it to FINISHED and publishes it.

Why does Instagram publishing need two API calls?

Instagram processes media asynchronously. The first call creates a container and returns a creation ID; the asset is transcoded in the background; only once status_code reads FINISHED can the container be published. PostMCP runs the poll loop so you see one synchronous result.

Can I post a Reel through the Instagram API?

Yes. A mediaUrl ending in .mp4 or .mov is submitted with media_type: REELS. Video containers get the full 60-second processing window before publishing.

Can I post text-only content to Instagram?

No. Instagram has no text-only feed post, so mediaUrl is effectively required. A request without media falls back to a placeholder image rather than failing outright.

Can I post an Instagram carousel through the API?

Yes. Pass mediaUrls, an ordered array of 2–10 public image or video URLs, instead of mediaUrl. PostMCP creates one item container per slide with is_carousel_item: true, polls each to FINISHED, creates the CAROUSEL container that lists them, polls that, and publishes it. Images and video can be mixed. Eleven slides are refused at creation, before any credits are spent, and preflight_post says the same without writing anything.

Do I need a business or creator account?

Yes. instagram_business_basic and instagram_business_content_publish are only granted to business and creator accounts. Personal accounts cannot publish through the API.

What is the Instagram caption character limit?

2,200 characters and a maximum of 30 hashtags per post. Your content becomes the caption verbatim.

Other social media APIs

Start posting to Instagram today

Connect the account, take an API key and send your first request in under five minutes — from a shell, your backend, or an AI agent.