Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
105 lines (84 loc) · 4.06 KB

File metadata and controls

105 lines (84 loc) · 4.06 KB

Update a Canned Response

Update a canned response.

HTTP MethodURLRequires Auth
POST/api/v1/canned-responsesyes

{% hint style="info" %} Permissions required:

  • save-canned-responses
  • save-all-canned-responses {% endhint %}

Body Parameters

KeyExample ValueDescription
_id*646ff3c3a8c3a3ba32d0fa95The canned response's ID.
shortcut*card-declinedThe shortcut to trigger the message snippet.
text*reasons for your card malfunctionThe message snippet.
scope*globalThe scope of the canned response. It can either be global, user or department.
tagscardThe tags for your canned response.
departmentId64181a0728384134ed600dccThe departmentId where the canned response belongs to. It is required if the scope is department.

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 Response

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.

{% tabs %} {% tab title="Authorization" %}

{
    "status": "error",
    "message": "You must be logged in to do this."
}

{% endtab %}

{% tab title="No Permission" %}

{
    "success": false,
    "error": "User does not have the permissions required for this action [error-unauthorized]"
}

{% endtab %}

{% tab title="Invalid Department" %}

{
    "success": false,
    "error": "Invalid department [error-invalid-department]",
    "errorType": "error-invalid-department",
    "details": {
        "method": "saveCannedResponse"
    }
}

{% endtab %}

{% tab title="Shortcut Exists" %}

{
    "success": false,
    "error": "Shortcut provided already exists [error-invalid-shortcut]",
    "errorType": "error-invalid-shortcut",
    "details": {
        "method": "saveCannedResponse"
    }
}

{% endtab %} {% endtabs %}

Change Log

Version Description
1.0.0 Added