Docs / Posts

comment_on_post

Comment on one post, or answer one comment on it.

This action can change or spend something, and when it does it happens right away. Read “Good to know” first.

What you give it

InputWhat it isWhere to get it
postUrl
needed
A post link or a post social id. The LinkedIn post URL.On LinkedIn, click the More icon (the three dots) at the top right of the post, then "Copy link to post".
Or run search_posts and use posts[].url from its answer.
9 more places to get it
text
needed
Text, up to 1250 characters. The comment text.You write it.
replyToCommentId
optional
A comment id. Id of a comment on that post to reply to (from list_post_comments).Run list_post_comments and use comments[].id from its answer.
2 more places to get it
mentions
optional
A list (a group of fields), up to 20. People or companies to mention. Put {{0}}, {{1}}, … in the text where each one goes (its position in this list).
What goes inside
You write it.
link
optional
A link. A link to show as a preview card. It should also appear in the text; otherwise LinkedIn adds it at the end.You write it.
imageUrl
optional
A link. One image to attach (a public https link, up to 10 MB).You write it.
asOrganization
optional
A organization id. Act as a company page you administer instead of yourself: that page's numeric id. No action here lists the pages you administer.No action here gives it.
connectionId
optional
A connection id. Which of your LinkedIn accounts to act from (its id from list_linkedin_accounts). Omit to use your first live one.Run list_linkedin_accounts and use accounts[].id from its answer.
15 more places to get it

Call it

curl -X POST https://api.heyreagent.com/v1/actions/comment_on_post \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "content-type: application/json" \
  -d '{"postUrl":"PASTE_POST_LINK_HERE","text":"Hello!"}'
The same call in JavaScript
const response = await fetch("https://api.heyreagent.com/v1/actions/comment_on_post", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_KEY",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "postUrl": "PASTE_POST_LINK_HERE",
    "text": "Hello!"
  }),
});
const answer = await response.json();
console.log(answer);
The same call in Python
import requests

response = requests.post(
    "https://api.heyreagent.com/v1/actions/comment_on_post",
    headers={"Authorization": "Bearer YOUR_KEY"},
    json={
        "postUrl": "PASTE_POST_LINK_HERE",
        "text": "Hello!",
    },
)
print(response.json())
The same call in n8n

Add an HTTP Request node and fill it in like this:

MethodPOST
URLhttps://api.heyreagent.com/v1/actions/comment_on_post
Send HeadersOn. Name Authorization, Value Bearer YOUR_KEY
Send BodyOn. Body Content Type JSON, Specify Body Using JSON, then paste the body below
{
  "postUrl": "PASTE_POST_LINK_HERE",
  "text": "Hello!"
}

Put your own key where it says YOUR_KEY. Put your own value where it says PASTE_…_HERE: the table above says where each one comes from. New here? Start with your first call.

What you get back

When it worked, the answer is { "ok": true, "result": { … } }. Inside result:

sent
postUrl
asReply
commentIdA comment id. Other actions take it.
fromthe account it ran on
usedTodaynumber
dailyLimitnumber

A field that does not apply to an answer is left out, or is null.

When it did not work, the answer is { "ok": false, "error": "…", "message": "…" }. What each error means.

Good to know

In Claude or ChatGPT

Once connected, ask in your own words. The assistant sees this action as a tool with the same name, comment_on_post, and the same inputs.