{"openapi":"3.1.0","info":{"title":"Nutritiono","version":"0.1.0"},"servers":[{"url":"https://intake.story0.com"}],"security":[{"oauth":["intake:read"]}],"paths":{"/v1/entries":{"post":{"summary":"Log intake for the authenticated account","security":[{"oauth":["intake:write"]}],"parameters":[{"in":"header","name":"Idempotency-Key","schema":{"type":"string","maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"category":{"type":"string","enum":["food","beverage","alcohol","cannabis","medication","supplement","other"]},"name":{"type":"string","minLength":1,"maxLength":200},"occurred_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,6})?(?:Z|[+-]\\d{2}:\\d{2})$"},"quantity":{"type":"object","properties":{"value":{"type":"number","minimum":0,"maximum":1000000000},"unit":{"type":"string","minLength":1,"maxLength":24}},"required":["value","unit"],"additionalProperties":false},"basis":{"default":"user_reported","type":"string","enum":["measured","estimated","user_reported"]},"route":{"type":"string","minLength":1,"maxLength":64},"nutrients":{"type":"object","properties":{"calories_kcal":{"type":"number","minimum":0,"maximum":1000000000},"protein_g":{"type":"number","minimum":0,"maximum":1000000000},"carbs_g":{"type":"number","minimum":0,"maximum":1000000000},"fat_g":{"type":"number","minimum":0,"maximum":1000000000},"fiber_g":{"type":"number","minimum":0,"maximum":1000000000},"micronutrients":{"type":"object","propertyNames":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"additionalProperties":{"type":"object","properties":{"value":{"type":"number","minimum":0,"maximum":1000000000},"unit":{"type":"string","enum":["g","mg","mcg"]}},"required":["value","unit"],"additionalProperties":false}}},"additionalProperties":false},"compounds":{"maxItems":32,"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-zA-Z][a-zA-Z0-9 _-]*$"},"value":{"type":"number","minimum":0,"maximum":1000000000},"unit":{"type":"string","enum":["g","mg","mcg","ml","l","iu","G","MG","MCG","ML","L","IU"]}},"required":["name","value","unit"],"additionalProperties":false}}},"required":["category","name","occurred_at","quantity"],"additionalProperties":false}}}},"responses":{"200":{"description":"Idempotent replay"},"201":{"description":"Created"},"409":{"description":"Key reused with different payload"}}},"get":{"summary":"Search scoped entries and aggregate every matching row","parameters":[{"name":"query","in":"query","schema":{"type":"string","minLength":1,"maxLength":200}},{"name":"category","in":"query","schema":{"type":"string","enum":["food","beverage","alcohol","cannabis","medication","supplement","other"]}},{"name":"window","in":"query","schema":{"default":"today","type":"string","enum":["today","past_24_hours","past_week","custom"]}},{"name":"timezone","in":"query","schema":{"default":"UTC","type":"string","minLength":1,"maxLength":100}},{"name":"from","in":"query","schema":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,6})?(?:Z|[+-]\\d{2}:\\d{2})$"}},{"name":"to","in":"query","schema":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,6})?(?:Z|[+-]\\d{2}:\\d{2})$"}},{"name":"limit","in":"query","schema":{"default":50,"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","schema":{"type":"string","minLength":1,"maxLength":4096,"pattern":"^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"}}],"responses":{"200":{"description":"Entries, full-window totals, coverage and cursor"}}}},"/v1/entries/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"responses":{"200":{"description":"Own entry"},"404":{"description":"Unavailable"}}},"delete":{"security":[{"oauth":["intake:write"]}],"responses":{"204":{"description":"Deleted"},"404":{"description":"Unavailable"}}}},"/v1/profile":{"get":{"responses":{"200":{"description":"Stable opaque authenticated profile ID"}}}}},"components":{"securitySchemes":{"oauth":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://intake.story0.com/oauth/authorize","tokenUrl":"https://intake.story0.com/oauth/token","scopes":{"intake:read":"Read own intake","intake:write":"Create and delete own intake"}}}}}}}