Work with Issue Tags
This page shows sample requests that let you work with tags in YouTrack.
Summary
Use the tag endpoints to read tags, create and update tags, and delete tags from YouTrack.
Permissions
Operations with tags are covered by the following permissions: Create Tag or Saved Search, Delete Tag or Saved Search, Edit Tag or Saved Search, Share Tag, Saved Search, or Agile Board.
In addition to these permissions that are required to perform the corresponding operation, you need to pay attention to the visibleFor and updateableBy attributes of a tag. By default, a tag is created with these parameters set to its owner. To share a tag, the user not only must have Share Tag, Saved Search, or Agile Board permission, but also should set these attributes correctly.
Step-by-Step
The following sections show how to read, create, update, and delete issue tags with the YouTrack REST API.
GET Requests for Tags
Use GET requests to read tags, inspect tag details, and find issues or users associated with tags.
Get a List of Tags
Get all tags that are visible to the current user, including tags they created and tags that are shared with them.
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
Get a Specific Tag
Use the tag ID to request details for a specific tag.
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
Read a List of Issues with a Specific Tag
To get all issues that have a specific tag, use:
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
Read Existing Tags Through Other Resources
You can also read tag data from issue and user resources.
Read Tags of a Specific Issue
To get the list of tags that are attached to a specific issue, use one of these requests:
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
Read Tags That Belong to a User
To get the list of tags that belong to a user, use:
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
POST Requests for Tags
Use POST requests to create tags, update tag attributes, and add tags when creating issues.
Create a New Tag
To create a new tag, use the POST request to the /api/tags endpoint. To create a tag, you must provide at least the name attribute.
Sample Request
The following request shows the API call for this operation.
Sample Response
If the request is successful, the response contains data similar to the following sample.
The tag owner is the user whose permanent token is used to send the request.
By default,
visibleForandupdateableByare set tonull, which means that only the tag's owner can see and update it.
Update a Specific Tag
To update a specific tag, for example to share it or attach it to several issues, use:
Sample Request
The following request shows the API call for this operation.
Use the following URIs to choose users and groups to share the tag with:
GET /youtrack/api/groups?fields=id,nameGET /youtrack/api/users?fields=id,nameGET /youtrack/api/issues?fields=id,summary&query=project:+RAP
Sample Response
If the request is successful, the response contains data similar to the following sample.
Create a New Issue and Tag It
To create a new issue and mark it with an existing tag, send a POST request to the /api/issues endpoint, and provide at least the following attributes in the request payload:
project: id or name of the project where you want to create the issue.summary: issue summary.tags: one or more tags to add to the issue.
Sample Request
The following request shows the API call for this operation.
To get the project ID, see Get a Project ID.
To get the tag ID, use a GET tags request with the query parameter:
GET /youtrack/api/tags?fields=id&query={tag name}
Sample Response
If the request is successful, the response contains data similar to the following sample.
DELETE Requests for Tags
Use DELETE requests to remove tags from YouTrack.
To delete a tag:
Send a DELETE request to the specific tag endpoint:
/api/tags/{tagID}curl -X DELETE 'https://example.youtrack.cloud/api/tags/6-14' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <YouTrack_token>'To check that the tag was deleted from the system, send a GET request to the same URI of the deleted tag:
curl -X GET 'https://example.youtrack.cloud/api/tags/6-14' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <YouTrack_token>'
In response, the server returns the following error in the response body: