---
title: "The organization's query history, newest first"
description: "Everyone's with audit.queries.list; with only audit.queries.get, your own."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Trails API › queries

`GET /v1/organizations/{orgId}/queries`

Everyone's with audit.queries.list; with only audit.queries.get, your own.

## Authentication

Requires one of the following:

- `apiKey`, http, header `Authorization`
- `oauth`, http, header `Authorization`
- `sessionCookie`, apiKey, in cookie

## Path parameters

- `ListQueries.path.orgId` (string, required) — The organization.
  - format `uuid`

## Query parameters

- `ListQueries.query.limit` (integer, optional) — Default 20.
  - format `int32`; min 1; max 100
- `ListQueries.query.cursor` (string, optional) — The previous page's nextCursor, for the same filters.
- `ListQueries.query.status` (string, optional) — queued, running, succeeded, failed or cancelled.
- `ListQueries.query.createdBy` (string, optional) — A principal ID.

## Code samples

### cURL

```curl
curl --request GET \
  --url https://audit.ezghcloud.com/v1/organizations/497f6eca-6276-4993-bfeb-53cbbbba6f08/queries \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://audit.ezghcloud.com/v1/organizations/497f6eca-6276-4993-bfeb-53cbbbba6f08/queries';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://audit.ezghcloud.com/v1/organizations/497f6eca-6276-4993-bfeb-53cbbbba6f08/queries"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

A page of queries.

#### Example

```json
{
  "nextCursor": "string",
  "queries": [
    {
      "cancelRequested": true,
      "createdAt": "2019-08-24T14:15:22Z",
      "createdBy": "string",
      "createdByIdentity": {},
      "error": {
        "code": "string",
        "message": "string"
      },
      "finishedAt": "string",
      "from": "2019-08-24T14:15:22Z",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "queuePosition": 0,
      "resultRows": 0,
      "sql": "string",
      "startedAt": "string",
      "stats": {
        "bytesScanned": "5020",
        "elapsedMs": 0,
        "resultRows": 0,
        "rowsScanned": 0
      },
      "status": "string",
      "to": "2019-08-24T14:15:22Z",
      "truncated": true
    }
  ]
}
```

- `ListQueries.response.200.queries` (array<object>, required)
  - `ListQueries.response.200.queries.cancelRequested` (boolean, required)
  - `ListQueries.response.200.queries.createdAt` (string, required)
    - format `date-time`
  - `ListQueries.response.200.queries.createdBy` (string, required) — The principal who started it.
  - `ListQueries.response.200.queries.from` (string, required)
    - format `date-time`
  - `ListQueries.response.200.queries.id` (string, required)
    - format `uuid`
  - `ListQueries.response.200.queries.queuePosition` (integer | null, required) — Its place in the organization's line while it's queued (1 is next), in GetQuery's answer; null otherwise, and in lists.
    - format `int64`
  - `ListQueries.response.200.queries.sql` (string, required)
  - `ListQueries.response.200.queries.status` (string, required) — queued, running, succeeded, failed or cancelled.
  - `ListQueries.response.200.queries.to` (string, required)
    - format `date-time`
  - `ListQueries.response.200.queries.truncated` (boolean, required)
  - `ListQueries.response.200.queries.createdByIdentity` (object | null, optional)
  - `ListQueries.response.200.queries.error` (one of, optional)
    - one of: [QueryError](/trails-api/schemas/QueryError/), `null`
  - `ListQueries.response.200.queries.finishedAt` (string | null, optional)
  - `ListQueries.response.200.queries.resultRows` (integer | null, optional)
    - format `int64`
  - `ListQueries.response.200.queries.startedAt` (string | null, optional)
  - `ListQueries.response.200.queries.stats` (one of, optional)
    - one of: [QueryStats](/trails-api/schemas/QueryStats/), `null`
- `ListQueries.response.200.nextCursor` (string | null, optional)

### 400

invalid_request, invalid_cursor, invalid_query (with line and column), or lookup_too_broad.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.400.error` (object, required)
  - `ListQueries.response.400.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.400.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.400.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.400.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.400.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.400.error.quota.id` (string, required)
    - `ListQueries.response.400.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.400.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.400.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.400.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.400.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.400.error.quota.region` (string, optional)
    - `ListQueries.response.400.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.400.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.400.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.400.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.400.error.reason` (string, optional) — query_failed: the query's own error code.

### 401

unauthenticated: no credential, or one that doesn't check out.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.401.error` (object, required)
  - `ListQueries.response.401.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.401.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.401.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.401.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.401.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.401.error.quota.id` (string, required)
    - `ListQueries.response.401.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.401.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.401.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.401.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.401.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.401.error.quota.region` (string, optional)
    - `ListQueries.response.401.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.401.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.401.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.401.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.401.error.reason` (string, optional) — query_failed: the query's own error code.

### 403

access_denied: the caller's policies don't allow the action; forbidden_origin: a cookie-authenticated write from an origin that isn't allowed.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.403.error` (object, required)
  - `ListQueries.response.403.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.403.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.403.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.403.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.403.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.403.error.quota.id` (string, required)
    - `ListQueries.response.403.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.403.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.403.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.403.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.403.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.403.error.quota.region` (string, optional)
    - `ListQueries.response.403.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.403.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.403.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.403.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.403.error.reason` (string, optional) — query_failed: the query's own error code.

### 404

not_found: unknown, malformed, or in an organization the caller isn't in.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.404.error` (object, required)
  - `ListQueries.response.404.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.404.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.404.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.404.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.404.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.404.error.quota.id` (string, required)
    - `ListQueries.response.404.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.404.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.404.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.404.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.404.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.404.error.quota.region` (string, optional)
    - `ListQueries.response.404.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.404.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.404.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.404.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.404.error.reason` (string, optional) — query_failed: the query's own error code.

### 429

too_many_requests or too_many_queries, with Retry-After; or quota_exceeded (with quota), never with Retry-After.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.429.error` (object, required)
  - `ListQueries.response.429.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.429.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.429.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.429.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.429.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.429.error.quota.id` (string, required)
    - `ListQueries.response.429.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.429.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.429.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.429.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.429.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.429.error.quota.region` (string, optional)
    - `ListQueries.response.429.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.429.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.429.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.429.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.429.error.reason` (string, optional) — query_failed: the query's own error code.

### 500

internal_error: a bug; the details are in the logs, under the request ID.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.500.error` (object, required)
  - `ListQueries.response.500.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.500.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.500.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.500.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.500.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.500.error.quota.id` (string, required)
    - `ListQueries.response.500.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.500.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.500.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.500.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.500.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.500.error.quota.region` (string, optional)
    - `ListQueries.response.500.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.500.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.500.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.500.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.500.error.reason` (string, optional) — query_failed: the query's own error code.

### 503

unavailable: a dependency the request needs is down. Retry after Retry-After.

#### Example

```json
{
  "error": {
    "code": "string",
    "column": 0,
    "line": 0,
    "message": "string",
    "quota": {
      "id": "string",
      "inFlight": 0,
      "kind": "allocation",
      "limit": 0,
      "periodStart": "2019-08-24T14:15:22Z",
      "region": "string",
      "resetsAt": "2019-08-24T14:15:22Z",
      "scope": "organization",
      "scopeResourceName": "string",
      "used": 0,
      "window": "string"
    },
    "reason": "string"
  }
}
```

- `ListQueries.response.503.error` (object, required)
  - `ListQueries.response.503.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `ListQueries.response.503.error.message` (string, required)
    - maxLength 1024
  - `ListQueries.response.503.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.503.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `ListQueries.response.503.error.quota` (object, optional) — quota_exceeded: the quota that refused the request. Trails Query's are audit.queries.queriesPerHour and audit.queries.bytesReadPerHour, rate quotas with a PT1H window. Never with Retry-After.
    - `ListQueries.response.503.error.quota.id` (string, required)
    - `ListQueries.response.503.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `ListQueries.response.503.error.quota.limit` (integer, required)
      - min 0
    - `ListQueries.response.503.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `ListQueries.response.503.error.quota.inFlight` (integer, optional)
      - min 0
    - `ListQueries.response.503.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `ListQueries.response.503.error.quota.region` (string, optional)
    - `ListQueries.response.503.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `ListQueries.response.503.error.quota.scopeResourceName` (string, optional)
    - `ListQueries.response.503.error.quota.used` (integer, optional)
      - min 0
    - `ListQueries.response.503.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `ListQueries.response.503.error.reason` (string, optional) — query_failed: the query's own error code.


Source: https://docs.ezghcloud.com/trails-api/queries/ListQueries/index.md
