跳转到内容
Rayrun
登录注册

认证与账号

登录 / 登出 / 注册 / 邀请接受 / 改密 / 当前身份。 完整参数、请求 / 响应 schema 见下方(本页只渲染该组):

v0.1.0
OpenAPI 3.0.3

Rayrun API

Rayrun REST API —— 控制台与命令行(rayrun CLI)的统一接口,也是自托管部署的 第三方集成的接入点。共 13 组、93 个端点(分组见左侧栏或「介绍」页的接口一览)。 基地址与部署同源:<实例地址>/v1(如 https://rayrun.example.com/v1)。 认证:Bearer Token(控制台「设置 → 我的 API Token」或 rayrun login 创建) 或浏览器会话 Cookie;GET /health 免认证。详见「介绍」页的认证一节。

Server:https://api.rayrunos.com/v1

Rayrun 托管平台

Client Libraries

认证与账号

​

登录 / 登出 / 注册 / 邀请接受 / 改密 / 当前身份。

密码登录(豁免幂等)

​

Body·

required
application/json
  • 空串 → 400 invalid_request

  • 用户名或邮箱(统一走此字段,兼容既有客户端)。空串 → 400 invalid_request。含 @ 时按邮箱校验与查询(邮箱不存在 → 401, 与密码错误不可区分);否则按用户名查询。两者均去首尾空白并转小写比较。

Responses

  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
Request Example for post/auth/login
curl https://api.rayrunos.com/v1/auth/login \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "username": "",
  "password": ""
}'
{
  "tenant_id": "string",
  "user_id": "string",
  "username": "string",
  "email": "string",
  "display_name": "string",
  "avatar_url": "string",
  "role": "owner",
  "email_binding_required": true,
  "platform_admin": true
}

登出

​

Responses

  • application/json
  • application/json
  • application/json
Request Example for post/auth/logout
curl https://api.rayrunos.com/v1/auth/logout \
  --request POST \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
No Body

当前身份

​

Responses

  • application/json
  • application/json
  • application/json
  • application/json
Request Example for get/auth/me
curl https://api.rayrunos.com/v1/auth/me \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "tenant_id": "string",
  "user_id": "string",
  "username": "string",
  "email": "string",
  "display_name": "string",
  "avatar_url": "string",
  "role": "owner",
  "email_binding_required": true,
  "platform_admin": true
}

自助注册(免认证 + 按 IP 注册限流;注册即建组织,注册者 = 该组织所有者)

​

豁免幂等(请求体含明文密码)。成功后注册即登录: 201 + Set-Cookie(与 login 同款属性)。组织名 = username,不可改。

注册赠金:新组织同时入账一笔赠金,金额 = env RAYRUN_SIGNUP_GRANT_CENTS(默认 5000 = ¥50;0 = 不发)。落为一条 billing.credit,payload.source.type = "grant"、ref_id = tenant_id。 账户上体现为余额 +5000 分。接受邀请(/auth/accept-invite)与平台 代开组织不发 —— 赠金对标的是「自助注册」,不是「组织被创建」。

Body·

required
application/json
  • 必填;去首尾空白并转小写后存储,全局唯一(大小写不敏感)。不做邮箱验证。格式非法或已被占用分别返回 400 / 409(details.field = "email")

  • 至少 8 位(自助注册规则;登录不设下限 —— 存量账号可能更短)

  • 非空;规范化后仅允许 [a-z0-9._-] 且不超过 64 字符;非保留名(RAYRUN_ADMIN_USERNAME 与 slug 落在 default/anonymous/system 的均拒绝)。比较大小写不敏感:服务端规范化为小写后存储与比对,Admin / ADMIN 与 admin 视为同一名字。同时作为组织标识,注册后不可修改

  • 可选;≤255 字符(users.display_name VARCHAR(255),超限 400 invalid_request)

Responses

  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
Request Example for post/auth/register
curl https://api.rayrunos.com/v1/auth/register \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "email": "",
  "username": "",
  "password": "",
  "display_name": ""
}'
{
  "tenant_id": "string",
  "tenant_name": "string",
  "user": {
    "user_id": "string",
    "tenant_id": "string",
    "username": "string",
    "display_name": "string",
    "role": "owner",
    "disabled_at": null,
    "created_at": "2026-11-11T06:00:17.727Z"
  }
}

接受邀请(免认证;一次性链接,token 明文只在邀请创建响应出现一次)

​

按 token 哈希查未过期、未撤销、未接受的邀请;成功后建 user(角色由邀请指定)、 标记 accepted_at,接受即登录 → 201 + Set-Cookie。邀请先到先得、不预占 username。

Body·

required
application/json
  • 邀请链接里的 token

  • 可选;≤255 字符(users.display_name VARCHAR(255),超限 400 invalid_request)

Responses

  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
Request Example for post/auth/accept-invite
curl https://api.rayrunos.com/v1/auth/accept-invite \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "token": "",
  "password": "",
  "display_name": ""
}'
{
  "tenant_id": "string",
  "user_id": "string",
  "username": "string",
  "email": "string",
  "display_name": "string",
  "avatar_url": "string",
  "role": "owner",
  "email_binding_required": true,
  "platform_admin": true
}

修改自己的密码(已认证;需验旧密码;成功后清当前 session 键)

​

Body·

required
application/json
  • password_set=1 时必填;微信自动建号(password_set=0)首次设置密码可省略。旧密码错误返回 400 invalid_request + details.field=old_password。

Responses

  • 已修改

  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
Request Example for post/auth/password
curl https://api.rayrunos.com/v1/auth/password \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --data '{
  "old_password": "",
  "new_password": ""
}'
No Body

Models