To receive live webhook notifications, the following conditions must be satisfied:
If the app permissions don't have an access level of Advanced Access, the app doesn't receive webhook notifications.
media
field.-1
.comments
and live_comments
webhooks fields. Create an endpoint that accepts and processes webhooks. During the configuration, select the Instagram Graph API object, click Set up, and subscribe to one or more Instagram fields.
Field | Description | Permissions Required |
---|---|---|
Comments on an IG Media owned by your app's Instagram user. The | ||
Comments on a live IG Media owned by your app's Instagram user. | ||
@mentions for your app's Instagram user in a comment. | ||
Metrics describing interactions on a story. Sent 1 hour after the story expires. |
Your app must enable Page subscriptions on the Page connected to the app user's account by sending a POST
request to the Page Subscribed Apps edge and subscribing to any Page field.
POST /{page-id}/subscribed_apps ?access_token={access-token} &subscribed_fields={fields}
Value Placeholder | Value Description |
---|---|
| ID of the Page connected to the app user's account. |
| App user's Page access tToken. |
| A Page field (example: |
Your app does not receive notifications for changes to a field unless you configure Page subscriptions in the App Dashboard and subscribe to that field.
curl -i -X POST \
"https://graph.facebook.com/v21.0
/1755847768034402/subscribed_apps?subscribed_fields=feed&access_token=EAAFB..."
{ "success": true }
If you subscribe to the story_insights
field, we send your endpoint a webhook notification containing user interaction metrics on a story, after the story has expired.
[ { "entry": [ { "changes": [ { "field": "story_insights", "value": { "media_id": "18023345989012587", "exits": 1, "replies": 0, "reach": 17, "taps_forward": 12, "taps_back": 0, "impressions": 28 } } ], "id": "17841405309211844", // Instagram Business or Creator Account ID "time": 1547687043 } ], "object": "instagram" } ]
If you subscribe to the mentions
field, we send your endpoint a webhook notification whenever an Instagram user @mentions an Instagram Business or Creator Account in a comment or caption.
For example, here's a sample comment webhook notification payload sent for an Instagram Business Account (17841405726653026
):
[ { "entry": [ { "changes": [ { "field": "mentions", "value": { "comment_id": "17894227972186120", "media_id": "17918195224117851" } } ], "id": "17841405726653026", "time": 1520622968 } ], "object": "instagram" } ]
To get the comment's contents, use the comment_id
property to query the GET /{ig-user-id}/mentioned_comment
edge:
GET https://graph.facebook.com/17841405726653026 ?fields=mentioned_comment.comment_id(17894227972186120)
{ "mentioned_comment": { "timestamp": "2018-03-20T00:05:29+0000", "text": "@bluebottle challenge?", "id": "17894227972186120" }, "id": "17841405726653026" }
When you get the response, parse the payload for the text
property to determine if you want to respond to the comment. To respond, use the webhook notification payload's caption_id
and media_id
property values to query the POST /{ig-user-id}/mentions
endpoint:
curl -i -X POST \ -d "comment_id=17894227972186120" \ -d "media_id=17918195224117851" \ -d "message=Challenge%20accepted!" \ -d "access_token={access-token}" \ "https://graph.facebook.com/17841405726653026/mentions"
{ "id": "17911496353086895" }
If you subscribe to the mentions
field, we send your endpoint a webhook notification whenever a user @mentions an Instagram Business or Creator Account in a comment or caption on a media object not owned by the Business or Creator.
For example, here's a sample caption @mention webhook notification sent for an Instagram Business Account (17841405726653026
):
[ { "entry": [ { "changes": [ { "field": "mentions", "value": { "media_id": "17918195224117851" } } ], "id": "17841405726653026", "time": 1520622968 } ], "object": "instagram" } ]
To get the caption's contents, use the media_id
property to query the GET /{ig-user-id}/mentioned_media
edge:
GET https://graph.facebook.com/17841405726653026 ?fields=mentioned_media.media_id(17918195224117851){caption,media_type}
{ "mentioned_media": { "caption": "@bluebottle There can be only one!", "media_type": "IMAGE", "id": "17918195224117851" }, "id": "17841405726653026" }
When you get the response, parse the payload for the caption
property to determine if you want to respond to the comment. To respond, use the webhook media_id
property to query the POST /{ig-user-id}/mentions
edge:
curl -i -X POST \ -d "media_id=17918195224117851" \ -d "message=MacLeod%20agrees!" \ -d "access_token={access-token}" \ "https://graph.facebook.com/17841405726653026/mentions"
{ "id": "17911496353086895" }