Log inStart Free Trial
easyCoexistence Official APIs

How to bring your customers' Instagram DMs and comments into your app

Connect each customer's Instagram account through easyCoexistence's Partner API, whose Meta-reviewed app spares you App Review, and set a webhook per channel: comments, mentions and DMs arrive as they happen, signed per account and not stored by default. Your app replies within Instagram's 24-hour window through an automation whose call_webhook step returns {"reply": "..."}, so the token stays with easyCoexistence.

easyCoexistence is social media infrastructure for AI agents: its Partner API connects your customers' WhatsApp, Instagram, Facebook and TikTok accounts to your product, with no app review on your side.

24 hours

Instagram's standard window for replying after a person's message, for most user actions; they have to write first.

1,000 bytes

The most text one Instagram DM can carry through the API, encoded as UTF-8.

2534041

Error subcode, under code 200, when the account owner has disabled access to Instagram direct messages.

No retries

Forwarded comments and DMs are relayed in memory and never stored, so each one is sent once.

5 minutes

Age after which a signed timestamp in X-EC-Signature should be rejected, with the HMAC compared in constant time.

30, 90 or 365 days

How long conversations that run through easyCoexistence automations are kept, by the period the account chooses.

How do DMs and comments get from Instagram into your app?

Through two pieces on each connected account: a webhook relays what happens on the account to your endpoint, and an automation carries your replies back. Instagram delivers its events to easyCoexistence's Meta app, which subscribes each account to comments, messages and mentions; easyCoexistence matches each event to its channel and forwards it, signed with that account's secret, to the URL you set. Your app stores it, threads it and shows it in your inbox, CRM or helpdesk. When an automation on the channel has a call_webhook step, the message also reaches your backend as a step, and the reply you return goes out from the customer's account.

1InstagramA comment, mention or DM on the customer's account
2easyCoexistenceMatches the account and signs the event
3Your webhookPUT /channels/{id}/webhook, checked with X-EC-Signature
4Your appStores and threads it in your inbox or CRM
5ReplyAn automation's call_webhook step returns {"reply"}

How do you turn on the webhook for a customer's account?

With one call per channel once the account connects: PUT /channels/{id}/webhook with your HTTPS URL. The answer carries a signing_secret, shown once and unique to that account, which you store against the channel_id; calling the PUT again issues a new one, and a url of null turns forwarding off. Each event then arrives as a POST with four keys: platform, account_id (the channel_id), external_id (the Instagram account's ID) and entry, Meta's webhook entry unchanged. Verify X-EC-Signature on the raw body before parsing: the header reads t=<unix>,v1=<hex>, where v1 is an HMAC-SHA256 of t, a dot and the body, keyed with the account's secret. What entry holds:

  • A comment: changes with field comments, and the comment's id, text, from and media.id.
  • A mention: changes with field mentions, when someone @mentions the account in a comment or a caption.
  • A DM: messaging, with the sender's ID, the message's mid and its text; messages the account sends come back marked is_echo, so a thread can show both sides.

What does your app store, and what does easyCoexistence keep?

Your app stores what your inbox shows, because forwarding keeps no copy. Each event is relayed in memory and sent once: easyCoexistence waits 8 seconds for your answer and never retries, so answer 2xx at once, process from a queue and keep the endpoint up. Forwards carry no delivery ID, so deduplicate on Meta's own IDs, a comment's ID or a message's mid. Threads are yours to build: group DMs by the sender's Instagram-scoped ID and comments by media.id, and key everything by account_id, the channel_id your customer connected. With an automation on the account, comments and DMs also pass through easyCoexistence so the flow can run, and those conversations are kept for the period the account chooses, 30, 90 or 365 days.

How does your app reply to a DM or a comment?

Through an automation on the customer's channel, because the Instagram token stays with easyCoexistence. Create one with POST /channels/{id}/automations, a dm_received or comment_received trigger and a call_webhook step with your URL. For each message, the step POSTs JSON to your backend, signed with X-EC-Signature using the automation's own secret, which the dashboard shows on that automation's page: the channel, the contact, the message or comment, and for a DM up to 10 recent messages as history. Answer within 20 seconds with {"reply": "..."} and easyCoexistence sends it from the customer's account, as a DM within 24 hours of the person's last message or, on a comment, as its one private reply. An answer without reply sends nothing, so your code can stay silent.

What the call_webhook step sends, and an answer that replies
POST <your call_webhook url>
X-EC-Event: automation.step
X-EC-Signature: t=1764680000,v1=<hex>

{
  "event": "automation.step",
  "dry_run": false,
  "automation": { "id": "4d2a…", "name": "Inbox replies" },
  "run_id": "7c0e…",
  "channel": { "type": "instagram", "channel_id": "9a41…", "username": "bloomcafe", "external_id": "…" },
  "contact": { "id": "<INSTAGRAM_SCOPED_ID>", "name": "Ana" },
  "message": { "id": "<MID>", "type": "text", "text": "Do you ship to Canada?", "at": "…" },
  "history": [{ "direction": "in", "text": "Do you ship to Canada?", "at": "…" }]
}

HTTP/1.1 200 OK
Content-Type: application/json

{ "reply": "We do! Orders to Canada arrive in 5 to 7 days." }

Which Instagram rules shape the inbox?

Meta's, and easyCoexistence checks them before sending, so your interface can mirror them:

  • People write first: the API cannot open a conversation, so every reply answers an incoming message and none starts a thread.
  • The 24-hour window: a DM reply goes out within 24 hours of the person's last message; after that the run is skipped with window_closed.
  • One private reply per comment, within 7 days of it; once the person answers, the conversation moves to DMs.
  • Allow access to messages: the account turns it on in the Instagram app under Settings, Messages and story replies, Message controls, Connected tools; while it is off, DMs fail with subcode 2534041.
  • Business or Creator accounts only, signed in with Instagram Login, with no Facebook Page needed.

How do you try a reply without sending it?

With the automation's test. POST /automations/{id}/test with a sample message runs the steps without sending anything to anyone, but your webhook really runs: it receives the same payload with dry_run true and answers as it would, so the run shows the actual reply your backend returned. When the answer has no reply, the run shows what your endpoint was sent and what it said back, which is the quickest way to fix a handler. An account gets 60 tests an hour. In production, GET /automations/{id}/runs keeps 30 days of runs with each step's output or error, and your events URL receives automation.run_failed when your endpoint times out, answers outside 2xx or is refused.

How to set it up

  1. Connect the accountCreate a connect session with channel instagram; the customer signs in with Instagram Login on a Business or Creator account.
  2. Set the webhookCall PUT /channels/{id}/webhook with your HTTPS URL and store the signing_secret against the channel_id.
  3. Store and thread eventsVerify X-EC-Signature on the raw body, answer 2xx at once, then file comments, mentions and DMs by Meta's IDs.
  4. Add the reply automationPOST /channels/{id}/automations with dm_received and a call_webhook step, and copy its signing secret from the dashboard.
  5. Answer with a replyReturn {"reply": "..."} within 20 seconds, inside the 24-hour window, or return no reply to stay silent.

Common mistakes

  • Processing a forwarded event before answering it. Each event is sent once, waits 8 seconds and is never retried, so acknowledge with 2xx and work from a queue.
  • Making the call_webhook step wait. It allows 20 seconds for {"reply"}, then the run fails and your account is emailed, so return a reply your code or model has ready, or none.
  • Looking for the step's signing secret in the API answer. The automation's secret is shown on its page in the dashboard and never in an API response, so copy it from there.
  • Designing a reply box for people to answer hours later. The REST API has no endpoint that sends a DM afterwards: replies leave through an automation, as fixed text, an ai_reply or your call_webhook answer within 20 seconds.
Doing this with EasyCoexistence

easyCoexistence brings your customers' Instagram comments, mentions and DMs into your inbox, CRM or helpdesk: each account connects through a hosted sign-in, its events reach your endpoint signed and without a stored copy, and automations send the replies your backend returns, with each account checked every 6 hours. The same calls work for Facebook Pages. US$ 9 to US$ 0.75 per connection per month, falling as you add connections, with the first 3 days free.

easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook, Google Business Profile and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.

Frequently asked questions

Do I need my own Meta app or App Review to read customers' Instagram DMs?

No. Accounts connect through easyCoexistence's Meta app, already reviewed by Meta, so your app receives their comments and DMs and sends replies without a review of its own.

Does the same webhook bring Facebook Page messages?

Yes, in the same shape. A Facebook Page's comments, Messenger messages and mentions reach the URL you set on that Page, and the same automations reply on Messenger.

Does easyCoexistence store Instagram DMs?

Not by default: they are forwarded to your endpoint without a copy. An account with an automation keeps its conversations for the 30, 90 or 365 days it chooses, so the flow can run.

How much does an Instagram inbox cost through easyCoexistence?

Each Instagram account your customers connect costs US$ 9 to US$ 0.75 a month, by the band of your total connections, with webhooks and automations included and the first 3 days free.

Keep reading

Connect your first channel in two minutes.

No platform reviews to wait for. Connect WhatsApp, Instagram, TikTok or another channel, then ask your AI to post, reply or report, and watch it work.

  • 3 days free
  • Cancel any time
  • Official APIs only
  • Monitored 24/7

Verified on