群組 API
管理你的群組與成員。
取得群組列表
Section titled “取得群組列表”GET /api/channels取得目前使用者有權限存取的所有群組。
{ "channels": [ { "channelId": "C1234567890abcdef", "name": "購物討論群", "type": "group", "enabledAt": "2025-01-15T08:00:00Z", "status": "active" }, { "channelId": "C0987654321fedcba", "name": "家族群組", "type": "group", "enabledAt": "2025-01-10T10:00:00Z", "status": "active" } ]}| 欄位 | 類型 | 說明 |
|---|---|---|
| channelId | string | 群組唯一識別碼 |
| name | string | 群組名稱 |
| type | string | 類型:group、room、user |
| enabledAt | string | 啟用時間 |
| status | string | 狀態:active、disabled |
取得群組詳情
Section titled “取得群組詳情”GET /api/channels/:channelId| 參數 | 說明 |
|---|---|
| channelId | 群組 ID |
{ "meta": { "channelId": "C1234567890abcdef", "type": "group", "name": "購物討論群", "picture": "https://profile.line-scdn.net/...", "createdAt": "2025-01-15T08:00:00Z", "createdBy": "system", "memberCount": 150 }, "config": { "assistant": { "enabled": true, "qa": { "enabled": true, "mode": "keyword" }, "welcome": { "enabled": true }, "rules": { "enabled": true } }, "backup": { "enabled": true } }, "role": "owner"}| 欄位 | 類型 | 說明 |
|---|---|---|
| channelId | string | 群組 ID |
| type | string | 類型 |
| name | string | 名稱 |
| picture | string | 頭像 URL |
| memberCount | number | 成員數量 |
config
Section titled “config”| 欄位 | 說明 |
|---|---|
| assistant | 自動回覆設定 |
| backup | 備份設定 |
使用者在此群組的角色:
owner- 群組管理者admin- 管理員member- 一般成員
取得群組成員
Section titled “取得群組成員”GET /api/channels/:channelId/members{ "members": [ { "userId": "U1234567890abcdef", "displayName": "王小明", "pictureUrl": "https://profile.line-scdn.net/...", "role": "owner", "joinedAt": "2025-01-15T08:00:00Z", "leftAt": null, "status": "active", "updatedAt": "2025-01-15T08:00:00Z" }, { "userId": "U0987654321fedcba", "displayName": "李小華", "pictureUrl": "https://profile.line-scdn.net/...", "role": "member", "joinedAt": "2025-01-16T10:00:00Z", "leftAt": null, "status": "active", "updatedAt": "2025-01-16T10:00:00Z" } ]}| 欄位 | 類型 | 說明 |
|---|---|---|
| userId | string | 使用者 ID |
| displayName | string | 顯示名稱 |
| pictureUrl | string | 頭像 URL |
| role | string | 角色:owner、admin、member |
| joinedAt | string | 加入時間 |
| leftAt | string | null | 離開時間(null 表示仍在群組中) |
| status | string | 狀態:active、left |
更新成員角色
Section titled “更新成員角色”PUT /api/channels/:channelId/members/:userId/role| 參數 | 說明 |
|---|---|
| channelId | 群組 ID |
| userId | 使用者 ID |
{ "role": "admin"}可設定的角色
Section titled “可設定的角色”| 角色 | 說明 |
|---|---|
| admin | 管理員(可管理設定) |
| member | 一般成員 |
{ "success": true}403 Forbidden
Section titled “403 Forbidden”{ "error": "Permission denied"}可能原因:
- 你不是該群組的成員
- 你沒有足夠的權限(需要 admin 或 owner)
404 Not Found
Section titled “404 Not Found”{ "error": "Channel not found"}可能原因:
- 群組 ID 不存在
- 群組已被刪除