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

# Connecting Instagram Business to your app

> Publish feed posts, manage comments and answer direct messages from your app, using a shared account or each person's own account.

Connect your app to Instagram Business to publish feed posts, manage comments, and answer direct messages, either from one shared account or from each person's own Instagram account.

***

## What you can do

Bring your Instagram account's posts, comments, and messages into your app's workflows.

> [card] Publish posts
>
> Post photos, videos, and carousels to your feed when something happens in your app, such as a new product being added.

> [card] Manage comments
>
> Read, reply to, and moderate comments on your posts, for example when a comment includes a keyword.

> [card] Answer direct messages
>
> Read direct messages and reply to them from your app within 24 hours of the person's last message.

**Example prompts**

Describe the content, what triggers the action, and any dynamic fields in the AI chat. For example:

```text wrap theme={null}
Automatically post new product photos to my Instagram feed.
```

```text wrap theme={null}
Create Instagram carousel posts from my portfolio gallery.
```

```text wrap theme={null}
Reply to comments on my Instagram posts when keywords are detected.
```

```text wrap theme={null}
Moderate comments on my Instagram posts automatically.
```

```text wrap theme={null}
Display my Instagram Business profile info and recent feed posts in my app.
```

***

## Connecting Instagram Business

Choose how people connect: one shared account for your whole app, or each person's own account.

> [tab] Shared connector
>
> Connect one account, and everyone who uses your app shares it and its data.
>
> > [!TIP]
> >
> > **Before you begin:** Connect with an Instagram Business or Creator account. You can switch your account type in the Instagram app's settings.
>
> **To add a shared Instagram Business connector:**
>
> 1. Click **Connectors** in your workspace sidebar.
> 2. Click **Add connector**.
> 3. Search for **Instagram Business** and click it.
> 4. Select **Shared connector**, then click **Next**.
> 5. Enter a **Connection name**.
> 6. In **Who can access**, choose where the connection can be used: **Apps and Super agent** (the default), **Apps only** or **Super agent only**.
> 7. (Optional) Select the [scopes](#scopes-and-permissions) your app needs under **Permissions**. To publish posts, select `instagram_business_content_publish`. To manage comments, select `instagram_business_manage_comments`.
> 8. Click **Add connector**.
> 9. Sign in with the Instagram account you want to share.

> [tab] App user connector
>
> Each person connects their own Instagram account, so your app can work with their posts, comments, and messages.
>
> > [!WARNING]
> >
> > Only workspace owners and admins can set this up.
>
> > [!TIP]
> >
> > **Before you set this up:**
> >
> > * **Developer app:** You need a Meta developer app set up with Instagram Business Login, and its Client ID and Client Secret. See [Using your own OAuth client](https://docs.base44.com/Integrations/Connectors.md#using-your-own-oauth-client).
> > * **Instagram accounts:** Each person who connects needs an Instagram Business or Creator account.
>
> **To add an app user Instagram Business connector:**
>
> 1. Click **Connectors** in your workspace sidebar.
> 2. Click **Add connector**.
> 3. Search for **Instagram Business** and click it.
> 4. Select **App user connector**, then click **Next**.
> 5. Copy the **Callback URL**.
> 6. In your Meta developer app, add the Callback URL to the allowed redirect URIs.
> 7. Back in the **Add Instagram Business Connection** form, enter a **Connector name**, **Client ID** and **Client Secret**.
> 8. (Optional) Review the preselected [scopes](#scopes-and-permissions) under **Scopes** and remove any your app doesn't need.
> 9. Click **Add Connector**.
>
> Then ask the AI chat in your app to add a way for people to connect their own Instagram account.

***

## Scopes and permissions

Scopes control what your app can do in Instagram. You choose them when you set up a connector.

> [card]
>
> **1. Base44 adds**
>
> These are always included, so they show checked and greyed out in the **Permissions** list for a shared connector, and as locked scopes under **Scopes** for an app user connector.
>
> * `instagram_business_basic`: View basic information about the account, such as its username and media
> * `instagram_business_manage_messages`: Read and reply to direct messages
>
> **2. You configure**
>
> For a shared connector, select the scopes your app needs in the **Permissions** list. For an app user connector, these are preselected under **Scopes**, and you can remove any your app doesn't need.
>
> * `instagram_business_content_publish`: Publish photos, videos, and carousels to the feed
> * `instagram_business_manage_comments`: Read, reply to, and moderate comments on the account's posts
>
> **Access:** Your app works with the Instagram account that authorizes the connection.

***

## Using backend functions

Once Instagram Business is connected, your backend functions can retrieve an access token and call the Instagram API directly. Base44 handles sign-in and keeps the token up to date for you.

* For a shared connection, use `getConnection()` to retrieve the token.
* For an app user connection, use `getCurrentAppUserConnection()` so each request uses the signed-in person's token.

Call the Instagram API at `graph.instagram.com` and pass the token in the `access_token` query parameter:

```javascript theme={null}
// Shared connection: one account the whole app uses
const { accessToken } = await base44.asServiceRole.connectors.getConnection("instagram");

const response = await fetch(
  `https://graph.instagram.com/me?fields=id,username&access_token=${accessToken}`,
);
const account = await response.json();
```

> [card] [Shared connectors](https://docs.base44.com/developers/backend/resources/connectors/shared-connectors.md)
>
> Configure, deploy, and call a shared connection from a backend function.

> [card] [App user connectors](https://docs.base44.com/developers/backend/resources/connectors/app-user-connectors.md)
>
> Retrieve a per-user token and call the API as the signed-in person.

***

## Troubleshooting

Check the connection and the timing of your replies if Instagram Business stops working in your app.

> [accordion] The connection needs to be reconnected
>
> If Instagram access is lost or expires, the connection shows **Reconnect this connection**. For a shared connector, [reconnect it](https://docs.base44.com/Integrations/Connectors.md#managing-your-connectors) and sign in with the same Instagram account. Every app that uses it works again. For an app user connector, each person reconnects their own account from inside your app.

> [accordion] A reply to a direct message fails
>
> Instagram accepts replies to a direct message within 24 hours of the person's last message. Reply within that window, or wait for the person to message you again.


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