Skip to content

API reference

Bookings

High-level booking flow. Find optimal slots, then create bookings with full orchestration — constraint validation, resource allocation, notification dispatch.

Key points

  • Bookings is the recommended high-level flow for most integrations
  • Two endpoints: find optimal slots, then create the booking
  • On 409, the response includes structured conflict details and alternative suggestions
  • Use POST /events directly when you need lower-level control (specific time, no scoring)

Bookings vs. events

Both /bookings and /events create events in the engine. The difference is the flow:

  • Bookings orchestrates the full path — ranking, slot selection, optional conflict tolerance, and richer error responses with suggested alternatives. Use this when your UI is “find me a time that works”.
  • Events creates the event at a specific time you’ve already chosen. Lower-level. Use this when you’ve done your own scoring or when the time is dictated by external constraints.

Most integrations should start with bookings. Drop to events only when you need precise control.

Find optimal slots

GET/api/v1/bookings/optimal-slots

Find ranked time slots for a proposed booking, scored by availability and constraint satisfaction.

Headers

  • x-organization-idUUIDrequired

    Organization scope

Query parameters

  • eventTypestringrequired

    Event type key from the template e.g. home_visit

  • primaryEntityIdUUIDrequired

    The primary entity for the booking

  • durationMinutesintegerrequired

    Required duration in minutes e.g. 60

  • startDatedate

    Earliest acceptable date (defaults to today) e.g. 2026-05-08

  • endDatedate

    Latest acceptable date (defaults to startDate + 7 days) e.g. 2026-05-15

  • maxResultsinteger

    Maximum slots to return (default 10, max 50)

Responses

200Ranked slots. Each carries a score (0-1) and any pre-allocated resources.
{
  "slots": [
    {
      "startTime": "2026-05-08T10:00:00Z",
      "endTime": "2026-05-08T11:00:00Z",
      "score": 0.95,
      "primaryEntityId": "ent_pt_9001",
      "availableResources": [
        {
          "resourceId": "res_van_2",
          "resourceType": "transport_vehicle"
        }
      ],
      "metadata": {
        "mergeOpportunity": false,
        "constraintsPassed": ["daily_hour_limit", "care_plan_alignment"]
      }
    },
    {
      "startTime": "2026-05-08T14:00:00Z",
      "endTime": "2026-05-08T15:00:00Z",
      "score": 0.88,
      "primaryEntityId": "ent_pt_9001",
      "metadata": {
        "mergeOpportunity": true,
        "existingEventIds": ["evt_pt_session_a"]
      }
    }
  ]
}

Create booking

POST/api/v1/bookings

Create a booking with full orchestration. Validates constraints, allocates resources atomically, dispatches notifications.

Headers

  • x-organization-idUUIDrequired

    Organization scope

  • x-template-idstringrequired

    Template ID

Request body

Required: eventType, title, startTime, endTime, primaryEntityId. allowConflicts defaults to false (the strict default).

{
  "eventType": "home_visit",
  "title": "Morning Home Visit",
  "description": "Routine morning care visit",
  "startTime": "2026-04-10T09:00:00Z",
  "endTime": "2026-04-10T10:00:00Z",
  "primaryEntityId": "ent_pt_9001",
  "location": {
    "latitude": 42.3601,
    "longitude": -71.0589,
    "address": "100 Summer Street, Boston, MA"
  },
  "participants": [
    { "entityId": "ent_staff_a8f4", "role": "provider", "isRequired": true }
  ],
  "resources": [
    { "entityId": "res_van_2", "resourceType": "transport_vehicle", "quantity": 1 }
  ],
  "allowConflicts": false
}

Responses

201Booking created with the resolved event
{
  "eventId": "evt_b29f4e58-...",
  "status": "scheduled",
  "eventType": "home_visit",
  "startTime": "2026-04-10T09:00:00Z",
  "endTime": "2026-04-10T10:00:00Z",
  "primaryEntityId": "ent_pt_9001",
  "participants": [...],
  "resources": [...],
  "createdAt": "2026-04-26T15:32:11Z"
}
400Request body failed validation (missing required fields, malformed time range, etc.)
409Constraint conflict — booking not created. Response details include the failing constraints and suggested alternatives.
{
  "statusCode": 409,
  "message": "Scheduling conflict detected",
  "error": "Conflict",
  "details": {
    "conflicts": [
      {
        "type": "daily_hour_limit",
        "message": "Daily hour limit of 8 hours would be exceeded",
        "currentHours": 7.5,
        "additionalHours": 1.0
      }
    ],
    "suggestions": [
      {
        "startTime": "2026-04-10T13:00:00Z",
        "endTime": "2026-04-10T14:00:00Z",
        "score": 0.82
      }
    ]
  }
}

Handling conflicts

A 409 from the bookings endpoint is structured to make recovery easy. The details.conflicts array names every failing constraint, and details.suggestions proposes alternative slots that would have passed.

Three common patterns:

  • Surface to the user — show the conflict message and suggestions, let the user pick an alternative
  • Auto-retry with the first suggestion — for systems where any nearby slot is acceptable
  • Set allowConflicts: true to override soft conflicts. This does not override hard constraints — those still block. Use sparingly; conflicts exist for reasons.

Don’t skip optimal-slots

Calling POST /bookings with a speculative time is fine, but you’ll get more 409s than necessary. Calling GET /bookings/optimal-slots first lets you pick a slot the engine has already vetted, then call create with confidence.