# ALWS RESTRO Restaurants API > Connect a restaurant website to ALWS RESTRO (restaurant billing/POS by ALWS, Alightway Solutions Pvt. Ltd.): > live menu, cart pricing, pickup/delivery orders, order status, table availability and table booking. > Orders appear in ALWS RESTRO "Website Orders"; bookings appear in "Reservations". Base URL: https://restro.alws.in/api/v1 Machine-readable contract (OpenAPI 3.1): https://developers.alws.in/restaurants/openapi.json Human docs: https://developers.alws.in/restaurants/ Support: restro@alws.in ## Conventions - JSON request/response. Money in INR (rupees, numbers). Dates YYYY-MM-DD and times HH:mm (24h) in India Standard Time. - Every request except GET /health needs: Authorization: Bearer - Errors: HTTP status + { "error": { "type", "code", "message", "requestId", "details"? } }. Use `code` in logic, show `message`. - Every response has X-Request-Id. Responses to requests that pass the key checks have X-RateLimit-Limit / -Remaining / -Reset. ## Keys (created only by the business owner in ALWS RESTRO: Account Setting -> API Keys; full key shown once) - pk_live_... publishable: safe in browser code. Browser requests (with an Origin header) from websites not listed for the key are refused (403 origin_not_allowed). Orders it creates always start unpaid. Reads/cancels an order or booking only with that record's accessToken (headers X-Order-Token / X-Reservation-Token). - sk_live_... secret: server only. Requests carrying a browser Origin header are refused (403 secret_key_in_browser). Can additionally list orders, read any order/booking of the business, mark online orders paid, send extraCharges and externalRef, and schedule orders up to 30 days ahead (publishable: 7). pk sending extraCharges/externalRef -> 403 secret_key_required. - Never place sk_ keys in browser code, mobile apps or repositories. ## Endpoints GET /health no key -> {status:"ok", version} GET /restaurant -> {name, address:{line,city,state}, phone, gstin} GET /menu -> {currency:"INR", categories:[{name,itemCount}], items:[{id,name,category,price,foodType:"veg"|"egg"|"nonveg"|null,specialMenu}]} Only items currently available at the counter (switched-off special menus are excluded). GET /tables -> {floors:[{floorId,floorName,tables:[{tableId,tableNumber}]}]} POST /orders/quote {items:[{itemId,quantity,note?(1..160, trimmed)}], couponCode?, extraCharges?(sk only):[{name(1..40),amount(0..10000)}] (max 5)} -> {items:[{itemId,name,category,foodType,unitPrice,quantity,lineTotal,note|null}], subtotal, discount|null, charges:[{name,percentage,amount}], chargesTotal, extraCharges:[{name,amount}], extraChargesTotal, roundOff, total} Pricing = counter rules: subtotal; each charge = % of subtotal; coupon per unit of applicable items (percentage of price or flat per unit); total = round(subtotal - discount + chargesTotal + extraChargesTotal) to nearest rupee. charges/chargesTotal = percentage charges only. Lines with the same itemId and same note are merged. quantity 1..999, up to 100 lines. note shows under the item in ALWS RESTRO. POST /orders [Idempotency-Key] {items, couponCode?, orderType:"pickup"|"delivery", customer:{name,phone,email?}, deliveryAddress?:{line, landmark?, city?, pincode?(6 digits), location?:{lat,lng}, distanceKm?(0..200, saved to 1 decimal)} (required for delivery), scheduledFor?(ISO with offset, future, <=7 days pk / <=30 days sk; staff see it as IST text like "17 Nov, 6:00 PM"; API returns the ISO value), notes?(<=500), payment?:{method:"cash"|"online"} (default cash), extraCharges?(sk only, as in quote), externalRef?(sk only; 1..64 [A-Za-z0-9._:-]; your own order number), expectedTotal?(recommended; 409 price_changed with details.quote if different)} Unknown fields -> 400. Website prices are never used. -> 201 Order + accessToken (returned only once). orderNumber is the short code to show the customer (= externalRef when sent). externalRef is unique per business: an existing order with it -> 409 duplicate_external_ref, details.orderId = that order's id. Order: items[] include note|null; charges = percentage charges then extraCharges; deliveryAddress:{line,location|null,distanceKm|null}|null. GET /orders/{id} sk, or pk + X-Order-Token -> Order POST /orders/{id}/cancel sk, or pk + X-Order-Token; only while status is pending or pending_payment (else 409 cannot_cancel); pk cannot cancel an order already paid online. POST /orders/{id}/payment sk only {provider, reference, amount(must equal total)} -> status pending, paymentStatus paid. Call only after YOUR server verified the payment with your gateway. Repeating for an already-paid order returns it unchanged. If the order was cancelled first: payment recorded with refundRequired, order stays cancelled, 409 order_cancelled_refund_required (refund it). GET /orders?status=&since=&externalRef=&limit= sk only -> {data:[Order newest first], hasMore}; limit 1..100 (default 50) GET /reservations/availability?date=&from=&to= -> {date,from,to,availableCount,tables:[{tableId,tableNumber,floorId,floorName,available}]} POST /reservations [Idempotency-Key] {date, from, to, tableId?, partySize?(1..100), customer:{name,phone,email?}, notes?} -> 201 Reservation + accessToken. Without tableId the first free table is chosen. 409 table_unavailable / no_table_available. From now up to 60 days ahead; from < to, same day, at most 4 hours (422 slot_too_long). Bookings added by staff in ALWS RESTRO count for availability. Publishable keys: one phone can hold at most 2 upcoming bookings (422 too_many_bookings). partySize and notes are saved and returned by the API; the ALWS RESTRO Reservations screen does not show them yet. GET /reservations/{id} sk, or pk + X-Reservation-Token POST /reservations/{id}/cancel sk, or pk + X-Reservation-Token; until the start time; removes the booking. ## WhatsApp one-time codes (secret key only) POST /otp/send {phone (Indian mobile), purpose?:"order_status"} -> {otpId, expiresInSeconds:300, channel:"whatsapp"} Sent from the ALWS WhatsApp number. Max 3 codes per phone per 15 min per restaurant (429 otp_rate_limited). 422 invalid_phone, 502 otp_send_failed. POST /otp/verify {otpId, code(6 digits)} -> {verified:true, phone(10 digits)}; 422 otp_invalid (details.attemptsLeft) / otp_expired; 429 otp_too_many_attempts after 5 wrong. Codes last 5 minutes and work once. Only a hash is stored. ## Order statuses (set by restaurant staff in ALWS RESTRO) pending_payment (online orders before payment is confirmed; hidden from the restaurant) -> pending -> processing -> shipped -> delivered; or cancelled. GET /orders also lists website orders not created through the API, which may carry other legacy status values. statusText: "Waiting for payment", "Received by the restaurant", "Being prepared", "Ready for pickup" / "Out for delivery", "Completed", "Cancelled". No webhooks yet: poll GET /orders/{id} (e.g. every 30 s while the customer's status page is open). ## Payments cash: order goes straight to the restaurant (payment shown as "Cash on delivery" or "Pay at pickup"). online: create order with payment.method "online" -> take payment with your own gateway -> verify on your server -> POST /orders/{id}/payment with the secret key. ALWS does not process, verify or refund payments. ## Reliability - Idempotency-Key (8-100 chars [A-Za-z0-9._:-]) on POST /orders and POST /reservations: the same key on a retry returns the first response (header Idempotent-Replayed: true); a different body -> 409 idempotency_conflict; still running -> 409 request_in_progress. Remembered 24 hours per API key. Use crypto.randomUUID() per new order; reuse it for retries. - Rate limits per key per minute: publishable 120 requests (20 creates), secret 600 requests (120 creates). Publishable keys also per visitor IP: 30 requests (5 creates) per minute. 20 failed key checks per IP per minute -> refused for the rest of the minute. 429 rate_limited + Retry-After. - Retry only network errors, 409 request_in_progress, 429 and 500, up to 3 times with backoff and the same Idempotency-Key. ## Error codes 400 invalid_request (details.fields), invalid_idempotency_key; 401 missing_api_key, invalid_api_key, api_key_revoked; 403 origin_not_allowed, secret_key_in_browser, secret_key_required, business_suspended, business_not_found; 404 not_found, route_not_found; 405 method_not_allowed; 409 price_changed, duplicate_external_ref (details.orderId), cannot_cancel, amount_mismatch, not_awaiting_payment, order_cancelled_refund_required, table_unavailable, no_table_available, idempotency_conflict, request_in_progress, busy; 413 body_too_large; 422 item_unavailable (details.itemIds), coupon_invalid (details.reason: not_found|inactive|expired|not_applicable), invalid_schedule, slot_in_past, slot_too_far, slot_too_long, too_many_bookings, no_tables, table_not_found; 429 rate_limited; 500 internal_error.