# Access groups API

## GET /api/v1/admin/access-groups

`GET /api/v1/admin/access-groups` · operation `listAccessGroups`

Global admin or viewer lists reusable model access groups (YAML base and console overrides) with the managed keys, YAML keys and team policies that reference each one. Requires access_groups.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | version, data and note | — |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## PUT /api/v1/admin/access-groups/{id}

`PUT /api/v1/admin/access-groups/{id}` · operation `upsertAccessGroup`

Global admin creates or edits a group with the current configuration version. Keys and team policies reference it as group:&lt;id&gt; in allowed_models; the change applies to every referencing key on its next request and is still intersected with team policies, plan rights and flags. Requires access_group_management. Canonical field names only.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required, min 0)
  - `group` ([AccessGroup](/docs/api/schemas/a/#accessgroup), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | New configuration version and group | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Stale configuration version | — |
| `422` | Unknown, wildcard, nested or duplicate model | — |


## DELETE /api/v1/admin/access-groups/{id}

`DELETE /api/v1/admin/access-groups/{id}` · operation `deleteAccessGroup`

Revert a YAML group to its declaration or remove a console group. Removal is refused while active managed keys, console team policies or YAML declarations reference it.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required, min 0)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | New version and reverted_to_yaml | — |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | No console override or feature disabled | — |
| `409` | Stale version or group still referenced | — |

