{
  "openapi": "3.1.0",
  "info": {
    "title": "subba public API",
    "version": "1.0.0",
    "summary": "Read a business's services, open times, prices and details, and book for a person.",
    "description": "subba is an AI receptionist and booking system for small businesses. Every business that takes bookings or orders with subba has a public slug (the last part of its booking link, https://book.subba.pro/b/{slug}). These endpoints are public and need no credentials.\n\nTo book for a person, POST /api/b/{slug}/book with \"agent\": true, or call the MCP server's create_booking (POST /mcp): the same booking, under the same rules. Always confirm the exact service, time, price and business with the person first.\n\nPrices are in pence (GBP). Times are epoch milliseconds. Payments go to the business's own Stripe account.",
    "contact": {
      "name": "subba",
      "email": "hello@subba.pro",
      "url": "https://subba.pro/docs"
    }
  },
  "externalDocs": {
    "description": "AGENTS.md: how agents use subba",
    "url": "https://subba.pro/AGENTS.md"
  },
  "servers": [
    {
      "url": "https://api.subba.pro"
    }
  ],
  "tags": [
    {
      "name": "booking",
      "description": "Services and open times of a business."
    },
    {
      "name": "ordering",
      "description": "A business's order page price list."
    },
    {
      "name": "discovery",
      "description": "Machine-readable descriptions of a business or of all businesses."
    },
    {
      "name": "mcp",
      "description": "The MCP server: list services, check availability and book."
    }
  ],
  "paths": {
    "/api/b/{slug}/services": {
      "get": {
        "tags": [
          "booking"
        ],
        "operationId": "listServices",
        "summary": "List a business's bookable services",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "responses": {
          "200": {
            "description": "The business and its bookable services.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceList"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/b/{slug}/slots": {
      "get": {
        "tags": [
          "booking"
        ],
        "operationId": "getAvailability",
        "summary": "Get open times for a service on a date",
        "description": "Appointments and jobs return open start times. Classes return upcoming sessions with places left (the date is ignored).",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          },
          {
            "name": "service",
            "in": "query",
            "required": true,
            "description": "A service id from listServices.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "The day, YYYY-MM-DD, in the business's time zone. Defaults to today.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "party",
            "in": "query",
            "required": false,
            "description": "How many people, for a table booking. Only times with a table that seats them are returned. Defaults to 1.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "description": "Only this team member's (or table's) times.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Open start times, or class sessions.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Slots"
                    },
                    {
                      "$ref": "#/components/schemas/Sessions"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/b/{slug}/book": {
      "post": {
        "tags": [
          "booking"
        ],
        "operationId": "createBooking",
        "summary": "Book a service for a person (as an AI agent)",
        "description": "Send \"agent\": true. Without it this is the booking page's own endpoint, which needs the customer's consent tick and a bot check only a person can pass (403 bot_check_failed). Agent bookings follow the MCP server's create_booking rules: a business can turn them off (agent_booking_disabled), they are limited to 50 per business and 5 per customer email a day (409 rate_limited) and 6 a minute per address (429 rate_limited), and the customer gets no email for a free booking, so give them the details and manageUrl. When the service is paid online, send them to checkoutUrl; the booking is held while they pay.",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingRequest"
              },
              "example": {
                "agent": true,
                "service": "svc_1",
                "start": 1796212800000,
                "name": "Sam Lee",
                "email": "sam@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Booked: confirmed, or held until paid at checkoutUrl.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingResult"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or wrong (name_required, invalid_email, invalid_phone, invalid_json).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "bot_check_failed: sent without \"agent\": true.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Not booked: slot_taken, session_full, agent_booking_disabled, rate_limited, bookings_off, payment_unavailable or code (with a message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 6 agent bookings a minute from one address.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/b/{slug}/menu": {
      "get": {
        "tags": [
          "ordering"
        ],
        "operationId": "getMenu",
        "summary": "Get a business's order page price list",
        "description": "Exactly what the business's order page shows. A choice's price is what it adds to the item. Open to any site (CORS), cached for a minute. Not found when the business does not take orders.",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "responses": {
          "200": {
            "description": "The price list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Menu"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/b/{slug}/info.json": {
      "get": {
        "tags": [
          "discovery"
        ],
        "operationId": "getBusinessInfo",
        "summary": "Get a business's public details",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "responses": {
          "200": {
            "description": "Name, address, phone, opening hours, website and time zone.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessInfo"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/b/{slug}/ai2w": {
      "get": {
        "tags": [
          "discovery"
        ],
        "operationId": "getBusinessManifest",
        "summary": "Get a business's AI2Web manifest",
        "description": "How an agent can discover and book this business: its endpoints, consent rules and how payments settle.",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "responses": {
          "200": {
            "description": "The AI2Web manifest.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/acp/feed.jsonl": {
      "get": {
        "tags": [
          "discovery"
        ],
        "operationId": "getProductFeed",
        "summary": "Get the product feed of every business (Agentic Commerce Protocol)",
        "description": "Each bookable service as a product, one JSON object per line.",
        "responses": {
          "200": {
            "description": "The feed.",
            "content": {
              "application/jsonl": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/b/{slug}/acp/feed.jsonl": {
      "get": {
        "tags": [
          "discovery"
        ],
        "operationId": "getBusinessProductFeed",
        "summary": "Get one business's product feed (Agentic Commerce Protocol)",
        "parameters": [
          {
            "$ref": "#/components/parameters/slug"
          }
        ],
        "responses": {
          "200": {
            "description": "The feed.",
            "content": {
              "application/jsonl": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "get": {
        "tags": [
          "mcp"
        ],
        "operationId": "getMcpInfo",
        "summary": "Get the MCP server's details and tools",
        "responses": {
          "200": {
            "description": "Server details and the tool list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "mcp"
        ],
        "operationId": "callMcp",
        "summary": "Call the MCP server (JSON-RPC 2.0, Streamable HTTP, stateless)",
        "description": "Tools: list_services (slug), check_availability (slug, service, optional date and party), create_booking (slug, service, start or sessionId, name, email, optional phone, party and notes). create_booking returns a Stripe checkout URL when the service needs paying. Confirm every detail with the person before booking. Limits: 50 agent bookings per business and 5 per customer email a day; a business can turn agent booking off.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "tools/call",
                "params": {
                  "name": "list_services",
                  "arguments": {
                    "slug": "example-salon"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/server-card": {
      "get": {
        "tags": [
          "mcp"
        ],
        "operationId": "getMcpServerCard",
        "summary": "Get the MCP server card",
        "responses": {
          "200": {
            "description": "The server card.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "slug": {
        "name": "slug",
        "in": "path",
        "required": true,
        "description": "The business's booking slug, from its booking link https://book.subba.pro/b/{slug}.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "NotFound": {
        "description": "No such business, or not something it offers.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Service": {
        "type": "object",
        "required": [
          "id",
          "name",
          "type",
          "duration",
          "price",
          "currency",
          "requiresPayment"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "appointment",
              "class",
              "job"
            ]
          },
          "duration": {
            "type": "integer",
            "description": "Minutes."
          },
          "price": {
            "type": "integer",
            "description": "Pence."
          },
          "currency": {
            "type": "string"
          },
          "requiresPayment": {
            "type": "boolean",
            "description": "Paid online when booked."
          },
          "deposit": {
            "type": "integer",
            "description": "Pence taken when booked, when not the full price."
          },
          "perPerson": {
            "type": "boolean"
          },
          "category": {
            "type": "string"
          },
          "turnaround": {
            "type": "integer",
            "description": "Minutes kept free after each booking."
          },
          "options": {
            "type": "array",
            "description": "Choices the customer makes, which can change the price and length.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ServiceList": {
        "type": "object",
        "required": [
          "business",
          "services"
        ],
        "properties": {
          "business": {
            "type": "string"
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "maxParty": {
            "type": "integer",
            "description": "The most people one booking can be for."
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Service"
            }
          }
        }
      },
      "Slots": {
        "type": "object",
        "required": [
          "type",
          "slots"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "appointment",
              "job"
            ]
          },
          "slots": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "start",
                "resourceId"
              ],
              "properties": {
                "start": {
                  "type": "integer",
                  "description": "Epoch ms."
                },
                "resourceId": {
                  "type": "string",
                  "description": "Who (or which table) is free then."
                }
              }
            }
          }
        }
      },
      "Sessions": {
        "type": "object",
        "required": [
          "type",
          "sessions"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "class"
          },
          "sessions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "start",
                "left"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "start": {
                  "type": "integer",
                  "description": "Epoch ms."
                },
                "left": {
                  "type": "integer",
                  "description": "Places left."
                },
                "with": {
                  "type": "string",
                  "description": "Who teaches it."
                }
              }
            }
          }
        }
      },
      "Menu": {
        "type": "object",
        "required": [
          "business",
          "currency",
          "items"
        ],
        "properties": {
          "business": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "section": {
                  "type": "string"
                },
                "price": {
                  "type": "integer",
                  "description": "Pence."
                },
                "soldOut": {
                  "type": "boolean"
                },
                "options": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "any": {
                        "type": "boolean",
                        "description": "Pick any number, else exactly one."
                      },
                      "choices": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "price": {
                              "type": "integer",
                              "description": "Pence added."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "BusinessInfo": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "business_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "opening_hours": {
            "type": [
              "array",
              "null"
            ]
          },
          "google_review_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "website_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": "string"
          }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "type": [
              "integer",
              "string"
            ]
          },
          "method": {
            "type": "string",
            "examples": [
              "initialize",
              "tools/list",
              "tools/call"
            ]
          },
          "params": {
            "type": "object"
          }
        }
      },
      "BookingRequest": {
        "type": "object",
        "required": [
          "agent",
          "service",
          "name",
          "email"
        ],
        "properties": {
          "agent": {
            "type": "boolean",
            "const": true,
            "description": "An AI agent booking for a person."
          },
          "service": {
            "type": "string",
            "description": "A service id from listServices."
          },
          "start": {
            "type": "integer",
            "description": "Epoch ms, one of the open times (appointments and jobs)."
          },
          "sessionId": {
            "type": "string",
            "description": "A class session id from getAvailability (classes)."
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "description": "Optional."
          },
          "party": {
            "type": "integer",
            "minimum": 1,
            "description": "How many people, for a table booking."
          },
          "notes": {
            "type": "string",
            "description": "Kept only when the business asks for booking notes."
          },
          "resourceId": {
            "type": "string",
            "description": "A team member (or table) from getAvailability. Else the free one for that time."
          }
        }
      },
      "BookingResult": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "bookingId": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe Checkout, when the service is paid online."
          },
          "confirmed": {
            "type": "boolean"
          },
          "manageUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the person can change or cancel it."
          }
        }
      }
    }
  }
}
