YouTrack Standalone 2019.3 Help

Saved Queries

This resource lets you access and work with saved searches in YouTrack.

Resource

/api/savedQueries

Returned entity

SavedQuery. For the description of the entity attributes, see Supported Fields section.

Supported methods

SavedQuery attributes

Represents a saved search.

Extends WatchFolder

This table describes attributes of the SavedQuery entity.

  • To receive an attribute in the response from server, specify it explicitly in the request parameter fields.

  • To update an attribute, provide it in the body of a POST request.

Field

Type

Description

query

String

The query that is saved in this search. Can be null.

issues

Array of Issues

The collection of issues that match this saved search. Read-only.

owner

User

A user who created — hence, owns — the watch folder. Read-only. Can be null.

visibleFor

UserGroup

Group of users that can see this watch folder. If the folder is visible only for its owner, this property is null. Can be null.

updateableBy

UserGroup

Group of users that can update this watch folder. If only the folder's owner can update it, this property is null. Can be null.

name

String

The name of the issue folder. Can be null.

Read a List of SavedQueries

Get all saved searches that are visible to the current user.

Request syntax

GET /api/savedQueries?{fields}&{$top}&{$skip}

Request parameters

Parameter

Type

Description

fields

String

A list of SavedQuery attributes that should be returned in the response. If no field is specified,only the entityID is returned

$skip

Int

Optional. Lets you set a number of returned entities to skip before returning the first one.

$top

Int

Optional. Lets you specify the maximum number of entries that are returned in the response.

Sample

Sample request URI

https://example.myjetbrains.com/youtrack/api/savedQueries?fields=id,name,query,owner(login,name),visibleFor(name,id),issues(idReadable,summary)&$skip=8&$top=3

Sample response body

[ { "issues": [ { "summary": "Example for Get specific issue tag", "idReadable": "RAP-2", "$type": "Issue" }, { "summary": "REST API lets you create issues!", "idReadable": "SP-46", "$type": "Issue" }, { "summary": "Issue from REST #1", "idReadable": "SP-16", "$type": "Issue" }, { "summary": "Issue from REST #1", "idReadable": "SP-7", "$type": "Issue" }, { "summary": "New summary", "idReadable": "SP-38", "$type": "Issue" } ], "query": "for: me", "visibleFor": { "name": "All Users", "id": "3-0", "$type": "UserGroup" }, "owner": { "login": "search_user_1918800649", "name": "system user", "$type": "User" }, "name": "Assigned to me", "id": "51-15", "$type": "SavedQuery" }, { "issues": [ { "summary": "REST API lets you create issues!", "idReadable": "SP-34", "$type": "Issue" }, { "summary": "Issue from REST #1", "idReadable": "SP-16", "$type": "Issue" }, { "summary": "Issue from REST #1", "idReadable": "SP-7", "$type": "Issue" }, { "summary": "Another issue created using REST API", "idReadable": "SP-32", "$type": "Issue" } ], "query": "commenter: me", "visibleFor": { "name": "All Users", "id": "3-0", "$type": "UserGroup" }, "owner": { "login": "search_user_1918800649", "name": "system user", "$type": "User" }, "name": "Commented by me", "id": "51-16", "$type": "SavedQuery" }, { "issues": [], "query": "project: {Scrum project from REST} has: -{Board Scrum project from REST Project Development} #Unresolved -Epic", "visibleFor": null, "owner": { "login": "john.doe", "name": "John Doe", "$type": "User" }, "name": "Scrum project from REST Scrum-Board-Backlog", "id": "51-17", "$type": "SavedQuery" } ]

Add a New SavedQuery

Create a new saved search.

Required attributes: name, query

Required permissions

Requires Create Watch Folder permission.

Request syntax

POST /api/savedQueries?{fields}

Request parameters

Parameter

Type

Description

fields

String

A list of SavedQuery attributes that should be returned in the response. If no field is specified,only the entityID is returned

Sample

Sample request URI

https://example.myjetbrains.com/youtrack/api/savedQueries?fields=id,name,query,owner(login,name),visibleFor(name,id),issues(id,idReadable,summary)

Sample request body

{ "query": "Priority: Major, Critical, Show-stopper #Unresolved", "name": "Requires Attention" }

Sample response body

{ "query": "Priority: Major, Critical, Show-stopper #Unresolved", "issues": [ { "idReadable": "SP-47", "summary": "REST API lets you create issues!", "$type": "Issue" }, { "idReadable": "SP-46", "summary": "REST API lets you create issues!", "$type": "Issue" }, { "idReadable": "SP-45", "summary": "REST API lets you create issues!", "$type": "Issue" }, { "idReadable": "SP-44", "summary": "REST API lets you create issues!", "$type": "Issue" }, { "idReadable": "SP-39", "summary": "Huston!", "$type": "Issue" }, { "idReadable": "SP-38", "summary": "New summary", "$type": "Issue" } ], "visibleFor": null, "owner": { "login": "john.doe", "name": "John Doe", "$type": "User" }, "name": "Requires Attention", "id": "51-34", "$type": "SavedQuery" }
Last modified: 16 March 2020