Box Developer Documentation

Join BoxWorks 2024 to discover what's possible with content and AI!

Register now!

List file comments

get
https://api.box.com/2.0
/files/:file_id/comments

Retrieves a list of comments for a file.

Request

bearer [ACCESS_TOKEN]
application/json

Path Parameters

stringin pathrequired
12345

The unique identifier that represents a file.

The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL https://*.app.box.com/files/123 the file_id is 123.

Query Parameters

string arrayin queryoptional
id,type,name

A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.

Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested.

integer (int64)in queryoptional
10001000

The maximum number of items to return per page.

integer (int64)in queryoptional
10000

The offset of the item at which to begin the response.

Queries with offset parameter value exceeding 10000 will be rejected with a 400 response.

Response

application/jsonComments

Returns a collection of comment objects. If there are no comments on this file an empty collection will be returned.

application/jsonClient error

An unexpected client error.

get
List file comments
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -i -X GET "https://api.box.com/2.0/files/12345/comments" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.comments.getFileComments(fileId);
Python Gen
client.comments.get_file_comments(file_id)
.NET Gen
await client.Comments.GetFileCommentsAsync(fileId: fileId);
Swift Gen (Beta)
try await client.comments.getFileComments(fileId: fileId)
Java
BoxFile file = new BoxFile(api, "id");
List<BoxComment.Info> comments = file.getComments();
Python
comments = client.file(file_id='11111').get_comments()
for comment in comments:
    print(f'Comment was left by {comment.created_by.name} at {comment.created_at}')
Node
var fileID = '12345';
client.files.getComments(fileID)
    .then(comments => {
        /* comments -> {
            total_count: 1,
            entries: 
            [ { type: 'comment',
                id: '11111',
                is_reply_comment: false,
                message: 'Great work!',
                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' } ] }
        */
    });
iOS
let iterator = client.files.listComments(forFile: "11111")
iterator.next { results in
    switch results {
    case let .success(page):
        for comment in page.entries {
            print(comment.message)
        }

    case let .failure(error):
        print(error)
    }
}

Response Example

{
  "entries": [
    {
      "id": "11446498",
      "type": "comment",
      "is_reply_comment": true,
      "message": "@Aaron Levie these tigers are cool!",
      "created_by": {
        "id": "11446498",
        "type": "user",
        "name": "Aaron Levie",
        "login": "ceo@example.com"
      },
      "created_at": "2012-12-12T10:53:43-08:00",
      "modified_at": "2012-12-12T10:53:43-08:00",
      "item": {
        "id": "11446498",
        "type": "file"
      },
      "tagged_message": "@[1234567:Aaron Levie] these tigers are cool!"
    }
  ],
  "limit": 1000,
  "offset": 2000,
  "order": [
    {
      "by": "type",
      "direction": "ASC"
    }
  ],
  "total_count": 5000
}