> ## 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.

# Comment on a Post

> Create a task to comment on a LinkedIn post as a user or company

Programmatically add comments to LinkedIn posts through OutX. Engage as a user or on behalf of a company, automate interactions, and keep conversations active without manual effort.

## Request Body

<ParamField body="post_id" type="string" required>
  The unique identifier of the post to comment on. This is the `id` field from the Posts API response.
</ParamField>

<ParamField body="user_email" type="string" required>
  Email address of the user who will comment on the post.

  * For **user** actor type: The user's email
  * For **company** actor type: The admin user's email who manages the company page
</ParamField>

<ParamField body="comment_text" type="string" required>
  The text content of the comment. Cannot be empty or whitespace-only.

  **Tips for effective comments:**

  * Be genuine and add value to the conversation
  * Keep it concise but meaningful
  * Ask questions to encourage engagement
  * Avoid generic responses like "Great post!"
</ParamField>

<ParamField body="actor_type" type="string" default="user">
  Who is posting the comment. Options:

  * `user` - Comment as an individual user
  * `company` - Comment on behalf of a company page
</ParamField>

<ParamField body="company_title" type="string">
  **Required when `actor_type` is `company`**

  The exact company name/title as it appears on LinkedIn. This is used to identify which company page should post the comment.
</ParamField>

<RequestExample>
  ```bash Comment as User theme={null}
  curl -X POST \
    "https://api.outx.ai/api-comment" \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "post_id": "123e4567-e89b-12d3-a456-426614174000",
      "user_email": "john.doe@example.com",
      "comment_text": "Great insights! Thanks for sharing.",
      "actor_type": "user"
    }'
  ```

  ```bash Comment as Company theme={null}
  curl -X POST \
    "https://api.outx.ai/api-comment" \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "post_id": "123e4567-e89b-12d3-a456-426614174000",
      "user_email": "admin@company.com",
      "comment_text": "Excellent points from our team perspective! We'\''ve seen similar trends in our industry.",
      "actor_type": "company",
      "company_title": "Acme Corporation"
    }'
  ```

  ```javascript JavaScript theme={null}
  // Comment as a user
  const commentAsUser = async (postId, userEmail, commentText) => {
    const response = await fetch(
      'https://api.outx.ai/api-comment',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
        },
        body: JSON.stringify({
          post_id: postId,
          user_email: userEmail,
          comment_text: commentText,
          actor_type: 'user'
        })
      }
    );
    
    return await response.json();
  };

  // Comment as a company
  const commentAsCompany = async (postId, adminEmail, commentText, companyTitle) => {
    const response = await fetch(
      'https://api.outx.ai/api-comment',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
        },
        body: JSON.stringify({
          post_id: postId,
          user_email: adminEmail,
          comment_text: commentText,
          actor_type: 'company',
          company_title: companyTitle
        })
      }
    );
    
    return await response.json();
  };

  // Usage
  const result = await commentAsUser(
    'post-123',
    'john@example.com',
    'This is a valuable perspective on AI trends. Have you considered the impact on smaller businesses?'
  );
  console.log(result.message);
  ```

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

  def comment_as_user(post_id, user_email, comment_text, api_key):
      """Add a comment to a post as a user"""
      url = 'https://api.outx.ai/api-comment'
      headers = {
          'Content-Type': 'application/json',
          'x-api-key': api_key
      }
      payload = {
          'post_id': post_id,
          'user_email': user_email,
          'comment_text': comment_text,
          'actor_type': 'user'
      }
      
      response = requests.post(url, headers=headers, json=payload)
      return response.json()

  def comment_as_company(post_id, admin_email, comment_text, company_title, api_key):
      """Add a comment to a post as a company"""
      url = 'https://api.outx.ai/api-comment'
      headers = {
          'Content-Type': 'application/json',
          'x-api-key': api_key
      }
      payload = {
          'post_id': post_id,
          'user_email': admin_email,
          'comment_text': comment_text,
          'actor_type': 'company',
          'company_title': company_title
      }
      
      response = requests.post(url, headers=headers, json=payload)
      return response.json()

  # Usage
  result = comment_as_user(
      'post-123',
      'john@example.com',
      'Great insights! Thanks for sharing.',
      'YOUR_API_KEY'
  )
  print(result['message'])
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "message": "Comment task created successfully",
    "task_id": "789e0123-e45b-67d8-a901-234567890123"
  }
  ```
</ResponseExample>

## Response Fields

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

<ResponseField name="message" type="string">
  Human-readable message about the operation
</ResponseField>

<ResponseField name="task_id" type="string">
  Unique identifier for the created task. Use this to track the task status.
</ResponseField>

## How It Works

<Steps>
  <Step title="Task Creation">
    When you call the Comment API, a task is created and queued for processing
  </Step>

  <Step title="Validation">
    The system validates:

    * Post exists and belongs to your team's watchlists
    * User email is valid and associated with your team
    * Comment text is not empty
    * Company title matches (if commenting as company)
    * You haven't exceeded plan limits
  </Step>

  <Step title="Asynchronous Processing">
    The comment is processed asynchronously by OutX's automation system
  </Step>

  <Step title="Execution">
    The comment is posted on LinkedIn on behalf of the specified user or company
  </Step>
</Steps>

## Actor Types Explained

### User Actor Type

When `actor_type` is `user`:

* The comment appears as coming from the individual user
* `user_email` should be the email of the user who will comment
* The user must be part of your OutX team
* No `company_title` is needed

**Use case:** Personal engagement, thought leadership, networking

### Company Actor Type

When `actor_type` is `company`:

* The comment appears as coming from your company page
* `user_email` should be the admin user's email who manages the company page
* `company_title` must exactly match the company name on LinkedIn
* The admin user must have permission to manage the company page

**Use case:** Brand engagement, company thought leadership, B2B marketing

## Error Responses

| Status Code | Error Message                                            | Description                                                |
| ----------- | -------------------------------------------------------- | ---------------------------------------------------------- |
| 400         | Missing required parameter: post\_id                     | `post_id` is required                                      |
| 400         | Missing required parameter: user\_email                  | `user_email` is required                                   |
| 400         | Missing required parameter: comment\_text                | `comment_text` is required                                 |
| 400         | comment\_text cannot be empty                            | Comment text is whitespace-only                            |
| 400         | Invalid actor\_type                                      | Must be 'user' or 'company'                                |
| 400         | company\_title is required when actor\_type is 'company' | Missing company title                                      |
| 400         | Post does not support comment functionality              | Post is missing required data                              |
| 401         | Unauthorized                                             | Invalid or missing API key                                 |
| 403         | Access denied                                            | Post doesn't belong to your team's watchlists              |
| 404         | Post not found                                           | Invalid post ID                                            |
| 404         | User not found                                           | Invalid user email                                         |
| 404         | Company not found                                        | Company title doesn't match any company for the admin user |
| 402         | Plan limit reached                                       | You've exceeded your plan's comment limit                  |

## Best Practices

<AccordionGroup>
  <Accordion title="Write Meaningful Comments" icon="pen">
    * Add value to the conversation
    * Share relevant experiences or insights
    * Ask thoughtful questions
    * Avoid generic responses
    * Be authentic and genuine
    * Keep comments concise but substantive
  </Accordion>

  <Accordion title="Respect Rate Limits" icon="gauge">
    * Don't comment on too many posts at once
    * Spread comments throughout the day
    * Monitor your plan limits
    * Implement delays between API calls
    * Quality over quantity
  </Accordion>

  <Accordion title="Personalize When Possible" icon="user-check">
    * Reference specific points from the post
    * Tailor comments to the context
    * Use the author's name when appropriate
    * Avoid copy-paste comments
    * Make each comment unique
  </Accordion>
</AccordionGroup>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Can I comment from a company page?">
    Yes. Set `actor_type` to `"company"` and provide the `company_title` field with the exact company name as it appears on LinkedIn. The `user_email` should be the email of an admin user who has permission to manage that company page.
  </Accordion>

  <Accordion title="Is there a character limit for comments?">
    The OutX API does not impose its own character limit on comments. However, LinkedIn's standard comment length limits apply. LinkedIn currently allows up to approximately 1,250 characters per comment. Keep your comments within this limit to ensure they are posted successfully.
  </Accordion>
</AccordionGroup>
