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
       }
     }'
Java
BoxFile file = new BoxFile(api, "id");
file.addComment("This file is pretty cool.");
Python
comment = client.file(file_id='11111').add_comment('When should I have this done by?')

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.

cURL
curl -i -X POST "https://api.box.com/2.0/comments" \
     -H "Authorization: Bearer <ACCESS_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{
       "tagged_message": "What do you think @[1234:John]?",
       "item": {
         "type": "file",
         "id": 123
       }
     }
Java
BoxFile file = new BoxFile(api, "id");
file.addComment("Message mentioning @[1234:user@box.com].");
Python
comment = client.file(file_id='11111').add_comment('Hey @[44444:boss], when should I have this done by?')