> ## Documentation Index
> Fetch the complete documentation index at: https://supastack.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For the full documentation corpus in one file, fetch: https://supastack.dev/llms-full.txt

# 工作區與成員

切換工作區、管理組織並處理邀請。

## 解析當前工作區

GET /api/workspaces 返回成員的工作區成員資格與當前工作區 id；帶工作區 id 的 POST 即切換。伺服器按“選擇 Cookie → 已存偏好 → 個人工作區”的順序解析上下文，並核驗即時成員資格，因此偽造或過期的選擇無法讀到別的工作區。


## 管理組織

GET /api/mobile/organization 返回成員、待處理邀請、席位用量以及呼叫方能力 —— canManage 與 canLeave；個人工作區則返回 notOrganization。POST 建立組織，PATCH 重新命名（僅所有者），DELETE 刪除（僅所有者，需輸入名稱確認）。

組織介面位於“設定 → 成員”與“設定 → 通用”；成員自己的顯示名修改走 Better Auth 的 profile 路由，接受 1 到 100 個字元。


## 邀請與接受

POST /api/mobile/invitations 以郵件發出角色為 admin、member 或 guest 的邀請 —— 僅所有者與管理員可用。帶型別的失敗涵蓋 alreadyMember、alreadyInvited、seatLimitExceeded、dailySendLimit 與 invalidInput，介面可以據此解釋每種拒絕。重發與撤銷位於邀請 id 路由上，且重發有速率限制。

接受動作通過 <scheme>://invite/<token> 深連結到達：應用把 token 提交到邀請接受路由，後者返回工作區 id、啟用該工作區，並在服務端記錄此偏好。錯誤涵蓋 expired、emailMismatch、not-pending 與 seat-limit-exceeded。


## 變更角色與移除成員

PATCH /api/mobile/members/:userId 指派 owner、admin、member 或 guest 角色；DELETE 移除成員；POST /api/mobile/members/leave 主動退出。唯一所有者不能退出或被降級，成員不能通過管理路由移除自己，未產生任何變化的角色修改會被拒絕而非記錄。


## 驗證與排障

測試席位上限、已撤銷的邀請連結、guest 角色被削減的操作，以及切回個人工作區。被移除成員的快取選擇必須在下一次請求時失敗關閉，而不是繼續讀取舊工作區。


## 下一篇

[AI 聊天與助手](https://supastack.dev/zh-tw/docs/mobile/chat.md)
