跳到內容

群組 API

管理你的群組與成員。

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"
}
]
}
欄位類型說明
channelIdstring群組唯一識別碼
namestring群組名稱
typestring類型:grouproomuser
enabledAtstring啟用時間
statusstring狀態:activedisabled

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"
}
欄位類型說明
channelIdstring群組 ID
typestring類型
namestring名稱
picturestring頭像 URL
memberCountnumber成員數量
欄位說明
assistant自動回覆設定
backup備份設定

使用者在此群組的角色:

  • owner - 群組管理者
  • admin - 管理員
  • member - 一般成員

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"
}
]
}
欄位類型說明
userIdstring使用者 ID
displayNamestring顯示名稱
pictureUrlstring頭像 URL
rolestring角色:owneradminmember
joinedAtstring加入時間
leftAtstring | null離開時間(null 表示仍在群組中)
statusstring狀態:activeleft

PUT /api/channels/:channelId/members/:userId/role
參數說明
channelId群組 ID
userId使用者 ID
{
"role": "admin"
}
角色說明
admin管理員(可管理設定)
member一般成員
{
"success": true
}

{
"error": "Permission denied"
}

可能原因:

  • 你不是該群組的成員
  • 你沒有足夠的權限(需要 admin 或 owner)
{
"error": "Channel not found"
}

可能原因:

  • 群組 ID 不存在
  • 群組已被刪除