> ## 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 resource baselines

> Create and manage configuration baselines for your cloud resources. Compare current state against a baseline to surface configuration drift findings.

A baseline is a snapshot of a resource's configuration at a specific point in time. InfraAudit uses baselines as the reference state for drift detection — any deviation from the baseline is reported as a drift finding.

Base path: `/api/v1/baselines`

***

## POST /baselines — create a baseline

Captures the current configuration of a resource as a new baseline.

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

### Request body

<ParamField body="resource_id" type="integer" required>
  The ID of the resource to baseline.
</ParamField>

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

### Response `201`

```json theme={null}
{
  "id": 7,
  "resource_id": 15,
  "configuration": { "...": "current resource config snapshot" },
  "captured_at": "2024-01-15T14:00:00Z",
  "created_by": 1
}
```

<ResponseField name="id" type="integer">
  Internal baseline ID.
</ResponseField>

<ResponseField name="configuration" type="object">
  The full resource configuration snapshot at the time the baseline was captured.
</ResponseField>

<ResponseField name="captured_at" type="string">
  ISO 8601 timestamp of when the baseline was captured.
</ResponseField>

***

## GET /baselines — list baselines

Returns all baselines for a resource.

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

### Query parameters

<ParamField query="resource_id" type="integer" required>
  The resource to list baselines for.
</ParamField>

***

## GET /baselines/{id} — get baseline

Returns the full baseline record including the configuration snapshot.

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

***

## GET /baselines/{id}/compare/{other_id} — compare two baselines

Returns a JSON diff between two baselines for the same resource. Useful for understanding how a resource's configuration has changed over time.

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

### Response

```json theme={null}
{
  "baseline_a": 5,
  "baseline_b": 7,
  "diff": [
    {
      "path": "encryption.enabled",
      "baseline_a_value": true,
      "baseline_b_value": false
    }
  ]
}
```

***

## DELETE /baselines/{id} — delete baseline

Deletes a baseline. Returns `204 No Content`.

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

<Warning>
  You cannot delete the only baseline for a resource that has active drift detection enabled. Capture a new baseline first, or disable drift detection for the resource before deleting.
</Warning>
