> ## 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.

# 更新变更

> 更新变更的标题、描述、状态、链接、标签、计划、执行清单或自定义字段取值。未传的字段保持原值。

## 限制说明

| 项目 | 说明 |
| - | - |
| 速率限制 | 每个账户 **300 次/分钟**；**20 次/秒** |
| 权限要求 | 无 —— 持有有效的 `app_key` 即可调用 |

## 使用说明

* 除 `change_id` 外至少要传一个字段，否则返回 `InvalidParameter`。
* `change_id` 不存在时返回 `InvalidParameter`。调用方须有权写入该变更所在的协作空间，规则与 `POST /change/create` 相同；未关联协作空间（`channel_id` 为 0）的变更只有账户所有者和管理员能更新。否则返回 `AccessDenied`。变更所属的协作空间不能修改。
* `change_status` 只能按固定流程流转：`Planned` → `Ready`、`Processing` 或 `Canceled`；`Ready` → `Processing` 或 `Canceled`；`Processing` → `Done` 或 `Failed`；`Done` 或 `Failed` → `Processing`（重新打开）。`Canceled` 不能再流转。传当前状态不报错；其他流转返回 `InvalidParameter`。`POST /change/info` 的 `next_statuses` 给出允许的流转。
* `title` 和 `change_status` 不能为空字符串；其他字符串字段传 `""` 即清空。
* `labels` 按键新增或覆盖，值为空字符串的键会被删除；`fields` 按键设置取值，值为 `null` 的键会被删除。两者中未传的键都保持不变。
* `checklist` 会整体替换原清单。`by` 和 `at` 会被忽略：原来已按相同 `text` 勾选的项保留原勾选人和时间，新勾选的项记为调用方勾选。
* 如果唯一的差别是勾选了哪些清单项（清单项内容和顺序都不变），勾选结果直接保存，不写时间线、不发通知，`last_time` 也不变。
* `planned_start_time` 和 `planned_end_time` 接受 Unix 秒或毫秒；更新后 `planned_end_time` 不能早于 `planned_start_time`。
* 变更表单的必填字段按更新后的变更校验，但只拒绝本次更新造成的空缺（返回 `InvalidParameter`，信息为 `required fields missing or empty: <字段键>`）；更新前就为空的必填字段不会阻止更新。
* 对在控制台或通过 `POST /change/create` 创建的变更，状态流转会向变更表单绑定的群组发送状态通知，修改变更表单上的其他字段会发送编辑通知。由集成上报的变更在这里更新时不发通知。
* 每次调用都会记录到账户审计日志。


## OpenAPI

````yaml /api-reference/on-call.openapi.zh.json post /change/update
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty 事件管理平台的公开 HTTP API —— 覆盖故障、通知模板、协作空间、值班排班、监控、RUM、以及平台管理。每次调用都需在
    query 中携带 `app_key`，该 key 在 Flashduty 控制台 我的 → APP Key 中创建（也可放在请求头
    `Fd-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: On-call/故障管理
    description: ''
  - name: On-call/协作空间
    description: ''
  - name: On-call/告警管理
    description: 查询、查看和处理告警，管理卡片视图与告警处理规则。
  - name: On-call/集成中心
    description: ''
  - name: On-call/IM 集成
    description: IM 集成相关查询，例如查看哪些集成开启了作战室。
  - name: On-call/值班排班
    description: ''
  - name: On-call/许可管理
    description: ''
  - name: On-call/日历管理
    description: ''
  - name: On-call/通知模板
    description: ''
  - name: On-call/标签增强
    description: 自定义字段、富化规则及数据映射（映射规则、映射数据、映射 API）管理。
  - name: On-call/分析看板
    description: ''
  - name: On-call/状态页
    description: ''
  - name: On-call/变更管理
    description: ''
  - name: On-call/专属集成
    description: 管理各协作空间的专属告警集成。
paths:
  /change/update:
    post:
      tags:
        - On-call/变更管理
      summary: 更新变更
      description: 更新变更的标题、描述、状态、链接、标签、计划、执行清单或自定义字段取值。未传的字段保持原值。
      operationId: change-write-update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateChangeRequest'
            example:
              change_id: 664a1b2c3d4e5f6a7b8c9d0e
              change_status: Processing
              labels:
                version: v3.2.0
                env: ''
              fields:
                risk_level: null
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/UpdateChangeResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  change_id: 664a1b2c3d4e5f6a7b8c9d0e
                  change_key: CHG-20261126-7Q2K
                  change_status: Processing
        '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:
    UpdateChangeRequest:
      type: object
      required:
        - change_id
      properties:
        change_id:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: 要更新的变更 ID，24 位十六进制字符串。
        title:
          type: string
          minLength: 1
          description: 变更标题，不能为空。
        description:
          type: string
          description: 变更描述。不传则保持原值，传空字符串即清空。
          x-flashduty-preserve-absence: true
        change_status:
          type: string
          enum:
            - Planned
            - Ready
            - Processing
            - Canceled
            - Done
            - Failed
          description: |-
            新状态；必须是当前状态，或当前状态可流转到的状态（见 `POST /change/info` 的 `next_statuses`）。
            | 取值 | 含义 |
            |---|---|
            | `Planned` | 已计划，未开始。 |
            | `Ready` | 就绪，待执行。 |
            | `Processing` | 执行中。 |
            | `Canceled` | 已取消。 |
            | `Done` | 已完成。 |
            | `Failed` | 失败。 |
        link:
          type: string
          description: 指向变更记录的外部链接：完整的 `http`/`https` 地址，或为空。不传则保持原值，传空字符串即清空。
          x-flashduty-preserve-absence: true
        labels:
          type: object
          additionalProperties:
            type: string
          description: 要新增或覆盖的标签；值为空字符串的键会被删除，未传的键保持不变。
        planned_start_time:
          type: integer
          format: int64
          minimum: 0
          description: 计划开始时间，Unix 时间戳（秒或毫秒）。不传则保持原值，传 `0` 即清空。
          x-flashduty-preserve-absence: true
        planned_end_time:
          type: integer
          format: int64
          minimum: 0
          description: 计划结束时间，Unix 时间戳（秒或毫秒）；不能早于 `planned_start_time`。不传则保持原值，传 `0` 即清空。
          x-flashduty-preserve-absence: true
        operator:
          type: string
          description: 变更执行人，成员邮箱或自由文本姓名。不传则保持原值，传空字符串即清空。
          x-flashduty-preserve-absence: true
        impact:
          type: string
          description: 变更影响，Markdown 文本。不传则保持原值，传空字符串即清空。
          x-flashduty-preserve-absence: true
        backout_plan:
          type: string
          description: 变更回滚方案，Markdown 文本。不传则保持原值，传空字符串即清空。
          x-flashduty-preserve-absence: true
        checklist:
          type: array
          items:
            $ref: '#/components/schemas/ChangeChecklistItem'
          description: >-
            完整的执行清单，整体替换原清单。`by` 和 `at` 会被忽略；原来已按相同 `text`
            勾选的项保留原勾选人，新勾选的项记为调用方勾选。不传则保持原清单，传空数组即清空。
          x-flashduty-preserve-absence: true
        fields:
          type: object
          additionalProperties: true
          description: 要设置的自定义字段取值，按字段名索引；值为 `null` 的键会被删除，未传的键保持不变。
    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: 接口返回的数据，格式见各接口的 200 响应。没有返回数据的接口会返回 `{}` 或完全不带 `data`。
      required:
        - request_id
    UpdateChangeResponse:
      type: object
      description: 更新后的变更。
      required:
        - change_id
        - change_key
        - change_status
      properties:
        change_id:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: 变更 ID。
        change_key:
          type: string
          description: 变更键。
        change_status:
          type: string
          enum:
            - Planned
            - Ready
            - Processing
            - Canceled
            - Done
            - Failed
          description: |-
            更新后的变更状态。
            | 取值 | 含义 |
            |---|---|
            | `Planned` | 已计划，未开始。 |
            | `Ready` | 就绪，待执行。 |
            | `Processing` | 执行中。 |
            | `Canceled` | 已取消。 |
            | `Done` | 已完成。 |
            | `Failed` | 失败。 |
    ChangeChecklistItem:
      type: object
      description: 变更执行清单中的一项。
      required:
        - text
      properties:
        text:
          type: string
          description: 清单项内容。
        done:
          type: boolean
          description: 该项是否已勾选完成。
        by:
          type: string
          description: 勾选该项的成员名称；未勾选时不返回。
        at:
          type: integer
          format: int64
          description: 勾选时间，Unix 时间戳（秒）；未勾选时不返回。
    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
    DutyError:
      type: object
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            按响应语言（query 参数 `locale` / `lang` 或请求头
            `Accept-Language`）返回的错误描述，可能包含出错的字段名，请不要解析它。
          example: The specified parameter template_id is not valid.
      required:
        - code
        - message
    ErrorCode:
      type: string
      description: >-
        错误码。所有失败响应都会把 `error.code` 设为下列稳定字符串之一，请以它而不是 HTTP 状态码做判断。


        | 错误码 | HTTP | 含义 |

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

        | `OK` | 200 | 保留值，失败的请求不会返回。 |

        | `InvalidParameter` | 400 | 参数缺失、类型错误或未通过校验，`message` 通常会指出字段名。 |

        | `BadRequest` | 400 | 请求违反业务规则或与对象当前状态冲突，`message` 会说明原因。 |

        | `InvalidContentType` | 400 | 请求体没有以 `application/json` 发送。 |

        | `ResourceNotFound` | 400 | 引用的对象在本账户中不存在或已删除。注意 HTTP 状态码是 400 而不是 404。
        |

        | `NoLicense` | 400 | 账户套餐不包含该功能、套餐配额已用完、套餐已过期或额度不足。 |

        | `ReferenceExist` | 400 | 对象仍被其他对象引用，无法删除。 |

        | `Unauthorized` | 401 | APP Key 缺失、无效或已删除。 |

        | `BalanceNotEnough` | 402 | 仅用于控制台计费流程，Open API 接口不会返回。 |

        | `AccessDenied` | 403 | APP Key 的权限范围或创建者角色不允许该操作或该对象。 |

        | `RouteNotFound` | 404 | 没有与该 HTTP 方法和路径匹配的接口。 |

        | `MethodNotAllowed` | 405 | 路径存在，但不支持该 HTTP 方法。 |

        | `UndonedOrderExist` | 409 | 仅用于控制台计费流程，Open API 接口不会返回。 |

        | `EntityTooLarge` | 413 | 请求体超出大小限制。 |

        | `RequestLocked` | 423 | 仅用于控制台登录保护，Open API 接口不会返回。 |

        | `RequestVerifyRequired` | 428 | 仅用于控制台验证码流程，Open API 接口不会返回。 |

        | `DangerousOperation` | 428 | 仅用于控制台高风险操作的 MFA 校验，Open API 接口不会返回。 |

        | `RequestTooFrequently` | 429 | 触发频率限制；请等待响应头
        `Flashcat-Request-Rate-Limit-Delay` 给出的秒数后再重试。 |

        | `InternalError` | 500 | 服务端意外错误；请退避后重试，反馈问题时附上 `request_id`。 |

        | `ServiceUnavailable` | 503 | 后端依赖过载或不可用，请退避后重试。 |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - EntityTooLarge
        - RequestLocked
        - RequestVerifyRequired
        - DangerousOperation
        - RequestTooFrequently
        - InternalError
        - ServiceUnavailable
      x-enumDescriptions:
        OK: 保留值，失败的请求不会返回。
        InvalidParameter: 参数缺失、类型错误或未通过校验，`message` 通常会指出字段名。
        BadRequest: 请求违反业务规则或与对象当前状态冲突，`message` 会说明原因。
        InvalidContentType: 请求体没有以 `application/json` 发送。
        ResourceNotFound: 引用的对象在本账户中不存在或已删除。注意 HTTP 状态码是 400 而不是 404。
        NoLicense: 账户套餐不包含该功能、套餐配额已用完、套餐已过期或额度不足。
        ReferenceExist: 对象仍被其他对象引用，无法删除。
        Unauthorized: APP Key 缺失、无效或已删除。
        BalanceNotEnough: 仅用于控制台计费流程，Open API 接口不会返回。
        AccessDenied: APP Key 的权限范围或创建者角色不允许该操作或该对象。
        RouteNotFound: 没有与该 HTTP 方法和路径匹配的接口。
        MethodNotAllowed: 路径存在，但不支持该 HTTP 方法。
        UndonedOrderExist: 仅用于控制台计费流程，Open API 接口不会返回。
        EntityTooLarge: 请求体超出大小限制。
        RequestLocked: 仅用于控制台登录保护，Open API 接口不会返回。
        RequestVerifyRequired: 仅用于控制台验证码流程，Open API 接口不会返回。
        DangerousOperation: 仅用于控制台高风险操作的 MFA 校验，Open API 接口不会返回。
        RequestTooFrequently: 触发频率限制；请等待响应头 `Flashcat-Request-Rate-Limit-Delay` 给出的秒数后再重试。
        InternalError: 服务端意外错误；请退避后重试，反馈问题时附上 `request_id`。
        ServiceUnavailable: 后端依赖过载或不可用，请退避后重试。
      example: InvalidParameter
  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: 触发频率限制。请等待响应头 `Flashcat-Request-Rate-Limit-Delay` 给出的秒数后重试。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
      headers:
        Flashcat-Request-Rate-Limit-Delay:
          description: 距当前限流窗口重置的秒数。请求被网关全局保护限流拒绝时不返回该响应头。
          schema:
            type: integer
            minimum: 0
    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。可通过 query 参数 `app_key` 或请求头
        `Fd-App-Key` 传入。实际可访问范围是该 APP Key 的权限范围与创建者当前角色权限的交集，请妥善保管。

````

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