{"openapi":"3.0.3","info":{"title":"AIPOS Partner Orders API","version":"1.0.0","description":"Place orders at a restaurant using AIPOS. Each restaurant issues you an API key. Orders are pending until restaurant staff accept them (with a preparation time) or refuse them; payment is taken at pickup or delivery."},"servers":[{"url":"/api/v1"}],"security":[{"apiKey":[]}],"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"Restaurant API key, e.g. `mc_live_...`"}},"schemas":{"Customer":{"type":"object","required":["name"],"properties":{"name":{"type":"string","maxLength":80},"phone":{"type":"string"},"address":{"type":"string","description":"Required for delivery."}}},"Order":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"externalRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","accepted","rejected","ready","completed","cancelled","expired"]},"type":{"type":"string","enum":["takeaway","delivery"]},"customer":{"$ref":"#/components/schemas/Customer"},"note":{"type":"string","nullable":true},"lines":{"type":"array","items":{"type":"object","properties":{"lineId":{"type":"string"},"productId":{"type":"string","format":"uuid"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPrice":{"type":"integer","description":"Amount in centimes of MAD (1250 = 12.50 MAD), VAT included."},"vatRate":{"type":"integer","description":"Basis points: 2000 = 20%."},"note":{"type":"string"}}}},"currency":{"type":"string","enum":["MAD"]},"subtotal":{"type":"integer","description":"Amount in centimes of MAD (1250 = 12.50 MAD), VAT included."},"total":{"type":"integer","description":"Amount in centimes of MAD (1250 = 12.50 MAD), VAT included."},"vat":{"type":"integer","description":"Amount in centimes of MAD (1250 = 12.50 MAD), VAT included."},"pickupAt":{"type":"string","format":"date-time","nullable":true},"prepMinutes":{"type":"integer","nullable":true},"readyAt":{"type":"string","format":"date-time","nullable":true,"description":"Estimated ready time, once accepted."},"rejectReason":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}}}},"paths":{"/menu":{"get":{"summary":"Products available for ordering, with current prices","description":"Scope: menu:read.","responses":{"200":{"description":"Menu"},"401":{"description":"Bad key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}}}}}}}},"/orders":{"post":{"summary":"Place an order","description":"Scope: orders:write. Prices are taken from the menu, never from the request. Send a unique Idempotency-Key per order: retries with the same key return the original order (200) instead of a duplicate.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":100}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type","customer","items"],"properties":{"externalRef":{"type":"string","maxLength":100},"type":{"type":"string","enum":["takeaway","delivery"]},"customer":{"$ref":"#/components/schemas/Customer"},"items":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"object","required":["productId","quantity"],"properties":{"productId":{"type":"string","format":"uuid"},"quantity":{"type":"integer","minimum":1,"maximum":99},"note":{"type":"string"}}}},"note":{"type":"string","maxLength":500},"pickupAt":{"type":"string","format":"date-time","description":"Omit for as soon as possible."}}}}}},"responses":{"200":{"description":"Idempotent replay of an earlier request"},"201":{"description":"Created, status pending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Missing Idempotency-Key or bad JSON"},"422":{"description":"Validation failed or unknown products","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}}}}},"429":{"description":"Rate limited (120 requests/minute per key)"}}}},"/orders/{id}":{"get":{"summary":"Order status","description":"Scope: orders:read. A key only sees its own orders.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"404":{"description":"Not found"}}}},"/orders/{id}/cancel":{"post":{"summary":"Cancel a pending order","description":"Scope: orders:write. Only while pending; once accepted, contact the restaurant.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Cancelled"},"409":{"description":"Not pending any more"}}}}}}