{"openapi":"3.0.3","info":{"title":"Stock Room public API","version":"1","description":"Read stock and record movements. Authenticate with header X-API-Key (create keys in Admin → API keys). Read-only keys can call GET endpoints; write keys can also POST movements. Intended for the IDEALX website and for LLM agents that answer stock questions."},"servers":[{"url":"http://stock.idealx.store/api/v1/public"}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"Item":{"type":"object","properties":{"sku":{"type":"string"},"brand":{"type":"string"},"article":{"type":"string"},"colour":{"type":"string"},"size":{"type":"string"},"cat":{"type":"string","enum":["boot","shoe","jacket","bag","belt","other"]},"qty":{"type":"integer"},"mrp":{"type":"integer","description":"rupees"},"cost":{"type":"integer","description":"rupees"},"loc":{"type":"string"},"updatedAt":{"type":"string","format":"date-time"}}},"Movement":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"sku":{"type":"string"},"type":{"type":"string","enum":["new","in","out","count","adj","delete"]},"delta":{"type":"integer"},"before":{"type":"integer"},"after":{"type":"integer"},"note":{"type":"string"},"ref":{"type":"string","nullable":true},"at":{"type":"string","format":"date-time"}}}}},"security":[{"ApiKey":[]}],"paths":{"/stock":{"get":{"summary":"All items with current quantity","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"asOf":{"type":"string"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Item"}}}}}}}}}},"/items/{sku}":{"get":{"summary":"One item with its last 50 movements","parameters":[{"name":"sku","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"},"404":{"description":"Unknown SKU"}}}},"/summary":{"get":{"summary":"Aggregated digest: totals, ageing, dead stock, top sellers, size gaps. Designed for LLM consumption.","responses":{"200":{"description":"OK"}}}},"/movements":{"post":{"summary":"Record a stock movement (idempotent on id)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sku","type"],"properties":{"id":{"type":"string","format":"uuid","description":"Client-generated; repeating it returns the original result"},"sku":{"type":"string"},"type":{"type":"string","enum":["in","out","count","adj"]},"delta":{"type":"integer","description":"for in/out/adj; negative for out"},"counted":{"type":"integer","description":"for count"},"note":{"type":"string"},"ref":{"type":"string"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"item":{"$ref":"#/components/schemas/Item"},"movement":{"$ref":"#/components/schemas/Movement"},"idempotent":{"type":"boolean"}}}}}},"403":{"description":"Key lacks write scope"},"404":{"description":"Unknown SKU"}}}}}}