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.
Summary
To apply a command to issues, send a POST request to the /api/commands endpoint with a request body that contains the command query and the target issues. You can also add optional attributes to add a comment, restrict comment visibility, or suppress notifications.
Step-by-Step
To apply a command to issues:
Choose the command query that you want to apply to the issue or issues. Use the same command syntax that you use in the YouTrack user interface.
Identify the target issue or issues. You can identify issues by their database entity ID, for example
"id":"2-1234", or their human-readable ID, for example"idReadable":"SDP-345".Build the request body. A minimal request body contains the
queryto apply and a collection ofissuesthat identify the target issues.Optional. Add command attributes such as
comment,visibility, orsilentwhen you need to add a comment, restrict comment visibility, or suppress notifications.Send a
POSTrequest to the commands endpoint:/api/commands
Minimal Request to Apply a Command
The following request applies a command with a minimal request body.
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 Restricted Comment Visibility
The following request assigns the specific issue to the current user and adds a new comment with restricted visibility.
The following request adds a tag to three issues and assigns them to user "jane.doe".
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.