{
  "openapi": "3.1.0",
  "info": {
    "title": "Kllivo Public API",
    "version": "1.0.0",
    "description": "Machine-readable contract for the supported Kllivo v1 public API and outbound webhook event envelopes. Request and response prices are always calculated by Kllivo. Webhook destinations are configured in the developer dashboard; signing and retry rules are documented in docs/PUBLIC_API.md."
  },
  "servers": [{ "url": "https://kllivoapp.com", "description": "Production API" }],
  "tags": [
    { "name": "Connection" }, { "name": "Store data" }, { "name": "Ordering" },
    { "name": "Delivery" }, { "name": "Checkout" }, { "name": "Location helper" }
  ],
  "security": [{ "KllivoOAuth": [] }],
  "paths": {
    "/api/v1/oauth/token": {
      "post": {
        "tags": ["Connection"], "summary": "Exchange an authorization code or rotate a refresh token", "operationId": "oauthToken", "security": [],
        "description": "Authorization codes are single-use and expire after 60 seconds. PKCE S256 is required. Confidential apps authenticate with HTTP Basic or client_id/client_secret form fields. Refresh tokens rotate on every successful refresh.",
        "requestBody": { "required": true, "content": { "application/x-www-form-urlencoded": { "schema": { "oneOf": [{ "$ref": "#/components/schemas/AuthorizationCodeRequest" }, { "$ref": "#/components/schemas/RefreshTokenRequest" }] } }, "application/json": { "schema": { "oneOf": [{ "$ref": "#/components/schemas/AuthorizationCodeRequest" }, { "$ref": "#/components/schemas/RefreshTokenRequest" }] } } } },
        "responses": { "200": { "description": "Access and refresh token pair", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenResponse" } } } }, "400": { "$ref": "#/components/responses/OAuthError" }, "401": { "$ref": "#/components/responses/OAuthError" } }
      }
    },
    "/api/v1/oauth/revoke": {
      "post": {
        "tags": ["Connection"], "summary": "Revoke an access or refresh token", "operationId": "oauthRevoke", "security": [],
        "requestBody": { "required": true, "content": { "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/RevokeTokenRequest" } }, "application/json": { "schema": { "$ref": "#/components/schemas/RevokeTokenRequest" } } } },
        "responses": { "200": { "description": "Token revoked or already invalid", "content": { "application/json": { "schema": { "type": "array", "maxItems": 0 } } } }, "400": { "$ref": "#/components/responses/OAuthError" } }
      }
    },
    "/api/v1/connection": {
      "get": {
        "tags": ["Connection"], "summary": "Inspect this connection", "operationId": "getConnection",
        "responses": { "200": { "description": "App connection and granted access", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConnectionResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/menu": {
      "get": {
        "tags": ["Store data"], "summary": "Read the connected restaurant menu", "operationId": "getMenu", "security": [{ "KllivoOAuth": ["menu:read"] }],
        "responses": { "200": { "description": "Active categories and visible menu items", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MenuResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/storefront": {
      "get": {
        "tags": ["Store data"], "summary": "Read public restaurant and authorized branch data", "operationId": "getStorefront", "security": [{ "KllivoOAuth": ["store:read"] }],
        "responses": { "200": { "description": "Whitelisted storefront information", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StorefrontResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/payment-options": {
      "get": {
        "tags": ["Store data"], "summary": "List enabled customer payment and delivery choices", "operationId": "getPaymentOptions", "security": [{ "KllivoOAuth": ["store:read"] }],
        "parameters": [
          { "name": "order_type", "in": "query", "schema": { "type": "string", "enum": ["pickup", "delivery"], "default": "pickup" } },
          { "name": "branch_id", "in": "query", "schema": { "type": "integer", "minimum": 1 } },
          { "name": "subtotal", "in": "query", "description": "Preview only; server recalculates on order submission.", "schema": { "type": "number", "minimum": 0 } }
        ],
        "responses": { "200": { "description": "Customer-facing enabled choices", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PaymentOptionsResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/discounts/validate": {
      "post": {
        "tags": ["Ordering"], "summary": "Preview a coupon against a server-priced cart", "operationId": "validateDiscount", "security": [{ "KllivoOAuth": ["store:read"] }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DiscountValidationRequest" } } } },
        "responses": { "200": { "description": "Coupon preview (not a reservation)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DiscountValidationResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/delivery-quotes/logix": {
      "post": {
        "tags": ["Delivery"], "summary": "Get a single-use LogiX delivery quote", "operationId": "quoteLogixDelivery", "security": [{ "KllivoOAuth": ["store:read"] }],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LogixQuoteRequest" } } } },
        "responses": { "200": { "description": "Quote valid for 15 minutes", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LogixQuoteResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "401": { "$ref": "#/components/responses/ApiError" }, "409": { "$ref": "#/components/responses/ApiError" }, "422": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/delivery-quotes/courier": {
      "post": {
        "tags": ["Delivery"], "summary": "Get a single-use quote from a connected courier", "operationId": "quoteCourierDelivery", "security": [{ "KllivoOAuth": ["store:read"] }],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CourierQuoteRequest" } } } },
        "responses": { "200": { "description": "Quote valid for 15 minutes", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CourierQuoteResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "401": { "$ref": "#/components/responses/ApiError" }, "409": { "$ref": "#/components/responses/ApiError" }, "422": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/orders": {
      "post": {
        "tags": ["Ordering"], "summary": "Submit an order directly to the connected restaurant", "operationId": "submitOrder", "security": [{ "KllivoOAuth": ["orders:submit"] }],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderRequest" }, "examples": {
          "pickupCash": { "summary": "Pickup with cash at pickup", "value": { "order_type": "pickup", "items": [{ "menu_item_id": 19, "quantity": 1 }], "customer": { "name": "Sam", "phone": "+355691234567" }, "payment_method": "pay_on_pickup", "channel": "whatsapp" } },
          "pickupOnline": { "summary": "Pickup with hosted online payment", "value": { "order_type": "pickup", "items": [{ "menu_item_id": 19, "quantity": 1 }], "customer": { "name": "Sam", "phone": "+355691234567" }, "payment_method": "stripe", "return_payment_url": true } },
          "fixedDelivery": { "summary": "Fixed-fee delivery", "value": { "order_type": "delivery", "items": [{ "menu_item_id": 19, "quantity": 1 }], "customer": { "name": "Sam", "phone": "+355691234567", "address": "12 Main Street, Tirana" }, "branch_id": 3, "delivery_option_id": 4, "payment_method": "cash_on_delivery" } },
          "quotedDelivery": { "summary": "Courier-quoted delivery", "value": { "order_type": "delivery", "items": [{ "menu_item_id": 19, "quantity": 1 }], "customer": { "name": "Sam", "phone": "+355691234567", "address": "12 Main Street, Tirana" }, "branch_id": 3, "delivery_quote_token": "<quote_token>", "payment_method": "cash_on_delivery" } },
          "configuredItem": { "summary": "Variant, extra and coupon", "value": { "order_type": "pickup", "items": [{ "menu_item_id": 19, "quantity": 1, "variant_id": "small", "extra_ids": ["extra-cheese"] }], "customer": { "name": "Sam", "phone": "+355691234567" }, "discount_code": "SAVE10", "payment_method": "pay_on_pickup" } }
        } } } },
        "responses": { "201": { "description": "Order created before online payment is completed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" }, "409": { "$ref": "#/components/responses/ApiError" }, "422": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/orders/{order_number}": {
      "get": {
        "tags": ["Ordering"], "summary": "Read order status without customer contact details", "operationId": "getOrderStatus", "description": "Use as a reconciliation fallback to signed order webhooks. Honor Retry-After. Stop when fulfillment status is delivered or cancelled.", "security": [{ "KllivoOAuth": ["orders:submit"] }],
        "parameters": [{ "name": "order_number", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "App-scoped order status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderStatusResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" }, "404": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/order-links": {
      "post": {
        "tags": ["Checkout"], "summary": "Create a hosted checkout link", "operationId": "createOrderLink", "security": [{ "KllivoOAuth": ["orders:link"] }],
        "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderLinkRequest" } } } },
        "responses": { "201": { "description": "Checkout session created; order is created after checkout submission", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderLinkResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "401": { "$ref": "#/components/responses/ApiError" }, "403": { "$ref": "#/components/responses/ApiError" }, "409": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/v1/order-links/{id}": {
      "get": {
        "tags": ["Checkout"], "summary": "Read a checkout link status", "operationId": "getOrderLinkStatus", "security": [{ "KllivoOAuth": ["orders:link"] }],
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1 } }],
        "responses": { "200": { "description": "Checkout link and safe completed order summary", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderLinkStatusResponse" } } } }, "401": { "$ref": "#/components/responses/ApiError" }, "404": { "$ref": "#/components/responses/ApiError" } }
      }
    },
    "/api/delivery-integrations/reverse-geocode": {
      "post": {
        "tags": ["Location helper"], "summary": "Resolve a customer pin into an address and signed location token", "operationId": "reverseGeocodeLocation", "security": [],
        "description": "Public checkout helper outside the OAuth v1 API. The opaque location token expires after 30 minutes. GPS accuracy must be positive and at most 75 metres; map_pin ignores accuracy.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReverseGeocodeRequest" } } } },
        "responses": { "200": { "description": "Legacy helper response envelope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReverseGeocodeResponse" } } } }, "400": { "$ref": "#/components/responses/ApiError" }, "422": { "$ref": "#/components/responses/ApiError" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "KllivoOAuth": { "type": "oauth2", "description": "OAuth 2.0 authorization code flow with required PKCE S256. Access tokens last one hour. Store tokens and client secrets on your server.", "flows": { "authorizationCode": { "authorizationUrl": "https://kllivoapp.com/connect", "tokenUrl": "https://kllivoapp.com/api/v1/oauth/token", "refreshUrl": "https://kllivoapp.com/api/v1/oauth/token", "scopes": { "menu:read": "Read the connected restaurant menu", "store:read": "Read storefront, choices, discounts and delivery quotes", "orders:link": "Create hosted checkout links and read their status", "orders:submit": "Submit orders and read their status" } } } }
    },
    "parameters": {
      "IdempotencyKey": { "name": "Idempotency-Key", "in": "header", "required": true, "description": "8–64 characters from A–Z, a–z, 0–9, underscore, hyphen, colon, or period. Replay only the same body with the same key; use a new key for a new quote/order attempt.", "schema": { "type": "string", "minLength": 8, "maxLength": 64, "pattern": "^[A-Za-z0-9_:.\\-]{8,64}$" } }
    },
    "responses": {
      "ApiError": { "description": "API error envelope.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiErrorResponse" } } } },
      "OAuthError": { "description": "OAuth error response.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OAuthErrorResponse" } } } }
    },
    "schemas": {
      "ApiErrorResponse": { "type": "object", "required": ["error", "request_id"], "properties": { "error": { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "details": { "type": ["object", "array", "null"], "additionalProperties": true } } }, "request_id": { "type": "string" } } },
      "OAuthErrorResponse": { "type": "object", "required": ["error", "error_description"], "properties": { "error": { "type": "string" }, "error_description": { "type": "string" } } },
      "AuthorizationCodeRequest": { "type": "object", "required": ["grant_type", "client_id", "code", "redirect_uri", "code_verifier"], "properties": { "grant_type": { "const": "authorization_code" }, "client_id": { "type": "string" }, "client_secret": { "type": "string", "writeOnly": true }, "code": { "type": "string" }, "redirect_uri": { "type": "string", "format": "uri" }, "code_verifier": { "type": "string", "minLength": 43, "maxLength": 128 } }, "additionalProperties": false },
      "RefreshTokenRequest": { "type": "object", "required": ["grant_type", "client_id", "refresh_token"], "properties": { "grant_type": { "const": "refresh_token" }, "client_id": { "type": "string" }, "client_secret": { "type": "string", "writeOnly": true }, "refresh_token": { "type": "string", "writeOnly": true } }, "additionalProperties": false },
      "RevokeTokenRequest": { "type": "object", "required": ["token", "client_id"], "properties": { "token": { "type": "string", "writeOnly": true }, "client_id": { "type": "string" }, "client_secret": { "type": "string", "writeOnly": true }, "token_type_hint": { "type": "string", "enum": ["access_token", "refresh_token"] } }, "additionalProperties": false },
      "TokenResponse": { "type": "object", "required": ["access_token", "token_type", "expires_in", "refresh_token", "refresh_expires_in", "restaurant_id", "scope"], "properties": { "access_token": { "type": "string", "writeOnly": true }, "token_type": { "const": "Bearer" }, "expires_in": { "type": "integer", "const": 3600 }, "refresh_token": { "type": "string", "writeOnly": true }, "refresh_expires_in": { "type": "integer" }, "restaurant_id": { "type": "integer" }, "branch_ids": { "type": ["array", "null"], "items": { "type": "integer" } }, "scope": { "type": "string" } } },
      "ConnectionResponse": { "$ref": "#/components/schemas/EnvelopeConnection" },
      "EnvelopeConnection": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "additionalProperties": true }, "request_id": { "type": "string" } } },
      "MenuResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["currency", "categories", "items"], "properties": { "currency": { "$ref": "#/components/schemas/Currency" }, "categories": { "type": "array", "items": { "$ref": "#/components/schemas/MenuCategory" } }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/MenuItem" } } } }, "request_id": { "type": "string" } } },
      "Currency": { "type": "object", "required": ["code", "symbol"], "properties": { "code": { "type": ["string", "null"] }, "symbol": { "type": ["string", "null"] } } },
      "MenuCategory": { "type": "object", "required": ["id", "name", "description", "sort_order"], "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "description": { "type": ["string", "null"] }, "sort_order": { "type": "integer" } } },
      "MenuItem": { "type": "object", "required": ["id", "category_id", "name", "price", "base_price", "available", "variants", "extras"], "properties": { "id": { "type": "integer" }, "category_id": { "type": ["integer", "null"] }, "name": { "type": "string" }, "description": { "type": ["string", "null"] }, "sku": { "type": ["string", "null"] }, "price": { "type": "number" }, "base_price": { "type": "number" }, "image": { "type": ["string", "null"], "format": "uri" }, "images": { "type": "array", "items": { "type": "string" } }, "allergens": { "type": "array", "items": {} }, "prep_time_minutes": { "type": ["integer", "null"] }, "available": { "type": "boolean" }, "variants": { "type": "array", "items": { "$ref": "#/components/schemas/MenuVariant" } }, "extras": { "type": "array", "items": { "$ref": "#/components/schemas/MenuExtra" } } } },
      "MenuVariant": { "type": "object", "required": ["id", "name", "price_adjustment"], "properties": { "id": { "type": ["string", "integer"] }, "name": { "type": "string" }, "price_adjustment": { "type": "number" } } },
      "MenuExtra": { "type": "object", "required": ["id", "name", "price", "required"], "properties": { "id": { "type": ["string", "integer"] }, "name": { "type": "string" }, "price": { "type": "number" }, "required": { "type": "boolean" } } },
      "StorefrontResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["restaurant"], "properties": { "restaurant": { "$ref": "#/components/schemas/Restaurant" } } }, "request_id": { "type": "string" } } },
      "Restaurant": { "type": "object", "required": ["id", "name", "slug", "currency", "minimum_order_amount", "default_language", "hours", "branches"], "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "slug": { "type": "string" }, "currency": { "$ref": "#/components/schemas/Currency" }, "minimum_order_amount": { "type": "number" }, "default_language": { "type": "string" }, "hours": { "type": "object", "additionalProperties": true }, "branches": { "type": "array", "items": { "$ref": "#/components/schemas/Branch" } } } },
      "Branch": { "type": "object", "required": ["id", "name", "address", "city", "country", "latitude", "longitude", "hours", "is_main"], "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "address": { "type": ["string", "null"] }, "city": { "type": ["string", "null"] }, "country": { "type": ["string", "null"] }, "latitude": { "type": ["number", "null"] }, "longitude": { "type": ["number", "null"] }, "hours": { "type": "object", "additionalProperties": true }, "is_main": { "type": "boolean" } } },
      "PaymentOptionsResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["payment_methods", "delivery"], "properties": { "payment_methods": { "type": "array", "items": { "$ref": "#/components/schemas/PaymentMethod" } }, "delivery": { "oneOf": [{ "$ref": "#/components/schemas/DeliveryChoices" }, { "type": "null" }] } } }, "request_id": { "type": "string" } } },
      "PaymentMethod": { "type": "object", "required": ["type", "id", "name"], "properties": { "type": { "type": "string", "enum": ["online", "manual", "offline"] }, "id": { "type": "string" }, "name": { "type": "string" } } },
      "DeliveryChoices": { "type": "object", "required": ["options", "quoted_options", "note"], "properties": { "options": { "type": "array", "items": { "$ref": "#/components/schemas/FixedDeliveryOption" } }, "quoted_options": { "type": "array", "items": { "oneOf": [{ "$ref": "#/components/schemas/LogixDeliveryOption" }, { "$ref": "#/components/schemas/CourierDeliveryOption" }] } }, "note": { "type": ["string", "null"] } } },
      "FixedDeliveryOption": { "type": "object", "required": ["id", "name", "description", "type", "fee", "min_order", "estimated_time", "meets_minimum"], "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "description": { "type": ["string", "null"] }, "type": { "type": "string", "description": "Restaurant-configured delivery type; values depend on configuration." }, "fee": { "type": ["number", "null"] }, "min_order": { "type": ["number", "null"] }, "estimated_time": { "type": ["string", "null"] }, "meets_minimum": { "type": "boolean" } } },
      "LogixDeliveryOption": { "type": "object", "required": ["id", "name", "type", "quote_required"], "properties": { "id": { "const": "logix" }, "name": { "type": "string" }, "type": { "const": "logix" }, "quote_required": { "const": true } } },
      "CourierDeliveryOption": { "type": "object", "required": ["id", "partner_id", "name", "description", "type", "quote_required"], "properties": { "id": { "type": "string", "pattern": "^courier-" }, "partner_id": { "type": "integer" }, "name": { "type": "string" }, "description": { "type": ["string", "null"] }, "type": { "const": "courier" }, "quote_required": { "const": true } } },
      "OrderLineInput": { "type": "object", "required": ["menu_item_id"], "properties": { "menu_item_id": { "type": "integer", "minimum": 1 }, "quantity": { "type": "integer", "minimum": 1, "maximum": 99, "default": 1 }, "variant_id": { "type": ["string", "integer"], "description": "Required if this menu item defines variants; rejected when it does not." }, "extra_ids": { "type": "array", "maxItems": 30, "items": { "type": ["string", "integer"] }, "description": "Include every menu extra marked required." }, "note": { "type": "string", "maxLength": 200 } }, "additionalProperties": false },
      "CustomerInput": { "type": "object", "required": ["name", "phone"], "properties": { "name": { "type": "string", "maxLength": 100 }, "phone": { "type": "string", "minLength": 6, "maxLength": 30 }, "email": { "type": "string", "format": "email" }, "address": { "type": "string", "maxLength": 500, "description": "Required for delivery; omit for pickup unless needed." } }, "additionalProperties": false },
      "OrderRequest": { "type": "object", "required": ["order_type", "items", "customer", "payment_method"], "properties": { "order_type": { "type": "string", "enum": ["pickup", "delivery"] }, "items": { "type": "array", "minItems": 1, "maxItems": 40, "items": { "$ref": "#/components/schemas/OrderLineInput" } }, "customer": { "$ref": "#/components/schemas/CustomerInput" }, "payment_method": { "type": "string", "description": "Enabled ID returned by GET /api/v1/payment-options." }, "branch_id": { "type": "integer", "minimum": 1, "description": "Conditionally required for multi-branch or restricted grants." }, "delivery_option_id": { "type": "integer", "minimum": 1, "description": "Fixed-fee option ID; mutually exclusive with delivery_quote_token." }, "delivery_quote_token": { "type": "string", "description": "Single-use token returned by a delivery quote; send the exact quoted dropoff address in customer.address." }, "discount_code": { "type": "string" }, "channel": { "type": "string", "enum": ["api", "web", "whatsapp", "qr"], "default": "api" }, "locale": { "type": "string", "default": "en" }, "source": { "type": "string", "minLength": 2, "maxLength": 40, "pattern": "^[a-z0-9_]+$", "default": "api_order" }, "external_ref": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Printable ASCII identifier unique per app." }, "return_payment_url": { "type": "boolean", "default": false }, "special_instructions": { "type": "string" }, "note": { "type": "string" } }, "allOf": [{ "if": { "properties": { "order_type": { "const": "delivery" } } }, "then": { "required": ["customer"], "properties": { "customer": { "required": ["name", "phone", "address"] } }, "anyOf": [{ "required": ["delivery_option_id"] }, { "required": ["delivery_quote_token"] }] } }], "additionalProperties": false },
      "DiscountValidationRequest": { "type": "object", "required": ["code", "items"], "properties": { "code": { "type": "string" }, "items": { "type": "array", "minItems": 1, "maxItems": 40, "items": { "$ref": "#/components/schemas/OrderLineInput" } }, "order_type": { "type": "string", "enum": ["pickup", "delivery"], "default": "pickup" }, "branch_id": { "type": "integer", "minimum": 1 }, "channel": { "type": "string", "enum": ["web", "whatsapp", "qr"], "default": "web" } }, "additionalProperties": false },
      "DiscountValidationResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["code", "type", "value", "discount_amount", "free_delivery", "subtotal", "minimum_order", "total_after_discount"], "properties": { "code": { "type": "string" }, "type": { "type": "string" }, "value": { "type": "number" }, "discount_amount": { "type": "number" }, "free_delivery": { "type": "boolean" }, "subtotal": { "type": "number" }, "minimum_order": { "type": "number" }, "total_after_discount": { "type": "number", "description": "Item subtotal after discount; tax and delivery are not included." } } }, "request_id": { "type": "string" } } },
      "LogixQuoteRequest": { "type": "object", "required": ["dropoff_address"], "properties": { "dropoff_address": { "type": "string", "minLength": 8, "maxLength": 500 }, "branch_id": { "type": "integer", "minimum": 1 } }, "additionalProperties": false },
      "LogixQuoteResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["quote_token", "dropoff_address", "price", "currency", "distance_km", "expires_at", "name", "estimated_time"], "properties": { "quote_token": { "type": "string", "pattern": "^[a-f0-9]{48}$" }, "dropoff_address": { "type": "string" }, "price": { "type": "number" }, "currency": { "type": "string" }, "distance_km": { "type": ["number", "null"] }, "expires_at": { "type": "string", "format": "date-time" }, "name": { "type": "string" }, "estimated_time": { "type": ["string", "null"] } } }, "request_id": { "type": "string" } } },
      "CourierQuoteRequest": { "type": "object", "required": ["partner_id", "dropoff_address"], "properties": { "partner_id": { "type": "integer", "minimum": 1, "description": "Read from the chosen courier entry in GET /api/v1/payment-options." }, "branch_id": { "type": "integer", "minimum": 1 }, "dropoff_address": { "type": "string", "minLength": 8, "maxLength": 500 }, "location_token": { "type": "string", "description": "Optional opaque signed token from the public reverse-geocode helper." }, "location_token_address": { "type": "string", "description": "Original address returned with location_token, when dropoff_address was edited." } }, "additionalProperties": false },
      "CourierQuoteResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["quote_token", "dropoff_address", "price", "currency", "distance_km", "route_distance_km", "duration_minutes", "expires_at", "partner_id", "name"], "properties": { "quote_token": { "type": "string", "pattern": "^[a-f0-9]{48}$" }, "dropoff_address": { "type": "string" }, "price": { "type": "number" }, "currency": { "type": "string" }, "distance_km": { "type": ["number", "null"] }, "route_distance_km": { "type": ["number", "null"] }, "duration_minutes": { "type": ["integer", "null"] }, "expires_at": { "type": "string", "format": "date-time" }, "partner_id": { "type": "integer" }, "name": { "type": "string" }, "logo_url": { "type": ["string", "null"], "format": "uri" } } }, "request_id": { "type": "string" } } },
      "OrderResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "$ref": "#/components/schemas/OrderCreated" }, "request_id": { "type": "string" } } },
      "OrderCreated": { "type": "object", "required": ["order_number", "status", "payment_status", "payment_method", "order_type", "branch_id", "items", "subtotal", "tax_amount", "delivery_fee", "discount_amount", "total"], "properties": { "order_number": { "type": "string" }, "status": { "$ref": "#/components/schemas/FulfillmentStatus" }, "payment_status": { "$ref": "#/components/schemas/PaymentStatus" }, "payment_method": { "type": "string" }, "order_type": { "type": "string", "enum": ["pickup", "delivery"] }, "branch_id": { "type": ["integer", "null"] }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderLineResult" } }, "subtotal": { "type": "number" }, "tax_amount": { "type": "number" }, "delivery_fee": { "type": "number" }, "discount_amount": { "type": "number" }, "total": { "type": "number" }, "payment_url": { "type": "string", "format": "uri", "description": "Present only when requested and supported for this positive-total online order." } } },
      "OrderLineResult": { "type": "object", "required": ["menu_item_id", "name", "quantity", "unit_price", "total_price"], "properties": { "menu_item_id": { "type": "integer" }, "name": { "type": "string" }, "quantity": { "type": "integer" }, "unit_price": { "type": "number" }, "total_price": { "type": "number" }, "variant_name": { "type": ["string", "null"] }, "extras": { "description": "Current handler serializes selected extras as JSON text; empty extras may be null.", "oneOf": [{ "type": "array", "items": {} }, { "type": ["string", "null"] }] }, "special_instructions": { "type": ["string", "null"] } } },
      "FulfillmentStatus": { "type": "string", "enum": ["pending", "received", "confirmed", "preparing", "ready", "out_for_delivery", "delivered", "cancelled"] },
      "PaymentStatus": { "type": "string", "enum": ["pending", "paid", "failed", "refunded"] },
      "OrderStatusResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["order_number", "order_type", "status", "payment_status", "payment_method", "subtotal", "tax_amount", "delivery_fee", "discount_amount", "total"], "properties": { "order_number": { "type": "string" }, "order_type": { "type": "string", "enum": ["pickup", "delivery"] }, "status": { "$ref": "#/components/schemas/FulfillmentStatus" }, "payment_status": { "$ref": "#/components/schemas/PaymentStatus" }, "payment_method": { "type": "string" }, "subtotal": { "type": "number" }, "tax_amount": { "type": "number" }, "delivery_fee": { "type": "number" }, "discount_amount": { "type": "number" }, "total": { "type": "number" }, "created_at": { "type": ["string", "null"], "format": "date-time" }, "updated_at": { "type": ["string", "null"], "format": "date-time" } } }, "request_id": { "type": "string" } } },
      "OrderLinkRequest": { "type": "object", "required": ["items", "order_type"], "properties": { "items": { "type": "array", "minItems": 1, "maxItems": 40, "items": { "$ref": "#/components/schemas/OrderLineInput" } }, "order_type": { "type": "string", "enum": ["pickup", "delivery"] }, "customer": { "$ref": "#/components/schemas/CustomerInput" }, "branch_id": { "type": "integer", "minimum": 1 }, "discount_code": { "type": "string" }, "channel": { "type": "string", "enum": ["web", "whatsapp", "qr"], "default": "web" }, "source": { "type": "string", "pattern": "^[a-z][a-z0-9_]{1,39}$", "default": "api" }, "locale": { "type": "string", "pattern": "^[a-z]{2}(-[A-Za-z]{2})?$" }, "external_ref": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Printable ASCII identifier." }, "expires_in_minutes": { "type": "integer", "minimum": 5, "maximum": 4320, "default": 1440 } }, "additionalProperties": false },
      "OrderLinkResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "properties": { "id": { "type": "integer" }, "url": { "type": "string", "format": "uri" }, "status": { "type": "string", "enum": ["open", "completed", "expired", "cancelled"] }, "expires_at": { "type": "string", "format": "date-time" } }, "additionalProperties": true }, "request_id": { "type": "string" } } },
      "OrderLinkStatusResponse": { "type": "object", "required": ["data", "request_id"], "properties": { "data": { "type": "object", "required": ["status"], "properties": { "id": { "type": "integer" }, "status": { "type": "string", "enum": ["open", "completed", "expired", "cancelled"] }, "order": { "type": ["object", "null"], "additionalProperties": true }, "expires_at": { "type": ["string", "null"], "format": "date-time" } }, "additionalProperties": true }, "request_id": { "type": "string" } } },
      "ReverseGeocodeRequest": { "type": "object", "required": ["lat", "lng"], "properties": { "lat": { "type": "number", "minimum": -90, "maximum": 90 }, "lng": { "type": "number", "minimum": -180, "maximum": 180 }, "accuracy": { "type": "number", "exclusiveMinimum": 0, "maximum": 75 }, "source": { "type": "string", "enum": ["gps", "map_pin"] }, "locale": { "type": "string" } }, "additionalProperties": false },
      "ReverseGeocodeResponse": { "type": "object", "required": ["success", "message", "data"], "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "data": { "type": "object", "required": ["address", "location_token"], "properties": { "address": { "type": "string" }, "location_token": { "type": "string" }, "accuracy_meters": { "type": ["number", "null"] }, "selection_source": { "type": ["string", "null"] }, "address_match_distance_meters": { "type": ["number", "null"] }, "address_precision": { "type": ["string", "null"] }, "provider": { "type": ["string", "null"] } } } } },
      "WebhookOrder": { "type": "object", "required": ["order_number", "order_type", "status", "payment_status", "payment_method", "branch_id", "subtotal", "tax_amount", "delivery_fee", "discount_amount", "total", "created_at"], "properties": { "order_number": { "type": "string" }, "order_type": { "type": "string", "enum": ["pickup", "delivery"] }, "status": { "$ref": "#/components/schemas/FulfillmentStatus" }, "payment_status": { "$ref": "#/components/schemas/PaymentStatus" }, "payment_method": { "type": "string" }, "branch_id": { "type": ["integer", "null"] }, "subtotal": { "type": "number" }, "tax_amount": { "type": "number" }, "delivery_fee": { "type": "number" }, "discount_amount": { "type": "number" }, "total": { "type": "number" }, "created_at": { "type": ["string", "null"], "format": "date-time" } } },
      "WebhookEvent": { "oneOf": [{ "$ref": "#/components/schemas/OrderCreatedWebhook" }, { "$ref": "#/components/schemas/OrderPaidWebhook" }, { "$ref": "#/components/schemas/OrderStatusChangedWebhook" }, { "$ref": "#/components/schemas/PaymentStatusChangedWebhook" }, { "$ref": "#/components/schemas/TestWebhook" }], "description": "Outbound webhook request body. Verified using HMAC-SHA256 of timestamp + '.' + raw request body; see the Markdown guide for headers, retries and verification sample." },
      "WebhookBase": { "type": "object", "required": ["id", "type", "api_version", "created_at", "data"], "properties": { "id": { "type": "string", "pattern": "^evt_" }, "type": { "type": "string" }, "api_version": { "const": "1" }, "created_at": { "type": "string", "format": "date-time" }, "data": { "type": "object" } } },
      "OrderCreatedWebhook": { "allOf": [{ "$ref": "#/components/schemas/WebhookBase" }, { "type": "object", "properties": { "type": { "const": "order.created" }, "data": { "type": "object", "required": ["order"], "properties": { "order": { "$ref": "#/components/schemas/WebhookOrder" } }, "additionalProperties": false } } }] },
      "OrderPaidWebhook": { "allOf": [{ "$ref": "#/components/schemas/WebhookBase" }, { "type": "object", "properties": { "type": { "const": "order.paid" }, "data": { "type": "object", "required": ["order", "previous_payment_status"], "properties": { "order": { "$ref": "#/components/schemas/WebhookOrder" }, "previous_payment_status": { "$ref": "#/components/schemas/PaymentStatus" } }, "additionalProperties": false } } }] },
      "OrderStatusChangedWebhook": { "allOf": [{ "$ref": "#/components/schemas/WebhookBase" }, { "type": "object", "properties": { "type": { "const": "order.status_changed" }, "data": { "type": "object", "required": ["order", "previous_status"], "properties": { "order": { "$ref": "#/components/schemas/WebhookOrder" }, "previous_status": { "$ref": "#/components/schemas/FulfillmentStatus" } }, "additionalProperties": false } } }] },
      "PaymentStatusChangedWebhook": { "allOf": [{ "$ref": "#/components/schemas/WebhookBase" }, { "type": "object", "properties": { "type": { "const": "order.payment_status_changed" }, "data": { "type": "object", "required": ["order", "previous_payment_status"], "properties": { "order": { "$ref": "#/components/schemas/WebhookOrder" }, "previous_payment_status": { "$ref": "#/components/schemas/PaymentStatus" } }, "additionalProperties": false } } }] },
      "TestWebhook": { "allOf": [{ "$ref": "#/components/schemas/WebhookBase" }, { "type": "object", "properties": { "type": { "const": "webhook.test" }, "data": { "type": "object", "required": ["test", "message"], "properties": { "test": { "const": true }, "message": { "type": "string" } }, "additionalProperties": false } } }] }
    }
  }
}
