# List

Launch stage: GA

`GET /api/2.0/sql/queries`

Gets a list of queries accessible to the user, ordered by creation time. **Warning:** Calling this API concurrently 10 or more times could result in throttling, service degradation, or a temporary ban.

API scopes: sql

## Query parameters

- `page_token` (string, optional)
- `page_size` (int32, optional)
  Default: `20`
  Constraints: `<= 100`

## Returns

- `results` (array of object, optional)
  - `id` (string, optional)
    UUID identifying the query.
    Example: `fe25e731-92f2-4838-9fb2-1ca364320a3d`
  - `display_name` (string, optional)
    Display name of the query that appears in list views, widget headings, and on the query page.
    Example: `Example query`
  - `description` (string, optional)
    General description that conveys additional information about this query such as usage notes.
    Example: `Example description`
  - `owner_user_name` (string, optional)
    Username of the user that owns the query.
    Example: `user@acme.com`
  - `warehouse_id` (string, optional)
    ID of the SQL warehouse attached to the query.
    Example: `a7066a8ef796be84`
  - `query_text` (string, optional)
    Text of the query to be run.
    Example: `SELECT 1`
  - `run_as_mode` (string, optional)
    Sets the "Run as" role for the object.
    Possible values: `OWNER`, `VIEWER`
  - `lifecycle_state` (string, optional)
    Indicates whether the query is trashed.
    Possible values: `ACTIVE`, `TRASHED`
  - `last_modifier_user_name` (string, optional)
    Username of the user who last saved changes to this query.
    Example: `user@acme.com`
  - `parent_path` (string, optional)
    Workspace path of the workspace folder containing the object.
    Example: `/Users/user@acme.com`
  - `tags` (array of string, optional)
  - `create_time` (string, optional)
    Timestamp when this query was created.
  - `update_time` (string, optional)
    Timestamp when this query was last updated.
  - `parameters` (array of object, optional)
    List of query parameter definitions.
    - `title` (string, optional)
      Text displayed in the user-facing parameter widget in the UI.
    - `name` (string, optional)
      Literal parameter marker that appears between double curly braces in the query text.
    - `text_value` (object, required)
      Text query parameter value.
      - `value` (string, optional)
    - `numeric_value` (object, required)
      Numeric query parameter value.
      - `value` (double, optional)
    - `enum_value` (object, required)
      Dropdown query parameter value.
      - `values` (array of string, optional)
        List of selected query parameter values.
      - `enum_options` (string, optional)
        List of valid query parameter values, newline delimited.
      - `multi_values_options` (object, optional)
        If specified, allows multiple values to be selected for this parameter.
    - `date_value` (object, required)
      Date query parameter value. Can only specify one of `dynamic_date_value` or `date_value`.
      - `dynamic_date_value` (string, required)
        Dynamic date-time value based on current date-time.
        Possible values: `NOW`, `YESTERDAY`
      - `date_value` (string, required)
        Manually specified date-time value.
      - `precision` (string, optional)
        Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD).
        Possible values: `DAY_PRECISION`, `MINUTE_PRECISION`, `SECOND_PRECISION`
    - `date_range_value` (object, required)
      Date-range query parameter value. Can only specify one of `dynamic_date_range_value` or `date_range_value`.
      - `dynamic_date_range_value` (string, required)
        Dynamic date-time range value based on current date-time.
        Possible values: `TODAY`, `YESTERDAY`, `THIS_WEEK`, `THIS_MONTH`, `THIS_YEAR`, `LAST_WEEK`, `LAST_MONTH`, `LAST_YEAR`, `LAST_HOUR`, `LAST_8_HOURS`, `LAST_24_HOURS`, `LAST_7_DAYS`, `LAST_14_DAYS`, `LAST_30_DAYS`, `LAST_60_DAYS`, `LAST_90_DAYS`, `LAST_12_MONTHS`
      - `date_range_value` (object, required)
        Manually specified date-time range value.
      - `precision` (string, optional)
        Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD).
        Possible values: `DAY_PRECISION`, `MINUTE_PRECISION`, `SECOND_PRECISION`
      - `start_day_of_week` (int32, optional)
    - `query_backed_value` (object, required)
      Query-based dropdown query parameter value.
      - `values` (array of string, optional)
        List of selected query parameter values.
      - `query_id` (string, optional)
        UUID of the query that provides the parameter values.
      - `multi_values_options` (object, optional)
        If specified, allows multiple values to be selected for this parameter.
  - `apply_auto_limit` (boolean, optional)
    Whether to apply a 1000 row limit to the query result.
  - `catalog` (string, optional)
    Name of the catalog where this query will be executed.
  - `schema` (string, optional)
    Name of the schema where this query will be executed.
- `next_page_token` (string, optional)

## Response

```json
{
  "next_page_token": "eDg",
  "results": [
    {
      "create_time": "2019-08-24T14:15:22Z",
      "description": "Example description",
      "display_name": "Example query 1",
      "id": "ae25e731-92f2-4838-9fb2-1ca364320a3d",
      "last_modifier_user_name": "user@acme.com",
      "lifecycle_state": "ACTIVE",
      "owner_user_name": "user@acme.com",
      "parameters": [
        {
          "name": "foo",
          "text_value": {
            "value": "bar"
          },
          "title": "foo"
        }
      ],
      "query_text": "SELECT 1",
      "run_as_mode": "OWNER",
      "tags": [
        "Tag 1"
      ],
      "update_time": "2019-08-24T14:15:22Z",
      "warehouse_id": "a7066a8ef796be84"
    },
    {
      "create_time": "2019-08-24T14:15:22Z",
      "description": "Example description",
      "display_name": "Example query 2",
      "id": "be25e731-92f2-4838-9fb2-1ca364320a3d",
      "last_modifier_user_name": "user@acme.com",
      "lifecycle_state": "ACTIVE",
      "owner_user_name": "user@acme.com",
      "parameters": [
        {
          "name": "foo",
          "text_value": {
            "value": "bar"
          },
          "title": "foo"
        }
      ],
      "query_text": "SELECT 1",
      "run_as_mode": "OWNER",
      "tags": [
        "Tag 1"
      ],
      "update_time": "2019-08-24T14:15:22Z",
      "warehouse_id": "a7066a8ef796be84"
    }
  ]
}
```

