# Get status, manifest, and result first chunk

Launch stage: GA

`GET /api/2.0/sql/statements/{statement_id}`

This request can be used to poll for the statement's status. StatementResponse contains
 `statement_id` and `status`; other fields might be absent or present depending on context.
 When the `status.state` field is `SUCCEEDED` it will also return the result manifest and the
 first chunk of the result data. When the statement is in the terminal states `CANCELED`,
 `CLOSED` or `FAILED`, it returns HTTP 200 with the state set. After at least 12 hours in
 terminal state, the statement is removed from the warehouse and further calls will receive an
 HTTP 404 response.

 **NOTE**
 This call currently might take up to 5 seconds to get the latest status and result.

API scopes: sql

## Path parameters

- `statement_id` (string, required)
  The statement ID is returned upon successfully submitting a SQL statement, and is a required
   reference for all subsequent calls.

## Query parameters

- `warehouse_id` (string, optional)
  For warehouse statement URLs, this field contains the warehouse_id path parameter.

## Returns

Returns the StatementResponse object.

## Response

### Statement failed with syntax errror

```json
{
  "statement_id": "01ee48eb-5124-1922-bb90-f98c82f024fe",
  "status": {
    "error": {
      "error_code": "BAD_REQUEST",
      "message": "[PARSE_SYNTAX_ERROR] Syntax error at or near ..."
    },
    "state": "FAILED"
  }
}
```

### Statement running

```json
{
  "statement_id": "01ed9db9-24c4-1cb6-a320-fb6ebbe7410d",
  "status": {
    "state": "RUNNING"
  }
}
```

### Statement succeeded with EXTERNAL_LINKS and CSV

```json
{
  "manifest": {
    "chunks": [
      {
        "chunk_index": 0,
        "row_count": 100,
        "row_offset": 0
      }
    ],
    "format": "CSV",
    "schema": {
      "column_count": 1,
      "columns": [
        {
          "name": "id",
          "position": 0,
          "type_name": "LONG",
          "type_text": "BIGINT"
        }
      ]
    },
    "total_byte_count": 293,
    "total_chunk_count": 1,
    "total_row_count": 100
  },
  "result": {
    "external_links": [
      {
        "byte_count": 293,
        "chunk_index": 0,
        "expiration": "2023-01-30T22:23:23.140Z",
        "external_link": "https://someplace.cloud-provider.com/very/long/path/...",
        "row_count": 100,
        "row_offset": 0
      }
    ]
  },
  "statement_id": "01eda0ea-9b4b-15ce-b8bb-a7d4114cb5ed",
  "status": {
    "state": "SUCCEEDED"
  }
}
```

### Statement succeeeded with INLINE data

```json
{
  "manifest": {
    "format": "JSON_ARRAY",
    "schema": {
      "column_count": 1,
      "columns": [
        {
          "name": "id",
          "position": 0,
          "type_name": "LONG",
          "type_text": "BIGINT"
        }
      ]
    }
  },
  "result": {
    "chunk_index": 0,
    "data_array": [
      [
        "0"
      ],
      [
        "1"
      ],
      [
        "2"
      ]
    ],
    "row_count": 3,
    "row_offset": 0
  },
  "statement_id": "01eda0e7-e315-1846-84e2-79a963ffad44",
  "status": {
    "state": "SUCCEEDED"
  }
}
```

