- [Resource: SavedQuery](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#SavedQuery)
  - [JSON representation](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#SavedQuery.SCHEMA_REPRESENTATION)
  - [Visibility](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#SavedQuery.Visibility)
- [Methods](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#METHODS_SUMMARY)

## Resource: SavedQuery

Describes a query that has been saved by a user.

| JSON representation |
|---|
| ``` { "name": string, "displayName": string, "description": string, "createTime": string, "updateTime": string, "visibility": enum (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#SavedQuery.Visibility`), // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "loggingQuery": { object (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LoggingQuery`) }, "opsAnalyticsQuery": { object (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/OpsAnalyticsQuery`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. Resource name of the saved query. In the format: "projects/[PROJECT_ID]/locations/[LOCATION_ID]/savedQueries/[QUERY_ID]" For a list of supported locations, see [Supported Regions](https://docs.cloud.google.com/logging/docs/region-support#bucket-regions) After the saved query is created, the location cannot be changed. If the user doesn't provide a \[QUERY_ID\], the system will generate an alphanumeric ID. |
| `displayName` | `string` Required. The user specified title for the SavedQuery. |
| `description` | `string` Optional. A human readable description of the saved query. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp when the saved query was created. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `updateTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp when the saved query was last updated. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `visibility` | ``enum (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries#SavedQuery.Visibility`)`` Required. The visibility status of this query, which determines its ownership. |
| The query that is saved. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `loggingQuery` | ``object (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LoggingQuery`)`` Logging query that can be executed in Logs Explorer or via Logging API. |
| `opsAnalyticsQuery` | ``object (`https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/OpsAnalyticsQuery`)`` Analytics query that can be executed in Log Analytics. |
| End of mutually exclusive fields. ||

### Visibility

Saved query visibility.

| Enums ||
|---|---|
| `VISIBILITY_UNSPECIFIED` | The saved query visibility is unspecified. A `savedQueries.create` request with an unspecified visibility will be rejected. |
| `PRIVATE` | The saved query is only visible to the user that created it. |
| `SHARED` | The saved query is visible to anyone in the project. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries/create` | Creates a new SavedQuery for the user making the request. |
| ### `https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries/delete` | Deletes an existing SavedQuery that was created by the user making the request. |
| ### `https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries/get` | Returns all data associated with the requested query. |
| ### `https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries/list` | Lists the SavedQueries that were created by the user making the request. |
| ### `https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.savedQueries/patch` | Updates an existing SavedQuery. |