## Cache groups (`cache-groups`)

A set of cache rules that many sites can reference; either platform groups or tenant-owned groups.

Authentication: User (some parameters admin only) · Docs: https://www-demo.kuxitong.com/en/docs/api/cache-groups

### GET `/api/v2/cache-groups`

List cache groups · Authentication: User (some parameters admin only)

Query parameters:

| Field | Type | Required | Description |
|---|---|---|---|
| `page` | integer |  | Page number, starting from 1 Default: 1 |
| `page_size` | integer |  | Items per page Default: 20 |
| `sort` | string |  | Sort fields, comma-separated; prefix `-` for descending, e.g. `-created_at,id` |
| `tenant_id` | integer |  | Admin only: filter by tenant. Ignored for tenant credentials, which only see their own tenant's data |

```sh
curl "https://panel.example.com/api/v2/cache-groups" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/cache-groups`

Create cache group · Authentication: User (some parameters admin only)

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `cache` | CacheConfig |  | Cache rules, same as the cache field ({rules, ignore_params}) of the node contract schema/site.json; validated by the server against the contract. |
| `des` | string |  | Description |
| `from_site_id` | integer |  | Save from a site (rules are taken from the site's current effective value; cache is ignored). |
| `is_default` | boolean |  | Platform default group (exactly one). |
| `name` | string | Yes | Name |
| `sort` | integer |  | Display order (smaller first). |
| `switch_site` | boolean |  | After saving, make the site reference the new group. |

```sh
curl -X POST "https://panel.example.com/api/v2/cache-groups" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### GET `/api/v2/cache-groups/{id}`

Get cache group · Authentication: User (some parameters admin only)

```sh
curl "https://panel.example.com/api/v2/cache-groups/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### PUT `/api/v2/cache-groups/{id}`

Update cache group · Authentication: User (some parameters admin only)

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `cache` | CacheConfig |  | Cache rules, same as the cache field ({rules, ignore_params}) of the node contract schema/site.json; validated by the server against the contract. |
| `des` | string |  | Description |
| `name` | string |  | Name |
| `sort` | integer |  | Display order (smaller first). |

```sh
curl -X PUT "https://panel.example.com/api/v2/cache-groups/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### DELETE `/api/v2/cache-groups/{id}`

Delete cache group · Authentication: User (some parameters admin only)

```sh
curl -X DELETE "https://panel.example.com/api/v2/cache-groups/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/cache-groups/{id}/copy`

Copy cache group · Authentication: User (some parameters admin only)

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `des` | string |  | Description |
| `name` | string | Yes | Name |
| `sort` | integer |  | Display order (smaller first). |

```sh
curl -X POST "https://panel.example.com/api/v2/cache-groups/{id}/copy" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/cache-groups/{id}/set-default`

Set as platform default group · Authentication: Admin only

```sh
curl -X POST "https://panel.example.com/api/v2/cache-groups/{id}/set-default" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

Cache groups object:

| Field | Type | Required | Description |
|---|---|---|---|
| `cache` | CacheConfig |  | Cache rules, same as the cache field ({rules, ignore_params}) of the node contract schema/site.json; validated by the server against the contract. |
| `created_at` | string |  | Created at (read-only) |
| `des` | string |  | Description |
| `from_site_id` | integer |  | Save from a site (rules are taken from the site's current effective value; cache is ignored). |
| `id` | integer |  | Record ID (read-only) |
| `is_default` | boolean |  | Platform default group (exactly one). (read-only) |
| `name` | string |  | Name |
| `site_count` | integer |  | Number of sites that reference it explicitly (tenant callers only count their own). (read-only) |
| `sort` | integer |  | Display order (smaller first). |
| `switch_site` | boolean |  | After saving, make the site reference the new group. |
| `tenant_id` | integer |  | Owning tenant; null = platform group. (read-only) |
| `updated_at` | string |  | Updated at (read-only) |
