REST API v1 · Resource
Instagram messages, posts, comments and insights.
API reference · Instagram
Endpoints
Paths are relative to https://fliok.com/api/v1. Each endpoint names the scope and the lowest key role it needs; a key without them gets 403 (see Authentication). The Instagram endpoints answer for a workspace once the feature is set up for it.
Instagram is a paid add-on on the Basic plan and up. Until your workspace has it, every /instagram endpoint answers 402 instagram_addon_required, with offer saying what the workspace owner can buy in Plan & billing (add_addon or upgrade_plan). Once it is set up and your Instagram professional account is connected in Integrations, these endpoints run the same code as the dashboard — the same roles, rules and limits. Reads need any key; replying, hiding and drafts need the agent role; scheduling, publishing and cancelling need admin.
- Replies only inside 24 hours. Instagram lets a business answer within 24 hours of the customer’s last message, and that is the only window: Instagram’s Human Agent tag (longer replies by a person) isn’t enabled for Fliok.
POST /instagram/sendanswers422 outside_24h_windowafter 24 hours. - Posts take photos by URL.
POST /instagram/mediadownloads a JPEG (up to 8 MB) from a public https:// address into your workspace and checks its shape for the post type; private and internal addresses are refused. Reels need a video, which you upload in the dashboard. - Nothing permanent from the API. Comments can be answered in public and hidden (reversibly); deleting a comment, and Instagram ads, stay in the dashboard.
- GET
/instagram/conversationsInstagram Direct chats, cursor-paginated, with whether the 24-hour reply window is openScopeinstagram:read· viewer role or higherNeeds an API key - GET
/instagram/conversations/{id}/messagesOne Instagram chat and its messages, newest firstScopeinstagram:read· viewer role or higherNeeds an API key - POST
/instagram/sendReply in an Instagram chat — only within 24 hours of the customer’s last messageScopeinstagram:write· agent role or higherNeeds an API key - POST
/instagram/mediaGive Fliok a JPEG by public https:// URL for a post; returns a mediaIdScopeinstagram:write· agent role or higherNeeds an API key - GET
/instagram/postsPosts written in Fliok: drafts, scheduled, published, failed, cancelledScopeinstagram:read· viewer role or higherNeeds an API key - POST
/instagram/postsSave a draft, schedule a post, or publish now (admin keys) from your mediaIdsScopeinstagram:write· agent role or higherNeeds an API key - GET
/instagram/posts/recentThe account’s own published posts on Instagram, live, with likes and commentsScopeinstagram:read· viewer role or higherNeeds an API key - GET
/instagram/posts/{id}One Fliok post — poll it for published or failedScopeinstagram:read· viewer role or higherNeeds an API key - POST
/instagram/posts/{id}/cancelCancel a scheduled post before it goes out (admin keys)Scopeinstagram:write· agent role or higherNeeds an API key - GET
/instagram/commentsComments and @mentions, filtered by needs_reply, all, mentions or hiddenScopeinstagram:read· viewer role or higherNeeds an API key - POST
/instagram/comments/{id}/replyReply in public under a commentScopeinstagram:write· agent role or higherNeeds an API key - POST
/instagram/comments/{id}/hideHide a comment from everyone but its author, or show it againScopeinstagram:write· agent role or higherNeeds an API key - GET
/instagram/insightsAccount summary for 7, 28 or 90 days: followers, views, reach, engagement, top postsScopeinstagram:read· viewer role or higherNeeds an API key
Examples
Read your Instagram inbox
curl "https://fliok.com/api/v1/instagram/conversations?limit=20" \
-H "Authorization: Bearer wa_YOUR_API_KEY"
curl "https://fliok.com/api/v1/instagram/conversations/9f1c2b7e-5d1a-4c3e-9b0a-2f6d8e7c1a44/messages?limit=50" \
-H "Authorization: Bearer wa_YOUR_API_KEY"// 200 OK — Instagram has no phone number: the contact is a name and an @username
{
"conversations": [
{
"id": "9f1c2b7e-5d1a-4c3e-9b0a-2f6d8e7c1a44",
"channel": "instagram",
"contact": { "id": "c4f6…", "name": "Riya Sen", "username": "riya.makes" },
"state": "open",
"unreadCount": 2,
"isArchived": false,
"assignedAgentId": null,
"lastMessageAt": "2026-10-05T09:58:12.000Z",
"lastCustomerMessageAt": "2026-10-05T09:58:12.000Z",
"windowOpen": true,
"windowExpiresAt": "2026-10-06T09:58:12.000Z",
"createdAt": "2026-10-01T11:00:00.000Z"
}
],
"nextCursor": null
}
// …/messages → the chat, then its messages (newest first). sender: contact | agent | ai | smb_echo
{
"conversation": { "id": "9f1c…", "windowOpen": true, … },
"messages": [
{ "id": "5d0e…", "mid": "aWdfZAG1…", "conversationId": "9f1c…", "sender": "contact", "type": "text",
"status": "delivered", "payload": { "type": "text", "text": { "body": "Is the blue one in stock?" } },
"createdAt": "2026-10-05T09:58:12.000Z", "sentAt": null, "failedAt": null, "errors": null }
],
"nextCursor": null
}Reply to an Instagram message
curl -X POST https://fliok.com/api/v1/instagram/send \
-H "Authorization: Bearer wa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: dm-riya-1042" \
-d '{ "conversationId": "9f1c2b7e-5d1a-4c3e-9b0a-2f6d8e7c1a44", "text": "Yes! Size M and L are in stock." }'// 200 OK — sent straight to Instagram, not queued
{ "ok": true, "messageIds": ["7a3b…"], "humanAgentTag": false }
// More than 24 hours since the customer last wrote. A teammate can still answer from the
// Instagram inbox; an integration only ever gets Instagram's 24-hour window.
// 422 { "error": "outside_24h_window", "message": "It's been more than 24 hours since they last wrote. …" }
// 422 { "error": "never_wrote", … } — they have never messaged you
// 502 { "error": "send_unconfirmed", … } — Instagram didn't answer; check the chat before sending againSchedule a post
# 1. Hand Fliok the photo: a JPEG at a public https:// address, up to 8 MB
curl -X POST https://fliok.com/api/v1/instagram/media \
-H "Authorization: Bearer wa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://cdn.example.com/diwali-lamps.jpg", "for": "image" }'
# -> 201 { "media": { "mediaId": "instagram-posts/…/1b2c….jpg", "size": 412233, "mime": "image/jpeg",
# "kind": "image", "width": 1080, "height": 1350 }, "hints": [] }
# 2. Schedule it (admin key). action: draft | schedule | publish
curl -X POST https://fliok.com/api/v1/instagram/posts \
-H "Authorization: Bearer wa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "image",
"caption": "Diwali lamps are back in stock ✨",
"media": ["instagram-posts/…/1b2c….jpg"],
"action": "schedule",
"scheduledAt": "2026-10-20T18:30:00+05:30"
}'
# 3. Changed your mind?
curl -X POST https://fliok.com/api/v1/instagram/posts/3e7a…/cancel -H "Authorization: Bearer wa_YOUR_API_KEY"// 201 Created (cancel → 200 with "status": "cancelled")
{
"post": {
"id": "3e7a…",
"kind": "image",
"caption": "Diwali lamps are back in stock ✨",
"media": [ { "mediaId": "instagram-posts/…/1b2c….jpg", "size": 412233, "mime": "image/jpeg", "kind": "image", "width": 1080, "height": 1350 } ],
"cover": null,
"shareToFeed": true,
"status": "scheduled",
"scheduledAt": "2026-10-20T13:00:00.000Z",
"publishedAt": null,
"igMediaId": null,
"permalink": null,
"errorMessage": null,
"attempts": 0,
"outcomeUnknown": false,
"otherAccount": false,
"createdById": null,
"createdAt": "2026-10-05T10:00:00.000Z",
"updatedAt": "2026-10-05T10:00:00.000Z"
}
}
// Instagram's rules are checked before anything is saved for later:
// 422 { "error": "invalid_post", "message": "…", "issues": ["…"] }
// 422 { "error": "invalid_schedule", "message": "…" } — 2 minutes to 75 days ahead
// The instagram.post.published webhook fires when it goes out.Answer comments
curl "https://fliok.com/api/v1/instagram/comments?filter=needs_reply&limit=20" \
-H "Authorization: Bearer wa_YOUR_API_KEY"
curl -X POST https://fliok.com/api/v1/instagram/comments/6c2d…/reply \
-H "Authorization: Bearer wa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "text": "₹1,499 — DM us to order!" }'
curl -X POST https://fliok.com/api/v1/instagram/comments/8e1f…/hide \
-H "Authorization: Bearer wa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "hidden": true }'// GET → 200 OK
{
"comments": [
{
"id": "6c2d…",
"kind": "comment",
"mediaId": "17800000000000001",
"inThread": false,
"username": "riya.makes",
"text": "Price?",
"commentedAt": "2026-10-05T09:40:00.000Z",
"hidden": false,
"reply": null,
"privateReply": null,
"privateReplyBlocked": null,
"ai": null,
"canHide": true,
"canDelete": true,
"media": { "permalink": "https://www.instagram.com/p/abc123/", "thumbnailUrl": "https://…", "caption": "New arrivals", "type": "IMAGE", "owner": null }
}
],
"nextCursor": null,
"counts": { "needs_reply": 1, "all": 14, "mentions": 2, "hidden": 0 },
"connection": { "connected": true, "canManage": true, "igUserId": "17841400000000001", "username": "yourshop" }
}
// reply → 200 { "ok": true } hide → 200 { "ok": true, "hidden": true }
// Replies are PUBLIC. Deleting a comment is not offered by the API — it can't be undone.Read insights
curl "https://fliok.com/api/v1/instagram/insights?days=28" -H "Authorization: Bearer wa_YOUR_API_KEY"// 200 OK — cached for three hours per period, so polling costs nothing at Instagram
{
"days": 28,
"fetchedAt": "2026-10-05T08:00:00.000Z",
"account": { "username": "yourshop", "name": "Your Shop", "followers": 12840, "follows": 310, "posts": 412, "pictureUrl": "https://…" },
"totals": { "views": 98213, "reach": 40122, … },
"approximate": [],
"followerChange": { "follows": 420, "unfollows": 96, "net": 324 },
"daily": [ { "day": "2026-09-08", "reach": 1210 }, … ],
"unavailable": [],
"posts": [ { "id": "1780…", "caption": "…", "permalink": "https://www.instagram.com/p/…/", "likeCount": 412, "commentsCount": 38, "insights": { … }, … } ],
"postsInPeriod": true,
"cached": true
}Rate limits
The buckets these endpoints use. Burst is how many requests you can make back-to-back from a full bucket; sustained is how fast it refills.
| Bucket | Endpoints | Burst | Sustained |
|---|---|---|---|
| Reads | /messages · /conversations · /contacts · /templates · /phone-numbers · GET /webhooks · Instagram reads · GET /payment-requests/{id} | 600 | 60 / sec |
| Instagram reply | POST /instagram/send | 120 | 30 / sec |
| Instagram comments | POST /instagram/comments/{id}/reply · /hide (each its own bucket) | 60 | 1 / sec |
| Instagram posts | POST /instagram/posts · POST /instagram/posts/{id}/cancel | 60 | 1 / sec |
| Instagram media | POST /instagram/media | 30 | 1 / 2 sec |
| Instagram live posts | GET /instagram/posts/recent | 30 | 1 / 2 sec |
Every limit, the RateLimit-* headers and what to do on a 429: Rate limits.