1. Account and OAuth prerequisites
Personal Instagram accounts cannot publish through the official Instagram Graph API. Before your code creates a single container, the account must be converted to a Business or Creator profile and linked to a Facebook Page where the authorizing user has full Page access.
Missing Page linkage is the single most common reason Meta OAuth succeeds while publishing returns an authorization error. Running PubNio preflight validation surfaces instagram_account_not_business and missing_scope before any upload begins.
| Placement | Media requirement | Aspect / caption constraints |
|---|---|---|
| Feed | 1 image (JPEG/PNG) or 1 video (MP4/MOV) | Up to 2,200 characters; 4:5 to 1.91:1 |
| Carousel | 2 to 10 images or videos | First item defines the container aspect ratio |
| Reel | 1 vertical MP4/MOV video (H.264 + AAC) | Recommended 9:16; polled until FINISHED |
| Story | 1 image or 1 vertical video | No clickable caption text; 24-hour TTL |
2. Why container polling fails in DIY integrations
Instagram does not accept raw multipart video bytes directly in a publish call. You create a media container with an HTTPS video URL, wait for Meta's transcoding pipeline to fetch and process the asset, poll status_code until it becomes FINISHED, and only then invoke media_publish.
If your server times out during polling and naively retries the entire flow, you risk creating orphaned containers or publishing twice. PubNio stages your media and handles container polling, while an idempotency key helps prevent duplicate publishes.
const video = await ws.media.importUrl({
url: "https://cdn.example.com/product-reel.mp4",
});
const draft = await ws.posts.create({
isDraft: true,
text: "Shipping multi-channel Reels over one API. #devtools",
targets: [
{
accountId: instagramAccountId,
placement: "reel",
media: [{ mediaId: video.mediaId }],
},
],
});
const check = await ws.posts.validate(draft.postId);
if (!check.valid) throw new Error(check.issues.map((i) => i.code).join(", "));
const post = await ws.posts.publish(draft.postId, {
idempotencyKey: "ig-reel-launch-01",
});
3. Preflight checks before hitting Meta rate limits
Validate every draft before dispatching. PubNio checks account linkage, caption length, media count (2 to 10 items for Carousels), and staged asset readiness up front for $0 so failed attempts never waste quota.