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

# 通知成员

> 以调用方身份向账户成员发送邮件，邮件内容由调用方提供。仅可使用 AI SRE 会话凭据调用；使用其他凭据调用会返回 AccessDenied 错误。邮件投递是异步的——`accepted` 表示邮件已入队，并不代表已送达。发送前先将 `dry_run` 设为 `true` 调用一次：响应中的 `html` 就是收件人将收到的邮件，可据此确认清洗后正文依赖的内容都还在。

## 限制说明

| 项目   | 说明                                             |
| ---- | ---------------------------------------------- |
| 速率限制 | 每个账户 **200 次/分钟**；**10 次/秒**                   |
| 权限要求 | 无——仅可使用 AI SRE 会话凭据调用；使用其他凭据调用会返回 AccessDenied |

## 使用说明

* 不是调用方账户内活跃成员、或没有邮箱地址的收件人会被跳过，不会导致整个请求失败。
* 是否发送邮件取决于每个收件人针对此类消息的通知偏好设置；未设置偏好的收件人默认会收到邮件。
* 收件人收到的邮件正文就是清洗后的 `html`，平台不会在其前后添加任何内容；发件人名称显示为调用方姓名加“(via AI SRE)”。
* 将 `dry_run` 设为 `true` 可执行全部检查并在 `html` 中返回将要发送的完整邮件，但不会发送：不会入队，也不占用每小时限额和同轮次去重。
* 同一收件人通过该接口每小时最多收到 20 封邮件；超出后同一窗口内该收件人的后续投递会被跳过并返回 `rate_limited`。
* 在同一个 AI SRE 会话轮次内重复调用，不会向已收到邮件的收件人重复发送；重复的收件人会被跳过并返回 `duplicate`。


## OpenAPI

````yaml /api-reference/platform.openapi.zh.json post /member/notify
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: 平台/成员管理
    description: ''
  - name: 平台/团队管理
    description: ''
  - name: 平台/角色与权限
    description: ''
  - name: 平台/审计日志
    description: 检索和读取账户操作审计日志。
  - name: 平台/账户设置
    description: 账户（主体）信息与设置
paths:
  /member/notify:
    post:
      tags:
        - 平台/成员管理
      summary: 通知成员
      description: >-
        以调用方身份向账户成员发送邮件，邮件内容由调用方提供。仅可使用 AI SRE 会话凭据调用；使用其他凭据调用会返回 AccessDenied
        错误。邮件投递是异步的——`accepted` 表示邮件已入队，并不代表已送达。发送前先将 `dry_run` 设为 `true`
        调用一次：响应中的 `html` 就是收件人将收到的邮件，可据此确认清洗后正文依赖的内容都还在。
      operationId: memberNotify
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemberNotifyRequest'
            example:
              person_ids:
                - 5068740052131
                - 5068740052132
              subject: Incident 20260914-1 needs your input
              html: <p>Can you confirm the rollback window?</p>
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/MemberNotifyResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  recipients:
                    - person_id: 5068740052131
                      status: accepted
                    - person_id: 5068740052132
                      status: skipped
                      reason: email_disabled
        '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:
    MemberNotifyRequest:
      type: object
      description: 邮件通知成员请求
      required:
        - subject
        - html
      properties:
        person_ids:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 20
          uniqueItems: true
          description: 收件人成员 ID 列表。可选，最多 20 个，不可重复；省略或为空时仅发送给调用方本人。
        subject:
          type: string
          minLength: 1
          maxLength: 200
          description: 邮件主题，按原样使用。必填，1–200 个字符；换行会被替换为空格，首尾空白会被去除。
        html:
          type: string
          maxLength: 102400
          description: >-
            邮件正文，HTML 片段（无需 `<html>`/`<head>`/`<body>` 包裹），即收件人看到的完整邮件正文。必填，原始
            UTF-8 内容不超过 102,400
            字节（更大的正文会被常见邮件客户端截断），且清洗后不能为空。服务端会进行清洗：`<script>`、`<style>`、`<iframe>`、`<object>`、`<embed>`、`<form>`、`<input>`、`<button>`、`<svg>`、`<meta>`、`<link>`、`<base>`
            标签及所有 `on*` 事件处理属性会被移除；图片仅在 `src` 为 `https` 时保留，其他来源或没有 `src` 的图片（包括
            `data:`）会被移除；链接仅允许 `http`、`https`、`mailto`。内联 `style` 属性按原样保留。
        dry_run:
          type: boolean
          default: false
          description: >-
            仅检查不发送。为 `true` 时执行全部检查，并在响应的 `html`
            中返回将要发送的完整邮件，但不会入队，也不占用每小时限额和同轮次去重。默认 `false`。
    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
    MemberNotifyResponse:
      type: object
      description: 邮件通知成员响应
      properties:
        recipients:
          type: array
          items:
            $ref: '#/components/schemas/MemberNotifyResultItem'
          description: 每个已解析收件人对应一条结果，顺序与解析后的收件人列表一致。`dry_run` 时为实际发送将得到的结果。
        html:
          type: string
          description: 仅当 `dry_run` 为 `true` 时返回：清洗后、收件人将收到的完整邮件 HTML。
    MemberNotifyResultItem:
      type: object
      description: 单个收件人的通知结果
      required:
        - person_id
        - status
      properties:
        person_id:
          type: integer
          format: int64
          description: 收件人成员 ID。
        status:
          type: string
          enum:
            - accepted
            - skipped
          description: 投递状态。`accepted` —— 邮件已入队等待异步投递；`skipped` —— 未入队，具体原因见 `reason`。
        reason:
          type: string
          enum:
            - not_member
            - no_email
            - email_disabled
            - duplicate
            - rate_limited
            - send_failed
          description: >-
            跳过原因，仅当 `status` 为 `skipped` 时出现。`not_member` ——
            不是调用方账户的活跃成员；`no_email` —— 该成员没有邮箱地址；`email_disabled` ——
            该成员针对此类消息的通知偏好中未包含邮件；`duplicate` —— 该收件人在同一个 AI SRE
            会话轮次中已经收到过一次消息；`rate_limited` —— 该收件人通过该接口在过去一小时内已被发送 20
            封邮件；`send_failed` —— 邮件入队失败。
    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: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
      required:
        - code
        - message
    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
  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
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````