## Node groups (`node-groups`)

Groups lines under one access name; a backup threshold can switch to the backup group automatically when usable lines run low.

Authentication: Admin only · Docs: https://www-demo.kuxitong.com/en/docs/api/node-groups

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

List node groups · Authentication: 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` |
| `ids` | string |  | Only list these IDs: comma-separated positive integers, at most 200 after deduplication (same as the page_size limit; more returns 400); an empty value is the same as omitting it. Combined with other filters as an intersection; IDs you cannot see are silently left out. Pagination is unchanged: set page_size to at least the number of IDs to get them in one page |

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

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

Create node group · Authentication: Admin only

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `backup_interval_s` | integer |  | Rotation interval in seconds in interval mode. |
| `backup_ip_num` | integer |  | Number of backup IPs in use per rotation in interval mode. |
| `backup_min_online` | integer |  | When usable lines in the group drop below this, access names referencing the group are switched to their own backup groups; 0 = never switch automatically, default 1 (switch when none is usable). |
| `backup_switch_order` | BackupSwitchOrder |  | Rotation order in interval mode: seq picks the least recently used first; rand picks at random. Values: ["seq","rand"] |
| `backup_switch_type` | BackupSwitchType |  | Backup IP switch mode. master_down: bring in as many backup IPs as there are unavailable primary IPs on the same DNS line; gt_online_ip: when online primary IPs are fewer than backup IPs, bring in backups to make up the difference (at most the number of unavailable primary IPs); interval: every IP in the group is a backup and they rotate on a timer (the group must have no primary IPs before switching to interval). Values: ["master_down","gt_online_ip","interval"] |
| `cname_hostname` | string |  | Host record part of the access name (for example www); lowercase letters, digits, hyphens, dot-separated labels; unique across groups (409 cname_hostname_taken); empty on create generates 8 random characters, empty on update keeps the current value. |
| `des` | string |  | Description |
| `name` | string | Yes | Name |
| `region_id` | integer |  | Region ID |

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

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

Get node group · Authentication: Admin only

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

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

Update node group · Authentication: Admin only

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `backup_interval_s` | integer |  | Rotation interval in seconds in interval mode. |
| `backup_ip_num` | integer |  | Number of backup IPs in use per rotation in interval mode. |
| `backup_min_online` | integer |  | When usable lines in the group drop below this, access names referencing the group are switched to their own backup groups; 0 = never switch automatically, default 1 (switch when none is usable). |
| `backup_switch_order` | BackupSwitchOrder |  | Rotation order in interval mode: seq picks the least recently used first; rand picks at random. Values: ["seq","rand"] |
| `backup_switch_type` | BackupSwitchType |  | Backup IP switch mode. master_down: bring in as many backup IPs as there are unavailable primary IPs on the same DNS line; gt_online_ip: when online primary IPs are fewer than backup IPs, bring in backups to make up the difference (at most the number of unavailable primary IPs); interval: every IP in the group is a backup and they rotate on a timer (the group must have no primary IPs before switching to interval). Values: ["master_down","gt_online_ip","interval"] |
| `cname_hostname` | string |  | Host record part of the access name (for example www); lowercase letters, digits, hyphens, dot-separated labels; unique across groups (409 cname_hostname_taken); empty on create generates 8 random characters, empty on update keeps the current value. |
| `des` | string |  | Description |
| `name` | string |  | Name |
| `region_id` | integer |  | Region ID |

```sh
curl -X PUT "https://panel.example.com/api/v2/node-groups/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"backup_min_online":2}'
```

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

Delete node group · Authentication: Admin only

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

Node groups object:

| Field | Type | Required | Description |
|---|---|---|---|
| `backup_active` | boolean |  | Automatically switched to the backup group by monitoring (switches back once usable lines recover to the threshold). (read-only) |
| `backup_interval_s` | integer |  | Rotation interval in seconds in interval mode. |
| `backup_ip_num` | integer |  | Number of backup IPs in use per rotation in interval mode. |
| `backup_min_online` | integer |  | When usable lines in the group drop below this, access names referencing the group are switched to their own backup groups; 0 = never switch automatically, default 1 (switch when none is usable). |
| `backup_switch_order` | BackupSwitchOrder |  | Rotation order in interval mode: seq picks the least recently used first; rand picks at random. Values: ["seq","rand"] |
| `backup_switch_type` | BackupSwitchType |  | Backup IP switch mode. master_down: bring in as many backup IPs as there are unavailable primary IPs on the same DNS line; gt_online_ip: when online primary IPs are fewer than backup IPs, bring in backups to make up the difference (at most the number of unavailable primary IPs); interval: every IP in the group is a backup and they rotate on a timer (the group must have no primary IPs before switching to interval). Values: ["master_down","gt_online_ip","interval"] |
| `backup_switched` | string |  | Time of the most recent automatic switch or switch-back. (read-only) |
| `cname_domains` | string[] |  | Access names (host record.root domain) pointing to this group, in alphabetical order; empty array if none reference it. (read-only) |
| `cname_hostname` | string |  | Host record part of the access name (for example www); lowercase letters, digits, hyphens, dot-separated labels; unique across groups (409 cname_hostname_taken); empty on create generates 8 random characters, empty on update keeps the current value. |
| `created_at` | string |  | Created at (read-only) |
| `des` | string |  | Description |
| `id` | integer |  | Record ID (read-only) |
| `name` | string |  | Name |
| `node_count` | integer |  | Number of distinct node IPs referenced by the lines in this group. (read-only) |
| `region_id` | integer |  | Region ID |
| `site_count` | integer |  | Number of sites whose access name points to this group. (read-only) |
| `stream_count` | integer |  | Number of TCP/UDP forwarding rules whose access name points to this group. (read-only) |
| `updated_at` | string |  | Updated at (read-only) |
