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

# 恢复仪表盘

> 把回收站中的仪表盘恢复，可选恢复到其他目录。



## OpenAPI

````yaml /api-reference/monitors.openapi.zh.json post /monit/dashboard/restore
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty 事件管理平台的公开 HTTP API —— 覆盖故障、通知模板、协作空间、值班排班、监控、RUM、以及平台管理。每次调用都需在
    query 中携带 `app_key`，该 key 在 Flashduty 控制台 账户 → APP Key 中签发。所有响应使用统一结构：成功时为
    `{ request_id, data }`，失败时为 `{ request_id, error }`。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: Monitors/告警规则
    description: 创建、管理和导出监控告警规则，查询规则统计和审计历史。
  - name: Monitors/告警数据源
    description: 管理监控告警规则用于查询指标的数据源。
  - name: Monitors/诊断分析
    description: Flashduty AI SRE 使用的诊断与查询接口——数据源即席查询、日志/指标诊断,以及监控对象侧的工具调用。
  - name: Monitors/通用工具
    description: 监控服务开通及数据预览工具。
  - name: Monitors/仪表盘
    description: 创建、搜索、版本化与运行 Monitors 仪表盘，并解析其变量与查询。
  - name: Monitors/规则分组
    description: 列出仪表盘与告警规则所在的监控节点树。
paths:
  /monit/dashboard/restore:
    post:
      tags:
        - Monitors/仪表盘
      summary: 恢复仪表盘
      description: 把回收站中的仪表盘恢复，可选恢复到其他目录。
      operationId: monit-dashboard-write-restore
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DashboardRestoreRequest'
            example:
              dashboard_id: 01990d7a-9c5b-7ab0-9c18-33e38f6f2101
              expected_revision: 8
              folder_id: 15
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/DashboardResource'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  dashboard_id: 01990d7a-9c5b-7ab0-9c18-33e38f6f2101
                  schema_version: dashboard.v1
                  revision: 7
                  folder_id: 12
                  folder_breadcrumb:
                    - Production
                    - Checkout
                  definition:
                    title: Checkout service overview
                    description: Traffic, errors and dependencies for the checkout service.
                    default_time_range:
                      from: now-1h
                      to: now
                    refresh_interval: 1m
                    variables:
                      - kind: custom
                        name: env
                        label: Environment
                        selection:
                          mode: single
                          include_all: false
                        options:
                          - text: Production
                            value: prod
                          - text: Staging
                            value: staging
                        default:
                          kind: values
                          values:
                            - prod
                    tabs:
                      - id: 01990d7a-9c5b-7ab0-9c18-33e38f6f2202
                        title: Overview
                        description: Golden signals.
                        top_panels: []
                        sections:
                          - id: 01990d7a-9c5b-7ab0-9c18-33e38f6f2303
                            title: Traffic
                            description: Request rate and latency.
                            collapsed: false
                            panels:
                              - id: 01990d7a-9c5b-7ab0-9c18-33e38f6f2404
                                title: Request rate
                                grid:
                                  x: 0
                                  'y': 0
                                  w: 12
                                  h: 8
                                datasource_ref:
                                  kind: fixed
                                  datasource_id: 10
                                  datasource_type: prometheus
                                queries:
                                  - ref_id: A
                                    legend_alias: '{{env}} requests'
                                    query:
                                      mode: range
                                      expr: >-
                                        sum(rate(http_requests_total{env="{{env}}"}[5m]))
                                      args: {}
                                      min_step_seconds: 30
                                viz_config:
                                  kind: time_series
                                  options: {}
                                  unit: count_per_second
                                  decimals: 2
                                  threshold:
                                    mode: higher_is_worse
                                    warning: 1000
                                    critical: 2000
                  created_by:
                    id: 10023
                    name: Ada Lovelace
                  updated_by:
                    id: 10088
                    name: Grace Hopper
                  created_at: 1791000000
                  updated_at: 1791100800
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    DashboardRestoreRequest:
      type: object
      description: 恢复回收站中的仪表盘，可选恢复到其他目录。
      properties:
        dashboard_id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 仪表盘的 canonical UUIDv7。
        expected_revision:
          type: integer
          format: uint64
          minimum: 1
          description: 调用方最后读到的版本号。若与已存版本不一致，写入会以 `DashboardRevisionConflict` 失败。
        folder_id:
          type:
            - integer
            - 'null'
          format: uint64
          minimum: 1
          description: 目标目录。省略则恢复到原目录；当原目录已不可写时调用会以 `RestoreFolderRequired` 失败，此时必须显式指定。
      required:
        - dashboard_id
        - expected_revision
    SuccessEnvelope:
      type: object
      description: >-
        成功响应结构。2xx 响应中 `request_id` 标识本次调用（同时出现在 `Flashcat-Request-Id`
        响应头中），`data` 为接口业务 payload。失败响应使用不同结构，参见 `ErrorResponse`。
      properties:
        request_id:
          type: string
          description: 本次请求的唯一 ID，也会在 Flashcat-Request-Id 响应头中返回。反馈问题时请一并附上。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        data:
          description: 每个接口自己的业务 payload，详见各接口的 200 响应 schema。
      required:
        - request_id
        - data
    DashboardResource:
      type: object
      description: >-
        已存储的仪表盘：包含标识、版本号、所在目录与完整定义。每次写入成功 `revision` 都会递增，下一次变更需把它作为
        `expected_revision` 回传。
      properties:
        dashboard_id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 创建时由调用方指定的 canonical UUIDv7。
        schema_version:
          type: string
          enum:
            - dashboard.v1
          description: '`definition` 的线上协议版本；只接受 `dashboard.v1`。'
        revision:
          type: integer
          format: uint64
          minimum: 1
          description: 当前版本号。
        folder_id:
          type: integer
          format: uint64
          minimum: 1
          description: 仪表盘所在目录的 ID。
        folder_breadcrumb:
          type: array
          items:
            type: string
          description: 从根目录到 `folder_id` 的目录名路径。
        definition:
          $ref: '#/components/schemas/DashboardDefinition'
        created_by:
          $ref: '#/components/schemas/DashboardActor'
        updated_by:
          $ref: '#/components/schemas/DashboardActor'
        created_at:
          type: integer
          format: int64
          description: Unix 时间戳（秒）。
        updated_at:
          type: integer
          format: int64
          description: Unix 时间戳（秒）。
      required:
        - dashboard_id
        - schema_version
        - revision
        - folder_id
        - folder_breadcrumb
        - definition
        - created_by
        - updated_by
        - created_at
        - updated_at
    DashboardDefinition:
      type: object
      description: >-
        以可移植 `dashboard.v1`
        文档形式存储的完整仪表盘内容。未知字段、重复字段、NaN/Inf、超范围数字与尾随值都会被拒绝；序列化后不得超过 1 MiB。
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 189
          description: 仪表盘标题，trim 后 1～189 个 Unicode 字符。
        description:
          type: string
          maxLength: 1024
          description: 可选描述，最多 1024 个 Unicode 字符。
        default_time_range:
          $ref: '#/components/schemas/DashboardRelativeTimeRange'
        refresh_interval:
          type: string
          enum:
            - 'off'
            - 30s
            - 1m
            - 5m
          description: 控制台自动刷新间隔：`off` 表示关闭自动刷新；`30s` = 每 30 秒；`1m` = 每 1 分钟；`5m` = 每 5 分钟。
        variables:
          type: array
          items:
            $ref: '#/components/schemas/DashboardVariable'
          maxItems: 20
          description: 仪表盘变量，最多 20 个。名称在定义内必须唯一且符合变量名正则。
        tabs:
          type: array
          items:
            $ref: '#/components/schemas/DashboardTab'
          minItems: 1
          maxItems: 10
          description: Tab，1～10 个。标题唯一，且所有 tab/section ID 必须是整份定义内唯一的 canonical UUIDv7。
      required:
        - title
        - default_time_range
        - refresh_interval
        - variables
        - tabs
    DashboardActor:
      type: object
      description: 记录为创建者、更新者或版本作者的账户成员。
      properties:
        id:
          type: integer
          format: uint64
          description: 成员 ID。
        name:
          type: string
          description: 成员展示名。
      required:
        - id
        - name
    ErrorResponse:
      type: object
      description: 错误响应结构。`error` 必填，`data` 不存在。
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          description: 本次请求的唯一追踪 ID（trace ID），反馈问题时请提供该值以便检索日志。
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    DashboardRelativeTimeRange:
      type: object
      description: 相对时间范围。`from` 只能取校验器允许的固定预设值，`to` 恒为字面量 `now`。
      properties:
        from:
          type: string
          enum:
            - now-15m
            - now-30m
            - now-1h
            - now-3h
            - now-6h
            - now-12h
            - now-24h
            - now-7d
          description: >-
            相对 `to` 的起始偏移：`now-15m` = 15 分钟前；`now-30m` = 30 分钟前；`now-1h` = 1
            小时前；`now-3h` = 3 小时前；`now-6h` = 6 小时前；`now-12h` = 12 小时前；`now-24h` =
            24 小时前；`now-7d` = 7 天前。
        to:
          type: string
          enum:
            - now
          description: 窗口结束点；只接受 `now`。
      required:
        - from
        - to
    DashboardVariable:
      description: 仪表盘变量。按 `kind` 选择对应分支。
      oneOf:
        - $ref: '#/components/schemas/DashboardDatasourceVariable'
        - $ref: '#/components/schemas/DashboardCustomVariable'
        - $ref: '#/components/schemas/DashboardQueryVariable'
      discriminator:
        propertyName: kind
        mapping:
          datasource: '#/components/schemas/DashboardDatasourceVariable'
          custom: '#/components/schemas/DashboardCustomVariable'
          query: '#/components/schemas/DashboardQueryVariable'
    DashboardTab:
      type: object
      description: 顶层 Tab。面板可直接挂在 tab 上（`top_panels`），也可放在 section 内。
      properties:
        id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 标识该 tab 的 canonical UUIDv7，在整份定义内唯一。
        title:
          type: string
          minLength: 1
          maxLength: 189
          description: Tab 标题，1～189 个 Unicode 字符，在 tab 之间唯一。
        description:
          type: string
          maxLength: 1024
          description: 可选 tab 描述。
        top_panels:
          type: array
          items:
            $ref: '#/components/schemas/DashboardPanel'
          maxItems: 30
          description: 直接放在该 tab 上的面板，最多 30 个。
        sections:
          type: array
          items:
            $ref: '#/components/schemas/DashboardSection'
          maxItems: 10
          description: 该 tab 下的 section，最多 10 个。
      required:
        - id
        - title
        - top_panels
        - sections
    DutyError:
      type: object
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
        reason:
          description: 可选的机器可读拒绝原因，包含数据源工具错误；结合 HTTP 状态及 code 判断。
          type: string
          x-flashduty-preserve-absence: true
      required:
        - code
        - message
    DashboardDatasourceVariable:
      type: object
      description: 数据源选择变量。候选项为账户下 `datasource_type` 类型的数据源。
      properties:
        kind:
          type: string
          enum:
            - datasource
          description: 变量类型判别字段，固定为 `datasource`，表示选择一个数据源。
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]{0,63}$
          description: 在 `{{ }}` 模板中引用的变量名，最多 64 个字符。
        label:
          type: string
          maxLength: 189
          description: 可选展示名，缺省时使用 `name`。
        datasource_type:
          type: string
          pattern: ^[a-z][a-z0-9_]{0,63}$
          description: 候选项来自的数据源类型。
        name_patterns:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 189
          maxItems: 10
          description: 缩小候选范围的通配符，空表示该类型下的全部数据源。
        default_datasource_id:
          type: integer
          format: uint64
          description: 默认数据源 ID。若默认值不可用，运行时按名称、再按 ID 取第一个候选项。
      required:
        - kind
        - name
        - datasource_type
    DashboardCustomVariable:
      type: object
      description: 候选项来自内联固定列表的变量。
      properties:
        kind:
          type: string
          enum:
            - custom
          description: 变量类型判别字段，固定为 `custom`，表示候选来自内联提供的固定列表。
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]{0,63}$
          description: 在 `{{ }}` 模板中引用的变量名，最多 64 个字符。
        label:
          type: string
          maxLength: 189
          description: 可选展示名，缺省时使用 `name`。
        selection:
          $ref: '#/components/schemas/DashboardSelectionConfig'
        options:
          type: array
          items:
            $ref: '#/components/schemas/DashboardCandidate'
          minItems: 1
          maxItems: 1000
          description: 候选项列表，1～1000 条。取值非空、唯一，且不得为 `$__all`。
        default:
          $ref: '#/components/schemas/DashboardSelection'
      required:
        - kind
        - name
        - selection
        - options
    DashboardQueryVariable:
      type: object
      description: 通过向数据源执行查询来解析候选项的变量。
      properties:
        kind:
          type: string
          enum:
            - query
          description: 变量类型判别字段，固定为 `query`，表示候选通过对数据源执行查询解析得到。
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]{0,63}$
          description: 在 `{{ }}` 模板中引用的变量名，最多 64 个字符。
        label:
          type: string
          maxLength: 189
          description: 可选展示名，缺省时使用 `name`。
        selection:
          $ref: '#/components/schemas/DashboardSelectionConfig'
        default:
          $ref: '#/components/schemas/DashboardSelection'
        datasource_ref:
          $ref: '#/components/schemas/DashboardDatasourceRef'
        variable_query:
          $ref: '#/components/schemas/DashboardVariableQuery'
        refresh:
          type: string
          enum:
            - on_dashboard_load
            - on_time_range_change
          description: >-
            候选项的重新计算时机：`on_dashboard_load` = 仪表盘加载时计算一次；`on_time_range_change` =
            时间范围每次变化时重新计算。
      required:
        - kind
        - name
        - selection
        - datasource_ref
        - variable_query
        - refresh
    DashboardPanel:
      type: object
      description: 单个可视化面板。同一容器内的面板不得重叠；24 列网格在保存时校验。
      properties:
        id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 标识该面板的 canonical UUIDv7，在整份定义内唯一。
        title:
          type: string
          minLength: 1
          maxLength: 189
          description: 面板标题。
        description:
          type: string
          maxLength: 1024
          description: 可选面板描述。
        grid:
          $ref: '#/components/schemas/DashboardGridPosition'
        datasource_ref:
          $ref: '#/components/schemas/DashboardDatasourceRef'
        queries:
          type: array
          items:
            $ref: '#/components/schemas/DashboardPanelQuery'
          maxItems: 26
          description: 面板内的查询。`time_series` 允许 1～26 条，`text` 不允许查询，其余类型必须恰好 1 条。
        viz_config:
          $ref: '#/components/schemas/DashboardVizConfig'
      required:
        - id
        - title
        - grid
        - queries
        - viz_config
    DashboardSection:
      type: object
      description: Tab 内可折叠的面板分组。
      properties:
        id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 标识该 section 的 canonical UUIDv7，在整份定义内唯一。
        title:
          type: string
          minLength: 1
          maxLength: 189
          description: Section 标题。
        description:
          type: string
          maxLength: 1024
          description: 可选 section 描述。
        collapsed:
          type: boolean
          description: 该 section 是否默认折叠。
        panels:
          type: array
          items:
            $ref: '#/components/schemas/DashboardPanel'
          maxItems: 30
          description: 该 section 内的面板，最多 30 个。
      required:
        - id
        - title
        - collapsed
        - panels
    ErrorCode:
      type: string
      description: >-
        Flashduty 错误码枚举。每个失败响应的 `error.code` 都是下列稳定值之一，HTTP 状态码仅作参考。


        | 错误码 | HTTP | 含义 |

        |---|---|---|

        | `OK` | 200 | 保留值，正常错误响应不会返回。 |

        | `InvalidParameter` | 400 | 必填参数缺失或未通过校验。 |

        | `BadRequest` | 400 | 通用的 400 错误，通常是请求本身不合法。 |

        | `InvalidContentType` | 400 | 请求头 `Content-Type` 不是 `application/json`。
        |

        | `ResourceNotFound` | 400 | 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。 |

        | `NoLicense` | 400 | 功能需要有效授权，但未找到可用的 license。 |

        | `ReferenceExist` | 400 | 该资源仍被其他实体引用，无法删除。 |

        | `Unauthorized` | 401 | `app_key` 缺失、无效或已过期。 |

        | `BalanceNotEnough` | 402 | 账户余额不足，无法执行需要计费的操作。 |

        | `AccessDenied` | 403 | 身份认证通过，但 RBAC 权限不足以执行该操作。 |

        | `RouteNotFound` | 404 | 请求的 URL 路径不是已知路由。 |

        | `MethodNotAllowed` | 405 | 当前路径不接受所使用的 HTTP 方法。 |

        | `UndonedOrderExist` | 409 | 账户存在未完成的订单，请稍后重试。 |

        | `RequestLocked` | 423 | 因连续失败被临时锁定。 |

        | `EntityTooLarge` | 413 | 请求体超过允许的最大长度。 |

        | `RequestTooFrequently` | 429 | 命中限流（全局、账户级或集成级）。 |

        | `RequestVerifyRequired` | 428 | 操作需要二次验证码，但未提供。 |

        | `DangerousOperation` | 428 | 危险操作，需要进行 MFA 验证。 |

        | `InternalError` | 500 | 服务端未预期错误。反馈问题请附上 `request_id`。 |

        | `ServiceUnavailable` | 503 | 后端依赖不可用，请稍后重试。 |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
      x-enumDescriptions:
        OK: 保留值，正常错误响应不会返回。
        InvalidParameter: 必填参数缺失或未通过校验。
        BadRequest: 通用的 400 错误，通常是请求本身不合法。
        InvalidContentType: 请求头 `Content-Type` 不是 `application/json`。
        ResourceNotFound: 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。
        NoLicense: 功能需要有效授权，但未找到可用的 license。
        ReferenceExist: 该资源仍被其他实体引用，无法删除。
        Unauthorized: '`app_key` 缺失、无效或已过期。'
        BalanceNotEnough: 账户余额不足，无法执行需要计费的操作。
        AccessDenied: 身份认证通过，但 RBAC 权限不足以执行该操作。
        RouteNotFound: 请求的 URL 路径不是已知路由。
        MethodNotAllowed: 当前路径不接受所使用的 HTTP 方法。
        UndonedOrderExist: 账户存在未完成的订单，请稍后重试。
        RequestLocked: 因连续失败被临时锁定。
        EntityTooLarge: 请求体超过允许的最大长度。
        RequestTooFrequently: 命中限流（全局、账户级或集成级）。
        RequestVerifyRequired: 操作需要二次验证码，但未提供。
        DangerousOperation: 危险操作，需要进行 MFA 验证。
        InternalError: 服务端未预期错误。反馈问题请附上 `request_id`。
        ServiceUnavailable: 后端依赖不可用，请稍后重试。
      example: InvalidParameter
    DashboardSelectionConfig:
      type: object
      description: 变量的选择数量约束。
      properties:
        mode:
          type: string
          enum:
            - single
            - multi
          description: 选择基数：`single` 表示解析后的选择恰好一个值；`multi` 表示允许选择多个值。
        include_all:
          type: boolean
          description: 为 true 时该变量额外提供 `all` 选项。
      required:
        - mode
        - include_all
    DashboardCandidate:
      type: object
      description: 自定义变量的一个候选项。
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 1024
          description: 选择器中展示的文案。
        value:
          type: string
          minLength: 1
          maxLength: 1024
          description: 替换进模板的取值。
      required:
        - text
        - value
    DashboardSelection:
      type: object
      description: 变量取值的具体选择。空的 `values` 数组是合法输入，表示未解析——服务端不会为其回退到默认值。
      properties:
        kind:
          type: string
          enum:
            - values
            - all
          description: '`values` 选择列出的项，`all` 表示全选（仅当 `include_all` 为 true 时可用）。'
        values:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 1024
          maxItems: 1000
          description: 已选值，需唯一且不得为 `$__all`。`kind` 为 `all` 时必须为空。
      required:
        - kind
    DashboardDatasourceRef:
      type: object
      description: 把面板或查询变量指向某个数据源——可以是固定 ID，也可以是渲染时求值的数据源变量。
      properties:
        kind:
          type: string
          enum:
            - fixed
            - variable
          description: '`fixed` 使用 `datasource_id`；`variable` 用 `name` 引用某个数据源变量。'
        datasource_id:
          type: integer
          format: uint64
          minimum: 1
          description: 数据源 ID。`kind` 为 `fixed` 时必填，为 `variable` 时禁止设置。
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]{0,63}$
          description: 数据源变量名。`kind` 为 `variable` 时必填，为 `fixed` 时禁止设置。
        datasource_type:
          type: string
          pattern: ^[a-z][a-z0-9_]{0,63}$
          description: 数据源类型标识，例如 `prometheus`、`victorialogs`。
      required:
        - kind
        - datasource_type
    DashboardVariableQuery:
      description: 变量查询。按 `kind` 选择分支；分支需与所引用数据源类型一致。
      oneOf:
        - $ref: '#/components/schemas/DashboardPrometheusVariableQuery'
        - $ref: '#/components/schemas/DashboardSQLVariableQuery'
        - $ref: '#/components/schemas/DashboardLogsVariableQuery'
      discriminator:
        propertyName: kind
        mapping:
          prometheus: '#/components/schemas/DashboardPrometheusVariableQuery'
          sql: '#/components/schemas/DashboardSQLVariableQuery'
          logs: '#/components/schemas/DashboardLogsVariableQuery'
    DashboardGridPosition:
      type: object
      description: 24 列网格位置。`x`、`y` 从 0 开始；`x + w` 不得超过 24。
      properties:
        x:
          type: integer
          minimum: 0
          maximum: 23
          description: 从 0 开始的列偏移。
        'y':
          type: integer
          minimum: 0
          description: 从 0 开始的行偏移。
        w:
          type: integer
          minimum: 1
          maximum: 24
          description: 宽度（列数），1～24。
        h:
          type: integer
          minimum: 1
          maximum: 100
          description: 高度（行数），1～100。
      required:
        - x
        - 'y'
        - w
        - h
    DashboardPanelQuery:
      type: object
      description: 面板内的一条查询。`ref_id` 用于标识面板中的序列，在同一面板内必须唯一。
      properties:
        ref_id:
          type: string
          pattern: ^[A-Z]$
          description: 单个大写字母（A～Z），在该面板内命名这条查询。
        query:
          $ref: '#/components/schemas/DashboardQuery'
        legend_alias:
          type: string
          maxLength: 1024
          description: 可选图例名；支持与 `expr` 相同的变量模板。
      required:
        - ref_id
        - query
    DashboardVizConfig:
      description: 可视化配置。`kind` 决定使用哪个分支以及哪个同级的配置对象必需；`time_series` 还携带通用的数值配置。
      oneOf:
        - $ref: '#/components/schemas/DashboardTimeSeriesViz'
        - $ref: '#/components/schemas/DashboardTableViz'
        - $ref: '#/components/schemas/DashboardStatViz'
        - $ref: '#/components/schemas/DashboardBarViz'
        - $ref: '#/components/schemas/DashboardGaugeViz'
        - $ref: '#/components/schemas/DashboardLogsViz'
        - $ref: '#/components/schemas/DashboardTextViz'
      discriminator:
        propertyName: kind
        mapping:
          time_series: '#/components/schemas/DashboardTimeSeriesViz'
          table: '#/components/schemas/DashboardTableViz'
          stat: '#/components/schemas/DashboardStatViz'
          bar: '#/components/schemas/DashboardBarViz'
          gauge: '#/components/schemas/DashboardGaugeViz'
          logs: '#/components/schemas/DashboardLogsViz'
          text: '#/components/schemas/DashboardTextViz'
    DashboardPrometheusVariableQuery:
      type: object
      description: Prometheus 标签取值查询。
      properties:
        kind:
          type: string
          enum:
            - prometheus
          description: 查询类型判别字段，固定为 `prometheus`，表示对 Prometheus 执行标签值查询。
        label:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_:.\-]{0,189}$
          description: 取值作为候选项的标签。
        metric:
          type: string
          description: 可选指标名，用于限定参与计算的序列。
        label_filters:
          type: array
          items:
            $ref: '#/components/schemas/DashboardLabelFilter'
          description: 可选匹配条件，在读取标签取值前先缩小序列范围。
      required:
        - kind
        - label
    DashboardSQLVariableQuery:
      type: object
      description: 返回一列候选项的 SQL 查询。
      properties:
        kind:
          type: string
          enum:
            - sql
          description: 查询类型判别字段，固定为 `sql`，表示执行返回单列候选的 SQL 查询。
        expr:
          type: string
          description: SQL 语句；可通过 `{{ }}` 引用其他变量。
        args:
          type: object
          additionalProperties:
            type: string
          description: 具名查询参数；默认为空对象。
        text_field:
          type: string
          description: 作为候选项文案的列；默认与取值列相同。
        value_field:
          type: string
          minLength: 1
          description: 作为候选项取值的列。
      required:
        - kind
        - expr
        - args
        - value_field
    DashboardLogsVariableQuery:
      type: object
      description: 返回某字段取值作为候选项的日志查询。
      properties:
        kind:
          type: string
          enum:
            - logs
          description: 查询类型判别字段，固定为 `logs`，表示执行返回某个字段取值作为候选的日志查询。
        expr:
          type: string
          description: 日志查询表达式；可通过 `{{ }}` 引用其他变量。
        args:
          type: object
          additionalProperties:
            type: string
          description: 具名查询参数；默认为空对象。
        field:
          type: string
          minLength: 1
          description: 取值作为候选项的日志字段。
      required:
        - kind
        - expr
        - args
        - field
    DashboardQuery:
      type: object
      description: 仪表盘与排障入口共用的查询内容。
      properties:
        mode:
          type: string
          enum:
            - instant
            - range
            - window
          description: 求值模式：`instant` 在单个时间点求值，`range` 求值一条按步长采样的曲线，`window` 返回时间窗口内的原始数据。
        expr:
          type: string
          description: 目标数据源语法下的查询表达式，可通过 `{{ }}` 模板引用事件标签。
        args:
          type: object
          additionalProperties:
            type: string
          description: 命名查询参数，默认空对象。值按原样透传，不允许包含 `{{ }}` 模板。
        min_step_seconds:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 1
          maximum: 9007199254740
          description: 最小步长（秒）。仅在 `mode` 为 `range` 时可用，且必须大于 0；省略或传 null 由服务端决定。
      required:
        - mode
        - expr
        - args
    DashboardTimeSeriesViz:
      type: object
      description: 时序图可视化。
      properties:
        kind:
          type: string
          enum:
            - time_series
          description: 可视化类型判别字段，固定为 `time_series`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        unit:
          type: string
          enum:
            - unitless
            - ratio
            - percent
            - milliseconds
            - seconds
            - bytes
            - bits
            - count_per_second
            - bytes_per_second
            - bits_per_second
          description: >-
            面板数值的展示单位：`unitless` = 原始数值；`ratio` = 占比（0–1 的小数）；`percent` =
            百分比；`milliseconds` = 毫秒；`seconds` = 秒；`bytes` = 字节；`bits` =
            比特；`count_per_second` = 每秒计数；`bytes_per_second` =
            每秒字节数；`bits_per_second` = 每秒比特数。
        decimals:
          type:
            - integer
            - 'null'
          minimum: 0
          description: 固定小数位；省略或传 null 由前端决定。
        threshold:
          $ref: '#/components/schemas/DashboardThreshold'
      required:
        - kind
        - options
    DashboardTableViz:
      type: object
      description: 表格可视化。
      properties:
        kind:
          type: string
          enum:
            - table
          description: 可视化类型判别字段，固定为 `table`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        column_options:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DashboardColumnOption'
          description: 按字段名索引的列展示覆盖配置，最多 100 项。
        sort:
          type: array
          items:
            $ref: '#/components/schemas/DashboardFieldSort'
          maxItems: 2
          description: 初始排序键；字段需唯一。
        link_columns:
          type: array
          items:
            $ref: '#/components/schemas/DashboardDataLink'
          maxItems: 5
          description: 以表格列形式渲染的下钻链接。与列级链接合计最多 5 个。
      required:
        - kind
        - options
    DashboardStatViz:
      type: object
      description: 单值（stat）可视化。
      properties:
        kind:
          type: string
          enum:
            - stat
          description: 可视化类型判别字段，固定为 `stat`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        unit:
          type: string
          enum:
            - unitless
            - ratio
            - percent
            - milliseconds
            - seconds
            - bytes
            - bits
            - count_per_second
            - bytes_per_second
            - bits_per_second
          description: >-
            面板数值的展示单位：`unitless` = 原始数值；`ratio` = 占比（0–1 的小数）；`percent` =
            百分比；`milliseconds` = 毫秒；`seconds` = 秒；`bytes` = 字节；`bits` =
            比特；`count_per_second` = 每秒计数；`bytes_per_second` =
            每秒字节数；`bits_per_second` = 每秒比特数。
        decimals:
          type:
            - integer
            - 'null'
          minimum: 0
          description: 固定小数位；省略或传 null 由前端决定。
        threshold:
          $ref: '#/components/schemas/DashboardThreshold'
        value_fields:
          type: array
          items:
            type: string
          description: 被归约为展示取值的字段。
        reducer:
          type: string
          enum:
            - last_non_null
            - min
            - max
            - mean
            - sum
          description: >-
            对返回行应用的归约方式：`last_non_null` = 最近的非空值；`min` = 最小值；`max` = 最大值；`mean`
            = 平均值；`sum` = 求和。
      required:
        - kind
        - options
        - value_fields
        - reducer
    DashboardBarViz:
      type: object
      description: 柱状图可视化。
      properties:
        kind:
          type: string
          enum:
            - bar
          description: 可视化类型判别字段，固定为 `bar`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        unit:
          type: string
          enum:
            - unitless
            - ratio
            - percent
            - milliseconds
            - seconds
            - bytes
            - bits
            - count_per_second
            - bytes_per_second
            - bits_per_second
          description: >-
            面板数值的展示单位：`unitless` = 原始数值；`ratio` = 占比（0–1 的小数）；`percent` =
            百分比；`milliseconds` = 毫秒；`seconds` = 秒；`bytes` = 字节；`bits` =
            比特；`count_per_second` = 每秒计数；`bytes_per_second` =
            每秒字节数；`bits_per_second` = 每秒比特数。
        decimals:
          type:
            - integer
            - 'null'
          minimum: 0
          description: 固定小数位；省略或传 null 由前端决定。
        threshold:
          $ref: '#/components/schemas/DashboardThreshold'
        category_field:
          type: string
          description: 提供类目轴的字段。
        value_fields:
          type: array
          items:
            type: string
          description: 提供柱值的字段。
        data_link:
          $ref: '#/components/schemas/DashboardDataLink'
      required:
        - kind
        - options
        - category_field
        - value_fields
    DashboardGaugeViz:
      type: object
      description: 仪表盘（gauge）可视化。
      properties:
        kind:
          type: string
          enum:
            - gauge
          description: 可视化类型判别字段，固定为 `gauge`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        unit:
          type: string
          enum:
            - unitless
            - ratio
            - percent
            - milliseconds
            - seconds
            - bytes
            - bits
            - count_per_second
            - bytes_per_second
            - bits_per_second
          description: >-
            面板数值的展示单位：`unitless` = 原始数值；`ratio` = 占比（0–1 的小数）；`percent` =
            百分比；`milliseconds` = 毫秒；`seconds` = 秒；`bytes` = 字节；`bits` =
            比特；`count_per_second` = 每秒计数；`bytes_per_second` =
            每秒字节数；`bits_per_second` = 每秒比特数。
        decimals:
          type:
            - integer
            - 'null'
          minimum: 0
          description: 固定小数位；省略或传 null 由前端决定。
        threshold:
          $ref: '#/components/schemas/DashboardThreshold'
        value_fields:
          type: array
          items:
            type: string
          description: 被归约为仪表值的字段。
        reducer:
          type: string
          enum:
            - last_non_null
            - min
            - max
            - mean
            - sum
          description: >-
            对返回行应用的归约方式：`last_non_null` = 最近的非空值；`min` = 最小值；`max` = 最大值；`mean`
            = 平均值；`sum` = 求和。
        min:
          type:
            - number
            - 'null'
          description: 刻度下限。
        max:
          type:
            - number
            - 'null'
          description: 刻度上限；两者都设置时必须大于 `min`。
      required:
        - kind
        - options
        - value_fields
        - reducer
    DashboardLogsViz:
      type: object
      description: 日志流可视化。
      properties:
        kind:
          type: string
          enum:
            - logs
          description: 可视化类型判别字段，固定为 `logs`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        display_fields:
          type: array
          items:
            type: string
          description: 每行渲染的日志字段。
      required:
        - kind
        - options
    DashboardTextViz:
      type: object
      description: Markdown 文本面板。
      properties:
        kind:
          type: string
          enum:
            - text
          description: 可视化类型判别字段，固定为 `text`。
        options:
          type: object
          additionalProperties: true
          description: 所选可视化类型的开放配置对象；也是定义中唯一无损 round-trip 的部分。缺失或 null 时规范化为 `{}`。
        markdown:
          type: string
          maxLength: 65536
          description: Markdown 正文，最多 64 KiB。仅限白名单节点（标题、列表、表格、链接、代码）可通过校验。
      required:
        - kind
        - options
        - markdown
    DashboardLabelFilter:
      type: object
      description: Prometheus 标签匹配条件。
      properties:
        label:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_:.\-]{0,189}$
          description: 标签名。
        op:
          type: string
          enum:
            - '='
            - '!='
            - '=~'
            - '!~'
          description: 匹配操作符：`=` = 等于；`!=` = 不等于；`=~` = 正则匹配；`!~` = 正则不匹配。
        value:
          type: string
          minLength: 1
          description: 匹配值；可通过 `{{ }}` 引用其他变量。
      required:
        - label
        - op
        - value
    DashboardThreshold:
      type: object
      description: 数值的颜色阈值。`warning`/`critical` 至少设置一个；两者都设置时需按 `mode` 满足大小关系。
      properties:
        mode:
          type: string
          enum:
            - higher_is_worse
            - lower_is_worse
          description: 比较方向：`higher_is_worse` = 值高于等于边界即为越限；`lower_is_worse` = 值低于等于边界即为越限。
        warning:
          type:
            - number
            - 'null'
          description: 警告阈值；需为有限数。
        critical:
          type:
            - number
            - 'null'
          description: 严重阈值；需为有限数。
      required:
        - mode
    DashboardColumnOption:
      type: object
      description: 表格中按列的展示覆盖配置。
      properties:
        display_name:
          type: string
          description: 替换原始字段名的表头文案。
        hidden:
          type:
            - boolean
            - 'null'
          description: 隐藏该列；省略表示保持可见。
        width_px:
          type:
            - integer
            - 'null'
          minimum: 80
          maximum: 1200
          description: 列宽（像素），80～1200。
        unit:
          type: string
          enum:
            - unitless
            - ratio
            - percent
            - milliseconds
            - seconds
            - bytes
            - bits
            - count_per_second
            - bytes_per_second
            - bits_per_second
          description: >-
            列展示单位覆盖：`unitless` = 原始数值；`ratio` = 占比（0–1 的小数）；`percent` =
            百分比；`milliseconds` = 毫秒；`seconds` = 秒；`bytes` = 字节；`bits` =
            比特；`count_per_second` = 每秒计数；`bytes_per_second` =
            每秒字节数；`bits_per_second` = 每秒比特数。
        threshold:
          $ref: '#/components/schemas/DashboardThreshold'
        threshold_display:
          type: string
          enum:
            - text
            - background
          description: 阈值的呈现方式：`text` = 为单元格文本着色；`background` = 为单元格背景着色。
        data_link:
          $ref: '#/components/schemas/DashboardDataLink'
    DashboardFieldSort:
      type: object
      description: 单个排序键。
      properties:
        field:
          type: string
          minLength: 1
          description: 排序字段名。
        direction:
          type: string
          enum:
            - asc
            - desc
          description: 排序方向：`asc` = 升序；`desc` = 降序。
      required:
        - field
        - direction
    DashboardDataLink:
      type: object
      description: 从表格列或柱状图面板下钻到另一个仪表盘的链接。目标仪表盘必须存在，且映射来源需与源面板的结构匹配。
      properties:
        dashboard_id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 目标仪表盘 ID。
        target_id:
          type: string
          pattern: >-
            ^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
          description: 可选的目标 tab/section/panel ID，用于在目标仪表盘中定位。
        pass_time:
          type: boolean
          description: 为 true 时把当前时间范围传递到目标仪表盘。
        variable_mappings:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DashboardLinkMapping'
          description: 把目标变量名映射到某个来源值，例如表格列或源变量。
      required:
        - dashboard_id
        - pass_time
        - variable_mappings
    DashboardLinkMapping:
      type: object
      description: 下钻变量映射中的一项。
      properties:
        source:
          type: string
          enum:
            - variable
            - row_column
            - category
            - series
            - value
          description: >-
            取值来源：`variable` = 仪表盘变量；`row_column` = 表格列（必须同时给出
            `column`）；`category` = 柱状图的类目；`series` = 序列名；`value` =
            数值本身。`category`、`series`、`value` 仅对柱状图面板有效。
        column:
          type: string
          description: 来源列名；`source` 为 `row_column` 时必填。
        name:
          type: string
          description: 来源仪表盘变量名；`source` 为 `variable` 时必填。
      required:
        - source
  responses:
    BadRequest:
      description: 请求非法 — 通常是参数缺失或格式不正确。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter is not valid.
    Unauthorized:
      description: app_key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    Forbidden:
      description: app_key 有效但没有执行该操作的权限。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            noEditPermission:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: AccessDenied
                  message: Access Denied.
    TooManyRequests:
      description: 命中限流。可能是全局 API 限流、账户级限流或集成级限流。限流按账户聚合。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: 服务端未预期错误。反馈问题时请携带 request_id。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.