# Edit an Organization's Discover Saved Query

##

PUT /api/0/organizations/{organization\_id\_or\_slug}/discover/saved/{query\_id}/

Modify a saved query.

### Path Parameters

* `organization_id_or_slug`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  REQUIRED

  The ID or slug of the organization the resource belongs to.

* `query_id`*&#x20;<!-- -->(<!-- -->integer<!-- -->)*

  REQUIRED

  The ID of the Discover query you'd like to retrieve.

### Body Parameters

* `name`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  REQUIRED

  The user-defined saved query name.

* `projects`*&#x20;<!-- -->(<!-- -->array<!-- -->(integer)<!-- -->)*

  The saved projects filter for this query.

* `queryDataset`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  The dataset you would like to query. Note: `discover` is a **deprecated** value. The allowed values are: `error-events`, `transaction-like`

  * `discover`
  * `error-events`
  * `transaction-like`

* `start`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  The saved start time for this saved query.

* `end`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  The saved end time for this saved query.

* `range`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  The saved time range period for this saved query.

* `fields`*&#x20;<!-- -->(<!-- -->array<!-- -->(string)<!-- -->)*

  The fields, functions, or equations that can be requested for the query. At most 20 fields can be selected per request. Each field can be one of the following types:

  * A built-in key field. See possible fields in the [properties table](/product/sentry-basics/search/searchable-properties/#properties-table), under any field that is an event property.
    <!-- -->
    * example: `field=transaction`

  * A tag. Tags should use the `tag[]` formatting to avoid ambiguity with any fields
    <!-- -->
    * example: `field=tag[isEnterprise]`

  * A function which will be in the format of `function_name(parameters,...)`. See possible functions in the [query builder documentation](/product/discover-queries/query-builder/#stacking-functions).

    <!-- -->

    * when a function is included, Discover will group by any tags or fields
    * example: `field=count_if(transaction.duration,greater,300)`

  * An equation when prefixed with `equation|`. Read more about [equations here](/product/discover-queries/query-builder/query-equations/).
    <!-- -->
    * example: `field=equation|count_if(transaction.duration,greater,300) / count() * 100`

* `orderby`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  How to order the query results. Must be something in the `field` list, excluding equations.

* `environment`*&#x20;<!-- -->(<!-- -->array<!-- -->(string)<!-- -->)*

  The name of environments to filter by.

* `query`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  Filters results by using [query syntax](/product/sentry-basics/search/).

* `yAxis`*&#x20;<!-- -->(<!-- -->array<!-- -->(string)<!-- -->)*

  Aggregate functions to be plotted on the chart.

* `display`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  Visualization type for saved query chart. Allowed values are:

  * default
  * previous
  * top5
  * daily
  * dailytop5
  * bar

* `topEvents`*&#x20;<!-- -->(<!-- -->integer<!-- -->)*

  Number of top events' timeseries to be visualized.

* `interval`*&#x20;<!-- -->(<!-- -->string<!-- -->)*

  Resolution of the time series.

### Scopes

You need to [authenticate via bearer auth token.](/api/auth/)

`<auth_token>` requires one of the following scopes:

* `org:admin`
* `org:read`
* `org:write`

```
curl https://sentry.io/api/0/organizations/{organization_id_or_slug}/discover/saved/{query_id}/ \
 -H 'Authorization: Bearer <auth_token>' \
 -X PUT \
 -H 'Content-Type: application/json' \
 -d '{}'
```

RESPONSESCHEMA

```
Copied
{
  "id": "1",
  "name": "Transactions by Volume",
  "projects": [],
  "version": 2,
  "queryDataset": "transaction-like",
  "datasetSource": "unknown",
  "expired": false,
  "dateCreated": "2024-07-25T19:35:38.422859Z",
  "dateUpdated": "2024-07-25T19:35:38.422874Z",
  "environment": [],
  "query": "transaction:/api/foo",
  "fields": [
    "transaction",
    "project",
    "count()",
    "avg(transaction.duration)",
    "p75()",
    "p95()"
  ],
  "widths": [],
  "range": "24h",
  "orderby": "-count",
  "yAxis": [
    "count()"
  ],
  "createdBy": {
    "id": "1",
    "name": "Admin",
    "username": "admin",
    "email": "admin@sentry.io",
    "avatarUrl": "www.example.com",
    "isActive": true,
    "hasPasswordAuth": true,
    "isManaged": false,
    "dateJoined": "2021-10-25T17:07:33.190596Z",
    "lastLogin": "2024-07-16T15:28:39.261659Z",
    "has2fa": true,
    "lastActive": "2024-07-16T20:45:49.364197Z",
    "isSuperuser": false,
    "isStaff": false,
    "experiments": {},
    "emails": [
      {
        "id": "1",
        "email": "admin@sentry.io",
        "is_verified": true
      }
    ],
    "avatar": {
      "avatarType": "letter_avatar",
      "avatarUuid": null,
      "avatarUrl": "www.example.com"
    }
  }
}
```
