> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developers.awork.com/apiv1/task-comments/post-comments-by-task-name-and-task-id/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.awork.com/_mcp/server. # Creates a new comment on the task with the specified id. POST https://api.awork.com/api/v1/tasks/{taskId}/comments Content-Type: application/json Creates a new comment on the task with the specified id. A user can only create a comment for him/herself, except for admins and api users.To create a comment the user must have at least `read` permissions on the specified task. Reference: https://developers.awork.com/apiv1/task-comments/post-comments-by-task-name-and-task-id ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `taskId` (string, required) — The id of the task to create the comment for. ### Body (application/json) This endpoint expects a CommentForm. - `message` (string, required) — The message of the comment. - `userId` (string, optional, nullable) — The id of the user who created the comment. Optional. If not set, defaults to the current user. - `previews` (list of string, optional, nullable) — The preview URLs to show a preview for. - `isHiddenForConnectUsers` (boolean, optional, nullable) — (optional) Whether the comment is hidden for connect users. Providing a null value will not change the current state. By default, comments are not hidden for connect users. - `isResolved` (boolean, optional, nullable) — Whether the comment has been resolved. Only available for comments on documents. - `inReplyToCommentId` (string, optional, nullable) — The parent comment this comment is a reply to. ## Response ### 200 OK - `id` (string, optional) — The id of the comment. - `entityId` (string, optional) — The id of the entity of the comment. Required. - `entityType` (string, optional, nullable) — The type of the entity of the comment. Can be "projects", "tasks". Required. - `entity` (IDefaultNameModel, optional) - `project` (IDefaultNameModel, optional) - `task` (IDefaultNameModel, optional) - `document` (IDefaultNameModel, optional) - `createdOn` (string, optional) — The date this object was created. - `createdBy` (string, optional) — The id of the user who created this object. - `user` (ConnectedUserModel, optional) - `agentId` (string, optional, nullable) — The agent that visibly authored this comment, when it was created by an agent run. - `agentNameSnapshot` (string, optional, nullable) — The agent name captured when the comment was created. - `updatedOn` (string, optional) — The date this object was last modified. - `updatedBy` (string, optional) — The id of the user who last modified this object. - `mentions` (Mentions, optional) — A mention is the tag of a user on a specific comment, so the user is notified. - `reactions` (list of Reaction, optional, nullable) — The reactions on a comment. - `formattedMessage` (string, optional, nullable) — The formatted and proccessed version of the comment message. E.g. mentions are in a human readable format. The formatted comment message is styled with html. - `plainFormattedMessage` (string, optional, nullable) — The formatted and proccessed version of the comment message. E.g. mentions are in a human readable format. The formatted comment message is not styled. - `resourceVersion` (long, optional) — The version of the entity, updated on every modification, to the ticks in UTC. Not identical to UpdatedOn. - `message` (string, optional, nullable) — The message of the comment. - `userId` (string, optional, nullable) — The id of the user who created the comment. Optional. If not set, defaults to the current user. - `previews` (list of string, optional, nullable) — The preview URLs to show a preview for. - `isHiddenForConnectUsers` (boolean, optional) — True if the comment should be hidden to connect users. - `isResolved` (boolean, optional, nullable) — Whether the comment has been resolved. Only available for comments on documents. - `inReplyToCommentId` (string, optional, nullable) — The parent comment this comment is a reply to. ## Errors ### 400 Bad Request Error Bad Request - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ### 401 Unauthorized Error Unauthorized - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ### 404 Not Found Error Not Found - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ## Types ### IDefaultNameModel - `id` (string, optional) — The id of the entity. - `name` (string, optional, nullable) — The name of the entity. ### ConnectedUserModel - `id` (string, optional) — The identifier of the nested model. - `firstName` (string, optional, nullable) — The first name of the user. - `lastName` (string, optional, nullable) — The last name of the user. - `hasImage` (boolean, optional, nullable) — Whether this user has a profile image. - `isExternal` (boolean, optional) — True if the model is coming from an external workspace (awork Connect). False otherwise. ### Mentions A mention is the tag of a user on a specific comment, so the user is notified. - `isMentioningPersonalAgent` (boolean, optional) — Gets or sets whether the comment mentions the awork Agent. - `users` (list of ConnectedUserModel, optional, nullable) — All users which have been mentioned in the comment. - `agentIds` (list of string, optional, nullable) — Stable ids of agents mentioned directly in the comment. - `everyUserHadPermissions` (boolean, optional) — If every user was able to receive the mention notification. If not, one of the users had no permissions to. ### Reaction The users reactions to a comment. - `userId` (string, optional) — All users ids that reacted with the emoji. - `emoji` (string, optional, nullable) — The emoji used as a reaction. ### ValidationErrorResponse The validation error response. - `property` (string, optional, nullable) — The name of the property that failed validation. - `message` (string, optional, nullable) — The reason why this property failed validation. ## Examples **Request** ```json { "message": "Hey team, the customer loved the latest designs!" } ``` **Response** ```json { "id": "123e4567-e89b-12d3-a456-426614174000", "entityId": "123e4567-e89b-12d3-a456-426614174000", "entityType": "tasks", "entity": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string" }, "project": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string" }, "task": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string" }, "document": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string" }, "createdOn": "2024-01-15T09:30:00Z", "createdBy": "123e4567-e89b-12d3-a456-426614174000", "user": { "id": "80a2b26b-9fb3-42b5-b6dc-126c437cad5d", "firstName": "Carla", "lastName": "Creative", "hasImage": true, "isExternal": true }, "agentId": "123e4567-e89b-12d3-a456-426614174000", "agentNameSnapshot": "string", "updatedOn": "2024-01-15T09:30:00Z", "updatedBy": "123e4567-e89b-12d3-a456-426614174000", "mentions": { "isMentioningPersonalAgent": true, "users": [ { "id": "80a2b26b-9fb3-42b5-b6dc-126c437cad5d", "firstName": "Carla", "lastName": "Creative", "hasImage": true, "isExternal": true } ], "agentIds": [ "string" ], "everyUserHadPermissions": true }, "reactions": [ { "userId": "123e4567-e89b-12d3-a456-426614174000", "emoji": "👍" } ], "formattedMessage": "Hey team, the customer loved the latest designs!", "plainFormattedMessage": "Hey team, the customer loved the latest designs!", "resourceVersion": 637825154598057900, "message": "Hey team, the customer loved the latest designs!", "userId": "123e4567-e89b-12d3-a456-426614174000", "previews": [ "https://www.awork.com/en/blog/automatic-project-management/" ], "isHiddenForConnectUsers": true, "isResolved": true, "inReplyToCommentId": "123e4567-e89b-12d3-a456-426614174000" } ``` **SDK Code** ```python import requests url = "https://api.awork.com/api/v1/tasks/taskId/comments" payload = { "message": "Hey team, the customer loved the latest designs!" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.awork.com/api/v1/tasks/taskId/comments'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"message":"Hey team, the customer loved the latest designs!"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.awork.com/api/v1/tasks/taskId/comments" payload := strings.NewReader("{\n \"message\": \"Hey team, the customer loved the latest designs!\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.awork.com/api/v1/tasks/taskId/comments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"message\": \"Hey team, the customer loved the latest designs!\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.awork.com/api/v1/tasks/taskId/comments") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"message\": \"Hey team, the customer loved the latest designs!\"\n}") .asString(); ``` ```php request('POST', 'https://api.awork.com/api/v1/tasks/taskId/comments', [ 'body' => '{ "message": "Hey team, the customer loved the latest designs!" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.awork.com/api/v1/tasks/taskId/comments"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"message\": \"Hey team, the customer loved the latest designs!\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["message": "Hey team, the customer loved the latest designs!"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.awork.com/api/v1/tasks/taskId/comments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```