InstantDM API Documentation

InstantDM is an Official Meta Business Partner that helps creators, businesses, and agencies automate their Instagram and Facebook DM conversations, comment responses, and lead generation flows. Built on the Meta Graph API.

What you can automate

Comment Automation — Automatically reply to comments and send DMs when someone comments on your post with a trigger word.

Flow Automation — Build multi-step DM flows with questions, buttons, media, and conditional logic. Collect leads, qualify prospects, and deliver content automatically.

AI Replies — Use AI models to generate contextual replies in DM conversations.

Why use the API?

The API lets you connect InstantDM with your existing tools. Receive real-time webhook events when comments, DMs, or flow completions happen. Send messages and reply to comments programmatically from Make.com, Zapier, n8n, or your own backend.

Platform

Official Meta Business Partner
Built on Meta Graph API v25.0

Base URL

https://api.instantdm.com

Dashboard

https://app.instantdm.com

API Endpoint

POST https://api.instantdm.com/api-webhook

Webhook Config

Settings → Integrations → Webhook Configuration

API Keys

Settings → Integrations → API Keys

Authentication

All API requests require an API key. Generate one from your InstantDM dashboard under Settings → Integrations → API Keys.

API access is available on eligible plans. View pricing →

Include the key in one of these headers:

HeaderFormat
AuthorizationBearer YOUR_API_KEY
x-api-keyYOUR_API_KEY
API keys are shown only once when generated. Store them securely.

Example Request

curl -X POST https://api.instantdm.com/api-webhook \
  -H "Authorization: Bearer sk-abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "action": "send_message",
    "type": "dm",
    "recipient_id": "2358708294634624",
    "message": {"text": "Hello!"}
  }'

Outbound Webhooks

InstantDM sends HTTP POST requests to your configured URL when events occur. Set one webhook URL and subscribe to the events you want.

Configure from: Settings → Integrations → Webhook Configuration

Headers on every webhook

HeaderDescription
Content-Typeapplication/json
X-Event-TypeEvent name (e.g. comment, dm_received)
X-TimestampISO-8601 UTC timestamp
X-Webhook-SignatureHMAC-SHA256 hex digest (if secret configured)

Available events

EventTrigger
commentNew comment on your post
dm_receivedNew direct message received
postbackButton clicked in DMs
question_answeredUser answers a flow question
flow_completedFlow automation completes

Webhook delivery format

POST https://your-webhook-url.com
Content-Type: application/json
X-Event-Type: comment
X-Timestamp: 2026-04-29T15:32:06+00:00
X-Webhook-Signature: a1b2c3d4...

comment

Fired when someone comments on your Instagram post. The payload is the raw Instagram webhook event as received from Meta.

Example payload

{
  "object": "instagram",
  "entry": [{
    "id": "17841432111391196",
    "time": 1777476726126,
    "changes": [{
      "field": "comments",
      "value": {
        "id": "17890012345",
        "text": "Love this!",
        "from": {"id": "123456", "username": "user123"},
        "media": {"id": "18071354672638470"}
      }
    }]
  }]
}

dm_received

Fired when you receive a new direct message. The payload is the raw Instagram webhook event.

Example payload

{
  "object": "instagram",
  "entry": [{
    "messaging": [{
      "sender": {"id": "2358708294634624"},
      "recipient": {"id": "17841432111391196"},
      "timestamp": 1777476725580,
      "message": {
        "mid": "aWdfZAG1f...",
        "text": "Hey, I'm interested!"
      }
    }]
  }]
}

postback

Fired when a user clicks a button in DMs. Includes the raw Instagram event plus an idm_optimized_body field with resolved postback data.

Example payload

{
  "object": "instagram",
  "entry": [{
    "messaging": [{
      "sender": {"id": "2358708294634624"},
      "postback": {
        "title": "Get Started",
        "payload": "{\"flow_id\":\"abc\"}"
      }
    }]
  }],
  "idm_optimized_body": {
    "user_id": "6703dbc9-...",
    "flow_id": "0e3501b6-...",
    "sender_id": "2358708294634624"
  }
}

question_answered

Fired each time a user answers a question in a flow. Gives you real-time data as the flow progresses.

FieldDescription
flow_idFlow automation ID
sender_idInstagram user ID of the responder
questionThe question text
question_typeType: email, phone, address, text, etc.
custom_variable_nameVariable name set in the flow editor
user_responseThe user's answer
skiptrue if the user skipped this question

Example payload

{
  "flow_id": "0e3501b6-...",
  "sender_id": "2358708294634624",
  "sender_username": "user123",
  "question": "What's your email?",
  "question_type": "email",
  "custom_variable_name": "user_email",
  "user_response": "user@example.com",
  "skip": false,
  "attempt_no": "1",
  "timestamp": "2026-04-29 17:11:59"
}

flow_completed

Fired once when a flow automation completes. Contains all collected data in one payload.

response_variables is a flat dict — keys are the custom_variable_name. Easy to map in Make.com or Zapier.

The flow_completed webhook only fires for flows with Webhook enabled in the flow editor's Integrations popup.

Example payload

{
  "flow_id": "0e3501b6-...",
  "flow_name": "Lead Gen Flow",
  "sender_id": "2358708294634624",
  "sender_username": "user123",
  "completed_at": "2026-04-29 17:17:15",
  "tags": ["lead", "vip"],
  "response_variables": {
    "email": "user@example.com",
    "phone": "+919876543210",
    "address": "123 Main St"
  }
}

Signature Verification

If you configure a webhook secret, every outbound request includes an X-Webhook-Signature header with an HMAC-SHA256 hex digest of the JSON body.

Always verify the signature before processing the webhook to ensure it came from InstantDM.

Node.js

const crypto = require('crypto');

function verify(body, signature, secret) {
  const computed = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(body))
    .digest('hex');
  return computed === signature;
}

Python

import hmac, hashlib, json

def verify(payload, signature, secret):
    computed = hmac.new(
        secret.encode(),
        json.dumps(payload).encode(),
        hashlib.sha256
    ).hexdigest()
    return computed == signature

Inbound API

Call InstantDM's API to perform actions from external systems. All actions use a single endpoint.

POST https://api.instantdm.com/api-webhook

Required headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Available actions

post_comment   — Reply to a comment
send_message   — Send a DM or comment private reply

Reply to Comment

Reply to a specific Instagram comment publicly.

FieldTypeRequiredDescription
actionstringYes"post_comment"
comment_idstringYesInstagram comment ID
comment_textstringYesReply text

Request

{
  "action": "post_comment",
  "comment_id": "17890012345",
  "comment_text": "Thanks! Check your DM"
}

Response

{
  "message": "Comment reply posted",
  "comment_id": "17890012346"
}

Send Message

Send a message via Instagram DM. Two types:

DM Message — Send to a user by their Instagram user ID.

Comment Private Reply — Reply to a comment privately via DM.

FieldTypeRequiredDescription
actionstringYes"send_message"
typestringNo"dm" (default) or "comment_reply"
recipient_idstringFor dmInstagram user ID
comment_idstringFor comment_replyInstagram comment ID
messageobjectYesMessage content (see formats)

DM Message

{
  "action": "send_message",
  "type": "dm",
  "recipient_id": "2358708294634624",
  "message": {"text": "Hello!"}
}

Comment Private Reply

{
  "action": "send_message",
  "type": "comment_reply",
  "comment_id": "17890012345",
  "message": {"text": "Here's the link..."}
}

Message Formats

The message field supports multiple formats. Pass the object directly — InstantDM forwards it to the Instagram Graph API.

For media support details and limitations, see the Meta Instagram Messaging API documentation.

Text

{"text": "Hello!"}

Image

{"attachment": {"type": "image",
  "payload": {"url": "https://example.com/photo.jpg"}}}

Video

{"attachment": {"type": "video",
  "payload": {"url": "https://example.com/video.mp4"}}}

Audio

{"attachment": {"type": "audio",
  "payload": {"url": "https://example.com/audio.mp3"}}}

Button Template

{"attachment": {"type": "template",
  "payload": {
    "template_type": "button",
    "text": "Choose an option:",
    "buttons": [
      {"type": "web_url", "title": "Visit", "url": "https://..."},
      {"type": "web_url", "title": "More", "url": "https://..."}
    ]
  }
}}

Quick Replies

{"text": "Pick one:",
  "quick_replies": [
    {"content_type": "text", "title": "A", "payload": "A"},
    {"content_type": "text", "title": "B", "payload": "B"}
  ]
}

Rate Limits

API rate limits are based on your InstantDM plan. On top of that, Meta's own rate limits also apply. Whichever limit is reached first, the automation will be stopped.

If you hit a rate limit, messages are not retried automatically — you'll need to resend them in the next rate limit window.

To avoid hitting limits, space out your API calls and monitor the response headers for rate limit status. For high-volume use cases, contact support for guidance.

Error Codes

CodeMessageCause
401Missing API keyNo Authorization or x-api-key header
401Invalid API keyKey not found or revoked
400Missing comment_id or comment_textpost_comment missing required fields
400Missing recipient_idsend_message (dm) missing recipient
400Missing comment_id for comment_replysend_message (comment_reply) missing comment ID
400Missing messageNo message content provided
400Unknown actionInvalid action value
404No Instagram access token foundUser has no connected IG account
4xx/5xxInstagram API errorError passed through from Meta Graph API
403API access requires higher planUser's plan doesn't include API access
403API & Webhook integrations require higher planTrying to enable webhook config on ineligible plan
403API keys require higher planTrying to generate API key on ineligible plan
429Hourly rate limit reached. Please try again later.Trendsetter/Trendsetter Pro user hit their hourly limit (2,000/hr or 20,000/hr)
402Insufficient credits. Please upgrade or purchase top-up credits.Multi-account plan user ran out of credits