> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# 轮换 Webhook 签名密钥

> 需要工作区 Management Token (mt-...)，可在 Dashboard > API > Management Tokens 中创建。发送 Authorization: Bearer mt-....。不支持 Inference API keys (sk-...) 和 Webhook 签名密钥 (whsec_...)。仅可访问该 token 所属的工作区。完整的 whsec_ 签名密钥仅在创建或轮换时返回。请妥善存储；GET/list 操作不会返回该密钥。轮换对新的投递立即生效；已在传输中的投递仍可使用之前的密钥。

使用工作区管理令牌 **`mt-…`**，不是模型调用 Key `sk-…`，也不是签名密钥 `whsec_…`。在 [Dashboard → API → Management Tokens](https://tokenlab.sh/dashboard/api?tab=tokens) 创建，以 `Authorization: Bearer mt-…` 发送。只能操作该工作区。

接入、事件、验签与失败处理见 [Webhook 管理 API 文档](/zh/guides/webhooks)。


## OpenAPI

````yaml openapi/zh.json POST /v1/management/webhooks/{webhookId}/rotate-secret
openapi: 3.1.0
info:
  title: TokenLab AI Gateway
  description: 组织余额、API key 管理以及通过管理 token 进行的 key 级别用量/计费管理
  version: 1.0.0
  termsOfService: https://tokenlab.sh/tos
  contact:
    name: Technical Support
    email: support@tokenlab.sh
servers:
  - url: https://api.tokenlab.sh
    description: 生产服务器
security:
  - BearerAuth: []
tags:
  - name: Chat
    description: Chat completions API (兼容 OpenAI)
  - name: Responses
    description: 兼容 OpenAI Responses API 的原生端点
  - name: Embeddings
    description: Text embeddings API
  - name: Images
    description: Image generation API
  - name: Audio
    description: Audio processing API (TTS & STT)
  - name: Video
    description: Video generation API
  - name: Models
    description: 可用模型列表
  - name: Anthropic
    description: 兼容 Anthropic 的 Messages API
  - name: Gemini
    description: 兼容 Google Gemini 的 API
  - name: Management
    description: 组织 API key 管理以及通过管理 token 进行的 key 级别用量/计费管理
  - name: Files
    description: 批量文件上传与检索
  - name: Batches
    description: 兼容 OpenAI 的异步批处理任务
  - name: Seedance Volc Compatible
    description: Seedance 2.0 Volc 风格兼容端点
  - name: Decisions
  - name: Webhooks
    description: 使用 Management Tokens (mt-...) 进行工作区 Webhook 管理。Inference API keys 不具备管理权限。
paths:
  /v1/management/webhooks/{webhookId}/rotate-secret:
    post:
      tags:
        - Webhooks
      summary: 轮换 Webhook 签名密钥
      description: >-
        需要工作区 Management Token (mt-...)，可在 Dashboard > API > Management Tokens
        中创建。发送 Authorization: Bearer mt-....。不支持 Inference API keys (sk-...) 和
        Webhook 签名密钥 (whsec_...)。仅可访问该 token 所属的工作区。完整的 whsec_
        签名密钥仅在创建或轮换时返回。请妥善存储；GET/list 操作不会返回该密钥。轮换对新的投递立即生效；已在传输中的投递仍可使用之前的密钥。
      operationId: rotateWebhookSecret
      parameters:
        - name: webhookId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 128
      responses:
        '200':
          description: 轮换 Webhook 签名密钥结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedWebhookEndpoint'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: 在该工作区中未找到 Webhook
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          description: 端点配额已满或端点已暂停
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - ManagementTokenAuth: []
components:
  schemas:
    CreatedWebhookEndpoint:
      type: object
      required:
        - id
        - object
        - url
        - events
        - is_active
        - description
        - created_at
        - updated_at
        - last_delivered_at
        - failure_count
        - secret
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - webhook_endpoint
        url:
          type: string
        events:
          type: array
          items:
            type: string
            enum:
              - task.completed
              - task.failed
              - task.timeout
        is_active:
          type: boolean
        description:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        last_delivered_at:
          type:
            - string
            - 'null'
          format: date-time
        failure_count:
          type: integer
        secret:
          type: string
      additionalProperties: false
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: 错误消息
            type:
              type: string
              description: 错误类型
              enum:
                - unauthorized
                - invalid_api_key
                - expired_api_key
                - permission_error
                - insufficient_balance
                - quota_exceeded
                - invalid_request_error
                - model_not_found
                - context_length_exceeded
                - unsupported_tool_choice
                - rate_limit_exceeded
                - server_error
                - upstream_error
                - all_channels_failed
                - timeout_error
                - not_found_error
                - no_contract_compatible_route
                - request_shape_channel_mismatch
                - upstream_contract_mismatch
                - platform_normalization_error
                - async_task_not_found
                - async_task_mapping_invalid
                - delivery_tier_unavailable
            code:
              type: string
              description: 错误代码
            param:
              type: string
              description: 导致错误的参数
            model:
              type: string
              description: 与错误关联的模型
            did_you_mean:
              type: string
            suggestions:
              type: array
              items:
                type: object
                required:
                  - id
                properties:
                  id:
                    type: string
                additionalProperties: true
            alternatives:
              type: array
              items:
                type: object
                required:
                  - id
                  - status
                  - tags
                properties:
                  id:
                    type: string
                  status:
                    type: string
                  tags:
                    type: array
                    items:
                      type: string
                additionalProperties: true
            hint:
              type: string
            retry_after:
              type: number
            retryable:
              type: boolean
            balance_usd:
              type: number
            estimated_cost_usd:
              type: number
            supported_operations:
              type: array
              items:
                type: string
            supported_parameters:
              type: array
              items:
                type: string
            required_selectors:
              type: array
              items:
                type: string
            optional_selectors:
              type: array
              items:
                type: string
            allowed_resolutions:
              type: array
              items:
                type: string
            allowed_durations:
              type: array
              items:
                type: string
            allowed_aspect_ratios:
              type: array
              items:
                type: string
            prompt_max_characters:
              type: number
            recommended_request:
              type: object
              additionalProperties: true
            request_endpoint:
              type:
                - string
                - 'null'
            request_shape_mode:
              type:
                - string
                - 'null'
            status_mode:
              type:
                - string
                - 'null'
            request_id:
              type: string
          required:
            - message
            - type
          additionalProperties: true
      additionalProperties: true
    ValidationError:
      allOf:
        - $ref: '#/components/schemas/ApiError'
        - type: object
          properties:
            validation_errors:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
                  code:
                    type: string
  responses:
    BadRequest:
      description: 错误请求 - 无效输入
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
          example:
            error:
              message: 'model: Model is required'
              type: invalid_request_error
              param: model
            validation_errors:
              - field: model
                message: Model is required
    Unauthorized:
      description: 未授权 - API key 无效或缺失
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            error:
              message: Invalid API key provided
              type: invalid_api_key
    Forbidden:
      description: 禁止访问
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            error:
              message: Organization is not active
              type: invalid_request_error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API Key 身份验证。在 [Dashboard > API > API
        Keys](https://tokenlab.sh/dashboard/api?tab=keys) 中创建或管理 API Key。
    ManagementTokenAuth:
      type: http
      scheme: bearer
      bearerFormat: Management Token
      description: >-
        管理令牌身份验证。在 [Dashboard > API > Management
        Tokens](https://tokenlab.sh/dashboard/api?tab=tokens) 中创建或管理管理令牌。

````