Log inStart Free Trial
easyCoexistence Official APIs

How to reply to Instagram DMs from your SaaS: the 24-hour window and private replies

Instagram lets a business reply to a DM within 24 hours of the person's last message and send one private reply to a comment within 7 days, never a cold first message. easyCoexistence's Partner API sends those replies for your SaaS through its Meta-reviewed app, with no App Review on your side: automations answer with a fixed text, an AI reply or your backend's text, priced per connected account.

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; the person has to write first.

7 days

How long after a comment its author can still get the account's one private reply; on a Live, only during the broadcast.

1,000 bytes

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

Connected Tools

The Instagram setting, under Message controls, where an account allows access to messages before any app can manage its DMs.

No token

What GET /channels/{id} returns for an Instagram account: the Graph API base and the account ID, never the access token.

Advanced Access

What your own Meta app needs, after App Review and Business Verification, to serve Instagram accounts you do not own.

What are Instagram's rules for replying to DMs?

Four, and each reply your SaaS sends has to fit them, whoever writes it. Meta sets them in its Instagram messaging and private replies documentation, and they apply in the same way to a fixed text, an answer from a model or a reply from your own backend:

  • The 24-hour window: a reply goes out within 24 hours of the person's latest message, and each new message from them opens the window again. A conversation started from a Click-to-Direct ad can stay open up to 7 days.
  • No cold DMs: the API sends only to people who have written to the account first. Someone who comments on a post or Reel is the exception, and only through a private reply.
  • One private reply per comment, within 7 days, or during the broadcast for a Live. It lands in the inbox of a follower and in Requests otherwise, and a follow-up waits for their answer, then has 24 hours.
  • Access to messages: the account turns on Allow Access to Messages under Settings, Messages and story replies, Message controls, Connected Tools. Until it does, no app can read or send its DMs.

How does a SaaS reply without holding the Instagram token?

Through automations that easyCoexistence runs on each customer's account. Meta's terms do not allow an Instagram account's token to be handed to another app, so easyCoexistence keeps it and renews it before its 60 days run out, and GET /channels/{id} gives your backend the account's IDs instead. Your backend creates an automation per account with POST /channels/{id}/automations, on the channel_id the customer came back with from the hosted sign-in. A dm_received trigger starts it on new DMs: any message, or only one with a keyword, a first message, one sent outside opening hours or one containing a phone number. A comment_received trigger starts it on comments instead. When several automations match, only the most specific answers, so a keyword automation and a catch-all never both reply. The text itself comes from one of three steps, the same ones behind easyCoexistence's Instagram automations:

reply_textA fixed text, with {{first_name}} and other fields filled in for each person
ai_replyWritten by a model on your own Anthropic, OpenAI or OpenRouter key, from your instructions
call_webhookYour backend gets the DM and answers {"reply": "..."}, which goes out as the DM

What does your backend receive from call_webhook, and what does it answer?

A signed POST for each DM, and your answer becomes the reply. easyCoexistence sends JSON to the step's URL with X-EC-Event set to automation.step and an X-EC-Signature header, an HMAC-SHA256 keyed with the automation's own secret, which the account owner copies from that automation's page in the dashboard. Verify it on the raw body and reject a timestamp older than 5 minutes. The body names the automation, the run, the channel with its channel_id, the person and their message, plus history: the chat's last 10 messages, oldest first, ending with the one that started the run. Look the customer up by channel_id, as you stored it when they connected.

Answer 2xx within 20 seconds with a reply field and easyCoexistence sends it as a DM from the customer's account. An empty or missing reply sends nothing and the flow goes on, so your code can choose silence. An error status or a timeout fails the step, ends the run and reaches your events URL as automation.run_failed.

A DM automation that asks your backend, and the request your backend gets
curl -X POST https://easycoexistence.com/api/v1/channels/$CHANNEL_ID/automations \
  -H "Authorization: Bearer $EC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Instagram DMs to our backend",
    "trigger": { "type": "dm_received", "match": "any" },
    "steps": [{ "type": "call_webhook", "url": "https://api.example.com/ec/instagram" }]
  }'

POST https://api.example.com/ec/instagram
X-EC-Event: automation.step
X-EC-Signature: t=1764684000,v1=<hex>

{
  "event": "automation.step",
  "dry_run": false,
  "automation": { "id": "4d2a…", "name": "Instagram DMs to our backend" },
  "run_id": "7c0e…",
  "channel": { "type": "instagram", "channel_id": "9a41…", "username": "harborcoffee", "external_id": "…" },
  "contact": { "id": "<INSTAGRAM_SCOPED_ID>", "name": "maria.silva" },
  "message": { "id": "<MID>", "type": "text", "text": "Do you ship to Lisbon?", "at": "2026-12-02T14:03:11.000Z" },
  "history": [
    { "direction": "out", "text": "Hi Maria! How can we help?", "at": "2026-12-02T14:01:02.000Z" },
    { "direction": "in", "text": "Do you ship to Lisbon?", "at": "2026-12-02T14:03:11.000Z" }
  ]
}

Your answer, within 20 seconds:
{ "reply": "We do: 2 to 3 days to Lisbon. Want the shipping rates?" }

How does easyCoexistence keep replies inside Meta's windows?

By checking before each send, so a late reply never reaches Meta. easyCoexistence records when each person last wrote, and a DM step that would go out more than 24 hours after that is skipped: the run ends with skip_reason window_closed and nothing is sent. A comment's private reply goes out as the comment arrives, far inside Meta's 7 days, and the API refuses an automation with a second DM step before the person answers, since Meta allows one private reply per comment. A wait step lasts at most 1,380 minutes, or 23 hours, which keeps a follow-up inside the window the person's message opened.

Two more guards protect the customer's account. When someone on their team answers a chat from Instagram, the automation stays quiet on it for takeover_hours, 4 by default, and the run records human_active. AI replies are capped per chat with ai_max_per_hour, 10 by default, so two bots can never keep answering each other.

How do you test a reply flow before customers see it?

With a dry run. POST /automations/{id}/test with a sample text runs the steps as if that DM had arrived, without sending anything. The AI step and your webhook really run, so the result shows the reply a person would get, and your endpoint sees dry_run set to true with an empty history; when it answers with no reply, the test shows what it was sent and what it returned. An account can run 60 tests an hour.

After launch, GET /automations/{id}/runs lists what the automation did on each message, newest first, for 30 days, with each step's status, output or error and its time in milliseconds, and it filters by status. Your events URL also receives automation.run_failed with the run ID, the failed step and the channel, never what anyone wrote, so your product can flag a customer's broken flow without polling.

How to set it up

  1. Connect the customer's accountPOST /connect-sessions with channel instagram and your customer's ID as external_ref; they sign in with Instagram on a Business or Creator account and return with a channel_id.
  2. Turn on access to messagesAsk the customer to switch on Allow Access to Messages in the Instagram app's Connected Tools, or their DMs cannot be read or answered.
  3. Create the reply automationPOST /channels/{id}/automations with a dm_received trigger and one reply step: reply_text, ai_reply, or call_webhook pointing at your endpoint.
  4. Answer from your endpointCheck X-EC-Signature, find the customer by channel_id and return a JSON object with a reply field inside the 20 seconds.
  5. Test, then read the runsSend sample DMs to POST /automations/{id}/test, then follow GET /automations/{id}/runs once real messages arrive.

Common mistakes

  • Doing slow work before answering the webhook. The reply has to come back within 20 seconds or the step fails and nothing is sent, so look up only what the answer needs and defer the rest.
  • Counting characters instead of bytes. Instagram takes 1,000 bytes of UTF-8 per DM, and accented letters and emoji use two to four bytes each, so keep replies short.
  • Adding a second DM step to a comment automation. Meta allows one private reply per comment, so the API refuses the flow with 400 invalid_request; the next DM waits for the person's answer.
  • Skipping the access check at onboarding. With Allow Access to Messages off, Meta refuses the account's DMs, so ask the customer to switch it on while they connect.
Doing this with EasyCoexistence

easyCoexistence connects your customers' Instagram accounts through one hosted sign-in and answers their DMs and comments from automations your backend creates: a fixed text, an AI reply on your own key or the text your webhook returns, each checked against Meta's windows before it goes out. Tokens stay with easyCoexistence, renewed and checked every 6 hours. 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

Can my SaaS send the first DM to an Instagram user?

No. Meta lets an account message only people who wrote to it first. Someone who comments can get one private reply within 7 days, and the conversation continues if they answer it.

What happens to a reply after the 24 hours are up?

It is not sent. The step is skipped, the run records window_closed, and nothing goes out until the person writes again, which opens a new window.

Do I need my own Meta app or App Review?

No. easyCoexistence is a Meta Tech Provider whose own app Meta has already reviewed, and your customers' accounts connect through it with Instagram's sign-in.

How much does easyCoexistence cost per Instagram account?

Each connected account is one connection, at US$ 9 to US$ 0.75 a month depending on your total connections, and the first 3 days are 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