{"openapi":"3.1.0","info":{"title":"GET /api/v1/advisory-firms/{firm_id}/clients/{business_id}/digest-preview","version":"1.0.0","description":"Preview a client's financial digest"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/advisory-firms/{firm_id}/clients/{business_id}/digest-preview":{"get":{"tags":["client-digest-preview"],"summary":"Preview a client's financial digest","description":"The data a client's weekly or monthly digest email and PDF would carry right now: health score, AR/AP, cash and runway, budget vs actual, highlights. Nothing is sent.","operationId":"preview_client_digest","parameters":[{"name":"firm_id","in":"path","required":true,"schema":{"type":"string","title":"Firm Id"}},{"name":"business_id","in":"path","required":true,"schema":{"type":"string","title":"Business Id"}},{"name":"frequency","in":"query","required":false,"schema":{"enum":["weekly","monthly"],"type":"string","default":"monthly","title":"Frequency"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_ClientDigestPreviewResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"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"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","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":"preview_client_digest_api_v1_advisory_firms__firm_id__clients__business_id__digest_preview_get"}}},"components":{"schemas":{"ClientDigestContent":{"properties":{"business_name":{"type":"string","title":"Business Name"},"period_label":{"type":"string","title":"Period Label"},"period_start":{"type":"string","format":"date","title":"Period Start"},"period_end":{"type":"string","format":"date","title":"Period End"},"as_of":{"type":"string","format":"date","title":"As Of"},"activity":{"$ref":"#/components/schemas/DigestActivity"},"ar_aging":{"anyOf":[{"$ref":"#/components/schemas/DigestArAging"},{"type":"null"}]},"ap_upcoming":{"anyOf":[{"$ref":"#/components/schemas/DigestApUpcoming"},{"type":"null"}]},"cash_position":{"anyOf":[{"$ref":"#/components/schemas/DigestCashPosition"},{"type":"null"}]},"budget_vs_actual":{"anyOf":[{"$ref":"#/components/schemas/DigestBudgetVsActual"},{"type":"null"}]},"health":{"anyOf":[{"$ref":"#/components/schemas/DigestHealthScore"},{"type":"null"}]},"highlights":{"items":{"type":"string"},"type":"array","title":"Highlights"}},"type":"object","required":["business_name","period_label","period_start","period_end","as_of","activity"],"title":"ClientDigestContent","description":"Everything the digest email and PDF render, as plain data."},"ClientDigestPreviewResponse":{"properties":{"business_id":{"type":"string","title":"Business Id"},"frequency":{"type":"string","title":"Frequency"},"digest":{"$ref":"#/components/schemas/ClientDigestContent"},"pdf_filename":{"type":"string","title":"Pdf Filename"}},"type":"object","required":["business_id","frequency","digest","pdf_filename"],"title":"ClientDigestPreviewResponse"},"DigestActivity":{"properties":{"money_in_cents":{"type":"integer","title":"Money In Cents","default":0},"money_out_cents":{"type":"integer","title":"Money Out Cents","default":0},"net_cents":{"type":"integer","title":"Net Cents","default":0},"transaction_count":{"type":"integer","title":"Transaction Count","default":0},"top_spend":{"items":{"$ref":"#/components/schemas/DigestTopSpend"},"type":"array","title":"Top Spend"}},"type":"object","title":"DigestActivity","description":"Money in / out for the digest window."},"DigestAgingBucket":{"properties":{"key":{"type":"string","title":"Key","description":"current, 1_30, 31_60, 61_90, 90_plus or unknown_due"},"label":{"type":"string","title":"Label"},"amount_cents":{"type":"integer","title":"Amount Cents"}},"type":"object","required":["key","label","amount_cents"],"title":"DigestAgingBucket"},"DigestApBill":{"properties":{"vendor":{"type":"string","title":"Vendor"},"amount_cents":{"type":"integer","title":"Amount Cents"},"due_date":{"type":"string","format":"date","title":"Due Date"}},"type":"object","required":["vendor","amount_cents","due_date"],"title":"DigestApBill"},"DigestApUpcoming":{"properties":{"window_days":{"type":"integer","title":"Window Days"},"total_cents":{"type":"integer","title":"Total Cents"},"bill_count":{"type":"integer","title":"Bill Count"},"bills":{"items":{"$ref":"#/components/schemas/DigestApBill"},"type":"array","title":"Bills"}},"type":"object","required":["window_days","total_cents","bill_count"],"title":"DigestApUpcoming"},"DigestArAging":{"properties":{"total_cents":{"type":"integer","title":"Total Cents"},"overdue_cents":{"type":"integer","title":"Overdue Cents"},"overdue_percent":{"type":"number","title":"Overdue Percent"},"buckets":{"items":{"$ref":"#/components/schemas/DigestAgingBucket"},"type":"array","title":"Buckets"},"top_overdue_customers":{"items":{"$ref":"#/components/schemas/DigestOverdueCustomer"},"type":"array","title":"Top Overdue Customers"}},"type":"object","required":["total_cents","overdue_cents","overdue_percent","buckets"],"title":"DigestArAging"},"DigestBudgetVariance":{"properties":{"name":{"type":"string","title":"Name"},"budget_cents":{"type":"integer","title":"Budget Cents"},"actual_cents":{"type":"integer","title":"Actual Cents"},"favorable":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Favorable"}},"type":"object","required":["name","budget_cents","actual_cents"],"title":"DigestBudgetVariance"},"DigestBudgetVsActual":{"properties":{"budget_name":{"type":"string","title":"Budget Name"},"revenue_budget_cents":{"type":"integer","title":"Revenue Budget Cents"},"revenue_actual_cents":{"type":"integer","title":"Revenue Actual Cents"},"expense_budget_cents":{"type":"integer","title":"Expense Budget Cents"},"expense_actual_cents":{"type":"integer","title":"Expense Actual Cents"},"net_income_budget_cents":{"type":"integer","title":"Net Income Budget Cents"},"net_income_actual_cents":{"type":"integer","title":"Net Income Actual Cents"},"top_variances":{"items":{"$ref":"#/components/schemas/DigestBudgetVariance"},"type":"array","title":"Top Variances"}},"type":"object","required":["budget_name","revenue_budget_cents","revenue_actual_cents","expense_budget_cents","expense_actual_cents","net_income_budget_cents","net_income_actual_cents"],"title":"DigestBudgetVsActual"},"DigestCashPosition":{"properties":{"cash_on_hand_cents":{"type":"integer","title":"Cash On Hand Cents"},"avg_monthly_burn_cents":{"type":"integer","title":"Avg Monthly Burn Cents"},"runway_months":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Runway Months","description":"Months of cash at the trailing burn; None when not burning cash."}},"type":"object","required":["cash_on_hand_cents","avg_monthly_burn_cents"],"title":"DigestCashPosition"},"DigestHealthComponent":{"properties":{"key":{"type":"string","title":"Key"},"label":{"type":"string","title":"Label"},"points":{"type":"number","title":"Points","description":"Points earned, 0..max_points."},"max_points":{"type":"integer","title":"Max Points"},"detail":{"type":"string","title":"Detail","description":"The measured number behind the points."}},"type":"object","required":["key","label","points","max_points","detail"],"title":"DigestHealthComponent"},"DigestHealthScore":{"properties":{"score":{"type":"integer","maximum":100.0,"minimum":0.0,"title":"Score"},"label":{"type":"string","title":"Label"},"components":{"items":{"$ref":"#/components/schemas/DigestHealthComponent"},"type":"array","title":"Components"},"explanation":{"type":"string","title":"Explanation"}},"type":"object","required":["score","label","components","explanation"],"title":"DigestHealthScore"},"DigestOverdueCustomer":{"properties":{"name":{"type":"string","title":"Name"},"overdue_cents":{"type":"integer","title":"Overdue Cents"},"oldest_days_past_due":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Oldest Days Past Due"}},"type":"object","required":["name","overdue_cents"],"title":"DigestOverdueCustomer"},"DigestTopSpend":{"properties":{"name":{"type":"string","title":"Name"},"amount_cents":{"type":"integer","title":"Amount Cents"}},"type":"object","required":["name","amount_cents"],"title":"DigestTopSpend"},"SuccessEnvelope_ClientDigestPreviewResponse_":{"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/ClientDigestPreviewResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[ClientDigestPreviewResponse]"},"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":[]}]}