---
title: "POST /v1/{v1Id}/{v1Id1}:queryAssets"
method: POST
path: "/v1/{v1Id}/{v1Id1}:queryAssets"
tags: ["v1"]
---

# POST /v1/{v1Id}/{v1Id1}:queryAssets

`POST /v1/{v1Id}/{v1Id1}:queryAssets`

## Request

- Base URL: `https://cloudasset.googleapis.com`
- URL: `https://cloudasset.googleapis.com/v1/{v1Id}/{v1Id1}:queryAssets`
- Auth: OAuth 2 and OAuth 2
  - Implicit: `https://accounts.google.com/o/oauth2/auth`
  - Scopes: `https://www.googleapis.com/auth/cloud-platform`
  - Authorization code: `https://accounts.google.com/o/oauth2/auth`
  - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-platform`

Issue a job that queries assets using a SQL statement compatible with [BigQuery SQL](https://cloud.google.com/bigquery/docs/introduction-sql). If the query execution finishes within timeout and there's no pagination, the full query results will be returned in the `QueryAssetsResponse`. Otherwise, full query results can be obtained by issuing extra requests with the `job_reference` from the a previous `QueryAssets` call. Note, the query result has approximately 10 GB limitation enforced by [BigQuery](https://cloud.google.com/bigquery/docs/best-practices-performance-output). Queries return larger results will result in errors.

## Path parameters

- `v1Id` string, required
- `v1Id1` string, required

## Query parameters

- `$.xgafv` '1' | '2'
- `access_token` string
- `alt` 'json' | 'media' | 'proto'
- `callback` string
- `fields` string
- `key` string
- `oauth_token` string
- `prettyPrint` boolean
- `quotaUser` string
- `uploadType` string
- `upload_protocol` string

## Request body

- QueryAssetsRequest: QueryAssets request.
  - `jobReference` string: Optional. Reference to the query job, which is from the `QueryAssetsResponse` of previous `QueryAssets` call.
  - `outputConfig` QueryAssetsOutputConfig: Output configuration query assets.
    - `bigqueryDestination` GoogleCloudAssetV1QueryAssetsOutputConfigBigQueryDestination: BigQuery destination.
      - `dataset` string: Required. The BigQuery dataset where the query results will be saved. It has the format of "projects/{projectId}/datasets/{datasetId}".
      - `table` string: Required. The BigQuery table where the query results will be saved. If this table does not exist, a new table with the given name will be created.
      - `writeDisposition` string: Specifies the action that occurs if the destination table or partition already exists. The following values are supported: * WRITE_TRUNCATE: If the table or partition already exists, BigQuery overwrites the entire table or all the partitions data. * WRITE_APPEND: If the table or partition already exists, BigQuery appends the data to the table or the latest partition. * WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY.
  - `pageSize` integer: Optional. The maximum number of rows to return in the results. Responses are limited to 10 MB and 1000 rows. By default, the maximum row count is 1000. When the byte or row count limit is reached, the rest of the query results will be paginated. The field will be ignored when [output_config] is specified.
  - `pageToken` string: Optional. A page token received from previous `QueryAssets`. The field will be ignored when [output_config] is specified.
  - `readTime` string, google-datetime: Optional. Queries cloud assets as they appeared at the specified point in time.
  - `readTimeWindow` TimeWindow: A time window specified by its `start_time` and `end_time`.
    - `endTime` string, google-datetime: End time of the time window (inclusive). If not specified, the current timestamp is used instead.
    - `startTime` string, google-datetime: Start time of the time window (exclusive).
  - `statement` string: Optional. A SQL statement that's compatible with [BigQuery SQL](https://cloud.google.com/bigquery/docs/introduction-sql).
  - `timeout` string, google-duration: Optional. Specifies the maximum amount of time that the client is willing to wait for the query to complete. By default, this limit is 5 min for the first query, and 1 minute for the following queries. If the query is complete, the `done` field in the `QueryAssetsResponse` is true, otherwise false. Like BigQuery [jobs.query API](https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query#queryrequest) The call is not guaranteed to wait for the specified timeout; it typically returns after around 200 seconds (200,000 milliseconds), even if the query is not complete. The field will be ignored when [output_config] is specified.

## Response `200`

Successful response

- QueryAssetsResponse: QueryAssets response.
  - `done` boolean: The query response, which can be either an `error` or a valid `response`. If `done` == `false` and the query result is being saved in an output, the output_config field will be set. If `done` == `true`, exactly one of `error`, `query_result` or `output_config` will be set. [done] is unset unless the [QueryAssetsResponse] contains a [QueryAssetsResponse.job_reference].
  - `error` Status: The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
    - `code` integer: The status code, which should be an enum value of google.rpc.Code.
    - `details` object[]: A list of messages that carry the error details. There is a common set of message types for APIs to use.
    - `message` string: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
  - `jobReference` string: Reference to a query job.
  - `outputConfig` QueryAssetsOutputConfig: Output configuration query assets.
    - `bigqueryDestination` GoogleCloudAssetV1QueryAssetsOutputConfigBigQueryDestination: BigQuery destination.
      - `dataset` string: Required. The BigQuery dataset where the query results will be saved. It has the format of "projects/{projectId}/datasets/{datasetId}".
      - `table` string: Required. The BigQuery table where the query results will be saved. If this table does not exist, a new table with the given name will be created.
      - `writeDisposition` string: Specifies the action that occurs if the destination table or partition already exists. The following values are supported: * WRITE_TRUNCATE: If the table or partition already exists, BigQuery overwrites the entire table or all the partitions data. * WRITE_APPEND: If the table or partition already exists, BigQuery appends the data to the table or the latest partition. * WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY.
  - `queryResult` QueryResult: Execution results of the query. The result is formatted as rows represented by BigQuery compatible [schema]. When pagination is necessary, it will contains the page token to retrieve the results of following pages.
    - `nextPageToken` string: Token to retrieve the next page of the results.
    - `rows` object[]: Each row hold a query result in the format of `Struct`.
    - `schema` TableSchema: BigQuery Compatible table schema.
      - `fields` TableFieldSchema[]: Describes the fields in a table.
        - `field` string: The field name. The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter or underscore. The maximum length is 128 characters.
        - `fields` TableFieldSchema[]: Describes the nested schema fields if the type property is set to RECORD.
        - `mode` string: The field mode. Possible values include NULLABLE, REQUIRED and REPEATED. The default value is NULLABLE.
        - `type` string: The field data type. Possible values include * STRING * BYTES * INTEGER * FLOAT * BOOLEAN * TIMESTAMP * DATE * TIME * DATETIME * GEOGRAPHY, * NUMERIC, * BIGNUMERIC, * RECORD (where RECORD indicates that the field contains a nested schema).
    - `totalRows` string, int64: Total rows of the whole query results.

---

[API](https://skmtc.dev/google/apis/cloudasset.md) - [All operations](https://skmtc.dev/google/apis/cloudasset/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/cloudasset/revisions/77b8c018c1d7?raw)
