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

# Create Comment

> Create a comment on a TikTok post

## Endpoint

```
POST https://api.ugc.inc/comment/create
```

## Overview

Create a comment on a TikTok video using one of your accounts. Use the returned `commentId` to check the status of the comment.

## Request Body

<ParamField body="accountId" type="string" required>
  Account ID to use for commenting The account must: - Be in `setup` status -
  Belong to your organization
</ParamField>

<ParamField body="postUrl" type="string" required>
  Full URL to the TikTok post to comment on **Format:**
  `https://www.tiktok.com/@username/video/{video_id}` **Example:**
  `https://www.tiktok.com/@creator/video/7234567890123456789`
</ParamField>

<ParamField body="commentText" type="string" required>
  The text content of the comment - Can include emojis - Maximum length: 150
  characters (TikTok limit) - Cannot be empty
</ParamField>

## Response

<ResponseField name="data" type="object">
  Comment creation response

  <Expandable title="Response properties">
    <ResponseField name="commentId" type="string">
      Unique comment identifier - use this to check the comment status
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.ugc.inc/comment/create \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "accountId": "acc_123456",
      "postUrl": "https://www.tiktok.com/@creator/video/7234567890123456789",
      "commentText": "Great video! 🔥"
    }'
  ```

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

  response = requests.post(
      'https://api.ugc.inc/comment/create',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'accountId': 'acc_123456',
          'postUrl': 'https://www.tiktok.com/@creator/video/7234567890123456789',
          'commentText': 'Great video! 🔥'
      }
  )

  data = response.json()

  if data['ok']:
      print('Comment created:', data['data']['commentId'])
      # Use this commentId to check status later
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.ugc.inc/comment/create", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      accountId: "acc_123456",
      postUrl: "https://www.tiktok.com/@creator/video/7234567890123456789",
      commentText: "Great video! 🔥",
    }),
  });

  const data = await response.json();

  if (data.ok) {
    console.log("Comment created:", data.data.commentId);
    // Use this commentId to check status later
  }
  ```

  ```typescript React theme={null}
  import { UGCClient } from "ugcinc";

  const client = new UGCClient({
    apiKey: "YOUR_API_KEY",
  });

  const response = await client.comments.createComment({
    accountId: "acc_123456",
    postUrl: "https://www.tiktok.com/@creator/video/7234567890123456789",
    commentText: "Great video! 🔥",
  });

  if (response.ok) {
    console.log(`Comment created: ${response.data.commentId}`);

    // Poll for status
    const checkStatus = async (commentId: string) => {
      const statusResponse = await client.comments.getComments({
        commentIds: [commentId],
      });

      if (statusResponse.ok && statusResponse.data.length > 0) {
        const comment = statusResponse.data[0];
        if (comment.status === "completed") {
          console.log("Comment posted!", comment.commentUrl);
        } else if (comment.status === "failed") {
          console.log("Comment failed:", comment.error);
        } else {
          // Still processing - check again later
          setTimeout(() => checkStatus(commentId), 5000);
        }
      }
    };

    checkStatus(response.data.commentId);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "ok": true,
    "code": 200,
    "message": "Success",
    "data": {
      "commentId": "550e8400-e29b-41d4-a716-446655440000"
    }
  }
  ```

  ```json Error Response (Account Not Found) theme={null}
  {
    "ok": false,
    "code": 404,
    "message": "Account not found"
  }
  ```

  ```json Error Response (Account Not Configured) theme={null}
  {
    "ok": false,
    "code": 400,
    "message": "Account is not fully configured"
  }
  ```

  ```json Error Response (Permission Denied) theme={null}
  {
    "ok": false,
    "code": 403,
    "message": "Account does not belong to this organization"
  }
  ```
</ResponseExample>
