---
title: "Read a succeeded query's rows: a page, or a download"
description: "With Accept: text/csv or application/x-ndjson, every stored row (up to 100 000) as a download. 409 query_not_finished (with Retry-After), query_failed (with reason) or query_cancelled; 410 results_expired 7 days after it finished. Pages and downloads are rate limited per organization (429 too_many_requests, with Retry-After)."
---

> 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/{queryId}/results`

With Accept: text/csv or application/x-ndjson, every stored row (up to 100 000) as a download. 409 query_not_finished (with Retry-After), query_failed (with reason) or query_cancelled; 410 results_expired 7 days after it finished. Pages and downloads are rate limited per organization (429 too_many_requests, with Retry-After).

## Authentication

Requires one of the following:

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

## Path parameters

- `GetQueryResults.path.orgId` (string, required) — The organization.
  - format `uuid`
- `GetQueryResults.path.queryId` (string, required) — The query.
  - format `uuid`

## Query parameters

- `GetQueryResults.query.limit` (integer, optional) — Default 100. A page also stops at 4 MiB.
  - format `int32`; min 1; max 1000
- `GetQueryResults.query.cursor` (string, optional) — The previous page's nextCursor.

## Code samples

### cURL

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

### TypeScript

```typescript
const url = 'https://audit.ezghcloud.com/v1/organizations/497f6eca-6276-4993-bfeb-53cbbbba6f08/queries/497f6eca-6276-4993-bfeb-53cbbbba6f08/results';
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/497f6eca-6276-4993-bfeb-53cbbbba6f08/results"

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

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

print(response.text)
```

## Responses

### 200

A page of rows, or the download.

#### Body (application/json)

- `GetQueryResults.response.200.columns` (array<object>, required)
  - `GetQueryResults.response.200.columns.name` (string, required)
  - `GetQueryResults.response.200.columns.type` (string, required) — The column's type.
- `GetQueryResults.response.200.rows` (array<array<object>>, required) — Each row's values, in the columns' order.
- `GetQueryResults.response.200.totalRows` (integer, required)
  - format `int64`
- `GetQueryResults.response.200.truncated` (boolean, required) — The result stopped at the row limit.
- `GetQueryResults.response.200.nextCursor` (string | null, optional)

##### Example

```json
{
  "columns": [
    {
      "name": "string",
      "type": "string"
    }
  ],
  "nextCursor": "string",
  "rows": [
    [
      {}
    ]
  ],
  "totalRows": 0,
  "truncated": true
}
```

#### Body (text/csv)

##### Example

```text
string
```

#### Body (application/x-ndjson)

##### Example

```json
"string"
```

### 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"
  }
}
```

- `GetQueryResults.response.400.error` (object, required)
  - `GetQueryResults.response.400.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.400.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.400.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.400.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.400.error.quota.id` (string, required)
    - `GetQueryResults.response.400.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.400.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.400.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.400.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.400.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.400.error.quota.region` (string, optional)
    - `GetQueryResults.response.400.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.400.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.400.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.400.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.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"
  }
}
```

- `GetQueryResults.response.401.error` (object, required)
  - `GetQueryResults.response.401.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.401.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.401.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.401.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.401.error.quota.id` (string, required)
    - `GetQueryResults.response.401.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.401.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.401.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.401.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.401.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.401.error.quota.region` (string, optional)
    - `GetQueryResults.response.401.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.401.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.401.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.401.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.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"
  }
}
```

- `GetQueryResults.response.403.error` (object, required)
  - `GetQueryResults.response.403.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.403.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.403.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.403.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.403.error.quota.id` (string, required)
    - `GetQueryResults.response.403.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.403.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.403.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.403.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.403.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.403.error.quota.region` (string, optional)
    - `GetQueryResults.response.403.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.403.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.403.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.403.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.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"
  }
}
```

- `GetQueryResults.response.404.error` (object, required)
  - `GetQueryResults.response.404.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.404.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.404.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.404.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.404.error.quota.id` (string, required)
    - `GetQueryResults.response.404.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.404.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.404.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.404.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.404.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.404.error.quota.region` (string, optional)
    - `GetQueryResults.response.404.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.404.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.404.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.404.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.response.404.error.reason` (string, optional) — query_failed: the query's own error code.

### 410

results_expired: the query's results are kept 7 days; run it again.

#### 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"
  }
}
```

- `GetQueryResults.response.410.error` (object, required)
  - `GetQueryResults.response.410.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.410.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.410.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.410.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.410.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.
    - `GetQueryResults.response.410.error.quota.id` (string, required)
    - `GetQueryResults.response.410.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.410.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.410.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.410.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.410.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.410.error.quota.region` (string, optional)
    - `GetQueryResults.response.410.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.410.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.410.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.410.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.response.410.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"
  }
}
```

- `GetQueryResults.response.429.error` (object, required)
  - `GetQueryResults.response.429.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.429.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.429.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.429.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.429.error.quota.id` (string, required)
    - `GetQueryResults.response.429.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.429.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.429.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.429.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.429.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.429.error.quota.region` (string, optional)
    - `GetQueryResults.response.429.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.429.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.429.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.429.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.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"
  }
}
```

- `GetQueryResults.response.500.error` (object, required)
  - `GetQueryResults.response.500.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.500.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.500.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.500.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.500.error.quota.id` (string, required)
    - `GetQueryResults.response.500.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.500.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.500.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.500.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.500.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.500.error.quota.region` (string, optional)
    - `GetQueryResults.response.500.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.500.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.500.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.500.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.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"
  }
}
```

- `GetQueryResults.response.503.error` (object, required)
  - `GetQueryResults.response.503.error.code` (string, required)
    - maxLength 64; pattern `^[a-z][a-z0-9_]*$`
  - `GetQueryResults.response.503.error.message` (string, required)
    - maxLength 1024
  - `GetQueryResults.response.503.error.column` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.response.503.error.line` (integer, optional) — invalid_query: where the SQL went wrong.
  - `GetQueryResults.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.
    - `GetQueryResults.response.503.error.quota.id` (string, required)
    - `GetQueryResults.response.503.error.quota.kind` (unknown, required)
      - one of `"allocation"`, `"rate"`, `"usage"`, `"concurrency"`
    - `GetQueryResults.response.503.error.quota.limit` (integer, required)
      - min 0
    - `GetQueryResults.response.503.error.quota.scope` (unknown, required)
      - one of `"organization"`, `"project"`, `"resource"`
    - `GetQueryResults.response.503.error.quota.inFlight` (integer, optional)
      - min 0
    - `GetQueryResults.response.503.error.quota.periodStart` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.503.error.quota.region` (string, optional)
    - `GetQueryResults.response.503.error.quota.resetsAt` (string, optional)
      - format `date-time`
    - `GetQueryResults.response.503.error.quota.scopeResourceName` (string, optional)
    - `GetQueryResults.response.503.error.quota.used` (integer, optional)
      - min 0
    - `GetQueryResults.response.503.error.quota.window` (string, optional) — rate only: an ISO 8601 duration, PT1S to PT1H.
  - `GetQueryResults.response.503.error.reason` (string, optional) — query_failed: the query's own error code.


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