---
type: api
title: Get async SQL search results
description: Get the current status and available results for an async SQL search or stored synchronous SQL search.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/operation/operation-sql-get-async
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/operation/operation-sql-get-async
products:
  - Elasticsearch
---

# Get async SQL search results

Availability: Generally available since 7.15

## Paths

- `GET` `/_sql/async/{id}`

#### Path parameters

- `id` (string) — required
  The identifier for the search.

## Description

Get the current status and available results for an async SQL search or stored synchronous SQL search.

If the Elasticsearch security features are enabled, only the user who first submitted the SQL search can retrieve the search using this API.

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `delimiter` (string · default: ,) — optional
  The separator for CSV results.
The API supports this parameter only for CSV responses.
- `format` (string) — optional
  The format for the response.
You must specify a format using this parameter or the `Accept` HTTP header.
If you specify both, the API uses this parameter.
- `keep_alive` (string · default: 5d) — optional
  The retention period for the search and its results.
It defaults to the `keep_alive` period for the original SQL search.
- `wait_for_completion_timeout` (string) — optional
  The period to wait for complete results.
It defaults to no timeout, meaning the request waits for complete search results.

## Response

`application/json`

- `id` (string)
  Identifier for the search.
This value is returned only for async and saved synchronous searches.
For CSV, TSV, and TXT responses, this value is returned in the `Async-ID` HTTP header.
- `is_running` (boolean)
  If `true`, the search is still running.
If `false`, the search has finished.
This value is returned only for async and saved synchronous searches.
For CSV, TSV, and TXT responses, this value is returned in the `Async-partial` HTTP header.
- `is_partial` (boolean)
  If `true`, the response does not contain complete search results.
If `is_partial` is `true` and `is_running` is `true`, the search is still running.
If `is_partial` is `true` but `is_running` is `false`, the results are partial due to a failure or timeout.
This value is returned only for async and saved synchronous searches.
For CSV, TSV, and TXT responses, this value is returned in the `Async-partial` HTTP header.
- `columns` (object[])
  Column headings for the search results. Each object is a column.
  - `name` (string)
  - `type` (string)
- `cursor` (string)
  The cursor for the next set of paginated results.
For CSV, TSV, and TXT responses, this value is returned in the `Cursor` HTTP header.
- `rows` (object[])
  The values for the search results.
## Code examples

#### Console

```console
GET _sql/async/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=?wait_for_completion_timeout=2s&format=json
```

#### JavaScript

```javascript
const response = await client.sql.getAsync({
  id: "FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=",
  wait_for_completion_timeout: "2s",
  format: "json",
});
```

#### Python

```python
resp = client.sql.get_async(
    id="FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=",
    wait_for_completion_timeout="2s",
    format="json",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_sql/async/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=?wait_for_completion_timeout=2s&format=json" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.sql().getAsync(g -> g
    .format("json")
    .id("FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=")
    .waitForCompletionTimeout(w -> w
        .time("2s")
    )
);
```

#### C#

```c#
var response = await client.Sql
    .GetAsyncAsync(id: "FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=", d1 => d1
        .Format("json")
        .WaitForCompletionTimeout("2s")
    );
```

#### PHP

```php
$resp = $client->sql()->getAsync([
    "id" => "FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=",
    "wait_for_completion_timeout" => "2s",
    "format" => "json",
]);
```

#### Ruby

```ruby
response = client.sql.get_async(
  id: "FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=",
  wait_for_completion_timeout: "2s",
  format: "json"
)
```

