Step 1: Instagram Account Prerequisites
Before connecting your account:- Switch your Instagram account to a Professional account (Business or Creator) in the Instagram mobile app under Settings and activity -> Account type and tools.
- Go to Settings and activity -> Messages and story replies -> Message controls and turn Allow access to messages ON under Connected tools.
Step 2: Create a Meta Developer App
- Open the Meta Developer Dashboard and click Create App.
- Choose Other -> Business (or select the Instagram API use case).
- Enter your app name and contact email, then click Create app.
Step 3: Add Instagram and Copy Credentials
- In your app dashboard, locate Instagram and click Set up.
- Open Instagram -> API setup with Instagram Business login.
- Copy your Instagram App ID and Instagram App Secret into your
.envfile:
- Under Business login settings, add your OAuth Redirect URI:
- Local development:
http://localhost:3000/api/instagram/callback - Production:
https://app.yourdomain.com/api/instagram/callback
- Local development:
Step 4: Add Your Account as an Instagram Tester
While your Meta app is in Development Mode, only accounts added as Instagram Testers can connect and trigger webhooks:- In the left sidebar, go to App roles -> Roles -> Add People -> Instagram Tester.
- Enter your Instagram username and send the invite.
- Open Instagram on the web or mobile app -> Settings -> Website permissions -> Apps and websites -> Tester invites and click Accept.
Step 5: Configure Webhooks (Local Development with ngrok)
Meta cannot send webhooks tolocalhost. Expose your local API server (port 4000) using ngrok:
https://abc123.ngrok-free.app) and configure the webhook in Instagram -> API setup with Instagram Business login -> Configure Webhook:
- Callback URL:
https://abc123.ngrok-free.app/api/webhook/instagram - Verify Token: Must match
META_WEBHOOK_VERIFY_TOKENin your.env(defaults toinstance_verify_tokenif unset).
Step 6: Subscribe to Webhook Fields
On the same webhook configuration screen, subscribe to the following fields:Step 7: Connect Your Account in Instance
- Open Instance (
http://localhost:3000) and go to/setupor Dashboard -> Settings -> Account Profile. - Click Connect Instagram.
- Instance redirects you to Instagram OAuth requesting these 4 permissions:
instagram_business_basicinstagram_business_manage_messagesinstagram_business_manage_commentsinstagram_business_content_publish
- Approve all 4 permissions. Once redirected back, your connected account appears in Account Profile and Posting.
