Developer Portal for YouTrack and Hub Help

Apply Commands to Issues

This page shows examples of how to apply a command to one or more issues in YouTrack using its REST API. Just as the commands in UI, its REST API implementation lets you perform operations with one or several issues much faster and easier.

Minimal request to apply command

A minimal request for a command requires you to send in the request body a query to apply and a collection of issues that should be represented by their IDs.

curl -X POST 'https://example.youtrack.cloud/api/commands' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ -H 'Content-Type: application/json' \ -d '{ "query": "Fixed", "issues": [ { "id": "2-17" } ] }'

For the sample minimal request without the fields parameter, the server sends a response with the 200 OK status and an empty body.

Command with a restricted visibility of its comment

The following request assigns the specific issue to the current user and adds a new comment with restricted visibility.

curl -X POST 'https://example.youtrack.cloud/api/commands' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ -H 'Content-Type: application/json' \ -d '{ "query":"for me ", "issues":[{"id":"2-15"}], "silent":false, "comment":"Still cannot reproduce.", "visibility": { "$type":"CommandLimitedVisibility", "permittedGroups":[{"id":"3-2"}] } }'

The following request adds a tag to three issues and assigns them to user "jane.doe".

curl -L -X POST 'https://example.youtrack.cloud/api/commands' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ --data-raw '{ "query":"tag To deploy for jane.doe", "issues":[{"idReadable":"SP-3967"},{"idReadable":"SP-4032"},{"idReadable":"SP-3990"} ] }'

Apply a command silently

Now let's apply a command silently. That is, the following request instructs YouTrack to not send notifications about the change. Such silent commands come handy when you need to update a significant number of issues simultaneously; For example, when you plan the next version release, or a milestone, and need to set or change version field.

To apply a command silently, all you need to do is to specify in the request payload the attribute "silent" set to true. In this sample we identified issues by their database entity id, not "idReadable" as in previous samples.

curl -L -X POST 'https://example.youtrack.cloud/api/commands' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYNk7' \ --data-raw '{ "query":"Fix version 2021.1 ", "issues":[{"id":"2-8456"},{"id":"2-8475"},{"id":"2-8476"},{"id":"2-8477"},{"id":"2-8480"},{"id":"2-8481"},{"id":"2-8482"},{"id":"2-8485"}, {"id":"2-8486"},{"id":"2-8489"},{"id":"2-8490"},{"id":"2-9000"},{"id":"2-9010"},{"id":"2-9011"} ], "silent":true }'
Last modified: 7 November 2024