Create a New Saved Query
Create a new saved query for the given organization.
Path Parameters
organization_id_or_slug
(string)REQUIREDThe ID or slug of the organization the resource belongs to.
Body Parameters
name
(string)REQUIREDThe user-defined saved query name.
projects
(array(integer))The saved projects filter for this query.
queryDataset
(string)The dataset you would like to query. Allowed values are:
- error-events
- transaction-like
discover
error-events
transaction-like
start
(string)The saved start time for this saved query.
end
(string)The saved end time for this saved query.
range
(string)The saved time range period for this saved query.
fields
(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, under any field that is an event property.
- example:
field=transaction
- example:
- A tag. Tags should use the
tag[]
formatting to avoid ambiguity with any fields- example:
field=tag[isEnterprise]
- example:
- A function which will be in the format of
function_name(parameters,...)
. See possible functions in the query builder documentation.- 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.- example:
field=equation|count_if(transaction.duration,greater,300) / count() * 100
- example:
- A built-in key field. See possible fields in the properties table, under any field that is an event property.
orderby
(string)How to order the query results. Must be something in the
field
list, excluding equations.environment
(array(string))The name of environments to filter by.
query
(string)Filters results by using query syntax.
yAxis
(array(string))Aggregate functions to be plotted on the chart.
display
(string)Visualization type for saved query chart. Allowed values are:
- default
- previous
- top5
- daily
- dailytop5
- bar
topEvents
(integer)Number of top events' timeseries to be visualized.
interval
(string)Resolution of the time series.
Scopes
<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/ \ -H 'Authorization: Bearer <auth_token>' \ -H 'Content-Type: application/json' \ -d '{}'
Copied{ "id": "1", "name": "Transactions by Volume", "projects": [], "version": 2, "queryDataset": "discover", "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" } } }