st.commentOnPost
This action allows you to leave a comment on a post.
In the SDK this is the commentOnPost method. It takes the parameters below except label and then, which exist only in workflow JSON, and returns the result below in data.
In the CLI this is linkedin post comment – the command is below, under Parameters.
Constraints
⏺️ Root Start: allowed, when
postUrlorpostUrnparameter is provided.
⬆️ Parent Actions: st.openPost, st.doForPosts.
⬇️ Child Actions: N/A.
Parameters
{
"actionType": "st.commentOnPost",
"label": "post1",
"postUrl": "https://www.linkedin.com/posts/post1",
"companyUrl": "https://www.linkedin.com/company/company1",
"text": "I completely agree with your point."
}In AI assistants, the MCP server runs this action as the comment_on_post tool.
In the CLI this is linkedin post comment:
linkedin post comment <url> <text> [flags]| Arg | Required | Description |
|---|---|---|
url | yes | LinkedIn post URL |
text | yes | Comment text (up to 1000 characters) |
| Flag | Type | Description |
|---|---|---|
--company-url | string | Comment on behalf of a company page |
The same text on the same post, already published through Linked API within 24 hours, is not published again – the command fails with
duplicateCommentand links the earlier comment when it is known. A comment published with--company-urlis counted separately from a personal one.
label(optional) – custom label for tracking this action in workflow completion.postUrl(required for root start unlesspostUrnis provided, forbidden for parent start) – LinkedIn URL of the post.postUrn(optional) – URN of the post, accepted instead ofpostUrl. When both are provided, the URL must contain that same URN.text– comment text, must be up to 1000 characters.companyUrl(optional) – LinkedIn company page URL. When provided, the comment will be posted on behalf of the company. Requires content admin access to the company page.
Result options
- Successful post commenting:
{
"actionType": "st.commentOnPost",
"label": "post1",
"success": true,
"data": {
"commentUrn": "urn:li:comment:(urn:li:activity:1234567890123456789,9876543210)",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(9876543210%2Curn%3Ali%3Aactivity%3A1234567890123456789)"
}
}label– included only if specified in the action parameters.data– information about the created comment.commentUrn– LinkedIn URN of the created comment, if available.commentUrl– canonical deep-link URL of the created comment, if available. It can be used as thecommentUrlinput for st.openComment, st.reactToComment, or st.replyToComment.
- Failed post commenting:
{
"actionType": "st.commentOnPost",
"label": "post1",
"success": false,
"error": {
"type": "commentingNotAllowed",
"message": "Commenting is not allowed on this post."
}
}label– included only if specified in the action parameters.error.type– enum with the following possible values:postNotFound– provided URL is not an existing LinkedIn post.duplicateComment– this account already published the same text on this post through Linked API within the last 24 hours, so it was not published again. Text is compared after trimming and collapsing whitespace, and a comment published as a company page is counted separately from a personal one. The message links the earlier comment when it is known.commentingNotAllowed– commenting is not allowed on this post. This could be due to the post author's privacy settings, LinkedIn restrictions on commenting, or because the post type does not support comments.noPostingPermission– no permission to comment on behalf of this company.