{"openapi":"3.1.0","info":{"title":"GET /api/v1/agents/roi","version":"1.0.0","description":"Role spend and outcome ROI metrics"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/agents/roi":{"get":{"tags":["agents"],"summary":"Role spend and outcome ROI metrics","description":"Per-role spend, approved proposals, revert rate, shadow mode, and estimated hours saved.","operationId":"agents_role_roi","parameters":[{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"default":30,"title":"Days"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_RoleRoiResponse_"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"agents_role_roi_api_v1_agents_roi_get"}}},"components":{"schemas":{"RoleRoiItem":{"properties":{"role_id":{"type":"string","title":"Role Id"},"role_name":{"type":"string","title":"Role Name"},"scope":{"type":"string","title":"Scope"},"shadow_mode":{"type":"boolean","title":"Shadow Mode","default":false},"runs_count":{"type":"integer","title":"Runs Count","default":0},"completed_runs":{"type":"integer","title":"Completed Runs","default":0},"shadow_runs_count":{"type":"integer","title":"Shadow Runs Count","default":0},"spend_usd":{"type":"number","title":"Spend Usd","default":0.0},"proposals_created":{"type":"integer","title":"Proposals Created","default":0},"proposals_approved":{"type":"integer","title":"Proposals Approved","default":0},"proposals_rejected":{"type":"integer","title":"Proposals Rejected","default":0},"proposals_reverted":{"type":"integer","title":"Proposals Reverted","default":0},"approval_rate":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Approval Rate"},"estimated_hours_saved":{"type":"number","title":"Estimated Hours Saved","default":0.0},"standing_rules_count":{"type":"integer","title":"Standing Rules Count","default":0},"event_triggers_count":{"type":"integer","title":"Event Triggers Count","default":0}},"type":"object","required":["role_id","role_name","scope"],"title":"RoleRoiItem"},"RoleRoiResponse":{"properties":{"days":{"type":"integer","title":"Days"},"total_spend_usd":{"type":"number","title":"Total Spend Usd"},"total_proposals_approved":{"type":"integer","title":"Total Proposals Approved"},"total_estimated_hours_saved":{"type":"number","title":"Total Estimated Hours Saved"},"roles":{"items":{"$ref":"#/components/schemas/RoleRoiItem"},"type":"array","title":"Roles"}},"type":"object","required":["days","total_spend_usd","total_proposals_approved","total_estimated_hours_saved","roles"],"title":"RoleRoiResponse"},"SuccessEnvelope_RoleRoiResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/RoleRoiResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[RoleRoiResponse]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}