# Step 2 of self-scheduling: get specific available time slots for a date range

Operation ID: `connectors.healthieGetAvailableSlotsForRange`

Step 2 of self-scheduling: get specific available time slots for a date range. Returns ``{"available_slots_for_range": [...], "appointment_type": {...} | None}``. `appt_type_id` and `appointment_type_id` are two separate GraphQL variables because Healthie's own schema types them differently across the same query (`availableSlotsForRange(appt_type_id: String)` vs. the sibling `appointmentType(id: ID)` lookup) — but every real caller means the same appointment type for both. `appointment_type_id` defaults to `appt_type_id` when not given separately; omitting it silently drops the `appointment_type` result to None, which upstream mapping code (see appointments/src/app.py's `_slot_from_openloop`) then treats as "no usable length" and discards every slot — confirmed live 2026-09-02 (1497 real slots in, 0 out) before this default was added.

## Public method

`getAvailableSlotsForRange`

Signature: `connectors.healthie.createClient(config).getAvailableSlotsForRange(body)`

Return type: `Promise<HealthieAvailabilityResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /connectors/healthie/get-available-slots-for-range`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`HealthieGetAvailableSlotsForRangeRequest`](../models/HealthieGetAvailableSlotsForRangeRequest.md) | Yes |  |  |  | No |  |

Request model: [`HealthieGetAvailableSlotsForRangeRequest`](../models/HealthieGetAvailableSlotsForRangeRequest.md)

## Request example

```json
{
  "api_url": "https://example.com/resource",
  "appt_type_id": "12345",
  "end_date": "example-end-date",
  "mode": "sandbox",
  "open_loop_url": "https://example.com/resource",
  "org_level": false,
  "provider_id": "12345",
  "secret_key": "example-api-key",
  "shard_id": "12345",
  "start_date": "example-start-date"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`HealthieGetAvailableSlotsForRangeResponse`](../models/HealthieGetAvailableSlotsForRangeResponse.md) | application/json | Successful response |

## Success response examples

### 200

```json
{
  "appointment_type": {
    "vendorField": "vendor-defined value"
  },
  "available_slots_for_range": {
    "vendorField": "vendor-defined value"
  }
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Connector validation rejected the payload, or a required field was missing or of the wrong type. |
| `401` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The HealthCloud bearer token is missing or invalid, or the vendor rejected the supplied connector credentials. |
| `500` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The connector failed unexpectedly. |
| `502` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor returned an application or transport-level failure. |
| `504` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor did not respond within the connector timeout. |

## Error examples

### 400 — Invalid request

```json
{
  "error": "Invalid request"
}
```

### 401 — Authorization required

```json
{
  "error": "Authorization required"
}
```

### 500 — Internal error

```json
{
  "error": "Internal error"
}
```

### 502 — Upstream vendor error

```json
{
  "error": "Upstream vendor error"
}
```

### 504 — Upstream timeout

```json
{
  "error": "Upstream timeout"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { HealthieGetAvailableSlotsForRangeRequest } from "@healthcloudai/hc-sdk";
```

```ts
const body = {
  "api_url": "https://example.com/resource",
  "appt_type_id": "12345",
  "end_date": "example-end-date",
  "mode": "sandbox",
  "open_loop_url": "https://example.com/resource",
  "org_level": false,
  "provider_id": "12345",
  "secret_key": "example-api-key",
  "shard_id": "12345",
  "start_date": "example-start-date"
};

const result = await connectors.healthie.createClient(config).getAvailableSlotsForRange(body);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"api_url":"https://example.com/resource","appt_type_id":"12345","end_date":"example-end-date","mode":"sandbox","open_loop_url":"https://example.com/resource","org_level":false,"provider_id":"12345","secret_key":"example-api-key","shard_id":"12345","start_date":"example-start-date"}' \
  'https://dev-api-connectors.health.cloud/connectors/healthie/get-available-slots-for-range'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
