{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mercantry-org/json-schema/mercantry-org-booking-status-schema.json",
  "title": "BookingStatus",
  "description": "Booking state machine position with structured outcome details.",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mercantry-org-openapi.json#/components/schemas/BookingStatus",
  "type": "object",
  "properties": {
    "booking_id": {
      "type": "string",
      "format": "uuid"
    },
    "merchant_id": {
      "type": "string",
      "format": "uuid"
    },
    "state": {
      "type": "string",
      "enum": [
        "pending",
        "queued",
        "in_progress",
        "needs_input",
        "confirmed",
        "failed",
        "cancelled"
      ]
    },
    "failure_reason": {
      "type": "string",
      "enum": [
        "no_answer",
        "fully_booked",
        "closed",
        "policy_mismatch",
        "merchant_declined",
        "bad_data",
        "expired_sla",
        "needs_input_timeout"
      ]
    },
    "requested_time": {
      "type": "string"
    },
    "window_minutes": {
      "type": "integer"
    },
    "party_size": {
      "type": "integer"
    },
    "confirmed_time": {
      "type": "string"
    },
    "confirmation_code": {
      "type": "string"
    },
    "merchant_instructions": {
      "type": "string"
    },
    "needs_input_options": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "time": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      },
      "description": "Merchant-offered alternatives awaiting the agent's decision (resolve via /v1/bookings/{id}/modify)."
    },
    "needs_input_deadline": {
      "type": "string"
    },
    "attempts": {
      "type": "integer"
    },
    "sla_deadline": {
      "type": "string",
      "description": "Terminal state guaranteed by this time (REQ-FUL-6)."
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    }
  }
}