How to Send Instagram DMs via API
Send and receive Instagram direct messages programmatically — chats, the 24-hour messaging window, attachments, reactions, and inbound webhooks via the Postproxy API.
How Instagram DMs map to the API
Postproxy models Instagram messaging with two resources:
- A Chat is a conversation between your Instagram professional account and one participant.
- A Message belongs to a chat and is either
inbound(from the user) oroutbound(from you).
Sends are asynchronous: the API accepts the message with status: "pending", delivers it to Instagram, then flips it to "published" and fills in external_id.
Prerequisites
- A Postproxy API key
- A connected Instagram professional (Business or Creator) profile — Postproxy holds the OAuth token and the Meta webhook subscription, so there is no Meta app review on your side
Reply to an incoming DM
List chats for the profile (newest activity first):
curl "https://api.postproxy.dev/api/profiles/PROFILE_ID/chats" \ -H "Authorization: Bearer YOUR_API_KEY"Then send into a chat:
curl -X POST "https://api.postproxy.dev/api/chats/CHAT_ID/messages" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "body": "Yes, we ship worldwide!" }'The response is 202 Accepted with the pending message. CHAT_ID accepts either the Postproxy hashid or Instagram’s native conversation ID.
The 24-hour messaging window
Meta only allows free-form messages within 24 hours of the participant’s last inbound message. Inside the window you can send as many messages as you like; outside it, sends fail. Check the chat’s last_inbound_at before sending if your automation can lag.
The one documented way around the window is a private reply to a comment — it opens a DM with a commenter up to 7 days after their comment.
Receive DMs with webhooks
Inbound Instagram messages arrive on your webhook endpoint as message.received events — no polling needed. Subscribe via the Webhooks API and you get the full message object, including any attachments already mirrored to durable storage.
Useful related events: message.sent, message.delivered, message.read (Instagram exposes delivery and read receipts), and message.deleted when a user unsends.
Two Instagram-specific inbound shapes worth handling:
- Story replies — the message carries a
story_replyobject pointing at your story. - Story mentions — arrive as a
story_mentionattachment; Postproxy mirrors the asset to permanent storage before the story expires.
Send an image or video
media accepts a public URL, multipart upload, or base64 — one attachment per send (a Meta Send API limit), and a send is either text or media, never both:
curl -X POST "https://api.postproxy.dev/api/chats/CHAT_ID/messages" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "media": ["https://yourcdn.com/size-chart.jpg"] }'React to a message
Reactions from your business account land in the user’s thread:
curl -X POST "https://api.postproxy.dev/api/messages/MESSAGE_ID/react" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "reaction": "love" }'Instagram’s outbound reaction API accepts only love. DELETE /api/messages/MESSAGE_ID/unreact removes it.
Can you DM any Instagram user via the API?
No. Instagram messaging is reply-based: a chat exists because the user messaged your account (or commented, via private replies). You can pre-create a chat with POST /api/profiles/PROFILE_ID/chats and the user’s Instagram-scoped ID, but the 24-hour window still governs whether a send succeeds. Cold outreach to arbitrary usernames is not something Meta’s API permits — any tool claiming otherwise is automating a logged-in session against Instagram’s terms.
Who is messaging you
Each chat’s metadata carries participant signals fetched from Meta: is_verified_user, follower_count, is_user_follow_business, is_business_follow_user. Useful for routing — e.g. escalate verified accounts or large followings to a human.
Full field reference, statuses, and error shapes: Direct Messages API. For Messenger, the same chat/message model applies — see How to Send Facebook Messenger Messages via API.