Instagram

Learn how to use Instagram with Composio

Overview

SLUG: INSTAGRAM

Description

Instagram is a social media platform for sharing photos, videos, and stories. Only supports Instagram Business and Creator accounts, not Instagram Personal accounts.

Authentication Details

client_id
stringRequired
client_secret
stringRequired
oauth_redirect_uri
stringDefaults to https://backend.composio.dev/api/v1/auth-apps/add
scopes
stringDefaults to instagram_business_basic,instagram_business_manage_messages,instagram_business_manage_comments,instagram_business_content_publish,instagram_business_manage_insights

Connecting to Instagram

Create an auth config

Use the dashboard to create an auth config for the Instagram toolkit. This allows you to connect multiple Instagram accounts to Composio for agents to use.

1

Select App

Navigate to Instagram.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Instagram Auth Config”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using OAuth2

1from composio import Composio
2
3# Replace these with your actual values
4instagram_auth_config_id = "ac_YOUR_INSTAGRAM_CONFIG_ID" # Auth config ID created above
5user_id = "0000-0000-0000" # UUID from database/application
6
7composio = Composio()
8
9
10def authenticate_toolkit(user_id: str, auth_config_id: str):
11 connection_request = composio.connected_accounts.initiate(
12 user_id=user_id,
13 auth_config_id=auth_config_id,
14 )
15
16 print(
17 f"Visit this URL to authenticate Instagram: {connection_request.redirect_url}"
18 )
19
20 # This will wait for the auth flow to be completed
21 connection_request.wait_for_connection(timeout=15)
22 return connection_request.id
23
24
25connection_id = authenticate_toolkit(user_id, instagram_auth_config_id)
26
27# You can also verify the connection status using:
28connected_account = composio.connected_accounts.get(connection_id)
29print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Instagram toolkit’s playground

For code examples, see the Tool calling guide and Provider examples.

Tool List

Tool Name: Create Media Container

Description

Create a draft media container for photos/videos/reels before publishing.

Action Parameters

caption
content_type
cover_url
graph_api_version
Defaults to v21.0
ig_user_id
image_url
is_carousel_item
media_type
video_url

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Create Post

Description

Publish a draft media container to Instagram (final publishing step). IMPORTANT: After creating a media container, Instagram may need time to process the media before it can be published. If called immediately after container creation, you may receive error code 9007 ("The media is not ready for publishing"). This action automatically retries with exponential backoff (up to ~45 seconds total) to handle this processing delay. For large videos or slow processing, consider using INSTAGRAM_GET_POST_STATUS to poll the container status until it shows 'FINISHED' before calling this action.

Action Parameters

creation_id
stringRequired
graph_api_version
Defaults to v21.0
ig_user_id
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Delete Comment

Description

Tool to delete a comment on Instagram media. Use when you need to remove a comment that was created by your Instagram Business or Creator Account. Note: You can only delete comments that your account created - you cannot delete other users' comments unless they are on your own media.

Action Parameters

graph_api_version
Defaults to v21.0
ig_comment_id
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get Conversation

Description

Get details about a specific Instagram DM conversation (participants, etc).

Action Parameters

conversation_id
stringRequired
graph_api_version
Defaults to v21.0

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get IG Comment Replies

Description

Get replies to a specific Instagram comment. Returns a list of comment replies with details like text, username, timestamp, and like count. Use when you need to retrieve child comments (replies) for a specific parent comment.

Action Parameters

after
before
fields
Defaults to id,text,username,timestamp,like_count,hidden,from,media,parent_id,legacy_instagram_comment_id
graph_api_version
Defaults to v21.0
ig_comment_id
stringRequired
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get Instagram Media

Description

Get a published Instagram Media object (photo, video, story, reel, or carousel). Use when you need to retrieve detailed information about a specific Instagram post including engagement metrics, caption, media URLs, and metadata. NOTE: This action is for published media only. For unpublished container IDs (from INSTAGRAM_CREATE_MEDIA_CONTAINER), use INSTAGRAM_GET_POST_STATUS to check status instead.

Action Parameters

fields
Defaults to id
graph_api_version
Defaults to v21.0
ig_media_id
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get IG Media Children

Description

Tool to get media objects (images/videos) that are children of an Instagram carousel/album post. Use when you need to retrieve individual media items from a carousel album post. Note: Carousel children media do not support insights queries - for analytics, query metrics at the parent carousel level.

Action Parameters

fields
Defaults to id,media_type,media_url,permalink,timestamp
graph_api_version
Defaults to v21.0
ig_media_id
stringRequired

Action Response

data
array
error
successful
booleanRequired

Tool Name: Get IG Media Comments

Description

Tool to retrieve comments on an Instagram media object. Use when you need to fetch comments from a specific Instagram post, photo, video, or carousel. Supports cursor-based pagination for navigating through large comment lists.

Action Parameters

after
before
fields
Defaults to id,text,username,timestamp,like_count,from,hidden,media,parent_id
graph_api_version
Defaults to v21.0
ig_media_id
stringRequired
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get IG Media Insights

Description

Tool to get insights and metrics for Instagram media objects (photos, videos, reels, carousel albums). Use when you need to retrieve performance data such as views, reach, likes, comments, saves, and shares for specific media. Note: Insights data is only available for media published within the last 2 years, and the account must have at least 1,000 followers.

Action Parameters

graph_api_version
Defaults to v21.0
ig_media_id
stringRequired
metric
arrayRequired
period
Defaults to lifetime

Action Response

composio_execution_message
data
arrayRequired
error
paging
successful
booleanRequired

Tool Name: Get IG User Content Publishing Limit

Description

Get an Instagram Business Account's current content publishing usage. Use this to monitor quota usage and avoid hitting rate limits when publishing content via the API.

Action Parameters

fields
Defaults to quota_usage,config
graph_api_version
Defaults to v21.0
ig_user_id

Action Response

data
array
error
successful
booleanRequired

Tool Name: Get IG User Live Media

Description

Get live media objects during an active Instagram broadcast. Returns the live video media ID and metadata when a live broadcast is in progress on an Instagram Business or Creator account. Use this to monitor active live streams and access real-time engagement data.

Action Parameters

fields
Defaults to id,media_type,media_url,timestamp,permalink
graph_api_version
Defaults to v21.0
ig_user_id

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get IG User Media

Description

Get Instagram user's media collection (posts, photos, videos, reels, carousels). Use when you need to retrieve all media published by an Instagram Business or Creator account with support for pagination and time-based filtering.

Action Parameters

after
before
fields
Defaults to id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username
ig_user_id
stringRequired
limit
Defaults to 25
since
until

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get IG User Stories

Description

Get active story media objects for an Instagram Business or Creator account. Returns stories that are currently active within the 24-hour window. Use this to retrieve story content, metadata, and engagement metrics for monitoring or analytics purposes.

Action Parameters

after
before
fields
Defaults to id,media_type,media_url,permalink,timestamp
graph_api_version
Defaults to v21.0
ig_user_id
limit

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get IG User Tags

Description

Get Instagram media where the user has been tagged by other users. Use when you need to retrieve all media in which an Instagram Business or Creator account has been tagged, including tags in captions, comments, or on the media itself.

Action Parameters

after
before
fields
Defaults to id,caption,media_type,media_url,permalink,timestamp,username
ig_user_id
stringRequired
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get Post Comments

Description

Get comments on an Instagram post.

Action Parameters

after
graph_api_version
Defaults to v21.0
ig_post_id
stringRequired
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get Post Insights

Description

Get Instagram post insights/analytics (impressions, reach, engagement, etc.).

Action Parameters

graph_api_version
Defaults to v21.0
ig_post_id
stringRequired
metric
metric_preset
Defaults to auto_safe

Action Response

data
arrayRequired
error
paging
successful
booleanRequired

Tool Name: Get Post Status

Description

Check the processing status of a draft post container.

Action Parameters

creation_id
stringRequired
graph_api_version
Defaults to v21.0

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get User Info

Description

Get Instagram user info including profile details and statistics.

Action Parameters

graph_api_version
Defaults to v21.0
ig_user_id

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Get User Insights

Description

Get Instagram account-level insights and analytics (profile views, reach, follower count, etc.). metric_type (time_series or total_value): When set to total_value, the API returns a total_value object instead of values. breakdown: Only applicable when metric_type=total_value and only for supported metrics. timeframe: Required for demographics-related metrics and overrides since/until for those metrics.

Action Parameters

breakdown
graph_api_version
Defaults to v21.0
ig_user_id
metric
metric_type
period
Defaults to day
since
timeframe
until

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Get User Media

Description

Get Instagram user's media (posts, photos, videos).

Action Parameters

after
graph_api_version
Defaults to v21.0
ig_user_id
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: List All Conversations

Description

List all Instagram DM conversations for the authenticated user.

Action Parameters

after
graph_api_version
Defaults to v21.0
ig_user_id
limit
Defaults to 25

Action Response

composio_execution_message
data
array
error
paging
successful
booleanRequired

Tool Name: List All Messages

Description

List all messages from a specific Instagram DM conversation.

Action Parameters

after
conversation_id
stringRequired
graph_api_version
Defaults to v21.0
limit
Defaults to 25

Action Response

data
array
error
paging
successful
booleanRequired

Tool Name: Mark Seen

Description

Mark Instagram DM messages as read/seen for a specific user. This action sends a 'mark_seen' sender action to indicate that messages from the specified recipient have been read. This is similar to the Facebook Messenger sender_action feature. IMPORTANT LIMITATIONS: - The sender_action API feature may have limited support on Instagram - The recipient must have an active 24-hour messaging window open - Requires instagram_manage_messages permission - Only works with Instagram Business or Creator accounts If this action fails with a 500 error, it may indicate that the sender_action feature is not supported for your Instagram account or the specific recipient.

Action Parameters

graph_api_version
Defaults to v21.0
ig_user_id
recipient_id
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Post IG Comment Replies

Description

Tool to create a reply to an Instagram comment. Use when you need to reply to a specific comment on an Instagram post owned by a Business or Creator account. The reply must be 300 characters or less, contain at most 4 hashtags and 1 URL, and cannot consist entirely of capital letters.

Action Parameters

graph_api_version
Defaults to v21.0
ig_comment_id
stringRequired
message
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Post IG Media Comments

Description

Tool to create a comment on an Instagram media object. Use when you need to post a comment on a specific Instagram post, photo, video, or carousel. The comment must be 300 characters or less, contain at most 4 hashtags and 1 URL, and cannot consist entirely of capital letters.

Action Parameters

graph_api_version
Defaults to v21.0
ig_media_id
stringRequired
message
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Post IG User Media

Description

Tool to create a media container for Instagram posts. Use this to create a container for images, videos, Reels, or carousels. This is the first step in Instagram's two-step publishing process - after creating the container, use the media_publish endpoint to publish it.

Action Parameters

audio_name
caption
children
collaborators
cover_url
graph_api_version
Defaults to v21.0
ig_user_id
stringRequired
image_url
is_carousel_item
location_id
media_type
share_to_feed
thumb_offset
user_tags
video_url

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Publish IG User Media

Description

Tool to publish a media container to an Instagram Business account. This action automatically waits for the container to finish processing before publishing. Rate limited to 25 API-published posts per 24-hour moving window. The publishing process: 1. First, create a media container using INSTAGRAM_CREATE_MEDIA_CONTAINER 2. Call this action with the creation_id - it will automatically poll for FINISHED status 3. Once ready, the media is published and the published media ID is returned For videos/reels, processing may take 30-120 seconds. Images are typically instant.

Action Parameters

creation_id
stringRequired
graph_api_version
Defaults to v21.0
ig_user_id
stringRequired
max_wait_seconds
Defaults to 60
poll_interval_seconds
Defaults to 3

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Reply to IG User Mentions

Description

Tool to reply to a mention of your Instagram Business or Creator account. Use when you need to respond to comments or media captions where your account has been @mentioned by another Instagram user. This creates a comment on the media or comment containing the mention.

Action Parameters

comment_id
graph_api_version
Defaults to v21.0
ig_user_id
stringRequired
media_id
stringRequired
message
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Reply To Comment

Description

Reply to a comment on Instagram media.

Action Parameters

graph_api_version
Defaults to v21.0
ig_comment_id
stringRequired
message
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Send Image

Description

Send an image via Instagram DM to a specific user.

Action Parameters

graph_api_version
Defaults to v21.0
ig_user_id
image_url
stringRequired
recipient_id
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired

Tool Name: Send Text Message

Description

Send a text message to an Instagram user via DM.

Action Parameters

graph_api_version
Defaults to v21.0
ig_user_id
recipient_id
stringRequired
reply_to_message_id
text
stringRequired

Action Response

data
objectRequired
error
successful
booleanRequired