{"openapi":"3.1.0","info":{"title":"BittyStack device ordering","version":"2.0.0","description":"Obtain a signed USD quote, request explicit buyer approval, submit shipping details, get a Lightning invoice, then poll server-confirmed settlement. Never submit wallet secrets. Treat unpaid or uncertain results as pending."},"servers":[{"url":"https://www.bittystack.com"}],"paths":{"/api/shop/quote":{"get":{"operationId":"getDeviceQuote","summary":"Get current price, coupon discount, referral, shipping, tax and signed ten-minute quote","description":"Pass the buyer’s coupon code as coupon and the partner code from their referral link as ref. Preserve both on quote refresh. A partner-linked coupon takes precedence over ref; quotes disclose the credited partner. Do not invent or substitute a referral. Show the final discounted total to the buyer and submit the complete returned quote unchanged.","parameters":[{"name":"coupon","in":"query","required":false,"schema":{"type":"string","maxLength":32},"description":"One buyer-provided coupon code"},{"name":"ref","in":"query","required":false,"schema":{"type":"string","maxLength":32},"description":"Partner code from the buyer-provided referral link"}],"responses":{"200":{"description":"Quote and paymentsAvailable. Do not place orders while false.","content":{"application/json":{"schema":{"type":"object","properties":{"quote":{"$ref":"#/components/schemas/Quote"},"paymentsAvailable":{"type":"boolean"}},"required":["quote","paymentsAvailable"]}}}}}}},"/api/shop/orders":{"post":{"operationId":"createDeviceOrder","summary":"Order one device with approved total and US shipping details","description":"Generate a UUID requestId and a cryptographically random 32-byte lowercase hexadecimal accessKey. Persist both before submitting. Retry uncertain responses with the identical body and keys; never create a replacement order. acceptedTerms requires explicit buyer authorization of the shipping/return terms and total.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrder"}}}},"responses":{"201":{"description":"Saved order: orderId, checkoutUrl, statusUrl and paymentUrl. Store checkoutUrl privately.","content":{"application/json":{"schema":{"type":"object"}}}},"409":{"description":"Quote expired, terms changed, spending limit exceeded or conflicting retry.","content":{"application/json":{"schema":{"type":"object"}}}},"503":{"description":"Ordering unavailable. No permission to pay or fulfill.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/shop/orders/{orderId}":{"get":{"operationId":"getOrderStatus","parameters":[{"name":"orderId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"security":[{"orderAccess":[]}],"summary":"Read private server-confirmed order status; never infer payment from a client claim","responses":{"200":{"description":"Order state, immutable total, discountCents, couponCode, affiliateCode, isTest and current payment if available.","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"No matching order/access key.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/shop/orders/{orderId}/payment":{"post":{"operationId":"getLightningPayment","parameters":[{"name":"orderId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"security":[{"orderAccess":[]}],"summary":"Obtain the saved Lightning invoice for this order","description":"POST {}. Pay only with explicit user authority, using an available Lightning wallet. Do not pay expired invoices or create duplicate orders after a timeout. If your agent has no Lightning wallet, give the user checkoutUrl and wait for them to pay.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},"responses":{"200":{"description":"Order with payment.invoice, amountSats and invoiceExpiresAt, or pending creation.","content":{"application/json":{"schema":{"type":"object"}}}},"409":{"description":"Retain the original order and reconcile before another payment.","content":{"application/json":{"schema":{"type":"object"}}}},"503":{"description":"Payments unavailable; retain original order.","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"securitySchemes":{"orderAccess":{"type":"http","scheme":"bearer","description":"The 64-character accessKey created for this individual order. Never the operator token or a wallet secret."}},"schemas":{"Quote":{"type":"object","required":["version","unitPriceCents","shippingCents","taxBasisPoints","taxCents","totalCents","expiresAt","termsVersion","signature","discountCents","couponCode","couponVersion","affiliateCode","affiliateVersion","affiliateName","commissionBasisPoints","isTest"],"properties":{"version":{"type":"integer","minimum":0},"unitPriceCents":{"type":"integer","minimum":0},"shippingCents":{"type":"integer","minimum":0},"taxBasisPoints":{"type":"integer","minimum":0},"taxCents":{"type":"integer","minimum":0},"totalCents":{"type":"integer","minimum":0},"expiresAt":{"type":"integer","minimum":0},"discountCents":{"type":"integer","minimum":0},"couponVersion":{"type":"integer","minimum":0},"affiliateVersion":{"type":"integer","minimum":0},"commissionBasisPoints":{"type":"integer","minimum":0},"couponCode":{"type":["string","null"]},"affiliateCode":{"type":["string","null"]},"affiliateName":{"type":["string","null"]},"isTest":{"type":"boolean"},"termsVersion":{"type":"string"},"signature":{"type":"string","pattern":"^[a-f0-9]{64}$"}}},"Customer":{"type":"object","additionalProperties":false,"required":["name","email","address1","city","state","postalCode","country"],"properties":{"name":{"type":"string","maxLength":100},"email":{"type":"string","format":"email","maxLength":254},"address1":{"type":"string","maxLength":120},"address2":{"type":"string","maxLength":120},"city":{"type":"string","maxLength":80},"state":{"type":"string","pattern":"^[A-Z]{2}$"},"postalCode":{"type":"string","pattern":"^[0-9]{5}(-[0-9]{4})?$"},"country":{"const":"US"}}},"CreateOrder":{"type":"object","additionalProperties":false,"required":["requestId","accessKey","customer","quote","acceptedTerms","source","maxTotalCents"],"properties":{"requestId":{"type":"string","format":"uuid"},"accessKey":{"type":"string","pattern":"^[a-f0-9]{64}$"},"customer":{"$ref":"#/components/schemas/Customer"},"quote":{"$ref":"#/components/schemas/Quote"},"acceptedTerms":{"const":"device-us-2026-10-v1"},"source":{"const":"agent"},"maxTotalCents":{"type":"integer","minimum":0,"description":"The maximum USD total explicitly approved by the buyer, in cents."}}}}}}