Links

Update a Canned Response

Update a canned response.
It requires the save-canned-responses and save-all-canned-responses permission.
URL
Requires Auth
HTTP Method
/api/v1/canned-responses
yes
POST

Headers

Argument
Example
Required
Description
X-User-Id
myuser-name
Required
The authenticated user ID.
X-Auth-Token
myauth-token
Required
Auth token.

Payload

Argument
Example
Required
Description
_id
646ff3c3a8c3a3ba32d0fa95
Required
The canned response's id.
shortcut
card-declined-update
Required
The shortcut to the message snippet.
text
updated reasons for your card malfunction
Required
The message snippet
scope
department
Required
The scope of the canned response. It can either be global, user or department.
tags
["card", "failure"]
Optional
The tags for your canned response.
departmentId
64181a0728384134ed600dcc
Optional; required, only if the scope is department.
The departmentId where the canned response belongs to. It is required if the scope is department.

Example payload

{
"_id": "646ff3c3a8c3a3ba32d0fa95",
"shortcut": "dcard-declined-update",
"text": "updated reasons for your card malfunction",
"scope": "department",
"departmentId": "64181a0728384134ed600dcc"
}

Example Call

curl --location 'http://localhost:3000/api/v1/canned-responses' \
--header 'X-User-Id: 2tTEqR7ZNMJ4HGGNa' \
--header 'X-Auth-Token: A6PF2Qa-wXunBXi3j77OBY-T-gl1BvJ11jYiSMt6Z_G' \
--header 'Content-Type: application/json' \
--data '{
"_id": "646ff3c3a8c3a3ba32d0fa95",
"shortcut": "department-check",
"text": "This is check test for departmental canned response",
"scope": "global",
"departmentId": "64181a0728384134ed600dcc"
}'

Example Result

Success

{
"success": true
}

Error

Any of the following errors can occur on the endpoint.
  • Authorization: Requires an authentication token for the request to be made.
  • No Permission: Occurs when the authenticated user doesn't have the save-canned-responses and save-all-canned-responses permission.
  • Invalid Department: If the scope of the canned response is department, a valid departmentId is required to specify the department it belongs to. This error occurs when there is no valid departmentId in the body of the request.
  • Shortcut Exists: The shortcut value of the canned response must be unique. This error occurs when the shortcut already exists.
Authorization
No Permission
Invalid Department
Shortcut Exists
{
"status": "error",
"message": "You must be logged in to do this."
}
{
"success": false,
"error": "User does not have the permissions required for this action [error-unauthorized]"
}
{
"success": false,
"error": "Invalid department [error-invalid-department]",
"errorType": "error-invalid-department",
"details": {
"method": "saveCannedResponse"
}
}
{
"success": false,
"error": "Shortcut provided already exists [error-invalid-shortcut]",
"errorType": "error-invalid-shortcut",
"details": {
"method": "saveCannedResponse"
}
}

Change Log

Version
Description
1.0.0
Added
Last modified 2mo ago
Deprecation for cloud services and apps is now extended to November 20, 2023. Rocket.Chat versions receive support for six months after release.