> ## 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 cloud providers

> Connect your AWS, GCP, Azure, and Kubernetes accounts to InfraAudit, list existing providers, trigger manual syncs, and remove providers via the API.

The providers endpoints let you connect cloud accounts to InfraAudit, trigger resource syncs, and remove accounts. Each cloud provider type has its own connect endpoint with provider-specific request fields.

Base path: `/api/v1/providers`

***

## POST /providers/aws/connect — connect AWS

Connect an AWS account using an IAM access key pair.

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

### Request body

<ParamField body="name" type="string" required>
  A human-readable label for this provider, for example `Production AWS`.
</ParamField>

<ParamField body="accessKeyId" type="string" required>
  Your AWS IAM access key ID.
</ParamField>

<ParamField body="secretAccessKey" type="string" required>
  Your AWS IAM secret access key.
</ParamField>

<ParamField body="region" type="string" required>
  The primary AWS region, for example `us-east-1`.
</ParamField>

```json theme={null}
{
  "name": "Production AWS",
  "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
  "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
  "region": "us-east-1"
}
```

### Response `201`

```json theme={null}
{
  "id": 1,
  "name": "Production AWS",
  "type": "aws",
  "status": "syncing",
  "created_at": "2024-01-15T10:00:00Z"
}
```

***

## POST /providers/gcp/connect — connect GCP

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

### Request body

<ParamField body="name" type="string" required>
  A human-readable label for this provider.
</ParamField>

<ParamField body="serviceAccountJson" type="string" required>
  The GCP service account JSON key file contents as a string.
</ParamField>

<ParamField body="projectId" type="string" required>
  Your GCP project ID.
</ParamField>

<ParamField body="billingDataset" type="string">
  BigQuery dataset name for billing export data.
</ParamField>

```json theme={null}
{
  "name": "GCP Production",
  "serviceAccountJson": "{ \"type\": \"service_account\", ... }",
  "projectId": "my-gcp-project",
  "billingDataset": "billing_export"
}
```

***

## POST /providers/azure/connect — connect Azure

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

### Request body

<ParamField body="name" type="string" required>
  A human-readable label for this provider.
</ParamField>

<ParamField body="clientId" type="string" required>
  Azure service principal client ID.
</ParamField>

<ParamField body="clientSecret" type="string" required>
  Azure service principal client secret.
</ParamField>

<ParamField body="tenantId" type="string" required>
  Azure Active Directory tenant ID.
</ParamField>

<ParamField body="subscriptionId" type="string" required>
  Azure subscription ID.
</ParamField>

```json theme={null}
{
  "name": "Azure Production",
  "clientId": "00000000-0000-0000-0000-000000000001",
  "clientSecret": "your-client-secret",
  "tenantId": "00000000-0000-0000-0000-000000000002",
  "subscriptionId": "00000000-0000-0000-0000-000000000003"
}
```

***

## POST /providers/kubernetes/connect — connect Kubernetes

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

### Request body

<ParamField body="name" type="string" required>
  A human-readable label for this cluster.
</ParamField>

<ParamField body="kubeconfig" type="string" required>
  The kubeconfig YAML contents as a string.
</ParamField>

```json theme={null}
{
  "name": "Production EKS",
  "kubeconfig": "apiVersion: v1\nkind: Config\n..."
}
```

***

## GET /providers — list providers

Returns all connected cloud providers.

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

### Response

```json theme={null}
[
  {
    "id": 1,
    "name": "Production AWS",
    "type": "aws",
    "status": "synced",
    "resource_count": 247,
    "last_synced_at": "2024-01-15T06:00:00Z"
  }
]
```

<ResponseField name="status" type="string">
  Current sync status: `syncing`, `synced`, or `error`.
</ResponseField>

***

## GET /providers/{id} — get provider

Returns details for a single provider. Credentials are never returned.

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

***

## POST /providers/{id}/sync — trigger manual sync

Triggers an immediate resource sync. Returns `202 Accepted` with a job ID.

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

### Response `202`

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

***

## DELETE /providers/{id} — disconnect provider

Removes stored credentials and stops future syncs. Historical data is retained.

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

Returns `204 No Content`.

<Warning>
  Deleting a provider removes its credentials immediately and stops all scheduled syncs. Resource and cost history are preserved for reporting purposes.
</Warning>
