Creating a trigger using an API request

Use this request to create trigger.

POST

https://api.tracker.yandex.net/v3/queues/{queue_ID}/triggers

Query format

Before making a request, get permission to access the API.

To create a trigger, use an HTTP POST request. In the request body, specify the parameters in JSON format.

POST /v3/queues/{queue_ID}/triggers
Host: api.tracker.yandex.net
Authorization: OAuth API_TOKEN
X-Org-ID or X-Cloud-Org-ID: ORGANIZATION_ID

{
    "name": "TRIGGER_NAME",
    "actions": [TRIGGER_ACTION_PARAMETERS],
    "conditions": [TRIGGER_CONDITION_PARAMETERS]
}
Headers
  • Host: address of the node that provides the API.

  • Authorization: Authorization token about these formats:

    • OAuth OAUTH_TOKEN: For authorization using the OAuth 2.0 protocol. Learn more

    • Bearer IAM_TOKEN: For authorization using an IAM token, if a Yandex Identity Hub organization is linked to Tracker. Learn more

  • ID types

    X-Org-ID or X-Cloud-Org-ID: Organization ID.

    • Use the X-Org-ID header if a Tracker organization is linked to Yandex 360 for Business.

    • Use the X-Cloud-Org-ID header if a Tracker organization is linked to Yandex Identity Hub.

    Finding the ID

    To get the organization ID, go to Administration → Organizations and copy the value from the ID field.

Resource
Parameter Description Data type
queue_ID Queue ID or key. The queue key is case-sensitive. String or number
Request body parameters

Required parameters

Parameter Description Data type
name Trigger name String
actions Array with trigger actions For more information, see Trigger action objects. Array of objects

Additional parameters

Parameter Description Data type
conditions Array with trigger conditions. For more information, see Trigger conditions and Trigger condition objects. Array of objects
active Trigger status Acceptable values include:
  • true: Active
  • false: Inactive
Boolean

Trigger conditions

The conditions parameter is an array of objects. Each object describes one condition; its type is specified in the type parameter. For condition types and their parameters, see Trigger condition objects.

  • Top-level conditions are combined with logical AND: the trigger fires when all conditions in the array are met.

  • To change the combination logic, use group objects:

    type value

    When the group condition is met

    Or

    At least one nested condition is met

    And

    All nested conditions are met

    Specify Or and And exactly as shown in the table, starting with a capital letter. Nested conditions of a group are passed in the conditions array. A group can contain both regular conditions and other Or and And groups.

Condition parameters in the response to the Getting trigger parameters request contain service fields and may differ from the parameters passed in a request. For example, for the FieldBecameEqual condition, the field parameter is passed in a request as a string with the field ID, while the response returns it as an object. Do not copy conditions from a response into a request body without checking: build them as described in Trigger condition objects.

For more information about conditions for the pendingReplyFrom field, see Pending reply from field.

Examples

In all examples, the trigger is created for the DESIGN queue. When the condition is met, the trigger changes the issue status to Open.

For all examples, use the POST method and the following headers:

POST /v3/queues/DESIGN/triggers
Host: api.tracker.yandex.net
Authorization: OAuth API_TOKEN
Content-Type: application/json
X-Org-ID or X-Cloud-Org-ID: ORGANIZATION_ID

Matching comment text

The trigger fires if the comment text matches Open.

{
    "name": "TriggerName",
    "actions": [
        {
            "type": "Transition",
            "status": {
                "key": "open"
            }
        }
    ],
    "conditions": [
        {
            "type": "CommentFullyMatchCondition",
            "word": "Open"
        }
    ]
}

Matching one of the phrases

The trigger fires if the comment text matches Need info or Нужна информация.

{
    "name": "TriggerName",
    "actions": [
        {
            "type": "Transition",
            "status": {
                "key": "open"
            }
        }
    ],
    "conditions": [
        {
            "type": "Or",
            "conditions": [
                {
                    "type": "CommentFullyMatchCondition",
                    "word": "Need info"
                },
                {
                    "type": "CommentFullyMatchCondition",
                    "word": "Нужна информация"
                }
            ]
        }
    ]
}

Nested condition groups

The trigger fires if the issue was updated and one of the following is true: the priority is Blocker, or the issue type is Bug and the priority is Critical. The Event.update condition and the Or group at the top level are combined with logical AND. The And group is nested inside Or.

{
    "name": "TriggerName",
    "actions": [
        {
            "type": "Transition",
            "status": {
                "key": "open"
            }
        }
    ],
    "conditions": [
        {
            "type": "Event.update"
        },
        {
            "type": "Or",
            "conditions": [
                {
                    "type": "FieldEquals",
                    "field": "priority",
                    "value": "blocker"
                },
                {
                    "type": "And",
                    "conditions": [
                        {
                            "type": "FieldEquals",
                            "field": "type",
                            "value": "bug"
                        },
                        {
                            "type": "FieldEquals",
                            "field": "priority",
                            "value": "critical"
                        }
                    ]
                }
            ]
        }
    ]
}

Pending reply from became non-empty

The trigger fires if the Pending reply from field (pendingReplyFrom) became non-empty.

{
    "name": "TriggerName",
    "actions": [
        {
            "type": "Transition",
            "status": {
                "key": "open"
            }
        }
    ],
    "conditions": [
        {
            "type": "FieldBecameNotEmpty",
            "field": "pendingReplyFrom"
        }
    ]
}

Pending reply from became equal to a specified set

The trigger fires if the set of users in the Pending reply from field (pendingReplyFrom) became equal to the set containing only user1. For this field, the value parameter is an array of users.

{
    "name": "TriggerName",
    "actions": [
        {
            "type": "Transition",
            "status": {
                "key": "open"
            }
        }
    ],
    "conditions": [
        {
            "type": "FieldBecameEqual",
            "field": "pendingReplyFrom",
            "value": [
                "user1"
            ]
        }
    ]
}

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://api.tracker.yandex.net/v3/queues/DESIGN/triggers/16",
"queue": {
    "self": "https://api.tracker.yandex.net/v3/queues/DESIGN",
    "id": "26",
    "key": "DESIGN",
    "display": "Design"
},
"name": "trigger_name",
"order": "0.0002",
"actions": [
    {
        "type": "Transition",
        "id": 1,
        "status": {
            "self": "https://api.tracker.yandex.net/v3/statuses/2",
            "id": "2",
            "key": "needInfo",
            "display": "Need info"
        }
    }
],
"conditions": [
    {
        "type": "Or",
        "conditions": [
            {
                "type": "Event.comment-create"
            }
        ]
    }
],
"version": 1,
"active": true
}


Response parameters
Parameter Description Data type
id Trigger ID String
self Links to trigger String
queue Queue to create the trigger Can be set as an object, a string (if the queue key is provided), or a number (if the queue ID is provided).
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 Acceptable values include:
  • true: Active
  • false: Inactive
Boolean

queue object fields

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

actions array object fields

Parameter Description Data type
type Action type. Acceptable values include:
  • Transition: Change the issue status.
  • Update: Change a field value.
  • Move: Move issue.
  • Event.comment-create: Add a comment.
  • CreateChecklist: Create a checklist.
  • Webhook: Send an HTTP request.
  • CalculateFormula: Calculate a value.
  • Event.create: Create an issue.
String
id Action ID String
status Issue status String

conditions array object fields

Each object in the conditions array describes one condition. Logical groups are returned with the Or or And type and contain a nested conditions array. For the full list of fields and acceptable type values, see the description of the trigger retrieval response.

status array object fields

Parameter Description Data type
self Address of the API resource with information about the status. String
id Status ID. String
key Status key. String
display Status 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
You are not authorized 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.
422
JSON validation error, the request is rejected.
500
Internal service error. Try again later.
503
The API service is temporarily unavailable.