> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infraudit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API endpoints for cost data and forecasts

> Retrieve multi-cloud billing overviews, daily cost trends, 30/60/90-day forecasts, and statistical anomalies via the InfraAudit costs API endpoints.

The costs endpoints give you programmatic access to InfraAudit's multi-cloud billing data. You can retrieve current-month overviews, daily or weekly trend breakdowns by service, cost forecasts with confidence intervals, and anomaly detection results.

Base path: `/api/v1/costs`

***

## POST /costs/sync — trigger billing sync

Fetches the latest billing data from all connected providers.

```http theme={null}
POST /api/v1/costs/sync
Authorization: Bearer <token>
```

### Response `202`

```json theme={null}
{
  "job_id": 55,
  "status": "running"
}
```

***

## GET /costs/overview — get cost overview

Returns the current month's spend, last month's total, and a breakdown by provider.

```http theme={null}
GET /api/v1/costs/overview
Authorization: Bearer <token>
```

### Response

```json theme={null}
{
  "current_month": {
    "amount": 4231.50,
    "currency": "USD",
    "from": "2024-01-01",
    "to": "2024-01-14"
  },
  "last_month": {
    "amount": 8450.00,
    "currency": "USD"
  },
  "mom_change_percent": -8.2,
  "by_provider": [
    { "provider_id": 1, "name": "AWS Production", "amount": 3800.00 },
    { "provider_id": 2, "name": "GCP Production", "amount": 431.50 }
  ]
}
```

***

## GET /costs/trend — get cost trend

Returns daily, weekly, or monthly cost data grouped by provider, service, or region.

```http theme={null}
GET /api/v1/costs/trend
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="provider_id" type="integer">
  Filter to a specific provider. Defaults to all providers.
</ParamField>

<ParamField query="days" type="integer" default="30">
  Number of days of history to return.
</ParamField>

<ParamField query="granularity" type="string" default="day">
  Aggregation granularity: `day`, `week`, or `month`.
</ParamField>

<ParamField query="group_by" type="string" default="provider">
  Group breakdown by: `provider`, `service`, or `region`.
</ParamField>

### Response

```json theme={null}
{
  "data": [
    {
      "date": "2024-01-14",
      "amount": 285.40,
      "breakdown": {
        "EC2": 180.00,
        "S3": 45.00,
        "RDS": 60.40
      }
    }
  ]
}
```

***

## GET /costs/forecast — get cost forecast

Returns a projected spend total with confidence interval and daily breakdown.

```http theme={null}
GET /api/v1/costs/forecast
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="days" type="integer" default="30">
  Forecast horizon in days: `30`, `60`, or `90`.
</ParamField>

<ParamField query="provider_id" type="integer">
  Scope forecast to a specific provider.
</ParamField>

### Response

```json theme={null}
{
  "forecast_days": 30,
  "projected_total": 8750.00,
  "confidence_interval": {
    "low": 7900.00,
    "high": 9600.00
  },
  "daily": [
    {
      "date": "2024-01-15",
      "amount": 291.67,
      "lower": 260.00,
      "upper": 320.00
    }
  ]
}
```

***

## GET /costs/anomalies — list cost anomalies

Returns days where actual spend exceeded the expected range.

```http theme={null}
GET /api/v1/costs/anomalies
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="provider_id" type="integer">
  Filter by provider.
</ParamField>

<ParamField query="days" type="integer" default="30">
  Look-back window in days.
</ParamField>

<ParamField query="status" type="string">
  Filter by status: `active` or `dismissed`.
</ParamField>

***

## POST /costs/anomalies/{id}/dismiss — dismiss anomaly

```http theme={null}
POST /api/v1/costs/anomalies/{id}/dismiss
Authorization: Bearer <token>
Content-Type: application/json
```

### Request body

<ParamField body="reason" type="string">
  Reason for dismissing the anomaly, for example `Planned migration`.
</ParamField>

```json theme={null}
{
  "reason": "Planned migration"
}
```
