Updating a trigger using an API request
Use this request to update a trigger.
Request format
Before making a request, get permission to access the API.
To update a trigger, use an HTTP PATCH
request. Request parameters are provided in the request body in JSON format.
PATCH /v2/queues/<queue_key_or_ID>/triggers/<trigger_id>?version=<trigger_current_version>
Host: https://api.tracker.yandex.net
Authorization: OAuth <OAuth_token>
X-Org-ID: <organization ID>
{
"name": "<trigger_name>",
"actions": [<trigger_action_parameters>]
}
Headers
-
Host
Address of the node that provides the API:
https://api.tracker.yandex.net
-
Authorization
OAuth token in
OAuth <OAuth_token>
format, e.g.:OAuth 0c4181a7c2cf4521964a72ff********
-
X-Org-ID or X-Cloud-Org-ID
Organization ID. You can find it out on the Tracker organizations page
.- If a Yandex 360 for Business organization is the only one linked to Tracker, the
X-Org-ID
header is used. - If a Yandex Cloud Organization organization is the only one linked to Tracker, the
X-Cloud-Org-ID
header is used. - If both Yandex 360 for Business and Yandex Cloud Organization organizations are linked to Tracker at the same time, the
X-Org-ID
header and the Yandex 360 for Business organization ID are used.
- If a Yandex 360 for Business organization is the only one linked to Tracker, the
Resource
Parameter | Description | Data type |
---|---|---|
<queue_ID_or_key> | Queue ID or key. The queue key is case-sensitive. | String or number |
<trigger_id> | Trigger ID | Number |
<current_trigger_version> | Current trigger version | Number |
Note
You can find the current trigger version in a response to a GET request to the trigger settings.
Request body parameters
Additional parameters
Parameter | Description | Data type |
---|---|---|
name | Trigger name | String |
actions | Array with trigger action objects | Array of objects |
conditions | Array with trigger conditions | Array of objects |
active | Trigger status. Acceptable values include:
|
Logical |
before | ID of the trigger before which to place this trigger | Number |
Trigger conditions
Depending on whether all or at least one condition is to be met, you can set the conditions field to either an array of elementary trigger condition objects (in this case, the trigger will fire if all the conditions are met) or an array with objects including both the array of elementary trigger condition objects and the type indicating how the conditions should be logically combined:
-
Elementary trigger condition object
-
Object indicating the type for combining trigger conditions:
Parameter Description Data type type Type for logically combining trigger conditions. Acceptable values include: Or
: Logical OR (Any
)And
: Logical AND (All
)
String conditions Array with elementary trigger condition objects Array of objects
Note
Trigger conditions (elementary and association type objects) can be grouped using an association type object.
The default combination type is logical AND ("type": "And"
). You do not need to specify this type.
When using the logical OR combination type ("type": "Or"
), you must specify the combination type.
Examples:
- Updating a trigger that fires if at least one of the conditions is met.
- Updating a trigger that fires if all the conditions are met.
- Updating a trigger that works when condition groups are met.
- Disabling a trigger.
- Moving a trigger in the list and activating it.
Example 1: Updating trigger conditions. The trigger must fire if at least one of the conditions is met.
- The HTTP
PATCH
method is used.- The trigger for the DESIGN queue is being updated.
- The trigger ID is 16 and its current version is 1.
- The trigger condition is updated: the comment text matches the Need info phrase.
- Trigger action: the issue status changes to Need info.
PATCH /v2/queues/DESIGN/triggers/16?version=1 Host: https://api.tracker.yandex.net Authorization: OAuth <OAuth token> X-Org-ID: <organization ID> { "actions": [ { "type": "Transition", "status": { "key": "needInfo" } } ], "conditions": [ { "type": "Or", "conditions": [ { "type": "CommentFullyMatchCondition", "word": "Need info"}, { "type": "CommentFullyMatchCondition", "word": "Need info"} ] } ] }
Example 2: Updating trigger conditions. The trigger must fire if all the conditions are met.
- The HTTP
PATCH
method is used.- The trigger for the DESIGN queue is being updated.
- The trigger ID is 16 and its current version is 2.
- The trigger condition is updated: the comment text matches the Need info phrase and the issue status is
In progress
.
PATCH /v2/queues/DESIGN/triggers/16?version=2 Host: https://api.tracker.yandex.net Authorization: OAuth <OAuth-token> X-Org-ID: <organization ID> { "actions": [ { "type": "Transition", "status": { "key": "needInfo" } } ], }
Example 3: Changing trigger conditions and trigger action. Trigger must be activated when one of the condition groups is met.
- The HTTP
PATCH
method is used.- The trigger for the DESIGN queue is being updated.
- The trigger ID is 16 and its current version is 2.
- The trigger condition is updated: Trigger is activated if one of the condition groups is met:
- Comment text matches the Need info phrase and the issue status is
In progress
.
- Comment text matches the No data phrase.
- Trigger action changes: the issue status changes to Need info.
PATCH /v2/queues/DESIGN/triggers/16?version=2 Host: https://api.tracker.yandex.net Authorization: OAuth <OAuth-token> X-Org-ID: <organization ID> { "actions": [ { "type": "Transition", "status": { "key": "needInfo" } } ], "conditions": [ { "conditions": [ { "conditions": [ { "ignoreCase": false, "noMatchBefore": false, "removeMarkup": false, "type": "CommentFullyMatchCondition", "word": "Need info" }, { "type": "FieldEquals", "field":"status", "value":"inProgress" } ], "type": "And" }, { "ignoreCase": false, "noMatchBefore": false, "removeMarkup": false, "type": "CommentFullyMatchCondition", "word": "No data" } ], "type": "Or" } ] }
Example 4: Disabling a trigger.
- The HTTP
PATCH
method is used.- The trigger for the DESIGN queue is being updated.
- The trigger ID is 16 and its current version is 3.
- The trigger is being deactivated.
PATCH /v2/queues/DESIGN/triggers/16?version=3 Host: https://api.tracker.yandex.net Authorization: OAuth <OAuth token> X-Org-ID: <organization ID> { "active": false, }
Example 5: Moving a trigger in the list and activating it.
- The HTTP
PATCH
method is used.- The trigger for the DESIGN queue is being updated.
- The trigger ID is 16 and its current version is 4.
- The trigger is being moved and placed before the trigger with the
6
ID and then activated.
PATCH /v2/queues/DESIGN/triggers/16?version=4 Host: https://api.tracker.yandex.net Authorization: OAuth <OAuth token> X-Org-ID: <organization ID> { "before": 6, "active": true, }
Response format
If the request is successful, the API returns a response with code 200 OK
.
The request body contains information about the created trigger in JSON format.
{
"id": 16,
"self": "https://https://api.tracker.yandex.net/v2/queues/DESIGN/triggers/16",
"queue": {
"self": "https://https://api.tracker.yandex.net/v2/queues/DESIGN",
"id": "26",
"key": "DESIGN",
"display": "Design"
},
"name": "TriggerName",
"order": "0.0002",
"actions": [
{
"type": "Transition",
"id": 2,
"status": {
"self": "https://https://api.tracker.yandex.net/v2/statuses/2",
"id": "2",
"key": "needInfo",
"display": "Need info"
}
}
],
"conditions": [
{
"type": "Or",
"conditions": [
{
"type": "CommentFullyMatchCondition",
"word": "Need info",
"ignoreCase": true,
"removeMarkup": true,
"noMatchBefore": false
},
{
"type": "CommentFullyMatchCondition",
"word": "Need info",
"ignoreCase": true,
"removeMarkup": true,
"noMatchBefore": false
}
]
}
],
"version": 2,
"active": true
}
Response parameters
Parameter | Description | Data type |
---|---|---|
id | Trigger ID | String |
self | Links to trigger | String |
queue | Queue to create the trigger | Object |
name | Trigger name | String |
order | Trigger weight. This parameter affects the order of trigger display in the interface. | String |
actions | Array with trigger actions | Array of objects |
conditions | Array with trigger conditions | Array of objects |
version | Trigger version. Each trigger update increases the version number. | Number |
active | Trigger status | Logical |
Object fields queue
Parameter | Description | Data type |
---|---|---|
self | Address of the API resource with information about the queue. | String |
id | Queue ID. | String |
key | Queue key. | String |
display | Queue name displayed. | String |
If the request is processed incorrectly, the API returns a message with error details:
- 400
- One or more request parameters have an invalid value.
- 403
- Insufficient rights to perform this action. You can check what rights you have in the Tracker interface. The same rights are required to perform an action via the API and interface.
- 404
- The requested object was not found. You may have specified an invalid object ID or key.
- 409
- There was a conflict when editing the object. The error may be due to an invalid update version.
- 412
- There was a conflict when editing the object. The error may be due to an invalid update version.
- 422
- JSON validation error, the request is rejected.
- 500
- Internal service error. Try resending your request in a few minutes.
- 503
- The API service is temporarily unavailable.