# Get status, manifest, and result first chunk

Launch stage: Public Preview

`GET /api/2.0/sql/warehouses/{warehouse_id}/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
 a 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

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

## Returns

Returns the StatementResponse object.

## Response

### Statement failed with syntax error

```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": [
      {
        "byte_count": 293,
        "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,
    "truncated": false
  },
  "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 succeeded with INLINE data

```json
{
  "manifest": {
    "chunks": [
      {
        "chunk_index": 0,
        "row_count": 3,
        "row_offset": 0
      }
    ],
    "format": "JSON_ARRAY",
    "schema": {
      "column_count": 1,
      "columns": [
        {
          "name": "id",
          "position": 0,
          "type_name": "LONG",
          "type_text": "BIGINT"
        }
      ]
    },
    "total_chunk_count": 1,
    "total_row_count": 3,
    "truncated": false
  },
  "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"
  }
}
```

