Skip to content

Comment-to-DM API

Someone comments a keyword on an Instagram post and gets a DM with the link, the guide or the code you promised. Add a public reply so the thread shows it worked. One API call sets it up.

No card required.

Automation201 Created
POST /v1/comment-automations
{
  "accountId": "int_ig_123",
  "name": "Meal prep guide",
  "postScope": "specific",
  "platformPostId": "17998412563201",
  "keywords": ["GUIDE"],
  "matchMode": "word",
  "publicReplies": ["Sent it to your DMs 📩"],
  "dmMessage": "Here's the 5-day meal prep guide: https://priya.co/prep"
}

Comments

  • alexkitchen Saving this for Sunday3h

  • jamie.eats GUIDE please!now

    priya.cooks Sent it to your DMs 📩now

priya.cooksBusiness chat

Today

Here's the 5-day meal prep guide: priya.co/prep

Set it up in three calls

Automations run on Postkey's side. Your app creates them, pauses them and reads what happened.

  1. Pick the post

    List the account's recent posts, or use postScope "any" to watch every post.

    GET /v1/comment-automations/posts
      ?accountId=int_ig_123
    { "posts": [ { "platformPostId": "17998412563201",
      "caption": "5-day meal prep guide…" } ] }
  2. Create the automation

    Keywords (up to 20), how they match, up to 5 public replies to rotate, and the DM.

    POST /v1/comment-automations
    { "accountId": "int_ig_123", "name": "Meal prep guide",
      "postScope": "specific", "platformPostId": "17998412563201",
      "keywords": ["GUIDE"], "matchMode": "word",
      "publicReplies": ["Sent it to your DMs 📩"],
      "dmMessage": "Here's the guide: https://priya.co/prep" }
    { "automation": { "id": "auto_4Qe1", "status": "active" } }
  3. Read the logs

    Every trigger: who commented, what they wrote, whether the DM and the public reply went out.

    GET /v1/comment-automations/auto_4Qe1/logs
    { "logs": [ { "commenterName": "jamie.eats",
      "commentText": "GUIDE please!", "privateReplySent": true } ] }

Comment-to-DM endpoints

Same key, same connected accounts and same response shape on every network. Failed calls cost nothing.

Comment-to-DM endpoints: endpoints and credit costs
CallWhat it doesEndpointCredits
CreateKeywords, match mode (exact, contains, word), words to skip, public replies and the DMPOST /v1/comment-automations0
ListEvery automation on an account, with triggered, sent and failed countsGET /v1/comment-automations0
PostsRecent posts you can attach an automation toGET /v1/comment-automations/posts0
Pause or editPause, resume or change keywords, replies or the DMPATCH /v1/comment-automations/{id}0
DeleteStop and remove an automationDELETE /v1/comment-automations/{id}0
LogsEach trigger with the comment, the DM status and the public reply statusGET /v1/comment-automations/{id}/logs0
Each DM sentCharged when the DM goes out, not when the automation runs1

Comment-to-DM is one of 6 APIs

Every API uses the same key, profiles and connected accounts.

Which networks each Postkey API supports
APIXInstagramYouTubeFacebookTikTokLinkedInPinterestGoogle Business
Publishing
Scheduling
Analytics
Comments
Comment to DMYou're here
Reviews

Comment-to-DM questions

Something not here? Email hello@postkey.dev. I answer every one myself.

Book a 15-minute call
  • Instagram Business and Creator accounts.

  • exact matches the whole comment, contains matches anywhere, and word matches it as a separate word, so GUIDE matches "guide please" but not "guidelines". Add excludeKeywords to skip comments you don't want to answer.

  • 1 credit per DM sent. Creating, pausing and reading logs are free.

Get your key and make the first call.

$ curl -X POST api.postkey.dev/v1/posts -H "x-access-key: …"

No card required.