Explore documentation

Slots and Availability

Managing time slots and provider availability

Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.

Create a Schedule

Create a Schedule resource that defines the availability container. actor[] is the only required field; it keeps the standard FHIR reference shape because a schedule can point to practitioners, locations, devices, etc. active defaults to true.

REST
curl -X POST https://api.esus.health/fhir/Schedule \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "active": true,
    "serviceCategory": [{
      "coding": [{
        "system": "http://terminology.hl7.org/CodeSystem/service-category",
        "code": "1",
        "display": "General Practice"
      }]
    }],
    "actor": [{
      "reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
      "display": "Dr. Sarah Johnson"
    }],
    "planningHorizon": {
      "start": "2026-04-21T08:00:00Z",
      "end": "2026-04-21T17:00:00Z"
    }
  }'
SDK
const created = await esus.fhir.create("Schedule", {
  "active": true,
  "serviceCategory": [
    {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/service-category",
          "code": "1",
          "display": "General Practice"
        }
      ]
    }
  ],
  "actor": [
    {
      "reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
      "display": "Dr. Sarah Johnson"
    }
  ],
  "planningHorizon": {
    "start": "2026-04-21T08:00:00Z",
    "end": "2026-04-21T17:00:00Z"
  }
});

Other optional fields: identifier[], serviceType[], specialty[], comment.

Find a Practitioner’s Schedule

Schedule search supports actor, active, service-type, specialty and date. All except active are partial text matches: actor accepts Practitioner/<id> or the bare id, and date matches text inside planningHorizon (no range semantics: a ge/le prefix is dropped and the date is matched as text, and only the first date value is used).

REST
curl "https://api.esus.health/fhir/Schedule?actor=Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789&active=true" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("Schedule", {
  "actor": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
  "active": true
});

Create Slots

Each slot references its parent schedule via the flat scheduleId field (not a FHIR reference object); it must be the id of an existing Schedule. scheduleId, start and end are required; status defaults to free and overbooked to false.

REST
curl -X POST https://api.esus.health/fhir/Slot \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
    "status": "free",
    "start": "2026-04-21T09:00:00Z",
    "end": "2026-04-21T09:30:00Z",
    "comment": "Available for general checkup"
  }'
SDK
const created = await esus.fhir.create("Slot", {
  "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
  "status": "free",
  "start": "2026-04-21T09:00:00Z",
  "end": "2026-04-21T09:30:00Z",
  "comment": "Available for general checkup"
});

Responses return the standard FHIR shape, "schedule": { "reference": "Schedule/aa11bb22-..." }, even though writes take scheduleId.

Slot Status Values

StatusMeaning
freeThe slot is available
busyThe slot is reserved
busy-unavailableThe slot exists but is not available
busy-tentativeThe slot is tentatively reserved
entered-in-errorRecorded in error

Slot status has no state machine: any value can be set with PUT/PATCH. The only automatic change is $book flipping free → busy. Cancelling an appointment does not free its slot; do it yourself:

curl -X PATCH https://api.esus.health/fhir/Slot/c1a2e3d4-5b6f-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{ "status": "free" }'

Search Available Slots

Slot search supports only these parameters:

ParameterMatching
scheduleExact Schedule id (<uuid> or Schedule/<uuid>; no schedule.actor chaining)
statusExact
startSame calendar day as the given date; no ge/le prefixes
service-typePartial text match

There is no date parameter and no _sort on Slot, and results come in no guaranteed order: sort by start on the client. To find a practitioner’s slots, first resolve their Schedule id (see above), then filter Slots by it.

REST
# All free slots for a schedule on a specific day
curl "https://api.esus.health/fhir/Slot?schedule=aa11bb22-cc33-dd44-ee55-ff6677889900&status=free&start=2026-04-21" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("Slot", {
  "schedule": "aa11bb22-cc33-dd44-ee55-ff6677889900",
  "status": "free",
  "start": "2026-04-21"
});

Creating Many Slots

There is no $bulk-create operation. Either loop over POST /fhir/Slot, or send a batch Bundle to POST /fhir (up to 50 entries; each entry is processed independently, not atomically). transaction Bundles are rejected with 422.

curl -X POST https://api.esus.health/fhir \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "resourceType": "Bundle",
    "type": "batch",
    "entry": [
      {
        "request": { "method": "POST", "url": "Slot" },
        "resource": { "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900", "start": "2026-04-21T09:00:00Z", "end": "2026-04-21T09:30:00Z" }
      },
      {
        "request": { "method": "POST", "url": "Slot" },
        "resource": { "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900", "start": "2026-04-21T09:30:00Z", "end": "2026-04-21T10:00:00Z" }
      }
    ]
  }'

The response is a batch-response Bundle with one status per entry; check each one.