> ## 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 report generation

> Generate, poll, and download InfraAudit reports as PDF or CSV. Covers drift findings, vulnerabilities, compliance assessment results, and cost summaries.

The reports endpoints let you generate scan reports, poll for generation status, and download the completed file. Reports are generated asynchronously and expire 24 hours after they become ready.

Base path: `/api/reports`

***

## POST /reports/generate — generate a report

Starts report generation. Returns a report ID and estimated generation time.

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

### Request body

<ParamField body="type" type="string" required>
  Report type: `drift_summary`, `vulnerability_report`, `compliance_assessment`, or `cost_report`.
</ParamField>

<ParamField body="format" type="string" required>
  Output format: `pdf` or `csv`.
</ParamField>

<ParamField body="provider_id" type="integer">
  Scope the report to a specific provider.
</ParamField>

<ParamField body="from" type="string">
  Start of the date range, in `YYYY-MM-DD` format.
</ParamField>

<ParamField body="to" type="string">
  End of the date range, in `YYYY-MM-DD` format.
</ParamField>

```json theme={null}
{
  "type": "cost_report",
  "provider_id": 1,
  "from": "2024-01-01",
  "to": "2024-01-31",
  "format": "pdf"
}
```

### Response `202`

```json theme={null}
{
  "report_id": "rpt_abc123",
  "status": "generating",
  "estimated_seconds": 15
}
```

***

## GET /reports/{id} — get report status

Poll this endpoint to check whether the report is ready.

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

### Response when complete

```json theme={null}
{
  "report_id": "rpt_abc123",
  "status": "ready",
  "download_url": "/api/reports/rpt_abc123/download",
  "expires_at": "2024-01-16T10:00:00Z"
}
```

<ResponseField name="status" type="string">
  Current status: `generating`, `ready`, or `failed`.
</ResponseField>

<ResponseField name="expires_at" type="string">
  ISO 8601 timestamp after which the download link is no longer valid.
</ResponseField>

***

## GET /reports/{id}/download — download report file

Downloads the generated report file.

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

The response uses the appropriate `Content-Type` header: `application/pdf` or `text/csv`.

<Warning>
  Download links expire 24 hours after the report becomes ready. Generate a new report if the link has expired.
</Warning>

***

## GET /reports — list recent reports

Returns reports generated in the last 30 days.

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

### Query parameters

<ParamField query="type" type="string">
  Filter by report type.
</ParamField>

<ParamField query="status" type="string">
  Filter by status: `generating`, `ready`, or `failed`.
</ParamField>
