> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Instagram Setup

> Connect your Instagram Business or Creator account to Instance via the official Meta Graph API and configure local or production webhooks.

Instance uses the official Instagram Graph API (via Instagram Business Login). It never asks for your Instagram password and never uses browser scraping.

***

## Step 1: Instagram Account Prerequisites

Before connecting your account:

1. Switch your Instagram account to a **Professional** account (**Business** or **Creator**) in the Instagram mobile app under **Settings and activity -> Account type and tools**.
2. 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

1. Open the [Meta Developer Dashboard](https://developers.facebook.com/) and click **Create App**.
2. Choose **Other** -> **Business** (or select the Instagram API use case).
3. Enter your app name and contact email, then click **Create app**.

***

## Step 3: Add Instagram and Copy Credentials

1. In your app dashboard, locate **Instagram** and click **Set up**.
2. Open **Instagram -> API setup with Instagram Business login**.
3. Copy your **Instagram App ID** and **Instagram App Secret** into your `.env` file:

```env theme={null}
INSTAGRAM_APP_ID="your-instagram-app-id"
INSTAGRAM_APP_SECRET="your-instagram-app-secret"
```

4. 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`

***

## 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:

1. In the left sidebar, go to **App roles -> Roles** -> **Add People** -> **Instagram Tester**.
2. Enter your Instagram username and send the invite.
3. 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 to `localhost`. Expose your local API server (port `4000`) using `ngrok`:

```bash theme={null}
ngrok http 4000
```

Copy the HTTPS forwarding URL (for example, `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_TOKEN` in your `.env` (defaults to `instance_verify_token` if unset).

Before clicking **Verify and Save**, switch **App Mode** from **Development** to **Live** in the top bar of the Meta Developer Dashboard. Webhooks deliver much more reliably in Live Mode, and turning it on will not break your local testing (automations for non-tester public accounts simply stay gated until App Review permissions are approved).

Click **Verify and Save**.

***

## Step 6: Subscribe to Webhook Fields

On the same webhook configuration screen, subscribe to the following fields:

| Webhook Field | Used For |
| :- | :- |
| **`messages`** | Incoming DMs, Story replies, Story reactions, Story mentions, and echo detection for human takeover |
| **`messaging_postbacks`** | Icebreaker button taps, Quick Reply taps, and Inline Button postbacks |
| **`comments`** | Post and Reel comments (Comment-to-DM triggers, auto-like, and Spam Shield hiding) |
| **`message_reactions`** | Emoji reactions on direct messages |
| **`live_comments`** | Comments on Instagram Live broadcasts (`TRIGGER_LIVE_COMMENT`) |

***

## Step 7: Connect Your Account in Instance

1. Open Instance (`http://localhost:3000`) and go to `/setup` or **Dashboard -> Settings -> Account Profile**.
2. Click **Connect Instagram**.
3. Instance redirects you to Instagram OAuth requesting these **4 permissions**:
   * `instagram_business_basic`
   * `instagram_business_manage_messages`
   * `instagram_business_manage_comments`
   * `instagram_business_content_publish`
4. Approve all 4 permissions. Once redirected back, your connected account appears in **Account Profile** and **Posting**.

***

## Step 8: Going to Production (Live Mode)

To automate DMs, comments, and scheduled posts for any public user worldwide (not just Testers), complete [Meta App Review](/docs/meta-app-review.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.