# Operations with Specific SavedQuery

This resource lets you access and work with saved searches in YouTrack.
|  Resource  |     ```GENERIC /api/savedQueries/{queryID} ```    |
| --- | --- |
|  Returned entity  |  [SavedQuery](api-entity-SavedQuery.html). For the description of the entity attributes, see [Supported Fields](#SavedQuery-supported-fields) section.  |
|  Supported methods  |      * `GET`: [Read a Specific SavedQuery](#get-SavedQuery-method).    * `POST`: [Update a Specific SavedQuery](#update-SavedQuery-method).    * `DELETE`: [Delete a Specific SavedQuery](#delete-SavedQuery-method).    |

## SavedQuery attributes

Represents a saved search.

### Related Resources

Below you can find the list of resources that let you work with this entity.

* [Saved Queries](resource-api-savedQueries.html)

* [Saved Queries of a User](resource-api-users-userID-savedQueries.html)

Extends [WatchFolder](api-entity-WatchFolder.html)

### Attributes

This table describes attributes of the `SavedQuery` entity.

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

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

|  Field  |  Type  |  Description  |
| --- | --- | --- |
|  id  |  String  |  The ID of the saved search. `Read-only`.  |
|  query  |  String  |  The query that is saved in this search. `Can be null`.  |
|  issues  |  [Array of Issues](api-entity-Issue.html)  |  The collection of issues that match this saved search. `Read-only`.  |
|  visibleFor  |  [UserGroup](api-entity-UserGroup.html)  |    Deprecated. Use the `readSharingSettings` attribute instead.  Group of users that can see this saved search. If the saved search is visible only to its owner, this property is null.   `Can be null`.  |
|  updateableBy  |  [UserGroup](api-entity-UserGroup.html)  |    Deprecated. Use the `updateSharingSettings` attribute instead.  Group of users that can update this saved search. If only the owner of the saved search can update it, this property is null.   `Can be null`.  |
|  readSharingSettings  |  [WatchFolderSharingSettings](api-entity-WatchFolderSharingSettings.html)  |  Users and groups that can see this saved search. If the saved search is visible only to its owner, this property contains an empty array. `Read-only`.  |
|  updateSharingSettings  |  [WatchFolderSharingSettings](api-entity-WatchFolderSharingSettings.html)  |  Users and groups that can update this saved search. If only the owner of the saved search can update it, this property contains an empty array. `Read-only`.  |
|  owner  |  [User](api-entity-User.html)  |  The user who created the watch folder. `Read-only`. `Can be null`.  |
|  name  |  String  |  The name of the issue folder.  |

## Read a Specific SavedQuery

Read settings of the saved search with the specified ID.

### Required permissions

To view a saved search, the user should be either its author or be a part of the user group the saved search is shared with.

### Request syntax

```GENERIC
GET /api/savedQueries/{queryID}?{fields}
```

|  {queryID}  |  Database ID of the saved search.  |
| --- | --- |

### 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

```CURL
https://example.youtrack.cloud/api/savedQueries/51-33?fields=id,name,query,owner(login,name),visibleFor(name,id),issues(id,idReadable,summary)
```

#### Sample response body

```JSON
{
  "query": "Priority: Major #Unresolved",
  "issues": [
    {
      "idReadable": "SP-38",
      "summary": "New summary",
      "id": "2-42",
      "$type": "Issue"
    }
  ],
  "visibleFor": null,
  "owner": {
    "login": "john.doe",
    "name": "John Doe",
    "$type": "User"
  },
  "name": "Unresolved Major",
  "id": "51-33",
  "$type": "SavedQuery"
}
```

## Update a Specific SavedQuery

Update settings of the saved search with the specified ID.

### Required permissions

To update a saved search, the user should be either its author or be a part of the user group that can edit this saved search.

### Request syntax

```GENERIC
POST /api/savedQueries/{queryID}?{fields}
```

|  {queryID}  |  Database ID of the saved search.  |
| --- | --- |

### 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

```CURL
https://example.youtrack.cloud/api/savedQueries/51-33?fields=id,name,query,owner(login,name),visibleFor(name,id),issues(id,idReadable,summary)
```

#### Sample request body

```JSON
{
  "query": "in: SP Priority: Major #Unresolved",
  "visibleFor": {"id":"3-2"},
  "name": "Major Unresolved in SP"
}
```

#### Sample response body

```JSON
{
  "query": "in: SP Priority: Major #Unresolved",
  "issues": [
    {
      "idReadable": "SP-38",
      "summary": "New summary",
      "id": "2-42",
      "$type": "Issue"
    }
  ],
  "visibleFor": {
    "name": "Sample Project Team",
    "id": "3-2",
    "$type": "UserGroup"
  },
  "owner": {
    "login": "john.doe",
    "name": "John Doe",
    "$type": "User"
  },
  "name": "Major Unresolved in SP",
  "id": "51-33",
  "$type": "SavedQuery"
}
```

## Delete a Specific SavedQuery

Delete the saved search with the specified ID.

### Required permissions

To delete a saved search, the user should be either its author or be a part of the user group that can edit this saved search.

### Request syntax

```GENERIC
DELETE /api/savedQueries/{queryID}
```

|  {queryID}  |  Database ID of the saved search.  |
| --- | --- |

### 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

```CURL
https://example.youtrack.cloud/api/savedQueries/51-33
```

