> ## 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 account settings and API keys

> Manage your InfraAudit account settings, create and revoke API keys, and administer team members using the settings and API keys endpoints.

The settings endpoints let you manage API keys for programmatic access and team member access to your InfraAudit account. API key values are shown only once at creation time — store them in your secrets manager immediately.

Base path: `/api/v1/settings`

***

## API keys

### GET /settings/api-keys — list API keys

Returns all active API keys. Key values are never returned after creation — only the prefix is shown.

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

### Response

```json theme={null}
[
  {
    "id": 1,
    "name": "CI/CD Pipeline",
    "prefix": "ia_live_abc...",
    "created_at": "2024-01-10T10:00:00Z",
    "last_used_at": "2024-01-15T09:12:00Z"
  }
]
```

***

### POST /settings/api-keys — create API key

Creates a new API key. The full key value is returned only in this response.

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

#### Request body

<ParamField body="name" type="string" required>
  A descriptive name for this key, for example `CI/CD Pipeline`.
</ParamField>

```json theme={null}
{
  "name": "CI/CD Pipeline"
}
```

#### Response `201`

```json theme={null}
{
  "id": 2,
  "name": "CI/CD Pipeline",
  "key": "ia_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
```

<Warning>
  Copy the `key` value immediately. It is shown only once and cannot be retrieved again. If you lose it, delete this key and create a new one.
</Warning>

***

### DELETE /settings/api-keys/{id} — revoke API key

Revokes and permanently deletes an API key. Requests using the deleted key will immediately receive `401 Unauthorized`.

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

Returns `204 No Content`.

***

## Team members

### GET /settings/team — list members

Returns all team members with their roles.

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

### Response

```json theme={null}
[
  {
    "id": 1,
    "email": "admin@example.com",
    "role": "admin",
    "joined_at": "2024-01-01T00:00:00Z",
    "last_active_at": "2024-01-15T10:00:00Z"
  }
]
```

***

### POST /settings/team/invite — invite a member

Sends an invitation email to a new team member.

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

#### Request body

<ParamField body="email" type="string" required>
  Email address to invite.
</ParamField>

<ParamField body="role" type="string" required>
  Role to assign: `user` or `admin`.
</ParamField>

```json theme={null}
{
  "email": "newuser@example.com",
  "role": "user"
}
```

***

### PUT /settings/team/{user_id} — update member role

Updates the role for a team member.

```http theme={null}
PUT /api/v1/settings/team/{user_id}
Authorization: Bearer <token>
Content-Type: application/json
```

#### Request body

<ParamField body="role" type="string" required>
  New role: `user` or `admin`.
</ParamField>

```json theme={null}
{
  "role": "admin"
}
```

***

### DELETE /settings/team/{user_id} — remove member

Removes a team member from the account.

```http theme={null}
DELETE /api/v1/settings/team/{user_id}
Authorization: Bearer <token>
```

Returns `204 No Content`.
