{"openapi":"3.1.0","info":{"title":"POST /api/v1/budgets/forecast","version":"1.0.0","description":"Generate forecast"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/budgets/forecast":{"post":{"tags":["budgets"],"summary":"Generate forecast","description":"Generate a financial forecast based on historical data.","operationId":"generate_forecast_api_v1_budgets_forecast_post","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"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateForecastRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForecastResponse"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"ForecastLineItem":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id","description":"Ledger UUID."},"ledger_name":{"type":"string","title":"Ledger Name","description":"Ledger name."},"ledger_type":{"type":"string","title":"Ledger Type","description":"Ledger type."},"historical_average":{"type":"integer","title":"Historical Average","description":"Average historical monthly amount."},"historical_trend":{"type":"number","title":"Historical Trend","description":"Monthly trend (slope)."},"periods":{"items":{"$ref":"#/components/schemas/ForecastPeriod"},"type":"array","title":"Periods","description":"Forecasted periods."}},"type":"object","required":["ledger_id","ledger_name","ledger_type","historical_average","historical_trend"],"title":"ForecastLineItem","description":"Forecast for a single ledger account."},"ForecastMethodEnum":{"type":"string","enum":["linear_trend","moving_average","seasonal","year_over_year"],"title":"ForecastMethodEnum","description":"Methods for generating forecasts."},"ForecastPeriod":{"properties":{"period_date":{"type":"string","format":"date","title":"Period Date","description":"First day of the forecasted month."},"forecasted_amount":{"type":"integer","title":"Forecasted Amount","description":"Forecasted amount in cents."},"confidence_low":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Confidence Low","description":"Lower confidence bound."},"confidence_high":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Confidence High","description":"Upper confidence bound."},"is_historical":{"type":"boolean","title":"Is Historical","description":"True if this is actual historical data.","default":false}},"type":"object","required":["period_date","forecasted_amount"],"title":"ForecastPeriod","description":"Single forecast period (month)."},"ForecastResponse":{"properties":{"business_id":{"type":"string","title":"Business Id","description":"Business UUID."},"business_name":{"type":"string","title":"Business Name","description":"Business name."},"forecast_start":{"type":"string","format":"date","title":"Forecast Start","description":"Forecast period start."},"forecast_end":{"type":"string","format":"date","title":"Forecast End","description":"Forecast period end."},"method":{"$ref":"#/components/schemas/ForecastMethodEnum","description":"Method used."},"generated_at":{"type":"string","format":"date-time","title":"Generated At","description":"Generation timestamp."},"revenue_items":{"items":{"$ref":"#/components/schemas/ForecastLineItem"},"type":"array","title":"Revenue Items","description":"Revenue account forecasts."},"total_forecasted_revenue":{"type":"integer","title":"Total Forecasted Revenue","description":"Total forecasted revenue."},"expense_items":{"items":{"$ref":"#/components/schemas/ForecastLineItem"},"type":"array","title":"Expense Items","description":"Expense account forecasts."},"total_forecasted_expenses":{"type":"integer","title":"Total Forecasted Expenses","description":"Total forecasted expenses."},"forecasted_net_income":{"type":"integer","title":"Forecasted Net Income","description":"Forecasted net income."},"cash_flow_forecast":{"items":{"$ref":"#/components/schemas/ForecastPeriod"},"type":"array","title":"Cash Flow Forecast","description":"Monthly cash flow projections."},"projected_ending_cash":{"type":"integer","title":"Projected Ending Cash","description":"Projected cash at forecast end."}},"type":"object","required":["business_id","business_name","forecast_start","forecast_end","method","generated_at","total_forecasted_revenue","total_forecasted_expenses","forecasted_net_income","projected_ending_cash"],"title":"ForecastResponse","description":"Complete financial forecast."},"GenerateForecastRequest":{"properties":{"method":{"$ref":"#/components/schemas/ForecastMethodEnum","description":"Forecasting method.","default":"linear_trend"},"lookback_months":{"type":"integer","maximum":60.0,"minimum":3.0,"title":"Lookback Months","description":"Historical months to analyze.","default":12},"forecast_months":{"type":"integer","maximum":36.0,"minimum":1.0,"title":"Forecast Months","description":"Months to forecast.","default":12},"growth_rate_percent":{"type":"integer","maximum":100.0,"minimum":-50.0,"title":"Growth Rate Percent","description":"Growth rate adjustment.","default":0},"use_seasonality":{"type":"boolean","title":"Use Seasonality","description":"Apply seasonal adjustments.","default":false},"include_cash_flow":{"type":"boolean","title":"Include Cash Flow","description":"Include cash flow projections.","default":true}},"type":"object","title":"GenerateForecastRequest","description":"Request to generate a financial forecast.","example":{"forecast_months":12,"growth_rate_percent":5,"include_cash_flow":true,"lookback_months":12,"method":"linear_trend","use_seasonality":true}},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}