# POST /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions

> Save the current cash forecast configuration as a named version

- **Tag:** cfo-portal
- **Operation ID:** `cfo_portal_create_version_api_v1_businesses__business_id__cfo_portal_cash_forecast_versions_post`

## Description

Snapshot the current cash forecast configuration + output.

The version captures the chosen budget, excluded ledgers, and
embedded one-time items, along with the full computed forecast
JSON. The snapshot is what stays stable as live data drifts; the
config is what's replayed against live data on load.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `business_id` (path, string, required)

## Request body

Schema: `CashForecastVersionCreate`

- `name` (string · required)
- `description` (string)
- `config` (CashForecastVersionConfig) → `CashForecastVersionConfig`
  - `budget_id` (string)
  - `excluded_budget_ledger_ids` (array · string)
  - `weeks` (integer)
  - `one_time_items_snapshot` (array · CashForecastOneTimeItemBase) → `CashForecastOneTimeItemBase` — Snapshot of the one-time items as they existed when the version was saved. Replays against live data don't re-load from the live ``cash_forecast_one_time_items`` table.

## Responses

### 201 — Successful Response

Schema: `CashForecastVersionDetail`

- `id` (string · required)
- `business_id` (string · required)
- `name` (string · required)
- `description` (string)
- `created_by_user_id` (string)
- `snapshot_as_of` (string · date-time · required)
- `created_at` (string · date-time · required)
- `updated_at` (string · date-time · required)
- `config` (CashForecastVersionConfig) → `CashForecastVersionConfig`
  - `budget_id` (string)
  - `excluded_budget_ledger_ids` (array · string)
  - `weeks` (integer)
  - `one_time_items_snapshot` (array · CashForecastOneTimeItemBase) → `CashForecastOneTimeItemBase` — Snapshot of the one-time items as they existed when the version was saved. Replays against live data don't re-load from the live ``cash_forecast_one_time_items`` table.
- `snapshot_output` (object) — Full ``CashForecast`` JSON captured at save time. Provides a stable historical view that doesn't shift as live data changes.

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "name": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/cfo-portal/cfo-portal-create-version
- OpenAPI slice: https://www.ondayzero.com/docs/reference/cfo-portal/cfo-portal-create-version/openapi.json
- Other endpoints in **cfo-portal**: https://www.ondayzero.com/docs/reference/cfo-portal
