# GET Request

To obtain the result of a [POST request](./post-for-autocoding-requests), poll for it with the `GET` API and check the `state`.

## Endpoint

| Field | Value |
| --- | --- |
| Endpoint | `https://services.hank.ai/autocoding/v1/tasks/{id}` |
| Method | `GET` |
| API Key header | `x-api-key` |
| API Key value | to be provided |

The `{id}` is the value returned in the response to a successful `POST` request.

## Polling on `state`

The `state` transitions from `In-Progress` to `Completed`:

- **`In-Progress`** — keep polling.
- **`Completed`** — the `result` contains the body of the predicted result.
- **`Error`** — the `error` property reflects the reason.

## Response

When `state` is `Completed`, `response.result.entities` is the list of line items. Each entity carries an `entityValue` array of predicted codes, each with a `code`, a `confidence`, the source `noteType`, and the `noteId` it was predicted from.

```json
{
  "id": "<id>",
  "response": {
    "result": {
      "job_id": "<internal id optionally supplied with POST request>",
      "entities": [
        {
          "id": "<unique within request>",
          "provider": "HBS",
          "entityValue": [
            {
              "id": "<unique within request>",
              "code": "20610",
              "confidence": 0.98,
              "noteType": "SurgeonProcedureNote",
              "noteId": 25
            }
          ],
          "order": 1,
          "type": "SurgCPT"
        }
      ]
    },
    "state": "Completed",
    "status": null,
    "metadata": {
      "apiKey": "apiKey value",
      "timeStamp": "timestamp",
      "processEndTime": "time",
      "processStartTime": "time"
    },
    "error": null
  }
}
```

The `type` of an entity is one of `SurgCPT`, `AnesCPT`, `ICD10`, `Modifier`, or `Practitioner`. The `job_id` echoes the optional internal `id` you supplied on the POST.
