Add Thread Comment

Adds a comment to a Thread of a Space.

MethodPOST
URLhttps://{subdomain}.kintone.com/k/v1/space/thread/comment.json
URL(guest space)https://{subdomain}.kintone.com/k/guest/{SpaceID}/v1/space/thread/comment.json
Authentication Password Authentication , Session Authentication
Content-Typeapplication/json

Contents

Permissions

  • The user must have access to the Space.

Request Parameters

Parameter Value Required Description
space Integer or String Yes The Space ID.
thread Integer or String Yes The Thread ID.
comment Object Yes An object including comment details.
comment.text String Conditional The comment contents.
A line break can be specified by LF.
The maximum characters of the comment is 65535. Required, if comment.files is not set.
comment.files Array Conditional An array including data of attachment files.
The maximum number of the files is 5.
Required, if comment.text is not set.
comment.files[].fileKey String Optional The fileKey of the attachment file.
fileKeys can be found from the response of the Upload File API. For more information, refer to the following article:
Upload File
comment.files[].width Integer or String Optional A width can be specified if the attachment file is an image.
The minimum is 100, and the maximum is 750.
If this parameter is ignored, the original width will be set (this width is the same size as the size when "Original" is chosen when adding an image to a thread via GUI). This parameter is ignored if the file is not an image.
comment.mentions Array Optional An array including mentions, that notify other Kintone users.
comment.mentions[].code String Optional The code of the user, group or department that will be mentioned.
The maximum number of mentions is 10.
The mentioned users will be placed in front of the comment text in the output.
comment.mentions[].type String Optional The entity type of the mentioned target.
  • USER: User
  • GROUP: Group
  • ORGANIZATION: Department

Sample Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var body = {
  'space': 1001,
  'thread': 1001,
  'comment': {
    'text': 'This is the Golden Gate Bridge in San Francisco. \nIsn\'t it gorgeous?',
    'mentions': [
      {
        'code': 'john',
        'type': 'USER'
      },
      {
        'code': 'HR_EBbG2z',
        'type': 'ORGANIZATION'
      },
      {
        'code': 'Travel Club_9mhZNJ',
        'type': 'GROUP'
      }
    ],
    'files': [
      {
        'fileKey': 'a8c5360e-e919-4ac6-a300-b24fbc9ee1ec',
        'width': 400
      }
    ]
  }
};

kintone.api(kintone.api.url('/k/v1/space/thread/comment.json', true), 'POST', body, function(resp) {
  // success
  console.log(resp);
}, function(error) {
  // error
  console.log(error);
});

XMLHttpRequest

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var body = {
  'space': 1001,
  'thread': 1001,
  'comment': {
    'text': 'This is the Golden Gate Bridge in San Francisco. \nIsn\'t it gorgeous?',
    'mentions': [
      {
        'code': 'john',
        'type': 'USER'
      },
      {
        'code': 'HR_EBbG2z',
        'type': 'ORGANIZATION'
      },
      {
        'code': 'Travel Club_9mhZNJ',
        'type': 'GROUP'
      }
    ],
    'files': [
      {
        'fileKey': 'a8c5360e-e919-4ac6-a300-b24fbc9ee1ec',
        'width': 400
      }
    ]
  },
  // CSRF TOKEN: used for all APIs that have an HTTP method of POST, PUT and DELETE on Kintone.
  '__REQUEST_TOKEN__': kintone.getRequestToken()
};

var url = 'https://{subdomain}.kintone.com/k/v1/space/thread/comment.json';
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
  if (xhr.status === 200) {
    // success
    console.log(JSON.parse(xhr.responseText));
  } else {
    // error
    console.log(JSON.parse(xhr.responseText));
  }
};
xhr.send(JSON.stringify(body));

Response Parameters

Parameter Type Description
id String The comment ID of the created comment.

Sample Response

1
2
3
{
  "id": 78
}

Sample Capture

Limitations

  • If the mentioned name has a localized name setting, and the language of the localized name is the same as the comment poster's language settings, the mentioned name will be posted as the localized name.
  • Inactive/deleted users, departments, and groups cannot be mentioned.
  • Errors will occur if you mention a user who is being invited to the guest space, but has not joined yet.