{"openapi":"3.1.0","info":{"title":"GET /api/v1/agents/procedures","version":"1.0.0","description":"List procedures"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/agents/procedures":{"get":{"tags":["agents"],"summary":"List procedures","description":"Every SOP this business has turned into a procedure draft, newest first.","operationId":"agents_procedures_list","parameters":[{"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_list_ProcedureOut__"}}}},"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_procedures_list_api_v1_agents_procedures_get"}}},"components":{"schemas":{"AgentResultCheck":{"properties":{"tool":{"type":"string","maxLength":128,"minLength":1,"title":"Tool"},"arguments":{"additionalProperties":true,"type":"object","title":"Arguments"},"path":{"items":{"type":"string"},"type":"array","maxItems":10,"minItems":1,"title":"Path"},"operator":{"type":"string","enum":["eq","lte","gte"],"title":"Operator","default":"eq"},"expected":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"title":"Expected"}},"type":"object","required":["tool","path","expected"],"title":"AgentResultCheck","description":"A deterministic re-read, never an instruction for a model to grade itself."},"AgentSkill":{"properties":{"name":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z0-9][a-z0-9-]*$","title":"Name"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"body":{"type":"string","title":"Body","description":"Markdown the role reads when the skill applies.","default":""},"enabled":{"type":"boolean","title":"Enabled","default":true},"learned":{"type":"boolean","title":"Learned","default":false}},"type":"object","required":["name"],"title":"AgentSkill","description":"A SKILL.md-shaped skill a role carries."},"ProcedureDraft":{"properties":{"jobs":{"items":{"$ref":"#/components/schemas/ProcedureJob"},"type":"array","title":"Jobs"},"roles":{"items":{"$ref":"#/components/schemas/ProcedureRole"},"type":"array","title":"Roles"},"schedules":{"items":{"$ref":"#/components/schemas/ProcedureSchedule"},"type":"array","title":"Schedules"},"params":{"additionalProperties":true,"type":"object","title":"Params"},"notes":{"items":{"type":"string"},"type":"array","title":"Notes"}},"type":"object","title":"ProcedureDraft"},"ProcedureJob":{"properties":{"id":{"type":"string","maxLength":40,"minLength":1,"title":"Id","description":"Stable key, e.g. B4."},"title":{"type":"string","maxLength":200,"minLength":1,"title":"Title"},"role_key":{"type":"string","title":"Role Key","description":"Role-library key or the name of a role in this draft."},"cadence":{"type":"string","enum":["monthly_close","weekly","daily","on_event","once"],"title":"Cadence","default":"monthly_close"},"due_business_day":{"anyOf":[{"type":"integer","maximum":23.0,"minimum":1.0},{"type":"null"}],"title":"Due Business Day"},"level":{"type":"string","enum":["auto","gate","human"],"title":"Level","description":"auto: read-only work; gate: proposes changes; human: a person does it.","default":"gate"},"inputs":{"items":{"type":"string"},"type":"array","title":"Inputs"},"depends_on":{"items":{"type":"string"},"type":"array","maxItems":50,"title":"Depends On"},"outputs":{"items":{"type":"string"},"type":"array","title":"Outputs"},"done_when":{"type":"string","title":"Done When","default":""},"steps":{"items":{"type":"string"},"type":"array","title":"Steps"},"tools":{"items":{"type":"string"},"type":"array","title":"Tools"},"human_does":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Human Does"},"result_checks":{"items":{"$ref":"#/components/schemas/AgentResultCheck"},"type":"array","maxItems":10,"title":"Result Checks"},"checklist_item_key":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}],"title":"Checklist Item Key"}},"type":"object","required":["id","title","role_key"],"title":"ProcedureJob","description":"One job the SOP describes, mapped onto a role."},"ProcedureOut":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"source_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"draft":{"$ref":"#/components/schemas/ProcedureDraft"},"version":{"type":"integer","title":"Version"},"installed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Installed At"},"installed":{"additionalProperties":true,"type":"object","title":"Installed"},"sop_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sop Id"},"sop_commit":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sop Commit"},"sop_status":{"type":"string","enum":["in_sync","behind","unlinked"],"title":"Sop Status","default":"unlinked"},"visibility":{"type":"string","enum":["business","firm","public"],"title":"Visibility","default":"business"},"published_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Published At"},"published_by_user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Published By User Id"},"source_procedure_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Procedure Id"},"install_count":{"type":"integer","title":"Install Count","default":0},"update_available":{"type":"boolean","title":"Update Available","default":false},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","business_id","draft","version","created_at","updated_at"],"title":"ProcedureOut"},"ProcedureRole":{"properties":{"key":{"type":"string","maxLength":64,"minLength":1,"title":"Key"},"name":{"type":"string","maxLength":80,"minLength":1,"title":"Name"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"instructions":{"type":"string","title":"Instructions","default":""},"scope":{"type":"string","enum":["read","changes"],"title":"Scope","default":"read"},"skills":{"items":{"$ref":"#/components/schemas/AgentSkill"},"type":"array","title":"Skills"},"library_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Library Key"},"browser":{"type":"boolean","title":"Browser","default":false}},"type":"object","required":["key","name"],"title":"ProcedureRole"},"ProcedureSchedule":{"properties":{"job_id":{"type":"string","title":"Job Id"},"cadence":{"type":"string","enum":["monthly_close","weekly","daily","on_event","once"],"title":"Cadence"},"due_business_day":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Due Business Day"},"cron":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cron"},"event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Event","description":"For on_event: plaid.sync.completed, stripe.payout.landed, ..."}},"type":"object","required":["job_id","cadence"],"title":"ProcedureSchedule"},"SuccessEnvelope_list_ProcedureOut__":{"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":[{"items":{"$ref":"#/components/schemas/ProcedureOut"},"type":"array"},{"type":"null"}],"title":"Data"}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[list[ProcedureOut]]"},"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":[]}]}