Box Developer Documentation

A beta version of the new Box developer documentation site is launching soon! Updated Developer Guides, modern API Reference, and AI-powered search are on the way to help you build with Box faster. Stay tuned for more updates.

Create Comment

Create Comment

To create a comment, call the POST /comments API with the message of the comment, as well as the ID of the file to leave the comment on.

cURL
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
       }
     }'
Node/TypeScript v10
await client.comments.createComment({
  message: message,
  item: {
    id: fileId,
    type: 'file' as CreateCommentRequestBodyItemTypeField,
  } satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);
Python v10
client.comments.create_comment(
    message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
)
.NET v10
await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));
Swift v10
try await client.comments.createComment(requestBody: CreateCommentRequestBody(message: message, item: CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.file)))
Java v10
client.getComments().createComment(new CreateCommentRequestBody(message, new CreateCommentRequestBodyItemField(fileId, CreateCommentRequestBodyItemTypeField.FILE)))
.NET v6
await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));
Node v4
await client.comments.createComment({
  message: message,
  item: {
    id: fileId,
    type: 'file' as CreateCommentRequestBodyItemTypeField,
  } satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);

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.