{"openapi":"3.1.0","info":{"title":"Tallowbrook Supply order API (demo)","version":"1.0.0","description":"A demo API by WebCRG for a fictional shop. Create a sandbox to get a key; every sandbox is private, in memory, and expires after 24 hours or when the server restarts. The payment, email and CRM services are simulated."},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Your sandbox key, sk_demo_…"}},"schemas":{}},"paths":{"/v1/sandboxes":{"post":{"summary":"Create a sandbox","tags":["Sandbox"],"description":"Returns a key for your own copy of the shop, seeded with its catalogue, customers and order history. Keep the key: it is shown once.","responses":{"201":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"key":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"}},"required":["id","key","expiresAt"]}}}},"429":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/sandbox":{"get":{"summary":"Your sandbox","tags":["Sandbox"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"},"outages":{"type":"object","properties":{"crm":{"type":"boolean"}},"required":["crm"]},"counts":{"type":"object","properties":{"products":{"type":"integer"},"customers":{"type":"integer"},"orders":{"type":"integer"},"events":{"type":"integer"}},"required":["products","customers","orders","events"]}},"required":["id","expiresAt","outages","counts"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/sandbox/outages":{"post":{"summary":"Simulate a CRM outage","tags":["Sandbox"],"description":"While the CRM is down, syncs retry with growing delays and are then parked for replay.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"crm":{"type":"boolean"}},"required":["crm"],"additionalProperties":false}}}},"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"},"outages":{"type":"object","properties":{"crm":{"type":"boolean"}},"required":["crm"]},"counts":{"type":"object","properties":{"products":{"type":"integer"},"customers":{"type":"integer"},"orders":{"type":"integer"},"events":{"type":"integer"}},"required":["products","customers","orders","events"]}},"required":["id","expiresAt","outages","counts"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/products":{"get":{"summary":"List products","tags":["Catalogue"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"in":"query","name":"limit","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"cursor","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"category","required":false},{"schema":{"type":"boolean"},"in":"query","name":"inStock","required":false},{"schema":{"type":"string","maxLength":60},"in":"query","name":"q","required":false}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"sku":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"priceCents":{"type":"integer"},"stock":{"type":"integer"}},"required":["id","sku","name","category","priceCents","stock"]}},"total":{"type":"integer"},"nextCursor":{"type":["null","string"]}},"required":["data","total","nextCursor"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/products/{id}":{"get":{"summary":"Get a product","tags":["Catalogue"],"parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"sku":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"priceCents":{"type":"integer"},"stock":{"type":"integer"}},"required":["id","sku","name","category","priceCents","stock"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/customers":{"get":{"summary":"List customers","tags":["Customers"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"in":"query","name":"limit","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"cursor","required":false},{"schema":{"type":"string","maxLength":120},"in":"query","name":"email","required":false}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","name","email","createdAt"]}},"total":{"type":"integer"},"nextCursor":{"type":["null","string"]}},"required":["data","total","nextCursor"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"summary":"Create a customer","tags":["Customers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"email":{"type":"string","format":"email","maxLength":120}},"required":["name","email"],"additionalProperties":false}}}},"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","name","email","createdAt"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/customers/{id}":{"get":{"summary":"Get a customer","tags":["Customers"],"parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","name","email","createdAt"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/orders":{"get":{"summary":"List orders","tags":["Orders"],"description":"Newest first. Filter by status or customer.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"in":"query","name":"limit","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"cursor","required":false},{"schema":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"in":"query","name":"status","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"customerId","required":false}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer"},"customerId":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"lines":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPriceCents":{"type":"integer"}},"required":["productId","name","quantity","unitPriceCents"]}},"subtotalCents":{"type":"integer"},"shippingCents":{"type":"integer"},"totalCents":{"type":"integer"},"paymentId":{"type":["null","string"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","number","customerId","status","lines","subtotalCents","shippingCents","totalCents","paymentId","createdAt","updatedAt"]}},"total":{"type":"integer"},"nextCursor":{"type":["null","string"]}},"required":["data","total","nextCursor"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"summary":"Place an order","tags":["Orders"],"description":"Checks the customer, the products and the stock, reserves the stock, and starts the payment. Send an Idempotency-Key header to make retries safe: the same key with the same body returns the first result instead of a second order.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"customerId":{"type":"string","maxLength":40},"items":{"type":"array","minItems":1,"maxItems":10,"items":{"type":"object","properties":{"productId":{"type":"string","maxLength":40},"quantity":{"type":"integer","minimum":1,"maximum":20}},"required":["productId","quantity"],"additionalProperties":false}}},"required":["customerId","items"],"additionalProperties":false}}}},"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":100},"in":"header","name":"idempotency-key","required":false}],"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer"},"customerId":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"lines":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPriceCents":{"type":"integer"}},"required":["productId","name","quantity","unitPriceCents"]}},"subtotalCents":{"type":"integer"},"shippingCents":{"type":"integer"},"totalCents":{"type":"integer"},"paymentId":{"type":["null","string"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","number","customerId","status","lines","subtotalCents","shippingCents","totalCents","paymentId","createdAt","updatedAt"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"422":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/orders/{id}":{"get":{"summary":"Get an order","tags":["Orders"],"parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer"},"customerId":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"lines":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPriceCents":{"type":"integer"}},"required":["productId","name","quantity","unitPriceCents"]}},"subtotalCents":{"type":"integer"},"shippingCents":{"type":"integer"},"totalCents":{"type":"integer"},"paymentId":{"type":["null","string"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","number","customerId","status","lines","subtotalCents","shippingCents","totalCents","paymentId","createdAt","updatedAt"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/orders/{id}/cancel":{"post":{"summary":"Cancel an unpaid order","tags":["Orders"],"description":"Releases the reserved stock. Paid orders are refunded instead.","parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer"},"customerId":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"lines":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPriceCents":{"type":"integer"}},"required":["productId","name","quantity","unitPriceCents"]}},"subtotalCents":{"type":"integer"},"shippingCents":{"type":"integer"},"totalCents":{"type":"integer"},"paymentId":{"type":["null","string"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","number","customerId","status","lines","subtotalCents","shippingCents","totalCents","paymentId","createdAt","updatedAt"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/orders/{id}/refund":{"post":{"summary":"Refund a paid order","tags":["Orders"],"parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer"},"customerId":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","cancelled","refunded"]},"lines":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer"},"unitPriceCents":{"type":"integer"}},"required":["productId","name","quantity","unitPriceCents"]}},"subtotalCents":{"type":"integer"},"shippingCents":{"type":"integer"},"totalCents":{"type":"integer"},"paymentId":{"type":["null","string"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","number","customerId","status","lines","subtotalCents","shippingCents","totalCents","paymentId","createdAt","updatedAt"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/events":{"get":{"summary":"The integration event log","tags":["Integrations"],"description":"Every step the API took with the payment provider, the email service and the CRM, newest first.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"in":"query","name":"limit","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"cursor","required":false},{"schema":{"type":"string","maxLength":40},"in":"query","name":"orderId","required":false},{"schema":{"type":"string","enum":["succeeded","failed","retrying","dead"]},"in":"query","name":"status","required":false}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string","format":"date-time"},"orderId":{"type":["null","string"]},"type":{"type":"string"},"provider":{"type":"string","enum":["payments","email","crm","api"]},"status":{"type":"string","enum":["succeeded","failed","retrying","dead"]},"attempts":{"type":"integer"},"detail":{"type":"string"}},"required":["id","at","orderId","type","provider","status","attempts","detail"]}},"total":{"type":"integer"},"nextCursor":{"type":["null","string"]}},"required":["data","total","nextCursor"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/events/{id}/replay":{"post":{"summary":"Replay a parked CRM sync","tags":["Integrations"],"parameters":[{"schema":{"type":"string","maxLength":40},"in":"path","name":"id","required":true}],"security":[{"bearerAuth":[]}],"responses":{"202":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string","format":"date-time"},"orderId":{"type":["null","string"]},"type":{"type":"string"},"provider":{"type":"string","enum":["payments","email","crm","api"]},"status":{"type":"string","enum":["succeeded","failed","retrying","dead"]},"attempts":{"type":"integer"},"detail":{"type":"string"}},"required":["id","at","orderId","type","provider","status","attempts","detail"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/webhooks/payments":{"post":{"summary":"Payment provider webhook","tags":["Integrations"],"description":"Called by the payment provider, signed with a shared secret (Webhook-Signature: t=…,v1=…). Unsigned or altered requests are refused.","responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"received":{"type":"boolean"},"result":{"type":"string"}},"required":["received","result"]}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/reports/sales":{"get":{"summary":"Sales report","tags":["Reports"],"description":"implementation=legacy runs one query per row; implementation=optimized batches its queries, caches the result and supports If-None-Match. X-Query-Count and Server-Timing show the difference.","parameters":[{"schema":{"type":"string","enum":["legacy","optimized"],"default":"optimized"},"in":"query","name":"implementation","required":false}],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"implementation":{"type":"string","enum":["legacy","optimized"]},"orders":{"type":"integer"},"revenueCents":{"type":"integer"},"byStatus":{"type":"object","additionalProperties":{"type":"integer"}},"topProducts":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"name":{"type":"string"},"units":{"type":"integer"},"revenueCents":{"type":"integer"}},"required":["productId","name","units","revenueCents"]}},"topCustomers":{"type":"array","items":{"type":"object","properties":{"customerId":{"type":"string"},"name":{"type":"string"},"orders":{"type":"integer"},"revenueCents":{"type":"integer"}},"required":["customerId","name","orders","revenueCents"]}}},"required":["implementation","orders","revenueCents","byStatus","topProducts","topCustomers"]}}}},"304":{"description":"Not modified"},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"field":{"type":"string"}},"required":["code","message"]}},"required":["error"]}}}}}}}},"servers":[{"url":"/demos/tallowbrook-api"}],"tags":[{"name":"Sandbox","description":"Your private copy of the shop"},{"name":"Catalogue"},{"name":"Customers"},{"name":"Orders"},{"name":"Integrations","description":"Payments, email and CRM, and the event log"},{"name":"Reports","description":"The same report, before and after optimisation"}]}