# Create a new appointment

Operation ID: `connectors.zocdocCreateAppointment`

Create a new appointment. Required fields: provider_location_id, visit_reason_id, start_time, patient_type, and patient (with first_name, last_name, email_address, phone_number, date_of_birth, sex_at_birth, patient_address).

## Public method

`createAppointment`

Signature: `connectors.zocdoc.createClient(config).createAppointment(body)`

Return type: `Promise<ZocdocCreateAppointmentResult>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /connectors/zocdoc/create-appointment`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "appointment_data": {
    "vendorField": "vendor-defined value"
  },
  "appointment_type": "providers",
  "client_id": "12345",
  "client_secret": "example-client-secret",
  "mode": "sandbox"
}
```

## Success responses

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

## Success response examples

### 200

```json
{
  "appointment_id": "12345",
  "appointment_status": "example-appointment-status",
  "cancellation_reason": "example-cancellation-reason",
  "cancellation_reason_type": "example-cancellation-reason-type",
  "confirmation_type": "example-confirmation-type",
  "created_time_utc": "example-created-time-utc",
  "developer_patient_id": "12345",
  "is_provider_resource": true,
  "last_modified_time_utc": "example-last-modified-time-utc",
  "location_phone_extension": "+15555550123",
  "location_phone_number": "+15555550123",
  "notes": "example-notes",
  "patient_type": "example-patient-type",
  "practice_id": "12345",
  "provider_location_id": "12345",
  "start_time": "example-start-time",
  "visit_reason_id": "12345",
  "visit_type": "example-visit-type",
  "waiting_room_path": "example-waiting-room-path"
}
```

## 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 { ZocdocCreateAppointmentRequest } from "@healthcloudai/hc-sdk";
```

```ts
const body = {
  "appointment_data": {
    "vendorField": "vendor-defined value"
  },
  "appointment_type": "providers",
  "client_id": "12345",
  "client_secret": "example-client-secret",
  "mode": "sandbox"
};

const result = await connectors.zocdoc.createClient(config).createAppointment(body);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"appointment_data":{"vendorField":"vendor-defined value"},"appointment_type":"providers","client_id":"12345","client_secret":"example-client-secret","mode":"sandbox"}' \
  'https://dev-api-connectors.health.cloud/connectors/zocdoc/create-appointment'
```

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