# Book an appointment

Operation ID: `appointments.book`

Book a patient into a free slot returned by `appointments.listSlots`. The operation creates the appointment and changes the selected slot from free to booked.

## Public method

`book`

Signature: `appointments.book(request)`

Return type: `Promise<Appointment>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /appointments/book`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "athena_appointment_id": "string",
  "patient_id": "string",
  "slot_id": "string",
  "start": "string",
  "steadymd_clinician_guid": "string"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`Appointment`](../models/Appointment.md) | application/json | Appointment created successfully |

## Success response examples

### 201

```json
{
  "appointment_id": "string",
  "athena_appointment_id": "string",
  "created_at": "string",
  "end": "string",
  "openloop_appointment_id": "string",
  "patient_id": "string",
  "provider_id": "string",
  "slot_id": "string",
  "slot_ids": [
    "string"
  ],
  "specialty_code": "string",
  "start": "string",
  "status": "scheduled",
  "steadymd_consult_guid": "string",
  "telehealth_link": "string",
  "updated_at": "string"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`appointments.ErrorResponse`](../models/appointments.ErrorResponse.md) | application/json | Bad request — missing slot_id or patient_id |
| `401` | [`appointments.ErrorResponse`](../models/appointments.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `404` | [`appointments.ErrorResponse`](../models/appointments.ErrorResponse.md) | application/json | The requested slot was not found |
| `409` | [`appointments.ErrorResponse`](../models/appointments.ErrorResponse.md) | application/json | Conflict — slot not available |
| `500` | [`appointments.ErrorResponse`](../models/appointments.ErrorResponse.md) | application/json | Internal server error |

## Error examples

### 400 — Required booking fields are missing

```json
{
  "error": "slot_id and patient_id are required"
}
```

### 401 — Missing or invalid access token

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

### 404 — FHIR Slot resource does not exist

```json
{
  "error": "Not Found"
}
```

### 409 — The selected slot is not free

```json
{
  "error": "Slot is not available (status: busy)"
}
```

### 500 — Unexpected service failure (sanitized example)

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

## NodeJS / TypeScript implementation

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

```ts
const request = {
  "athena_appointment_id": "string",
  "patient_id": "string",
  "slot_id": "string",
  "start": "string",
  "steadymd_clinician_guid": "string"
};

const result = await appointments.book(request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"athena_appointment_id":"string","patient_id":"string","slot_id":"string","start":"string","steadymd_clinician_guid":"string"}' \
  'https://dev-api-appointments.health.cloud/appointments/book'
```

## 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.
