> ## 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 AI-powered recommendations

> List and filter AI-generated InfraAudit recommendations for cost savings, security, and compliance — then apply or dismiss them via the REST API.

The recommendations endpoints expose InfraAudit's Gemini-powered suggestions for cost savings, security improvements, and performance optimisations. Recommendations are generated per resource and include estimated monthly savings where applicable.

Base path: `/api/v1/recommendations`

***

## GET /recommendations — list recommendations

Returns a paginated list of recommendations across all resources.

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

### Query parameters

<ParamField query="type" type="string">
  Filter by recommendation type: `cost`, `security`, or `performance`.
</ParamField>

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

<ParamField query="resource_id" type="integer">
  Filter by resource.
</ParamField>

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

<ParamField query="page" type="integer" default="1">
  Page number.
</ParamField>

<ParamField query="per_page" type="integer" default="20">
  Results per page. Maximum is 100.
</ParamField>

### Response

```json theme={null}
{
  "data": [
    {
      "id": 1,
      "type": "cost",
      "title": "Downsize overprovisioned EC2 instance",
      "description": "Instance web-server-01 uses 8% average CPU over 30 days. Downsizing from t3.large to t3.small saves approximately $42/month.",
      "estimated_monthly_savings": 42.00,
      "resource_id": 15,
      "resource_name": "web-server-01",
      "status": "pending",
      "created_at": "2024-01-15T04:30:00Z"
    }
  ],
  "meta": { "total": 8, "page": 1, "per_page": 20 }
}
```

<ResponseField name="estimated_monthly_savings" type="number">
  Estimated monthly cost savings in USD. Present only for `cost` type recommendations.
</ResponseField>

***

## GET /recommendations/{id} — get recommendation

Returns full recommendation details including step-by-step remediation instructions.

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

***

## POST /recommendations/generate — generate recommendation

Generates a new AI recommendation for a specific resource, or updates an existing pending one.

```http theme={null}
POST /api/v1/recommendations/generate
Authorization: Bearer <token>
Content-Type: application/json
```

### Request body

<ParamField body="resource_id" type="integer" required>
  The resource to generate a recommendation for.
</ParamField>

```json theme={null}
{
  "resource_id": 15
}
```

***

## POST /recommendations/{id}/apply — apply recommendation

Marks a recommendation as applied and optionally creates a remediation action.

```http theme={null}
POST /api/v1/recommendations/{id}/apply
Authorization: Bearer <token>
```

***

## POST /recommendations/{id}/dismiss — dismiss recommendation

Dismisses a recommendation with an optional reason.

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

### Request body (optional)

<ParamField body="reason" type="string">
  Explanation for dismissing this recommendation.
</ParamField>

```json theme={null}
{
  "reason": "Not applicable — instance is reserved"
}
```
