{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bot.yoyoo.org/schemas/v1/bot-credential.schema.json",
  "title": "BotCredential",
  "description": "Bot 凭证。仅在 POST /v1/bots 创建成功或 POST /v1/bots/{id}/credentials/rotate 轮换时返回；之后不可再读取明文 secret。",
  "type": "object",
  "additionalProperties": false,
  "required": ["bot_id", "secret", "secret_prefix", "expires_at"],
  "properties": {
    "bot_id": {
      "type": "string",
      "pattern": "^bot_[0-9A-HJKMNP-TV-Z]{26}$",
      "description": "对应 Bot 资源 id。"
    },
    "secret": {
      "type": "string",
      "pattern": "^ybt_live_[A-Za-z0-9]{32,}$",
      "description": "Bot 密钥。用于 Authorization: Bearer {secret}、WebSocket 连接与 Webhook 签名校验。仅展示一次，须妥善保存。"
    },
    "secret_prefix": {
      "type": "string",
      "pattern": "^ybt_live_[A-Za-z0-9]{8}$",
      "description": "secret 前缀，用于控制台展示与识别，例如 ybt_live_ab12cd34。"
    },
    "expires_at": {
      "type": ["string", "null"],
      "format": "date-time",
      "description": "凭证过期时间；null 表示长期有效直至主动轮换或吊销。"
    }
  }
}
