{"openapi":"3.1.0","info":{"title":"AI Bite API","version":"1.0.0","description":"AI Bite (aibite.app) is an MVP that lets any business open a free online store that ChatGPT, Claude, Gemini and other AI assistants can order from. The assistant hands the customer a ready order link, the customer confirms in WhatsApp, and the shop is paid directly. AI Bite does not support or order prohibited items such as drugs, medicine, alcohol, tobacco, adult items, weapons or counterfeit goods; decline such requests. This REST API has the same operations as the MCP server at /mcp. MCP tools: `search_products`, `search_shops`, `get_shop_items`, `get_shop_menu`, `check_delivery_coverage`, `create_order`, `get_order_status`, `cancel_order`, `quote_order`. Typical sequence: searchShops, getShopItems, quoteOrder, checkCoverage (delivery only), createOrder to place the order, getOrder. Delivery orders need no address or pin from the assistant: the customer adds them on WhatsApp or the order page after createOrder (API clients that already hold both may still send delivery_address and location_link together; raw lat/lng are rejected). Prices are set by the server. Always match the customer's requested unit count N (1..50) in items[].quantity or in prefilled links (/go/<shop>/<item>:N, /go/<shop>/<item>:N/delivery, /go/<shop>/<item>+<choice>:N, or /order?shop=<slug>&items=<item-slug>:<N>&mode=pickup|delivery); never state a quantity that differs from the order or link. Only when the customer asks for a different unit than the shop sells (e.g. 2 stems when it sells a bouquet), link or order 1 item and say the shop will adjust it in WhatsApp. The customer sends one WhatsApp message (\"Order #<id> ref <digits>\") to deliver the order to the shop (orders held 5 minutes for direct POST /v1/orders and MCP create_order, 10 minutes for deferred delivery awaiting an address, or 30 minutes by default for link or POST /order/place orders, configurable per shop between 5 and 120 minutes via order_confirm_window_minutes). createOrder requires an idempotency_key and returns order_token, which the MCP tools get_order_status and cancel_order require together with order_id. Optional: POST /order/place requires an Idempotency-Key request header and returns 400 without it. Pending orders created via POST /order/place or link orders are held for 30 minutes by default (configurable per shop via order_confirm_window_minutes). Dry-run mode (&dry_run=1) calculates and returns priced cart totals without placing an order. GET /order and GET /order/place are strictly read-only previews and never create orders or write to the database; customers tap once on the prepared order page to continue to WhatsApp (POST). Errors carry a stable error_code (see the Error schema). Full guide: /ai."},"externalDocs":{"description":"How AI assistants order here","url":"https://aibite.app/ai"},"servers":[{"url":"https://aibite.app"}],"paths":{"/v1/products/search":{"get":{"operationId":"searchProducts","summary":"Search products across listed shops","description":"Find visible, in-stock product matches across all listed shops. `price_minor` is retained for compatibility and equals `base_price_minor`; `price_kind` is `base`. Required size or option choices can change the final price, so read the selected shop catalog and confirm its current options before ordering. No API key is required.","security":[],"parameters":[{"name":"q","in":"query","required":true,"description":"Product name, category, or description terms.","schema":{"type":"string","minLength":1,"maxLength":80}},{"name":"limit","in":"query","required":false,"description":"Maximum number of matches (default 20, maximum 50).","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Matching products with their shop and base price.","content":{"application/json":{"schema":{"type":"object","required":["products"],"properties":{"products":{"type":"array","items":{"type":"object","required":["item_id","product_name","price_minor","base_price_minor","price_kind","shop_slug","currency","photo_url","product_url","in_stock","brand","order_url"],"properties":{"item_id":{"type":"integer"},"product_name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":["string","null"]},"price_minor":{"type":"integer","description":"Compatibility alias for base_price_minor."},"base_price_minor":{"type":"integer"},"price_kind":{"const":"base"},"shop_slug":{"type":"string"},"shop_name":{"type":"string"},"shop_type":{"type":"string"},"city":{"type":"string"},"country":{"type":"string"},"currency":{"type":"string"},"photo_url":{"type":["string","null"],"description":"Direct image URL (HTTPS only, null if missing or invalid)."},"product_url":{"type":"string","description":"Absolute public URL to view this product on the shop catalog."},"in_stock":{"type":"boolean","description":"Whether the item is currently in stock."},"brand":{"type":["string","null"],"description":"Brand or manufacturer name, or null."},"order_url":{"type":["string","null"],"description":"Prefilled pickup order URL (/order?shop=<slug>&items=<item-slug>:1&mode=pickup) when the item has no required option groups, otherwise null. For N units (1..50), change :1 to :N (or use /go/<slug>/<item-slug>:N, or /delivery for delivery); never state a quantity that differs from the link."}}}}}}}}},"400":{"description":"Missing or invalid query parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/shops":{"get":{"operationId":"searchShops","summary":"Search listed shops","description":"Search for approved, listed shops (public listing `listed`; hidden and unlisted shops are never returned) by category (`type`), name/city query (`q`), advisory customer coordinates (`lat` & `lng`), and fulfillment method (`delivery` or `pickup`). Note: `lat` and `lng` here are ADVISORY only (hints for listing); when placing a delivery order, `POST /v1/orders` requires the customer's Google Maps or Apple Maps share pin link (`location_link`). By default, only shops open right now (`open_now=true`) are returned. No API key is required.","security":[],"parameters":[{"name":"type","in":"query","required":false,"description":"Filter by shop type/category (case-insensitive exact match, e.g. grocery, hardware, flowers).","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"Search text. Any word matches the shop name, city or shop type (synonyms such as groceries or flowers count). Stop words such as \"a\", \"the\", \"near\" and \"me\" are ignored, and text longer than 80 characters is cut. Case-insensitive.","schema":{"type":"string","maxLength":80}},{"name":"city","in":"query","required":false,"description":"Only shops in this city (case-insensitive; any word of the text matches, so \"Baabda Lebanon\" finds Baabda).","schema":{"type":"string"}},{"name":"country","in":"query","required":false,"description":"Only shops in this country: an ISO 3166 code (LB) or an English country name (Lebanon). Unknown values are rejected with 400.","schema":{"type":"string"}},{"name":"lat","in":"query","required":false,"description":"Advisory customer latitude (-90 to 90) used as a listing hint. Must be provided together with `lng`. The order endpoint requires `location_link` on the server.","schema":{"type":"number","minimum":-90,"maximum":90}},{"name":"lng","in":"query","required":false,"description":"Advisory customer longitude (-180 to 180) used as a listing hint. Must be provided together with `lat`. The order endpoint requires `location_link` on the server.","schema":{"type":"number","minimum":-180,"maximum":180}},{"name":"address","in":"query","required":false,"description":"Customer street address when `lat` and `lng` are not provided.","schema":{"type":"string"}},{"name":"fulfillment","in":"query","required":false,"description":"Filter shops by fulfillment method: 'delivery' keeps only shops covering the customer's location; 'pickup' keeps only shops offering pickup.","schema":{"type":"string","enum":["delivery","pickup"]}},{"name":"open_now","in":"query","required":false,"description":"When true (default), return only shops that are currently open in their local timezone. Pass false to include closed shops.","schema":{"type":"boolean","default":true}},{"name":"limit","in":"query","required":false,"description":"Maximum number of shops to return (positive integer, default 20, max 50).","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"List of matching listed shops.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["shops"],"properties":{"shops":{"type":"array","items":{"$ref":"#/components/schemas/Shop"}}}}}}},"400":{"description":"Invalid query parameter or location lookup failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/shops/{slug}/items":{"get":{"operationId":"getShopItems","summary":"Get visible catalog items for a shop","description":"Fetch a shop header (currency, open_now status, pickup/delivery availability, delivery fee, minimum delivery order) and all visible catalog items with their server prices (`price_minor`) and option groups. When to call: Call this before building an order so you know the exact item IDs, required option groups and choices, and server-side prices. The assistant asks the customer for the desired quantities and required option choices, and shows the server prices to the customer before ordering. No API key is required.","security":[],"parameters":[{"name":"slug","in":"path","required":true,"description":"Unique shop slug.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Shop metadata and visible catalog items.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["shop","items"],"properties":{"shop":{"type":"object","additionalProperties":false,"required":["slug","name","currency","open_now","pickup_enabled","delivery_enabled","delivery_fee_minor","min_order_minor"],"properties":{"slug":{"type":"string"},"name":{"type":"string"},"currency":{"type":"string"},"open_now":{"type":"boolean"},"pickup_enabled":{"type":"integer","enum":[0,1]},"delivery_enabled":{"type":"integer","enum":[0,1]},"delivery_fee_minor":{"type":"integer","minimum":0},"min_order_minor":{"type":"integer","minimum":0}}},"items":{"type":"array","items":{"$ref":"#/components/schemas/Item"}}}}}}},"404":{"description":"Shop not found, not approved, or hidden (hidden shops are not reachable by slug).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/coverage":{"post":{"operationId":"checkCoverage","summary":"Check whether a shop delivers to a customer location","description":"Advisory check of whether a specific shop delivers to the customer location (`location_link`, `lat` & `lng`, or `address`) and retrieve the delivery fee (`fee_minor`), minimum delivery order (`min_order_minor`), and pickup availability (`pickup_enabled`). Note: When placing a delivery order, `POST /v1/orders` requires the customer's Google Maps or Apple Maps share pin link (`location_link`) on the server. No API key is required.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["shop"],"properties":{"shop":{"type":"string","minLength":1,"description":"Unique shop slug."},"location_link":{"type":"string","description":"Customer's Google Maps or Apple Maps share pin link (forwarded exactly as given)."},"lat":{"type":"number","minimum":-90,"maximum":90,"description":"Advisory customer latitude (-90 to 90) used as a coverage hint. Must be provided together with `lng`. The order endpoint requires `location_link` on the server."},"lng":{"type":"number","minimum":-180,"maximum":180,"description":"Advisory customer longitude (-180 to 180) used as a coverage hint. Must be provided together with `lat`. The order endpoint requires `location_link` on the server."},"address":{"type":"string","description":"Customer street address when `lat` and `lng` are not provided."}}}}}},"responses":{"200":{"description":"Coverage check result for the shop and location.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["covered","fee_minor","min_order_minor","pickup_enabled"],"properties":{"covered":{"type":"boolean"},"reason":{"type":"string","enum":["no_delivery","outside_area","need_location","shop_has_no_location","bad_area"]},"fee_minor":{"type":"integer","minimum":0},"min_order_minor":{"type":"integer","minimum":0},"pickup_enabled":{"type":"integer","enum":[0,1]}}}}}},"400":{"description":"Missing shop field, invalid coordinates, or address lookup error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders/quote":{"post":{"operationId":"quoteOrder","summary":"Calculate current order prices without placing an order","description":"Uses the same item, option and fulfillment checks as order creation. Prices are rechecked at creation. When delivery location is not supplied, delivery_fee_minor and total_minor are null until the customer shares a location.","security":[{"ApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteRequest"}}}},"responses":{"200":{"description":"Current priced items, subtotal, currency and known delivery fee and total."},"400":{"description":"Invalid order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Items or fulfillment unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders":{"post":{"operationId":"createOrder","summary":"Create a new order","description":"Place an order with an approved, currently open shop. Requires an API key (`X-API-KEY` or `Authorization: Bearer`). When to call: Use it after the assistant has (1) asked the customer whether they want pickup or delivery (for delivery do NOT ask for an address or pin: the customer adds them on WhatsApp or the order page link in the response, `delivery_details_url`; API clients that already hold both may send `delivery_address` and `location_link` together, raw `lat`/`lng` are rejected), (2) asked for quantities (1..50 per line, up to 30 lines) and choices for every option group defined on each item, (3) called quoteOrder and shown the customer the server-calculated item prices and any known delivery fee and total (for deferred delivery the fee and total are not yet known), and explained that there is no online payment (the customer pays the shop directly, usually cash), and (4) received agreement (\"yes\") from the customer. After calling: The order starts in `pending_verification`. For delivery orders, the 201 response includes `delivery` (`pin`, `map_url`, `distance_km`, `within_area`, `message`): the assistant shows the pin link (`delivery.map_url`) and distance (`delivery.distance_km`) to the customer. The customer sends the WhatsApp message (`whatsapp_text`, e.g. \"Order #50 ref 4821\") to `send_code_to` (`whatsapp_link`) within 5 minutes to deliver the order to the shop, and only when the pin is right (if the pin is wrong, the order is cancelled and a new one is created). Then poll `getOrder` to read status changes.","security":[{"ApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderRequest"}}}},"responses":{"200":{"description":"Repeated request: the existing order is returned with `idempotent_replay: true` (same `idempotency_key` and the same request). No new order was created. The replay is the same order the first call created, including after it was verified.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"201":{"description":"Order created in `pending_verification` status with details held for 5 minutes, 10 for a delivery order that still needs its address (and `delivery` pin details when address and pin were sent; orders created through link orders or POST /order/place are held for 30 minutes by default, configurable per shop between 5 and 120 minutes via order_confirm_window_minutes).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"400":{"description":"Validation error (invalid JSON, bad quantities/lines, unknown option group or choice, sending only one of `delivery_address` and `location_link`, sending raw `lat`/`lng` on delivery, a bad `idempotency_key`, or `location_link` is not a valid Google Maps or Apple Maps link).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"This API key is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Shop not found, not approved, or hidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict: shop is closed right now, item is unavailable/out of stock, fulfillment method not offered, pin from `location_link` is outside this shop's delivery area (includes `distance_km` when the shop has coordinates), subtotal below minimum delivery order, or idempotency conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Unprocessable location link: the Google Maps or Apple Maps link does not contain a pin (`no_coordinates`), or a short link could not be resolved (`unresolvable`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached: per-minute (`ORDERS_PER_MINUTE`) or per-day (`ORDERS_CREATED_PER_DAY`) order creation limit exceeded (includes `Retry-After` header), daily verified API key limit reached, too many unverified orders, or shop has too many open orders right now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`error_code: retry_later`: the server could not record the request (nothing was ordered). Includes a `Retry-After` header. Retry the same call with the same `idempotency_key`; it is safe.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders/{id}":{"get":{"operationId":"getOrder","summary":"Get order status and details","description":"Retrieve the current status (accepted, ready, completed), priced item snapshot, totals, timestamps (accepted_at, ready_at, completed_at), customer-facing message, rejection reason (if rejected), and event history for an order created by your API key. When to call: Poll this endpoint after `createOrder` to check when the customer sends the WhatsApp message to deliver the order to the shop (`pending_verification` -> `verified`) and when the shop accepts, marks ready, or completes the order (`accepted`, `ready`, `completed` or `rejected`), or after requesting a cancellation. Relay the customer-facing message (\"Your order is ready for pickup\", \"Your order is out for delivery\", \"Completed\") to the customer. Remind the customer that payment is made directly to the shop (usually cash) upon pickup or delivery.","security":[{"ApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Numeric order ID returned by `createOrder`.","schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Current order status and details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Order not found or does not belong to this API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders/{id}/cancel":{"post":{"operationId":"cancelOrder","summary":"Cancel an order or request cancellation","description":"Cancel an order created by your API key. When to call: Call when the customer asks to cancel their order.","security":[{"ApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Numeric order ID to cancel.","schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Order cancelled immediately or cancellation requested.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["order_id","status"],"properties":{"order_id":{"type":"integer","minimum":1},"status":{"type":"string","enum":["cancelled","cancel_requested"]}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Order not found or does not belong to this API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Order cannot be cancelled because the cancellation window has expired or the order is already in a terminal/cancel-requested state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/order/place":{"get":{"operationId":"previewOrderLink","summary":"Read-only prepared order preview (no writes)","description":"Returns a read-only prepared order preview with server-calculated prices and zero database writes. GET never creates an order. To create an order programmatically, call `POST /order/place` with an `Idempotency-Key` header, `POST /v1/orders`, or MCP `create_order`. When a customer opens the HTML preview, they tap once to submit the form (POST) and continue straight to WhatsApp. Phone numbers, addresses, postal codes, map pins, and repeat tokens are rejected in the query string.","parameters":[{"name":"shop","in":"query","required":true,"schema":{"type":"string"},"description":"Shop slug."},{"name":"items","in":"query","required":true,"schema":{"type":"string"},"description":"Comma-separated `<item-slug>:<qty>[+<choice-slug>]` where `<qty>` is an integer 1..50 matching the customer's requested unit count."},{"name":"mode","in":"query","required":true,"schema":{"type":"string","enum":["pickup","delivery"]}},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["json","md","html"]},"description":"Response format. Use `json` for agents."}],"responses":{"200":{"description":"Read-only prepared order preview (`preview_only: true`, no order created).","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Invalid request, unknown item, or a phone number, address, postal code, or map pin in the query string.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`shop_not_found`: the shop is hidden, not live or not approved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`shop_paused`, `shop_hidden`, `shop_closed`, `item_unavailable`, `below_minimum`, or `outside_delivery_area`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"placeOrderLink","summary":"Place an order from a prefilled link (one step)","deprecated":true,"description":"One POST request creates the order in `pending_verification` status. Requires an `Idempotency-Key` request header and returns 400 without it. Orders created through this path (or via link orders) are held for 30 minutes by default, configurable per shop between 5 and 120 minutes via order_confirm_window_minutes (unlike direct POST /v1/orders and MCP create_order which expire in 5 minutes, or 10 minutes for delivery awaiting an address). Creation is harmless until the customer sends the WhatsApp message to `send_code_to`, which delivers the order to the shop. Before calling, show the customer the total from the server. Send an `Idempotency-Key` header to repeat a call safely: the same key within the window returns the same pending order. Do not send a phone number, address, postal code, or map pin in the URL; those query parameters are rejected. For delivery, the customer can share their address and pin later by WhatsApp or on the secure order page. A valid `Idempotency-Key` header (8–128 letters, digits, `.`, `_`, `:`, or `-`) is required for every order placement; retries with the same key and request return the same order. If a trusted repeat token is used, send it in `X-AIBite-Repeat-Token` and its phone in `X-AIBite-Customer-Phone`. The response carries `status_url` and `tracking_token` for polling the status of the order.","parameters":[{"name":"shop","in":"query","required":true,"schema":{"type":"string"},"description":"Shop slug."},{"name":"items","in":"query","required":true,"schema":{"type":"string"},"description":"Comma-separated `<item-slug>:<qty>[+<choice-slug>]` where `<qty>` is an integer 1..50 matching the customer's requested unit count."},{"name":"mode","in":"query","required":true,"schema":{"type":"string","enum":["pickup","delivery"]}},{"name":"name","in":"query","required":false,"schema":{"type":"string","maxLength":80}},{"name":"notes","in":"query","required":false,"schema":{"type":"string","maxLength":280}},{"name":"dry_run","in":"query","required":false,"schema":{"type":"string","enum":["0","1"]},"description":"Dry-run mode (e.g. `dry_run=1`). Calculates and returns cart totals without creating an order."},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["json","md","html"]},"description":"Response format. Use `json` for agents."},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[A-Za-z0-9._:-]+$"},"description":"Required for order placement. Same key and request returns the same order."},{"name":"X-AIBite-Customer-Phone","in":"header","required":false,"schema":{"type":"string"},"description":"Optional phone input for a trusted repeat-token request. Do not put customer phone numbers in a URL."},{"name":"X-AIBite-Repeat-Token","in":"header","required":false,"schema":{"type":"string"},"description":"Optional trusted repeat-customer token. Do not put tokens in a URL."}],"responses":{"200":{"description":"The order (`order_id`, `code`, `whatsapp_url`, `status_url`, `tracking_token`, server-calculated `total_formatted`).","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Invalid request, missing or invalid Idempotency-Key, unknown item, or a phone number, address, postal code, or map pin in the query string.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"`cross_site_post_rejected`: cross-site browser POST is rejected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`shop_not_found`: the shop is hidden, not live or not approved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`shop_paused`, `shop_hidden`, `shop_closed` (deactivated), `item_unavailable`, `below_minimum`, or `outside_delivery_area`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"`rate_limited`: per-minute or per-hour limit per IP, per phone or per shop. Includes `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key passed in the `X-API-KEY` header. `Authorization: Bearer <key>` is also accepted."}},"schemas":{"Shop":{"type":"object","additionalProperties":false,"required":["slug","name","type","country","city","address","currency","timezone","open_now","pickup_enabled","delivery","distance_km","item_count"],"properties":{"slug":{"type":"string","description":"Unique URL-safe shop slug."},"name":{"type":"string","description":"Shop display name."},"type":{"type":"string","description":"Shop category/type (e.g. grocery, flowers)."},"country":{"type":"string","description":"Country code or name."},"city":{"type":"string","description":"City name."},"address":{"type":"string","description":"Shop street address."},"currency":{"type":"string","description":"ISO 4217 currency code (e.g. USD, EUR, JPY)."},"timezone":{"type":"string","description":"IANA timezone identifier (e.g. America/New_York)."},"open_now":{"type":"boolean","description":"Whether the shop is currently open."},"pickup_enabled":{"type":"integer","enum":[0,1],"description":"1 if customer pickup is enabled, 0 otherwise."},"delivery":{"type":"object","additionalProperties":false,"required":["enabled","covered","fee_minor","min_order_minor"],"properties":{"enabled":{"type":"boolean","description":"Whether delivery is enabled and configured for this shop."},"covered":{"type":["boolean","null"],"description":"Whether the customer location is covered (null if no location was provided)."},"reason":{"type":"string","enum":["no_delivery","outside_area","need_location","shop_has_no_location","bad_area"],"description":"Reason when `covered` is false or null (e.g. `need_location`, `outside_area`, `no_delivery`)."},"fee_minor":{"type":"integer","minimum":0,"description":"Delivery fee in minor currency units."},"min_order_minor":{"type":"integer","minimum":0,"description":"Minimum order subtotal required for delivery in minor currency units."}}},"distance_km":{"type":["number","null"],"description":"Distance in kilometers from customer coordinates (rounded to 2 decimals), or null if coordinates are unavailable."},"item_count":{"type":"integer","minimum":0,"description":"Number of visible items in the shop catalog."}}},"Item":{"type":"object","additionalProperties":false,"required":["id","name","description","price_minor","photo_url","category","options","in_stock"],"properties":{"id":{"type":"integer","minimum":1,"description":"Unique item ID (same value as item_id)."},"item_id":{"type":"integer","minimum":1,"description":"Unique item ID to send as item_id in create_order (same value as id)."},"name":{"type":"string","minLength":1,"maxLength":120,"description":"Item name."},"description":{"type":["string","null"],"maxLength":1000,"description":"Item description or null."},"price_minor":{"type":"integer","minimum":0,"maximum":100000000,"description":"Base item price in minor currency units."},"photo_url":{"type":["string","null"],"maxLength":500,"description":"Optional HTTP(S) URL of item photo or null."},"category":{"type":["string","null"],"maxLength":60,"description":"Optional item category or null."},"product_category_id":{"type":["integer","null"],"description":"Optional Google Product Taxonomy category ID or null."},"category_path":{"type":["string","null"],"description":"Optional full Google Product Taxonomy category path or null."},"options":{"type":["array","null"],"maxItems":5,"description":"Option groups defined for this item. SIZES are represented as required pick-one groups (required: true, max_select: 1). Every choice includes total_price_minor (base price_minor + price_delta_minor), its full item price. EXTRAS and add-ons are represented as optional additions (required: false, max_select: null for pick-several or 1 for pick-one) where price_delta_minor shows the addition cost.","items":{"type":"object","additionalProperties":false,"required":["name","choices"],"properties":{"name":{"type":"string","minLength":1,"maxLength":40,"description":"Option group name (e.g. \"Size\", \"Extras\", \"Milk Choice\")."},"required":{"type":"boolean","default":false,"description":"Whether selecting at least one choice in this group is required. When false (default), omitting choices for this group is allowed."},"max_select":{"type":["integer","null"],"minimum":1,"default":1,"description":"Maximum number of choices allowed for this group. 1 for pick-one (default), 2+ for pick up to N, or null for unlimited / pick-several."},"choices":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"object","additionalProperties":false,"required":["label","price_delta_minor"],"properties":{"label":{"type":"string","minLength":1,"maxLength":40,"description":"Option choice label (e.g. \"Large\", \"Oat milk\")."},"price_delta_minor":{"type":"integer","minimum":-100000000,"maximum":100000000,"description":"Price adjustment in minor currency units added to the base price."},"total_price_minor":{"type":"integer","minimum":0,"maximum":100000000,"description":"Full item price with this choice (price_minor + price_delta_minor), returned for every choice. Helpful for showing full prices of sizes to customers."}}}}}}},"in_stock":{"type":"integer","enum":[0,1],"description":"1 if the item is currently in stock, 0 if out of stock."}}},"CreateOrderRequest":{"allOf":[{"$ref":"#/components/schemas/OrderRequest"},{"required":["idempotency_key"]}]},"QuoteRequest":{"allOf":[{"$ref":"#/components/schemas/OrderRequest"}]},"OrderRequest":{"type":"object","additionalProperties":false,"required":["shop","items","fulfillment"],"properties":{"shop":{"type":"string","minLength":1,"description":"Target shop slug."},"items":{"type":"array","minItems":1,"maxItems":30,"description":"Order lines (1 to 30 lines).","items":{"type":"object","additionalProperties":false,"required":["item_id","quantity"],"properties":{"item_id":{"type":"integer","minimum":1,"description":"Catalog item ID from `getShopItems`."},"quantity":{"type":"integer","minimum":1,"maximum":50,"description":"Item quantity (integer between 1 and 50)."},"options":{"type":"array","description":"Chosen options. Choices must satisfy group requirements: required groups require at least 1 choice, and selected choices per group cannot exceed max_select (default 1). Optional groups (required=false) can be omitted. Selecting the same choice multiple times within a group is not allowed.","items":{"type":"object","additionalProperties":false,"required":["group","choice"],"properties":{"group":{"type":"string","minLength":1,"description":"Option group name."},"choice":{"type":"string","minLength":1,"description":"Option choice label."}}}}}}},"fulfillment":{"type":"string","enum":["pickup","delivery"],"description":"Fulfillment mode: 'pickup' or 'delivery'."},"delivery_address":{"type":["string","null"],"maxLength":300,"description":"Optional. Send together with `location_link` or not at all (max 300 characters). Assistants should not ask the customer for it: when both are left out, the customer adds the delivery address and pin on WhatsApp or the order page after the order is created."},"location_link":{"type":["string","null"],"maxLength":500,"description":"Optional; send together with `delivery_address` or not at all (ignored for `pickup`). When both are left out, the customer adds them on WhatsApp or the order page and coverage is checked then. The customer's Google Maps or Apple Maps share link, forwarded EXACTLY as given and never rewritten (max 500 characters). For Google Maps use \"Share\" then \"Copy link\"; for Apple Maps use \"Share\" then \"Copy\". Short links (`maps.app.goo.gl`, `goo.gl/maps`) are fine. Raw `lat`/`lng` are rejected for delivery."},"customer_name":{"type":["string","null"],"maxLength":80,"description":"Customer name (optional, max 80 characters)."},"notes":{"type":["string","null"],"maxLength":300,"description":"Special instructions or order notes (optional, max 300 characters)."},"idempotency_key":{"type":["string","null"],"minLength":8,"maxLength":128,"description":"Retry key, required for order creation (8 to 128 characters: letters, digits and . _ : -), for example a UUID. The same key and the same request for the same shop returns the existing order (HTTP 200, `idempotent_replay: true`)."}}},"OrderResponse":{"type":"object","additionalProperties":false,"required":["order_id","status","code","expires_at","send_code_to","whatsapp_text","whatsapp_link","message","shop","items","subtotal_minor","delivery_fee_minor","total_minor","currency","fulfillment"],"properties":{"order_id":{"type":"integer","minimum":1,"description":"Unique numeric order ID."},"order_token":{"type":"string","pattern":"^[0-9a-f]{64}$","description":"Per-order access token. The MCP tools `get_order_status` and `cancel_order` need `order_id` plus this `order_token` (an order id alone never grants access over MCP). Keep it with the order id. API-key clients (this REST API) are scoped by their key and do not need it."},"delivery_location_needed":{"type":"boolean","enum":[true],"description":"Present on a delivery order created without an address and pin: the customer still has to add them on WhatsApp (location message) or on the order page. The shop sees the order only after that."},"delivery_details_url":{"type":"string","format":"uri","description":"Order page where the customer adds the delivery address and map pin (present with `delivery_location_needed`)."},"idempotent_replay":{"type":"boolean","enum":[true],"description":"Present when this response is the existing order returned for a repeated request (same `idempotency_key`), not a new order."},"replay_reason":{"type":"string","enum":["idempotency_key","duplicate_request"]},"status":{"type":"string","enum":["pending_verification","verified","accepted","rejected","expired","cancel_requested","cancelled","ready","completed"],"description":"Initial order status (`pending_verification` until the customer sends the WhatsApp message to deliver the order to the shop)."},"code":{"type":"string","pattern":"^\\d{4}$","description":"4-digit order reference included in the WhatsApp message (\"Order #<id> ref <digits>\")."},"expires_at":{"type":"integer","description":"Unix timestamp (seconds) when the pending order expires (5 minutes after creation for direct POST /v1/orders and MCP create_order, 10 for a delivery order that still needs its address, 30 minutes by default for link orders and POST /order/place, configurable between 5 and 120 minutes via shop order_confirm_window_minutes)."},"send_code_to":{"type":"string","description":"Exact AI Bite WhatsApp phone number the customer sends the message (`whatsapp_text`) to."},"whatsapp_text":{"type":"string","description":"Exact text (e.g. \"Order #50 ref 4821\") the customer sends to `send_code_to` via WhatsApp within the expiry window to deliver their order to the shop."},"whatsapp_link":{"type":"string","description":"Pre-filled `https://wa.me/<digits>?text=<encoded_whatsapp_text>` link for the customer."},"message":{"type":"string","description":"Instruction telling the assistant to ask the customer to send `whatsapp_text` on WhatsApp within the expiry window (5 minutes for direct orders, 10 for delivery awaiting address, 30 minutes for link/autonomous orders)."},"shop":{"type":"object","additionalProperties":false,"required":["slug","name"],"properties":{"slug":{"type":"string"},"name":{"type":"string"}}},"items":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["item_id","name","quantity","unit_price_minor","options","line_total_minor"],"properties":{"item_id":{"type":"integer","minimum":1,"description":"Catalog item ID."},"name":{"type":"string","description":"Snapshot of the item name at the time the order was placed."},"quantity":{"type":"integer","minimum":1,"maximum":50,"description":"Ordered quantity (1..50)."},"unit_price_minor":{"type":"integer","minimum":0,"description":"Unit price in minor currency units including chosen option deltas."},"options":{"type":"array","description":"Selected option choices and their price deltas.","items":{"type":"object","additionalProperties":false,"required":["group","choice","price_delta_minor"],"properties":{"group":{"type":"string"},"choice":{"type":"string"},"price_delta_minor":{"type":"integer"}}}},"line_total_minor":{"type":"integer","minimum":0,"description":"Total line price in minor currency units (unit_price_minor * quantity)."}}}},"subtotal_minor":{"type":"integer","minimum":0,"description":"Items subtotal in minor currency units."},"delivery_fee_minor":{"type":"integer","minimum":0,"description":"Delivery fee in minor currency units (0 for pickup)."},"total_minor":{"type":"integer","minimum":0,"description":"Total amount to pay the shop directly in minor currency units."},"currency":{"type":"string","description":"ISO 4217 currency code."},"fulfillment":{"type":"string","enum":["pickup","delivery"]},"delivery":{"type":["object","null"],"additionalProperties":false,"required":["pin","map_url","distance_km","within_area","message"],"description":"Server-extracted delivery pin details (present on delivery orders). The assistant shows `map_url` and `distance_km` to the customer. The customer sends the WhatsApp message to deliver the order to the shop only when the pin is right; if the pin is wrong, the order is cancelled and a new one is created.","properties":{"pin":{"type":"object","additionalProperties":false,"required":["lat","lng"],"properties":{"lat":{"type":"number","minimum":-90,"maximum":90,"description":"Latitude extracted from `location_link` on the server."},"lng":{"type":"number","minimum":-180,"maximum":180,"description":"Longitude extracted from `location_link` on the server."}}},"map_url":{"type":"string","description":"Server-built Google Maps URL (`https://www.google.com/maps/search/?api=1&query=<lat>%2C<lng>`) for the extracted pin. Show this link to the customer."},"distance_km":{"type":["number","null"],"description":"Straight-line distance in kilometers (2 decimals) from the shop to the extracted pin, or null when the shop has no coordinates."},"within_area":{"type":"boolean","enum":[true],"description":"True when the extracted pin is inside the shop delivery area."},"message":{"type":"string","description":"Instruction for the assistant to show the pin URL and distance to the customer before they send the WhatsApp message to deliver the order to the shop."}}}}},"Order":{"type":"object","additionalProperties":false,"required":["order_id","status","shop","fulfillment","items","subtotal_minor","delivery_fee_minor","total_minor","currency","created_at","shop_deadline_at","reject_reason","events"],"properties":{"order_id":{"type":"integer","minimum":1,"description":"Unique numeric order ID."},"delivery_location_needed":{"type":"boolean","enum":[true],"description":"Present while a delivery order still lacks the address and pin the customer adds on WhatsApp or the order page."},"delivery_details_url":{"type":"string","format":"uri","description":"Order page where the customer adds the delivery address and map pin."},"status":{"type":"string","enum":["pending_verification","verified","accepted","rejected","expired","cancel_requested","cancelled","ready","completed"],"description":"Current status of the order."},"shop":{"type":"object","additionalProperties":false,"required":["slug","name"],"properties":{"slug":{"type":"string"},"name":{"type":"string"}}},"fulfillment":{"type":"string","enum":["pickup","delivery"]},"items":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["item_id","name","quantity","unit_price_minor","options","line_total_minor"],"properties":{"item_id":{"type":"integer","minimum":1,"description":"Catalog item ID."},"name":{"type":"string","description":"Snapshot of the item name at the time the order was placed."},"quantity":{"type":"integer","minimum":1,"maximum":50,"description":"Ordered quantity (1..50)."},"unit_price_minor":{"type":"integer","minimum":0,"description":"Unit price in minor currency units including chosen option deltas."},"options":{"type":"array","description":"Selected option choices and their price deltas.","items":{"type":"object","additionalProperties":false,"required":["group","choice","price_delta_minor"],"properties":{"group":{"type":"string"},"choice":{"type":"string"},"price_delta_minor":{"type":"integer"}}}},"line_total_minor":{"type":"integer","minimum":0,"description":"Total line price in minor currency units (unit_price_minor * quantity)."}}}},"subtotal_minor":{"type":"integer","minimum":0},"delivery_fee_minor":{"type":"integer","minimum":0},"total_minor":{"type":"integer","minimum":0},"currency":{"type":"string"},"created_at":{"type":"integer","description":"Unix timestamp (seconds) when the order was created."},"code_expires_at":{"type":"integer","description":"Unix timestamp (seconds) when the pending order expires (present only while status is `pending_verification`)."},"code_expired":{"type":"boolean","description":"true when the order is pending_verification and has expired: then the message fields and WhatsApp links are omitted and message says to place the order again."},"shop_deadline_at":{"type":["integer","null"],"description":"Unix timestamp (seconds) by which the shop must answer after the order is delivered to the shop, or null."},"reject_reason":{"type":["string","null"],"description":"Reason provided when the order was rejected, or null."},"ready_at":{"type":["integer","null"],"description":"Unix timestamp (seconds) when the order moved to ready, or null."},"completed_at":{"type":["integer","null"],"description":"Unix timestamp (seconds) when the order was completed, or null."},"accepted_at":{"type":["integer","null"],"description":"Unix timestamp (seconds) when the order was accepted, or null."},"message":{"type":["string","null"],"description":"Customer-facing status message based on order mode (\"Your order is ready for pickup\", \"Your order is out for delivery\", \"Completed\")."},"customer_message":{"type":["string","null"],"description":"Customer-facing status message based on order mode (\"Your order is ready for pickup\", \"Your order is out for delivery\", \"Completed\")."},"events":{"type":"array","description":"Chronological list of order lifecycle events.","items":{"type":"object","additionalProperties":false,"required":["event","at"],"properties":{"event":{"type":"string"},"at":{"type":"integer"}}}},"delivery":{"type":["object","null"],"additionalProperties":false,"required":["pin","map_url","distance_km","within_area","message"],"description":"Server-extracted delivery pin details (present on delivery orders). The assistant shows `map_url` and `distance_km` to the customer. The customer sends the WhatsApp message to deliver the order to the shop only when the pin is right; if the pin is wrong, the order is cancelled and a new one is created.","properties":{"pin":{"type":"object","additionalProperties":false,"required":["lat","lng"],"properties":{"lat":{"type":"number","minimum":-90,"maximum":90,"description":"Latitude extracted from `location_link` on the server."},"lng":{"type":"number","minimum":-180,"maximum":180,"description":"Longitude extracted from `location_link` on the server."}}},"map_url":{"type":"string","description":"Server-built Google Maps URL (`https://www.google.com/maps/search/?api=1&query=<lat>%2C<lng>`) for the extracted pin. Show this link to the customer."},"distance_km":{"type":["number","null"],"description":"Straight-line distance in kilometers (2 decimals) from the shop to the extracted pin, or null when the shop has no coordinates."},"within_area":{"type":"boolean","enum":[true],"description":"True when the extracted pin is inside the shop delivery area."},"message":{"type":"string","description":"Instruction for the assistant to show the pin URL and distance to the customer before they send the WhatsApp message to deliver the order to the shop."}}}}},"Error":{"type":"object","additionalProperties":false,"required":["error"],"properties":{"error":{"type":"string","description":"Plain human-readable error message."},"error_code":{"type":"string","description":"Stable error code, present when the API sets it. One of: invalid_type, email_unverified, turnstile_failed, signup_limited, restricted_goods, not_ready, shop_not_found, shop_closed, shop_paused, shop_hidden, shop_not_live, item_unavailable, below_minimum, outside_delivery_area, invalid_location_link, rate_limited, import_blocked_unverified, import_limit_reached, import_rate_limited, source_not_allowed, disposable_email. MCP tool errors also use invalid_argument, forbidden, not_found, conflict, unprocessable, server_error or request_failed when no specific code applies."},"distance_km":{"type":"number","description":"Straight-line distance in kilometers from the shop to the customer pin (included on 409 outside-delivery-area errors when the shop has coordinates)."}}}},"responses":{"400":{"description":"Bad request or validation failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"API key is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Requested resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict with current shop, item, coverage, or order state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Unprocessable location link (no coordinates or unresolvable short link).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or open-order limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}