{"openapi":"3.1.0","info":{"title":"GET /api/v1/agents/needs-you","version":"1.0.0","description":"What agents need from you"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/agents/needs-you":{"get":{"tags":["agents"],"summary":"What agents need from you","description":"Pending proposed changes, open cards, parked questions and recent failed runs for this business, or every business you can see with `all=true`.","operationId":"agents_needs_you","parameters":[{"name":"all","in":"query","required":false,"schema":{"type":"boolean","description":"Every business the caller can see","default":false,"title":"All"},"description":"Every business the caller can see"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"counts_only","in":"query","required":false,"schema":{"type":"boolean","description":"Only the counts; every item list comes back empty","default":false,"title":"Counts Only"},"description":"Only the counts; every item list comes back empty"},{"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_NeedsYouResponse_"}}}},"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_needs_you_api_v1_agents_needs_you_get"}}},"components":{"schemas":{"ConflictingChange":{"properties":{"id":{"type":"string","title":"Id"},"summary":{"type":"string","title":"Summary"},"what":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"What","description":"What the other proposal sets, e.g. 'tag Pecan (0077)'."},"records":{"type":"integer","title":"Records","description":"Records both proposals change.","default":1}},"type":"object","required":["id","summary"],"title":"ConflictingChange","description":"Another waiting proposal that changes the same record."},"FreshLook":{"properties":{"id":{"type":"string","title":"Id"},"summary":{"type":"string","title":"Summary"},"decided_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Decided At"}},"type":"object","required":["id","summary"],"title":"FreshLook","description":"A change applied to the same record after this one was proposed."},"NeedsYouCard":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"run_id":{"type":"string","title":"Run Id"},"run_title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Title"},"role_name":{"type":"string","title":"Role Name","default":""},"kind":{"type":"string","enum":["permission","question","sign_in","secret"],"title":"Kind"},"title":{"type":"string","title":"Title"},"body":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Body"},"payload":{"additionalProperties":true,"type":"object","title":"Payload"},"status":{"type":"string","enum":["pending","answered","denied","expired","cancelled"],"title":"Status"},"answer":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Answer"},"answered_by_user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Answered By User Id"},"answered_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Answered At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"can_answer":{"type":"boolean","title":"Can Answer","description":"Whether the caller may answer it: a question, sign-in or secret needs write permission; a permission card the requester or an admin.","default":true},"business_name":{"type":"string","title":"Business Name","default":""},"requester_user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Requester User Id"},"channel_post_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Channel Post Id"}},"type":"object","required":["id","business_id","run_id","kind","title","status","created_at"],"title":"NeedsYouCard","description":"A pending card plus who asked for the run, so a client can tell a\npermission card's requester from everyone else (``can_answer`` is true\nfor every reader here; the answer endpoint enforces the rule)."},"NeedsYouFailedRun":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"business_name":{"type":"string","title":"Business Name","default":""},"title":{"type":"string","title":"Title"},"brief":{"type":"string","title":"Brief"},"done_when":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Done When"},"role_id":{"type":"string","title":"Role Id"},"role_name":{"type":"string","title":"Role Name","default":""},"outcome":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Outcome"},"outcome_detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Outcome Detail"},"finished_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Finished At"},"channel_post_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Channel Post Id"},"question":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Question","description":"The question it was waiting on when it expired unanswered."},"reopenable":{"type":"boolean","title":"Reopenable","description":"It expired waiting for an answer: `POST /runs/{id}/reopen`.","default":false}},"type":"object","required":["id","business_id","title","brief","role_id"],"title":"NeedsYouFailedRun","description":"A run that failed in the last seven days, with what a retry needs."},"NeedsYouPendingChange":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"business_name":{"type":"string","title":"Business Name","default":""},"summary":{"type":"string","title":"Summary"},"tool_name":{"type":"string","title":"Tool Name"},"tier":{"type":"integer","title":"Tier","default":2},"tier_reasons":{"items":{"type":"string"},"type":"array","title":"Tier Reasons"},"impact_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Impact Cents"},"destructive":{"type":"boolean","title":"Destructive","default":false},"agent_run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Run Id"},"agent_role_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Role Id"},"agent_role_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Role Name"},"channel_post_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Channel Post Id"},"proposed_by_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Proposed By Name"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason","description":"Why the teammate proposed it: SOP rule, evidence"},"blocked_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Blocked By","description":"The waiting change to approve before this one (it needs it)"},"records":{"items":{"$ref":"#/components/schemas/ProposalRecordLine"},"type":"array","title":"Records","description":"The first records the change touches"},"records_total":{"type":"integer","title":"Records Total","description":"Every record the change touches","default":0},"conflicts":{"items":{"$ref":"#/components/schemas/ConflictingChange"},"type":"array","title":"Conflicts","description":"Other waiting proposals that change the same record"},"fresh_look":{"anyOf":[{"$ref":"#/components/schemas/FreshLook"},{"type":"null"}],"description":"A change applied to the same record since this was proposed"}},"type":"object","required":["id","business_id","summary","tool_name","created_at"],"title":"NeedsYouPendingChange","description":"A proposed change waiting for a decision, with the job that filed it."},"NeedsYouQuestion":{"properties":{"run_id":{"type":"string","title":"Run Id"},"business_id":{"type":"string","title":"Business Id"},"business_name":{"type":"string","title":"Business Name","default":""},"title":{"type":"string","title":"Title"},"role_id":{"type":"string","title":"Role Id"},"role_name":{"type":"string","title":"Role Name","default":""},"text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Text"},"options":{"items":{"type":"string"},"type":"array","title":"Options"},"channel_post_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Channel Post Id"},"asked_at":{"type":"string","format":"date-time","title":"Asked At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At","description":"When the parked job closes as 'Expired: no answer' if nobody answers (it can be reopened)."}},"type":"object","required":["run_id","business_id","title","role_id","asked_at"],"title":"NeedsYouQuestion","description":"A run parked on a question with no card; ``POST /runs/{id}/answer`` resumes it."},"NeedsYouResponse":{"properties":{"proposed_changes":{"type":"integer","title":"Proposed Changes","default":0},"cards":{"type":"integer","title":"Cards","default":0},"sign_ins":{"type":"integer","title":"Sign Ins","default":0},"question_cards":{"type":"integer","title":"Question Cards","default":0},"questions":{"type":"integer","title":"Questions","default":0},"failed_runs":{"type":"integer","title":"Failed Runs","default":0},"total":{"type":"integer","title":"Total","default":0},"replenishment_proposals":{"type":"integer","title":"Replenishment Proposals","default":0},"items":{"items":{"$ref":"#/components/schemas/NeedsYouRow"},"type":"array","title":"Items"},"pending_changes":{"items":{"$ref":"#/components/schemas/NeedsYouPendingChange"},"type":"array","title":"Pending Changes"},"card_items":{"items":{"$ref":"#/components/schemas/NeedsYouCard"},"type":"array","title":"Card Items"},"sign_in_items":{"items":{"$ref":"#/components/schemas/NeedsYouCard"},"type":"array","title":"Sign In Items"},"question_items":{"items":{"$ref":"#/components/schemas/NeedsYouQuestion"},"type":"array","title":"Question Items"},"failed_run_items":{"items":{"$ref":"#/components/schemas/NeedsYouFailedRun"},"type":"array","title":"Failed Run Items"}},"type":"object","title":"NeedsYouResponse"},"NeedsYouRow":{"properties":{"kind":{"type":"string","enum":["proposed_change","card","question","failed_run","sign_in"],"title":"Kind"},"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"business_name":{"type":"string","title":"Business Name","default":""},"title":{"type":"string","title":"Title"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"},"role_name":{"type":"string","title":"Role Name","default":""},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"action_url":{"type":"string","title":"Action Url"}},"type":"object","required":["kind","id","business_id","title","created_at","action_url"],"title":"NeedsYouRow"},"ProposalRecordLine":{"properties":{"label":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Label","description":"Merchant, number or name"},"field":{"type":"string","title":"Field","description":"What changes on the record"},"before":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Before"},"after":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"After"},"amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount Cents"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail","description":"The record's bank text and account"},"receipt":{"anyOf":[{"$ref":"#/components/schemas/ReceiptPreview"},{"type":"null"}]}},"type":"object","required":["field"],"title":"ProposalRecordLine","description":"One record a proposed change touches, as a card line reads it."},"ReceiptPreview":{"properties":{"email_id":{"type":"string","title":"Email Id"},"file_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"File Name"},"s3_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"S3 Key","description":"Attachment key; POST /emails/{email_id}/attachments/{s3_key} signs it."},"content_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Content Type"},"sender":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sender","description":"Who sent it (the original sender of a forward)."},"subject":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject"},"received_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Received At"},"note":{"items":{"type":"string"},"type":"array","title":"Note","description":"First lines written with the receipt."},"read":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Read","description":"What reading the file found: document type, confidence."},"found":{"additionalProperties":{"type":"string"},"type":"object","title":"Found","description":"Values read from the file: merchant, date, total, description."}},"type":"object","required":["email_id"],"title":"ReceiptPreview","description":"The emailed receipt an ``attach_email_receipt`` proposal would file."},"SuccessEnvelope_NeedsYouResponse_":{"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/NeedsYouResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[NeedsYouResponse]"},"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":[]}]}