> ## Documentation Index
> Fetch the complete documentation index at: https://www.outx.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LinkedIn Comment API - Comment on Posts via API

> Programmatically comment on LinkedIn posts using the OutX LinkedIn Automation API. Add comments to any post via its activity URN with custom text.

The Comment Post endpoint creates an async task to post a comment on a LinkedIn post. You provide the post's activity URN and the comment text, and the API handles posting the comment through your team's oldest admin member's LinkedIn account.

## Endpoint

```
POST https://api.outx.ai/linkedin-agent/comment-post
```

## Request Body

<ParamField body="social_urn" type="string" required>
  The LinkedIn activity URN of the post (e.g., `"urn:li:activity:7123456789012345678"`)
</ParamField>

<ParamField body="comment_text" type="string" required>
  The text content of the comment to post
</ParamField>

<Tip>
  **Don't have a social URN?** Use [Fetch Posts](/docs/linkedin-api/fetch-profiles-posts) to retrieve posts from a profile, each post in the response includes its activity URN. If you only have a profile slug, first use [Fetch Profile](/docs/linkedin-api/fetch-profile) to get the profile URN, then fetch their posts.
</Tip>

<Warning>
  The comment is posted using your team's **oldest admin member's LinkedIn account**. Make sure this team member is aware that comments will be posted from their account via the API.
</Warning>

## Response

The endpoint returns immediately with a task ID:

<ResponseField name="success" type="boolean">
  Whether the task was created successfully
</ResponseField>

<ResponseField name="api_agent_task_id" type="string">
  UUID to poll for results via [Get Task Status](/docs/linkedin-api/get-task-status)
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable confirmation
</ResponseField>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "api_agent_task_id": "550e8400-e29b-41d4-a716-446655440000",
    "message": "Comment post task created successfully"
  }
  ```
</ResponseExample>

## Polling for Results

Poll the [Get Task Status](/docs/linkedin-api/get-task-status) endpoint to confirm the comment was posted:

```
GET https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=550e8400-e29b-41d4-a716-446655440000
```

### Completed Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "task_input": {
      "task_type": "agent_comment_post",
      "social_urn": "urn:li:activity:7123456789012345678",
      "comment_text": "Great insights! Thanks for sharing."
    },
    "task_output": {
      "commented": true
    }
  }
}
```

## Code Examples

<RequestExample>
  ```bash cURL theme={null}
  # Comment on a post
  curl -X POST \
    "https://api.outx.ai/linkedin-agent/comment-post" \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "social_urn": "urn:li:activity:7123456789012345678",
      "comment_text": "Great insights! Thanks for sharing."
    }'

  # Check the result
  curl -X GET \
    "https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=TASK_ID" \
    -H "x-api-key: YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  async function commentOnPost(socialUrn, commentText) {
    // Create the comment task
    const response = await fetch(
      "https://api.outx.ai/linkedin-agent/comment-post",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": "YOUR_API_KEY",
        },
        body: JSON.stringify({
          social_urn: socialUrn,
          comment_text: commentText,
        }),
      }
    );

    const { api_agent_task_id } = await response.json();

    // Poll for completion
    while (true) {
      const statusRes = await fetch(
        `https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=${api_agent_task_id}`,
        { headers: { "x-api-key": "YOUR_API_KEY" } }
      );

      const result = await statusRes.json();
      if (result.data.status === "completed") {
        return result.data.task_output;
      }

      await new Promise((r) => setTimeout(r, 5000));
    }
  }

  const result = await commentOnPost(
    "urn:li:activity:7123456789012345678",
    "Great insights! Thanks for sharing."
  );
  console.log(result); // { commented: true }
  ```

  ```python Python theme={null}
  import requests
  import time

  def comment_on_post(social_urn, comment_text):
      headers = {
          "Content-Type": "application/json",
          "x-api-key": "YOUR_API_KEY",
      }

      # Create the comment task
      response = requests.post(
          "https://api.outx.ai/linkedin-agent/comment-post",
          headers=headers,
          json={
              "social_urn": social_urn,
              "comment_text": comment_text,
          },
      )
      task_id = response.json()["api_agent_task_id"]

      # Poll for completion
      while True:
          result = requests.get(
              "https://api.outx.ai/linkedin-agent/get-task-status",
              headers={"x-api-key": "YOUR_API_KEY"},
              params={"api_agent_task_id": task_id},
          ).json()

          if result["data"]["status"] == "completed":
              return result["data"]["task_output"]

          time.sleep(5)

  result = comment_on_post(
      "urn:li:activity:7123456789012345678",
      "Great insights! Thanks for sharing."
  )
  print(result)  # {"commented": True}
  ```
</RequestExample>

## Best Practices for Comments

<Tip>
  Well-crafted comments drive better engagement and reflect positively on your LinkedIn presence. Here are some tips for effective automated commenting.
</Tip>

* **Be genuine and specific.** Reference something from the post content rather than posting generic responses like "Great post!"
* **Add value.** Share a related insight, ask a thoughtful question, or offer a complementary perspective.
* **Keep it concise.** LinkedIn comments that are 1-3 sentences tend to perform best.
* **Vary your comments.** If you are commenting on multiple posts, make each comment unique. Repeating the same text can look spammy.
* **Space out your comments.** Avoid commenting on dozens of posts in rapid succession. Natural timing patterns are less likely to trigger LinkedIn's activity monitoring.

## Error Responses

| Status | Error                                 | Description                                                                                        |
| ------ | ------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `400`  | `Missing or invalid 'social_urn'`     | The `social_urn` field is missing or not a string                                                  |
| `400`  | `Missing or invalid 'comment_text'`   | The `comment_text` field is missing or not a string                                                |
| `401`  | `Missing API Key` / `Invalid API Key` | API key is missing or invalid                                                                      |
| `403`  | `Plugin installation required...`     | No team member has an active Chrome extension. See [Authentication](/docs/api-reference/authentication) |
| `404`  | `No admin user found in the team`     | Your team has no admin members                                                                     |

## FAQ

<AccordionGroup>
  <Accordion title="Whose LinkedIn account posts the comment?">
    The comment is posted using your team's **oldest admin member's** LinkedIn account (sorted by when they joined the team). This is the team member whose Chrome extension session executes the action.
  </Accordion>

  <Accordion title="Is there a character limit for comments?">
    LinkedIn's own comment character limit applies (approximately 1,250 characters). The API does not enforce an additional limit, but your comment will be truncated by LinkedIn if it exceeds their limit.
  </Accordion>

  <Accordion title="Can I include mentions or hashtags in the comment text?">
    You can include hashtags (e.g., `#AI #MachineLearning`) directly in the `comment_text`. LinkedIn will render them as clickable hashtags. @mentions of specific users are not currently supported through the API.
  </Accordion>

  <Accordion title="Can I edit or delete a comment after posting?">
    The API currently supports posting comments only. Editing and deleting comments is on our [roadmap](/docs/linkedin-api/coming-soon). You can manually edit or delete comments from the LinkedIn interface.
  </Accordion>

  <Accordion title="What about rate limits?">
    **OutX does not rate-limit these requests for you.** OutX is a proxy, every comment you trigger is executed immediately on LinkedIn through a real browser session. Space comments at least 30–60 seconds apart, distribute them throughout the day, and keep daily volume realistic. Posting many comments in rapid succession can trigger LinkedIn's activity monitoring. See [Rate Limits](/docs/api-reference/rate-limits) for safe usage guidelines.
  </Accordion>
</AccordionGroup>

## Related

* [Like Post](/docs/linkedin-api/like-post) - Like posts alongside commenting
* [Fetch Posts](/docs/linkedin-api/fetch-profiles-posts) - Fetch posts to get activity URNs
* [Get Task Status](/docs/linkedin-api/get-task-status) - Poll for task results

***

## Learn More

* [How to Automate LinkedIn Comments](https://www.outx.ai/blog/linkedin-auto-commentor)
* [Automate LinkedIn Likes & Comments](https://www.outx.ai/blog/automate-linkedin-likes-comments)
* [LinkedIn Automation Safety Guide](https://www.outx.ai/blog/linkedin-automation-safety-guide-best-practices-2026)
