Instagram access token.
See InstagramPostInput.
Promise of the published media id, or null if any step failed (the API's error is logged).
import { createInstagramPost, MetaMediaType } from "naystack/socials";
// Reel
await createInstagramPost(accessToken, {
media: { url: "https://cdn.example.com/promo.mp4", type: MetaMediaType.Video },
caption: "Behind the scenes",
shareToFeed: true,
});
// Carousel
await createInstagramPost(accessToken, {
caption: "Campaign recap",
media: [
{ url: "https://cdn.example.com/1.jpg", type: MetaMediaType.Photo },
{ url: "https://cdn.example.com/2.mp4", type: MetaMediaType.Video },
],
});
Publishes to Instagram — feed image, reel, story or carousel, chosen from the media you pass. Creates the media container, waits for Instagram to finish processing it, then publishes.
Needs an access token with the
instagram_business_content_publishscope and an Instagram professional account. Media URLs must be publicly reachable (Instagram downloads them server-side) and images must be JPEG. Instagram allows 100 published posts per rolling 24 hours.