跳到正文
MuoCeon 文档中心
v1account 上下文

账户资料

GET /v1/account/me 与 PATCH /v1/account/me:字段表、更新语义与约束。

/v1/account/me 是账号自己的扩展档案。身份字段来自 auth,扩展档案归 account,响应里分成两段而不是摊平——合并成一层会让「这个字段归哪个上下文」在接口契约里彻底消失。

GET /me

curl 'https://id.example.com/v1/account/me' \
  -H "Authorization: Bearer $ACCOUNT_ACCESS_TOKEN"
{
  "success": true,
  "sub": "usr_...",
  "username": "alice",
  "display_name": "Alice",
  "email": "alice@example.com",
  "email_verified": true,
  "created_at": "2026-01-04T10:00:00.000Z",
  "profile": {
    "gender": "female",
    "birthdate": "1994-03-08",
    "age": 32,
    "locale": "zh-Hans",
    "timezone": "Asia/Shanghai",
    "bio": "Hello",
    "metadata": {}
  }
}
字段归属说明
subauth用户唯一标识
usernameauth用户名,可为 null
display_nameauth展示名
email / email_verifiedauth主邮箱与其验证状态
created_atauth账号创建时间
profile.genderaccount性别,可空
profile.birthdateaccount生日,YYYY-MM-DD,可空
profile.ageaccount由生日推导的年龄,只读,可空
profile.localeaccount语言偏好,可空
profile.timezoneaccount时区,可空
profile.bioaccount简介,最长 2000 字符
profile.metadataaccount自定义键值,写入受上限约束

PATCH /me

局部更新:省略的字段保持不变,显式传 null 表示清空。

参数类型说明
genderstring | null1–32 字符
birthdatestring | nullYYYY-MM-DD,必须是真实存在的日期
localestring | null1–35 字符
timezonestring | null1–64 字符
biostring | null最长 2000 字符
metadataobject键 1–64 字符,最多 32 个键,序列化后不超过 4096 字节
curl -X PATCH 'https://id.example.com/v1/account/me' \
  -H "Authorization: Bearer $ACCOUNT_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"bio":"Hello","timezone":"Asia/Shanghai"}'

未知字段会被拒绝

请求体是严格模式:出现未声明的字段会报错,而不是静默忽略。PATCH 里多出来的键通常意味着客户端拼错了名字,忽略掉会让用户以为改动生效了,实际什么都没发生。

生日必须是真实日期

只校验格式不够:2023-02-30 格式合法但日期不存在,存进去之后年龄推导会得到负数或 NaN。

规则

规则说明
不要求提权更新档案不丢失任何数据
age 不可写由 birthdate 推导,避免两者自相矛盾
metadata 上限只约束写入,不约束读取;否则历史数据会让 GET 校验失败

相关

本页目录