{"openapi":"3.1.0","info":{"title":"Command Deck — Tenant Data API","version":"1.0.0","description":"Read your fulfillment data and push orders/adjustments. Authenticate with a per-tenant API key (`Authorization: Bearer cd_…`) minted in Admin → API keys. All responses are scoped to your tenant. Reads are cursor-paginated; every response carries `x-ratelimit-*` headers."},"servers":[{"url":"https://{tenant}.cartforge.io/api/v1","variables":{"tenant":{"default":"your-subdomain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"cd_<prefix>_<secret>"}},"parameters":{"cursor":{"name":"cursor","in":"query","schema":{"type":"string"},"description":"Opaque next-page cursor."},"limit":{"name":"limit","in":"query","schema":{"type":"integer","default":50,"maximum":200}}},"schemas":{"ListEnvelope":{"type":"object","properties":{"data":{"type":"array","items":{}},"nextCursor":{"type":["string","null"]}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}},"OrderIngest":{"type":"object","required":["salesChannelCode","order"],"properties":{"salesChannelCode":{"type":"string","description":"Inbound code of the sales channel (or use facilityCode)."},"facilityCode":{"type":"string"},"order":{"type":"object","required":["externalOrderId","lines"],"properties":{"externalOrderId":{"type":"string"},"displayName":{"type":"string"},"shippingMethod":{"type":"string"},"shipTo":{"type":"object"},"lines":{"type":"array","items":{"type":"object","required":["sku","qty"],"properties":{"sku":{"type":"string"},"qty":{"type":"integer"}}}}}}}},"InventoryAdjustment":{"type":"object","required":["sku","facilityCode","locationCode","delta","idempotencyKey"],"properties":{"sku":{"type":"string"},"facilityCode":{"type":"string"},"locationCode":{"type":"string"},"delta":{"type":"integer","description":"Non-zero signed quantity change."},"lotNumber":{"type":"string"},"reason":{"type":"string"},"idempotencyKey":{"type":"string","minLength":8}}}}},"paths":{"/products":{"get":{"summary":"List products (master catalog)","tags":["Catalog"],"parameters":[{"$ref":"#/components/parameters/cursor"},{"$ref":"#/components/parameters/limit"}],"responses":{"200":{"description":"OK"}}}},"/inventory":{"get":{"summary":"List inventory / ATP","tags":["Inventory"],"parameters":[{"name":"level","in":"query","schema":{"type":"string","enum":["bin","facility","master"],"default":"bin"},"description":"bin = per location/lot; facility = ATP per (facility, variant); master = ATP per variant."},{"name":"sku","in":"query","schema":{"type":"string"}},{"name":"facilityCode","in":"query","schema":{"type":"string"}},{"$ref":"#/components/parameters/cursor"},{"$ref":"#/components/parameters/limit"}],"responses":{"200":{"description":"available = on_hand − reserved (ATP)"}}},"post":{"summary":"Write an inventory adjustment","tags":["Inventory"],"security":[{"bearerAuth":[]}],"description":"Requires `write` scope. Idempotent by idempotencyKey.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryAdjustment"}}}},"responses":{"200":{"description":"Applied (or no-op on idempotent replay)"},"403":{"description":"read-only key"}}}},"/orders":{"get":{"summary":"List orders","tags":["Orders"],"parameters":[{"$ref":"#/components/parameters/cursor"},{"$ref":"#/components/parameters/limit"}],"responses":{"200":{"description":"OK"}}},"post":{"summary":"Ingest an order","tags":["Orders"],"security":[{"bearerAuth":[]}],"description":"Requires `write` scope. Normalizes + routes to a facility + reserves stock.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderIngest"}}}},"responses":{"200":{"description":"Duplicate"},"201":{"description":"Allocated"},"202":{"description":"Accepted (unfulfillable/pending)"}}}},"/purchase-orders":{"get":{"summary":"List purchase orders","tags":["Inbound"],"responses":{"200":{"description":"OK"}}}},"/shipments":{"get":{"summary":"List shipments","tags":["Outbound"],"responses":{"200":{"description":"OK"}}}},"/events":{"get":{"summary":"List domain events","tags":["Events"],"responses":{"200":{"description":"OK"}}}},"/export":{"get":{"summary":"Full tenant export (JSON)","tags":["Export"],"responses":{"200":{"description":"All tenant tables"}}}}}}