> ## 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.

# API Cookbook: Common InfraAudit Workflows

> End-to-end code examples for the most common InfraAudit API workflows, from connecting a cloud account to handling webhook events.

These examples walk through complete, real-world workflows using the InfraAudit REST API. Each example includes the full request sequence with curl commands and explains what to expect at each step.

<CardGroup cols={2}>
  <Card title="Connect an AWS Account" icon="aws" href="/api/examples/connect-aws">
    Authenticate, connect AWS, and verify the initial resource sync.
  </Card>

  <Card title="Run a Drift Scan" icon="radar" href="/api/examples/run-drift-scan">
    Trigger a drift scan, poll for completion, and list findings by severity.
  </Card>

  <Card title="Fetch a Cost Report" icon="circle-dollar-sign" href="/api/examples/fetch-cost-report">
    Pull 30-day cost trends, check for anomalies, and generate a PDF report.
  </Card>

  <Card title="Subscribe to Webhooks" icon="webhook" href="/api/examples/subscribe-to-webhooks">
    Register a webhook, verify signatures, and handle incoming events in Node.js.
  </Card>
</CardGroup>

## Before you start

All examples require a Bearer token. Get one from the InfraAudit web UI under **Settings → API Keys**, or by calling `POST /api/v1/auth/login`.

Set these environment variables before running any example:

```bash theme={null}
export TOKEN="your-api-token"
export BASE_URL="https://api.infraaudit.dev"   # SaaS
# or
export BASE_URL="http://localhost:8080"         # Self-hosted
```
