← capabilitiesscheduling.write

create_booking

booking.create_booking · v0.1.0

Create a confirmed appointment on a provider's calendar.

Semantics

Reserves a specific time slot for a named service with a named customer. The provider's calendar becomes blocked for the duration. The customer receives a confirmation. The booking is later addressable by `booking_id` for cancellation or status lookups.

Invariants

  • `start_at` must be strictly in the future at the time of the call.
  • `service_id` must be a service the provider currently offers.
  • If a booking with the same `(provider_id, service_id, start_at, customer.email)` was created within the previous 60 seconds, the same `booking_id` is returned and no second booking is persisted (idempotency window).
  • If the requested slot is no longer free at submit time, the call fails with `slot_taken` and returns the closest free slots from `available_alternatives`.
  • The booking's `end_at` is derived from the service's declared duration; callers do not specify it.

When to use

When the user has already chosen which service, which provider, and which time. If any of those is missing, call `check_availability` first.

Input schema

{
  "type": "object",
  "required": [
    "service_id",
    "start_at",
    "customer"
  ],
  "properties": {
    "notes": {
      "type": "string",
      "description": "Free-text note from customer to provider, max 1000 chars."
    },
    "customer": {
      "type": "object",
      "required": [
        "name",
        "email"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "phone": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "start_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 instant in UTC."
    },
    "service_id": {
      "type": "string",
      "description": "Provider-scoped service identifier from the provider's catalog (e.g. as returned by check_availability)."
    },
    "agent_vendor": {
      "type": "string",
      "description": "Self-identification of the calling agent (claude, chatgpt, cursor, ...). Optional but recommended."
    }
  },
  "additionalProperties": false
}

Output schema

{
  "type": "object",
  "required": [
    "ok"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "error": {
      "enum": [
        "slot_taken",
        "invalid_service",
        "past_time",
        "invalid_input"
      ],
      "type": "string"
    },
    "end_at": {
      "type": "string",
      "format": "date-time"
    },
    "service": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "customer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        }
      }
    },
    "start_at": {
      "type": "string",
      "format": "date-time"
    },
    "confirmed": {
      "type": "boolean"
    },
    "booking_id": {
      "type": "string"
    },
    "cancellation_url": {
      "type": "string",
      "format": "uri"
    },
    "available_alternatives": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "end_at": {
            "type": "string",
            "format": "date-time"
          },
          "start_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}

Recent conformance runs

passprovidertestmswhen
bookio:studio-sanghaidempotency_window30505-18 19:50
bookio:studio-sangharejects_unknown_service11705-18 19:50
bookio:studio-sangharejects_past_time005-18 19:50
bookio:studio-sanghahappy_path23605-18 19:50
bookio:verde-wellness-austinidempotency_window30405-18 19:50
bookio:verde-wellness-austinrejects_unknown_service10705-18 19:50
bookio:verde-wellness-austinrejects_past_time005-18 19:50
bookio:verde-wellness-austinhappy_path22305-18 19:50
bookio:bistro-modra-houbaidempotency_window36505-18 19:50
bookio:bistro-modra-houbarejects_unknown_service12205-18 19:50
bookio:bistro-modra-houbarejects_past_time005-18 19:50
bookio:bistro-modra-houbahappy_path27405-18 19:50
bookio:aurora-hair-brooklynidempotency_window28105-18 19:50
bookio:aurora-hair-brooklynrejects_unknown_service11405-18 19:50
bookio:aurora-hair-brooklynrejects_past_time005-18 19:50
bookio:aurora-hair-brooklynhappy_path24605-18 19:50
bookio:salon-auroraidempotency_window27505-18 19:50
bookio:salon-aurorarejects_unknown_service11505-18 19:50
bookio:salon-aurorarejects_past_time005-18 19:50
bookio:salon-aurorahappy_path27205-18 19:50
bookio:massage-relaxidempotency_window27805-18 19:50
bookio:massage-relaxrejects_unknown_service11105-18 19:50
bookio:massage-relaxrejects_past_time105-18 19:50
bookio:massage-relaxhappy_path25505-18 19:50
bookio:ink-quarter-portlandidempotency_window27205-18 19:50
bookio:ink-quarter-portlandrejects_unknown_service10905-18 19:50
bookio:ink-quarter-portlandrejects_past_time005-18 19:50
bookio:ink-quarter-portlandhappy_path24305-18 19:50
bookio:ink-houseidempotency_window36705-18 19:50
bookio:ink-houserejects_unknown_service12905-18 19:50
bookio:ink-houserejects_past_time005-18 19:50
bookio:ink-househappy_path30205-18 19:50
bookio:fitness-zelenaidempotency_window28305-18 19:50
bookio:fitness-zelenarejects_unknown_service11605-18 19:50
bookio:fitness-zelenarejects_past_time005-18 19:50
bookio:fitness-zelenahappy_path31405-18 19:50
bookio:dental-vinohradyidempotency_window29105-18 19:50
bookio:dental-vinohradyrejects_unknown_service14205-18 19:50
bookio:dental-vinohradyrejects_past_time005-18 19:50
bookio:dental-vinohradyhappy_path27005-18 19:50