POST/api/v1/dev/apps注册应用

注册开放平台应用:声明回调地址、令牌形态(jwt / opaque)与申请的 scope。注册后进入待审批状态;clientSecret 仅此一次完整返回。

Request

Headers

NameData TypeRequiredDescription
AuthorizationstringYes会话令牌认证,格式 `Bearer <sessionToken>`
Content-TypestringYes请求体内容类型(默认值 "application/json")
type RequestHeaders = {
  /** 会话令牌认证,格式 `Bearer <sessionToken>` */
  Authorization: string
  /** 请求体内容类型,默认值 "application/json" */
  Content-Type: string
}
{
  "Authorization": "Bearer st_7c1f9e05b28d4a63",
  "Content-Type": "application/json"
}

Body

NameData TypeRequiredDescription
namestringYes应用名称
homepagestringNo应用主页
redirectUrisarrayYes允许的回调地址(https)
tokenTypestringYes访问令牌形态:jwt / opaque
scopesarrayYes申请的 scope 列表
type RequestBody = {
  /** 应用名称 */
  name: string
  /** 应用主页 */
  homepage?: string
  /** 允许的回调地址(https) */
  redirectUris: string[]
  /** 访问令牌形态:jwt / opaque */
  tokenType: string
  /** 申请的 scope 列表 */
  scopes: string[]
}
{
  "name": "Xeegam Analytics",
  "homepage": "https://analytics.xeegam.com",
  "redirectUris": [
    "https://analytics.xeegam.com/oauth/callback"
  ],
  "tokenType": "jwt",
  "scopes": [
    "user:profile:read",
    "orgs:list"
  ]
}

Response

Body

NameData TypeRequiredDescription
appIdstringYes应用 ID
namestringYes应用名称
clientIdstringYes客户端标识
clientSecretstringYes客户端密钥(仅此一次完整返回,请妥善保存)
tokenTypestringYes令牌形态
statusstringYes固定为 pending
scopesarrayYes申请的 scope
createdAtstringYes注册时间
type ResponseBody = {
  /** 应用 ID */
  appId: string
  /** 应用名称 */
  name: string
  /** 客户端标识 */
  clientId: string
  /** 客户端密钥(仅此一次完整返回,请妥善保存) */
  clientSecret: string
  /** 令牌形态 */
  tokenType: string
  /** 固定为 pending */
  status: string
  /** 申请的 scope */
  scopes: string[]
  /** 注册时间 */
  createdAt: string
}
{
  "appId": "01JD8SNST2N5U6X1BU9YBHK4C7J",
  "name": "Xeegam Analytics",
  "clientId": "cli_9f2ka81mdx",
  "clientSecret": "cs_5Kx9mQeR2vB8wL7pN3tZ6yH4",
  "tokenType": "jwt",
  "status": "pending",
  "scopes": [
    "user:profile:read",
    "orgs:list"
  ],
  "createdAt": "2026-10-01T10:00:00Z"
}

HTTP Code

HTTP Status Meaning Notes
200 成功 返回新应用与凭据
400 参数无效 回调地址非 https 或 scope 不存在

Response Code

响应使用统一信封 {id, code, messages, result},其 code 字段:

code Meaning Notes
0 成功 返回新应用与凭据
2701 回调地址无效 非 https 或格式不合法
2704 scope 无效 含目录中不存在的 scope

Examples

POST /api/v1/dev/apps
Authorization: Bearer st_7c1f9e05b28d4a63
Content-Type: application/json

{
  "name": "Xeegam Analytics",
  "homepage": "https://analytics.xeegam.com",
  "redirectUris": ["https://analytics.xeegam.com/oauth/callback"],
  "tokenType": "jwt",
  "scopes": ["user:profile:read", "orgs:list"]
}
{
  "id": "01JD8SSJZE8Z6BUV",
  "code": 0,
  "messages": [],
  "result": {
    "appId": "01JD8SNST2N5U6X1BU9YBHK4C7J",
    "name": "Xeegam Analytics",
    "clientId": "cli_9f2ka81mdx",
    "clientSecret": "cs_5Kx9mQeR2vB8wL7pN3tZ6yH4",
    "tokenType": "jwt",
    "status": "pending",
    "scopes": ["user:profile:read", "orgs:list"],
    "createdAt": "2026-10-01T10:00:00Z"
  }
}

Remarks

审批通过前应用不能发起授权;tokenType 注册后不可变更,变更须注册新应用。