# Get spend forecast

> Returns forecasted spend value, confidence bounds, and a 60-point sparkline (past 30 days actual + next 30 days forecast).

Source: https://docs.levelfour.ai/api-reference/costs/get-costs-forecast


## GET /api/v1/costs/forecast

Returns forecasted spend value, confidence bounds, and a 60-point sparkline (past 30 days actual + next 30 days forecast).

### Authentication

Send `Authorization: Bearer <token>`.

### Parameters

- `provider` (query, string, default `aws`): Provider to forecast, or all. A provider with no costs returns an empty forecast.
- `horizon` (query, string, default `eom`): Forecast horizon
- `credits` (query, one of `before`, `after`, default `after`): Cost basis for Google Cloud: after credits (default) or before them. AWS stays on its invoiced basis.

### Responses

#### 200: Successful Response

- `success` (boolean, default `true`)
- `timestamp` (date-time string)
- `data` (object, required)
  - `forecast_value` (number, required): Forecasted value for the horizon
  - `forecast_low` (number, required): Lower confidence bound
  - `forecast_high` (number, required): Upper confidence bound
  - `confidence_pct` (number, required): Confidence percent (default 80)
  - `sparkline` (array of number, required): 60 values: past 30 days actual + next 30 forecasted
  - `future_start_index` (integer, required): Index in sparkline where future starts (0-based)
  - `delta_pct_vs_last_month` (number, nullable): Forecast value vs previous month total, as percent
  - `booked_to_date` (number, nullable): Spend already booked this month
  - `daily_rate` (number, nullable): Median daily spend the projection uses
  - `days_remaining` (integer, nullable): Days the projection covers, counted from the last actual
  - `actuals_through` (string, nullable): Last day with billing data, YYYY-MM-DD. Days after it are projected, not booked.
  - `days_since_last_actual` (integer, nullable): How far behind today the billing data stops. Above zero means the projection covers days already past.
  - `daily_rate_sample_days` (integer, nullable): Days in the trailing window that carried any billing data
  - `daily_rate_thin_days` (integer, nullable): Sampled days worth less than a tenth of the median. Above zero usually means an account stopped delivering billing data rather than that spend fell.
  - `daily_rate_window_days` (integer, nullable): Length of the trailing window, in days
  - `credits` (one of `before`, `after`, nullable): Cost basis applied: after or before Google Cloud credits

#### Errors

- `400`: Bad Request
- `401`: Authentication Error
- `403`: Authorization Error
- `404`: Not Found
- `409`: Conflict
- `422`: Validation Error
- `429`: Rate Limit Exceeded
- `500`: Internal Server Error

Body of `400`, `401`, `403`, `404`, `409`, `422`, `429`, `500`:

- `success` (`false`, required)
- `error` (object, required)
  - `code` (string, required)
  - `message` (string, required)
  - `details` (any)
- `timestamp` (date-time string, required)
