igpost is a Go CLI for posting photos, reels, and carousels to Instagram using the official Graph API. It uploads local media to https://uguu.se for temporary hosting, then publishes via the Instagram Graph API.
go install github.com/mahmoud/igpostercli/cmd/igpost@latestmake build
./bin/igpost --help- Create a Meta app in the Meta Developers dashboard and add the Instagram Graph API product.
- Link a Facebook Page to your Instagram Business/Creator account.
- Generate a short-lived user token with the required permissions (typically:
instagram_basic,instagram_content_publish,pages_show_list). - Exchange the short-lived token for a long-lived token using
igpost token exchange. - Use
igpost accountto fetch your Instagram Business/User ID.
Global flags:
--profile: Profile name (selects stored config + keychain token).--user-id: OverrideIG_USER_IDat runtime.--page-id: OverrideIG_PAGE_IDat runtime.--business-id: OverrideIG_BUSINESS_IDat runtime.
Do you need BOTH IG_USER_ID and IG_PAGE_ID to post?
- For posting, you only need
IG_USER_ID+IG_ACCESS_TOKEN. IG_PAGE_IDis only needed to lookup the IG user ID (viaigpost account).
So the typical flow is:
- Get
IG_PAGE_ID(one time). - Run:
igpost --page-id <PAGE_ID> account- It prints
IG_USER_ID=... - From then on, use
IG_USER_ID(you can keepIG_PAGE_IDaround, but it’s not required for posting).
igpost photo --file path/to/photo.jpg --caption "hello"igpost photo --url https://example.com/photo.jpg --caption "hello"igpost reel --file path/to/video.mp4 --caption "hello"igpost carousel --files img1.jpg img2.jpg --caption "hello"igpost token exchange --short-token "<short_token>"
igpost token debugigpost account
igpost owned-pages --business-id <BUSINESS_ID>Profiles store non-secret values in ~/.config/igpostercli/config.json, while access tokens are stored in the OS keychain.
Resolution order:
- CLI flags (e.g.
--user-id,--page-id,--business-id) - Selected profile (
--profileorIG_PROFILE) - Environment variables /
.env
igpost profile set brand-a --access-token "<token>" --user-id <IG_USER_ID> --page-id <PAGE_ID> --business-id <BUSINESS_ID>
igpost profile show brand-a
igpost profile list
igpost profile delete brand-aSet these in .env (see .env.example) or export them in your shell.
IG_APP_ID: Meta app ID.IG_APP_SECRET: Meta app secret.IG_ACCESS_TOKEN: Long-lived Instagram User access token.IG_PROFILE: Profile name (default:default).IG_PAGE_ID: Facebook Page ID connected to your Instagram account.IG_BUSINESS_ID: Meta Business ID (for listing owned pages).IG_USER_ID: Instagram Business/User ID.IG_GRAPH_VERSION: Graph API version (default:v19.0).IG_POLL_INTERVAL: Polling interval for media processing (default:5s).IG_POLL_TIMEOUT: Polling timeout for media processing (default:300s).
Long-lived tokens expire. When yours is near expiry:
- Generate a new short-lived token in the Meta dashboard.
- Run:
igpost token exchange --short-token "<short_token>"- Update
IG_ACCESS_TOKENwith the new value.