> ## Documentation Index
> Fetch the complete documentation index at: https://wukong.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 添加频道订阅者

> 向频道添加订阅者（成员）

## 概述

向频道添加订阅者（成员），支持批量添加和重置模式。

## 请求体

### 必传参数

<ParamField body="channel_id" type="string" required>
  频道 ID
</ParamField>

<ParamField body="channel_type" type="integer" required>
  频道类型

  * `1` - 个人频道
  * `2` - 群组频道
</ParamField>

<ParamField body="subscribers" type="array" required>
  要添加的订阅者用户 ID 列表

  <ParamField body="subscribers[]" type="string">
    用户 ID
  </ParamField>
</ParamField>

### 可选参数

<ParamField body="reset" type="integer" default={0}>
  是否重置现有订阅者

  * `0` - 不重置，追加新订阅者
  * `1` - 重置，替换所有现有订阅者
</ParamField>

<ParamField body="temp_subscriber" type="integer" default={0}>
  是否为临时订阅者

  * `0` - 永久订阅者
  * `1` - 临时订阅者
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "http://localhost:5001/channel/subscriber_add" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "group123",
      "channel_type": 2,
      "subscribers": ["user4", "user5", "user6"],
      "reset": 0,
      "temp_subscriber": 0
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('http://localhost:5001/channel/subscriber_add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      channel_id: 'group123',
      channel_type: 2,
      subscribers: ['user4', 'user5', 'user6'],
      reset: 0,
      temp_subscriber: 0
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  data = {
      "channel_id": "group123",
      "channel_type": 2,
      "subscribers": ["user4", "user5", "user6"],
      "reset": 0,
      "temp_subscriber": 0
  }

  response = requests.post('http://localhost:5001/channel/subscriber_add', json=data)
  result = response.json()
  print(result)
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      data := map[string]interface{}{
          "channel_id":      "group123",
          "channel_type":    2,
          "subscribers":     []string{"user4", "user5", "user6"},
          "reset":           0,
          "temp_subscriber": 0,
      }
      
      jsonData, _ := json.Marshal(data)
      
      resp, err := http.Post(
          "http://localhost:5001/channel/subscriber_add",
          "application/json",
          bytes.NewBuffer(jsonData),
      )
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()
      
      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("%+v\n", result)
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 成功响应 theme={null}
  {
    "status": "ok"
  }
  ```
</ResponseExample>

## 响应字段

<ResponseField name="status" type="string" required>
  操作状态，成功时返回 `"ok"`
</ResponseField>

## 状态码

| 状态码 | 说明      |
| --- | ------- |
| 200 | 订阅者添加成功 |
| 400 | 请求参数错误  |
| 403 | 没有操作权限  |
| 404 | 频道不存在   |
| 500 | 服务器内部错误 |

## 参数说明

### 重置模式 (reset)

| 值 | 模式   | 说明               | 使用场景    |
| - | ---- | ---------------- | ------- |
| 0 | 追加模式 | 在现有成员基础上添加新成员    | 邀请新成员加入 |
| 1 | 重置模式 | 清空现有成员，设置为新的成员列表 | 重新组建群组  |

### 临时订阅者 (temp\_subscriber)

| 值 | 类型    | 特点      | 适用场景       |
| - | ----- | ------- | ---------- |
| 0 | 永久订阅者 | 持久的成员关系 | 正式群组成员     |
| 1 | 临时订阅者 | 临时的成员关系 | 临时访客、会议参与者 |

## 使用场景

### 群组管理

* **邀请新成员**：群主或管理员邀请新用户加入群组
* **批量导入**：从其他平台批量导入成员列表
* **重建群组**：使用重置模式重新组建群组成员
