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

# Create Comment

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

To create a comment, call the <Link href="/reference/post-comments">`POST /comments`</Link> API with the
message of the comment, as well as the ID of the file to leave the comment on.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/comments" \
       -H "authorization: Bearer <ACCESS_TOKEN>" \
       -H "content-type: application/json" \
       -d '{
         "message": "Review completed!",
         "item": {
           "type": "file",
           "id": 426436
         }
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.comments.createComment({
    message: message,
    item: {
      id: fileId,
      type: 'file' as CreateCommentRequestBodyItemTypeField,
    } satisfies CreateCommentRequestBodyItemField,
  } satisfies CreateCommentRequestBody);
  ```

  ```python Python v10 theme={null}
  client.comments.create_comment(
      message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
  )
  ```

  ```cs .NET v10 theme={null}
  await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));
  ```

  ```swift Swift v10 theme={null}
  try await client.comments.createComment(requestBody: CreateCommentRequestBody(message: message, item: CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.file)))
  ```

  ```java Java v10 theme={null}
  client.getComments().createComment(new CreateCommentRequestBody(message, new CreateCommentRequestBodyItemField(fileId, CreateCommentRequestBodyItemTypeField.FILE)))
  ```

  ```java Java v5 theme={null}
  BoxFile file = new BoxFile(api, "id");
  file.addComment("This file is pretty cool.");
  ```

  ```python Python v4 theme={null}
  comment = client.file(file_id='11111').add_comment('When should I have this done by?')
  ```

  ```cs .NET v6 theme={null}
  var requestParams = new BoxCommentRequest()
  {
      Item = new BoxRequestEntity()
      {
          Type = BoxType.File,
          Id = "12345"
      },
      Message = "Great work!"
  };
  BoxComment comment = await client.CommentsManager.AddCommentAsync(requestParams);
  ```

  ```javascript Node v4 theme={null}
  client.comments.create('33333', 'Is this the latest version?')
      .then(comment => {
          /* comment -> {
              type: 'comment',
              id: '11111',
              is_reply_comment: false,
              message: 'Is this the latest version?',
              created_by: 
              { type: 'user',
                  id: '22222',
                  name: 'Example User',
                  login: 'user@example.com' },
              created_at: '2012-12-12T11:25:01-08:00',
              item: { id: '33333', type: 'file' },
              modified_at: '2012-12-12T11:25:01-08:00' }
          */
      });
  ```
</CodeGroup>

A comment's message can also mentions users using the `@` sign. To do so, add
the string `@[userid:name]` anywhere within the message. The `user_id` is the
target user's ID, where the `name` can be any custom phrase. In the Box UI this
name will link to the user's profile.

Then, pass this string as the `tagged_message` instead of the `message`.

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("Create comment"), href: "/reference/post-comments", badge: "POST" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("Create Reply"), href: "/guides/comments/create-reply", badge: "GUIDE" }
]}
/>
