---
title: "Get Query Results"
method: GET
path: "/api/queries/{id}"
tags: ["Query Runner"]
---

# Get Query Results

`GET /api/queries/{id}`

Fetches the latest status for a submitted query and, once complete, returns fields and paginated results.

This endpoint is the second step of the query-runner flow. First call
[`POST /api/connections/{connection_id}/query`](../../../api-reference/query-runner/run-query),
then poll this endpoint with the returned ID.

Results may be paginated across multiple blobs. When that happens, use the
opaque `links.next` and `links.previous` URLs exactly as returned. Do not try to
construct the `page` token yourself.

If the query is still running, the response may include only status metadata.
If the task is complete but the caller is not the same user that created it,
the endpoint returns `404`.

## Path parameters

- `id` string, uuid, required — Unique identifier of the query task, as returned by POST /api/connections/{connection_id}/query.

## Query parameters

- `page` string — Opaque pagination token returned in the links.next or links.previous URL of the previous response.

## Headers

- `X-Polytomic-Version` string

## Response `200`

OK

- QueryResultsEnvelope
  - `data` RunQueryResult
    - `count` integer — The number of rows returned by the query. This will not be returned until the query completes.
    - `error` string — Error message if the query failed.
    - `expires` string — The time at which the query will expire and be deleted. This will not be returned until the query completes.
    - `fields` string[] — The names of the fields returned by the query. This will not be returned until the query completes.
    - `id` string, uuid — The ID of the query task. Poll GET /api/queries/{id} until the task reaches done or failed to retrieve results.
    - `results` object[] — The query results, returned as an array of objects.
    - `status` 'created' | 'running' | 'done' | 'failed'
  - `links` RunQueryPagination
    - `next` string — URL to the next page of results, if available. This may be returned as a host relative path.
    - `previous` string — URL to the previous page of results, if available. This may be returned as a host relative path.

## Other responses

- `400` — Bad Request
- `404` — Not Found
- `500` — Internal Server Error

---

[API](https://skmtc.net/polytomic/apis/polytomic-api.md) · [All operations](https://skmtc.net/polytomic/apis/polytomic-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/polytomic/polytomic-api/versions/b509e00e80aa/schema)
