# Post to Instagram from Claude Code

Turn a hosted release video into an Instagram Reel. Connect Claude Code to PubNio over MCP, choose the destination, and have Claude Code check delivery and return the permalink.

Canonical page: https://pubnio.com/claude/instagram

## Connect Claude Code

### Add PubNio to .mcp.json

Project scope. Commit it so everyone who opens the repository gets the same server, or run the claude mcp add command once instead.

```json
{
  "mcpServers": {
    "pubnio": {
      "type": "http",
      "url": "https://pubnio.com/mcp"
    }
  }
}
```

Or from a terminal:

```sh
claude mcp add --transport http pubnio https://pubnio.com/mcp
```

### Sign in

1. Start Claude Code in the project and run /mcp.
2. Select pubnio. A server from .mcp.json asks you to approve it first.
3. Authenticate. Your browser opens PubNio sign-in; approve the workspace and return to Claude Code.

### Install the skill (optional)

```sh
claude plugin marketplace add pubnio/agent-skills
claude plugin install pnio@pubnio
```

Installs the pnio skill as a Claude Code plugin from the pubnio/agent-skills marketplace.

### Connect your Instagram account

[Open PubNio](https://pubnio.com/app), choose your workspace, and go to Accounts. Use the same workspace when you sign in from Claude Code.

- Instagram Business or Creator account linked to an authorized Facebook Page, or connected through the Instagram Login flow.
- Publishing permission for the selected Instagram profile, granted when you connect it in PubNio.
- A ready Instagram media item: JPEG or PNG for images, H.264 MP4 with AAC audio for video.
- The Reel video at an HTTPS URL. A public or signed HTTPS link PubNio can fetch. A file of up to 8 MiB can go inline as base64 instead.

### Check the destination

```
List the Instagram accounts in my PubNio workspace and show which are ready to publish. Do not create, schedule, or publish a post.
```

## Worked job: Ship a release Reel

Contract example: sample IDs and URLs. The request and both responses decode against PubNio's API schemas; no provider confirmed this post.

### Prompt

```
Find my ready Instagram account in PubNio. If there are several, ask me which one to use. Import the video at https://cdn.example.com/release.mp4 and prepare a Reel with a caption based on CHANGELOG.md. Show me the account, video, and caption before submitting. Once I approve, publish once. Check the delivery status and return the Instagram permalink when it is published. If the result is still pending, give me the post ID and the latest status.
```

### What Claude Code runs: the Code Mode flow

```text
search   -> find the media-import, media-status, create-post, and read-post operations
execute  -> import media { url: "https://cdn.example.com/release.mp4" }
         => 202 { mediaId: "…", status: "processing" }
execute  -> read media status, sleep 1s between checks
         => { status: "ready" }
execute  -> create post { text: "…", publishNow: true, targets: [ { accountId: "…", provider: "instagram", placement: "reel", media: [ { mediaId: "…" } ] } ] }
            Idempotency-Key: claude-instagram-reel-2026-12-04
         => 202 { postId, targets: [instagram/reel: queued] }
execute  -> read post, sleep 1s between checks, within the 30s budget
         => { status: "published", url: "https://www.instagram.com/reel/CXXXXXXXXXX/" }
```

### Settled result (200 OK)

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "isDraft": false,
  "revision": 1,
  "scheduledAt": null,
  "text": "Shipping weekly queues in one API call.",
  "media": [
    {
      "mediaId": "00000000-0000-4000-8000-000000000005"
    }
  ],
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "instagram",
      "placement": "reel",
      "media": [
        {
          "mediaId": "00000000-0000-4000-8000-000000000005"
        }
      ]
    }
  ],
  "deliveries": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "instagram",
      "placement": "reel",
      "canRetry": false,
      "canReconcile": false,
      "revision": 1,
      "status": "published",
      "providerRef": {
        "id": "17841400000000000",
        "kind": "instagram_media"
      },
      "url": "https://www.instagram.com/reel/CXXXXXXXXXX/"
    }
  ],
  "status": "published",
  "createdAt": "2026-12-04T07:20:00.000Z",
  "updatedAt": "2026-12-04T07:20:18.000Z"
}
```

### From approval to delivery

Illustrative conversation and result with sample data.

**Claude Code:** I found the ready Instagram professional account for Example Studio. I imported release.mp4 and will post it as a Reel with this caption: “Shipping weekly queues in one API call.”

**You:** Approved. Publish the Reel to Example Studio’s Instagram.

**Claude Code:** PubNio accepted the Reel and its delivery is still confirming. I checked the same submission again once Instagram published it and got the Reel link.

#### Example delivery result

- Status: `published`

- Destination: Example Studio · Instagram Reel

- Sample URL: `https://www.instagram.com/reel/CXXXXXXXXXX/`

## Check delivery and get the link

- Have Claude Code read the status of the post it just submitted in the same workspace.
- Wait while any delivery is queued, submitting, or confirming. Do not create a second post for the same intent.
- Treat a delivery as live only when it reports status: published and includes providerRef or url.
- If Claude Code stops waiting, save the post ID and ask it to check that post later.

## Instagram rules Claude Code runs into

Account kinds: social account. Connection scopes: `instagram_business_content_publish`.

| Placement | Default | Media types | Max per target | Caption limit |
| --- | --- | --- | --- | --- |
| `feed` | Yes | image | 1 | 2,200 |
| `reel` | — | video | 1 | 2,200 |
| `carousel` | — | image, video | 20 | 2,200 |
| `story` | — | image, video | 1 | 2,200 |

- Feed takes one image.
- A Reel takes one video.
- A Story takes one image or video.
- A Carousel takes up to 20 images or videos, all imported and ready before publishing.
- Captions run up to 2,200 characters.
- Images: JPEG or PNG; avoid WebP and AVIF.
- Videos: H.264 MP4 with AAC audio; use 9:16 vertical framing for Reels and Stories.
- Instagram requires media on every placement; there is no text-only post.
- PubNio handles container creation and polling; do not poll Instagram container IDs yourself.

## Failures and recovery

### Instagram issue codes

| Code | Cause | Fix | Retry |
| --- | --- | --- | --- |
| `account_not_ready` | The connected account's OAuth token is expired, revoked, or disconnected. | Reconnect the account in the PubNio workspace, then re-validate. | After reconnect |
| `publish_permission_required` | The OAuth grant is missing a required publishing scope. | Re-authorize the account in the workspace with publish permissions enabled. | After reconnect |
| `media_required` | Placement (such as Instagram Feed/Reel, Pinterest Pin, TikTok, or YouTube) requires media. | Import or upload media and attach its `mediaId` to the target. | No |
| `media_count` | Attached media count is below minimum or above the placement's maximum. | Adjust the `media` array (for example, 1 video for Reels/YouTube, 2–20 for carousels). | No |
| `media_type` | Media kind (image, video, document) does not match the placement. | Supply a matching media type for the selected placement. | No |
| `media_mime_type` | File MIME type is rejected by the provider (for example, unsupported codec or container). | Convert to a supported MIME type (such as `image/jpeg`, `image/png`, `video/mp4`, or `application/pdf`). | No |
| `media_too_large` | Asset exceeds the provider's byte-size ceiling (such as 100 MB for LinkedIn PDFs). | Compress or trim the asset below the platform ceiling and re-import. | No |
| `media_not_ready` | Media import or verification is still in progress. | Poll `media.status` until it reports `ready`, then re-validate. | Yes |

### Claude Code setup problems

- /mcp lists pubnio as needing authentication. Select pubnio and authenticate again. PubNio answers an expired or revoked token with 401 and a sign-in challenge.
- Writes fail with 403 read_only_mode. PubNio returns 403 read_only_mode when the server URL ends in ?readOnly=1. Point the entry at https://pubnio.com/mcp to allow writes.

### Claude Code quirks

- Claude Code asks each person to approve a project server from .mcp.json before it connects.
- Sign-in starts inside a session from /mcp, not from a separate login command.

## What it won't do

- Publish a text-only Instagram post. Every placement needs media.
- Publish to a Personal Instagram profile. Connect a Business or Creator account.
- Lift Instagram's daily publish cap for an account.
- Connect accounts, create API keys, or manage webhooks from an MCP session that uses an API key. Those operations need a person signed in, so connect the MCP server with browser OAuth or use the PubNio web app.
- Stream binary uploads through execute. Import media from an HTTPS URL, or send a file of up to 8 MiB inline as base64.
- Run one execute call past 30 seconds or past its request limit. The script returns the post ID so the next call can check it.

## Frequently asked questions

### Does Claude Code need a PubNio API key to publish to Instagram?

No. Claude Code uses the hosted MCP server with browser OAuth, and the resulting token is scoped to your workspace permissions.

### Can Claude Code publish Instagram Reels, Carousels, Feed posts, and Stories?

Yes. All four placements use the same create-post target; only the placement and media rules change.

### What does a failed Instagram publish cost?

Only confirmed publishes count. Failed attempts, drafts, and provider rejections before confirmation do not consume a paid publish.

### How does Claude Code know Instagram actually published the post?

Read the post status after admission. A delivery is confirmed only when it reports published with a provider reference or permalink.

### Should I commit .mcp.json with the PubNio entry?

Yes. The entry holds only the public URL https://pubnio.com/mcp. Each person approves the server and signs in from /mcp, so no token lands in the repository.

### Is there a PubNio plugin for Claude Code?

Yes. Run claude plugin marketplace add pubnio/agent-skills, then claude plugin install pnio@pubnio. The MCP server works without it.

## Also works with

- [Post to Instagram from Codex](https://pubnio.com/codex/instagram)
- [Post to Instagram from Cursor](https://pubnio.com/cursor/instagram)
- [Post to Instagram from OpenCode](https://pubnio.com/opencode/instagram)
- [Post to LinkedIn from Claude Code](https://pubnio.com/claude/linkedin)
- [Upload YouTube Shorts from Claude Code](https://pubnio.com/claude/youtube)
- [Post to a Facebook Page from Claude Code](https://pubnio.com/claude/facebook)
- [Create a Pinterest Pin from Claude Code](https://pubnio.com/claude/pinterest)
- [Post a TikTok video from Claude Code](https://pubnio.com/claude/tiktok)
- [Publish an X thread from Claude Code](https://pubnio.com/claude/x)
- [Claude Code setup](https://pubnio.com/claude)
- [Instagram publishing API](https://pubnio.com/platforms/instagram)
- [Instagram MCP](https://pubnio.com/instagram-mcp)
- [Instagram network reference](https://pubnio.com/docs/networks/instagram/)
- [Instagram error codes](https://pubnio.com/docs/errors/instagram/)
- [Pricing](https://pubnio.com/pricing)

## Get started with PubNio

Connect unlimited accounts at $0 per account. Pay as you go includes 50 free confirmed publishes a month on your first workspace, then $20 per 1,000. X API fees are separate.

## REST API reference

Contract example: sample IDs and URLs. The request and both responses decode against PubNio's API schemas; no provider confirmed this post.

```http
POST /api/v1/posts?workspaceId=00000000-0000-4000-8000-000000000006
Authorization: Bearer pn_live_***
Idempotency-Key: claude-instagram-reel-2026-12-04
Content-Type: application/json

{
  "text": "Shipping weekly queues in one API call.",
  "publishNow": true,
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "instagram",
      "placement": "reel",
      "media": [
        {
          "mediaId": "00000000-0000-4000-8000-000000000005"
        }
      ]
    }
  ]
}
```

### 202 Accepted

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "idempotencyKey": "claude-instagram-reel-2026-12-04",
  "targets": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "instagram",
      "placement": "reel",
      "canRetry": false,
      "canReconcile": false,
      "status": "queued",
      "scheduledAt": null,
      "url": null,
      "issue": null
    }
  ],
  "warnings": []
}
```

