> ## Documentation Index
> Fetch the complete documentation index at: https://test-8ad8522e-doc-review-20260703-031622.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 立即执行自动化规则

> 手动启动一条自动化规则并返回运行与会话信息。

## 调用限制

| 项    | 值                                                              |
| ---- | -------------------------------------------------------------- |
| 速率限制 | 同一规则手动执行最多 **1 次/分钟**；全局 API 限制为 **1,000 次/分钟**、**50 次/秒** 每账户 |
| 权限   | 有效 `app_key`；调用者必须可管理目标规则                                      |

## 使用说明

* 此接口不创建新的触发器配置，而是立即按规则当前配置启动一次真实运行。
* 服务端会先执行运行前检查；检查通过后创建 `manual` 类型运行，并异步执行隐藏会话。
* 成功响应会返回 `run_id`，并在会话创建完成后返回 `session_id`，可用它跳转到对应会话查看消息、工具调用与产物。
* 同一规则手动执行最多每分钟一次；过于频繁会返回 429。


## OpenAPI

````yaml /api-reference/safari.openapi.zh.json post /safari/automation/rule/run
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty AI SRE 平台的公开 HTTP API —— 技能、MCP 服务器（连接器）、A2A 智能体与会话。所有接口均使用
    Flashduty 控制台签发的 `app_key` 查询参数进行认证。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: AI SRE/技能
  - name: AI SRE/MCP 服务器
  - name: AI SRE/A2A 智能体
  - name: AI SRE/会话
  - name: AI SRE/Automations
paths:
  /safari/automation/rule/run:
    post:
      tags:
        - AI SRE/Automations
      summary: 立即执行自动化规则
      description: 手动启动一条自动化规则并返回运行与会话信息。
      operationId: automation-rule-write-run
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AutomationRuleIDRequest'
            example:
              rule_id: auto_7NnLzY2Qp8xS4kUaV3mR6b
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/AutomationManualRunResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  rule_id: auto_7NnLzY2Qp8xS4kUaV3mR6b
                  trigger_kind: manual
                  preflight:
                    ok: true
                    checks:
                      - rule_enabled
                      - environment_available
                    scope: team
                    owner_id: 80011
                    team_id: 123
                    app_name: ai-sre
                  run:
                    run_id: taskrun_5oDvqiG64uur6sBNsTc4u
                    session_id: sess_4tQm9aN2kP8xV7sL6dRy3e
        '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'
      security:
        - AppKeyAuth: []
components:
  schemas:
    AutomationRuleIDRequest:
      type: object
      properties:
        rule_id:
          type: string
          description: 规则 ID。
      required:
        - rule_id
    ResponseEnvelope:
      type: object
      description: >-
        Standard response envelope used by every Flashduty public API. On
        success `data` contains the endpoint-specific payload and `error` is
        absent. On failure `error` is present and `data` is absent. `request_id`
        is always present and is also mirrored in the `Flashcat-Request-Id`
        response header.
      properties:
        request_id:
          type: string
          description: >-
            Unique ID for this request. Mirrored in the Flashcat-Request-Id
            header. Include it when reporting issues.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
        data:
          description: Endpoint-specific payload. See each operation's 200 response schema.
      required:
        - request_id
    AutomationManualRunResponse:
      type: object
      properties:
        rule_id:
          type: string
          description: 规则 ID。
        trigger_kind:
          type: string
          enum:
            - manual
          description: 固定为 manual，表示立即执行触发。
        preflight:
          $ref: '#/components/schemas/AutomationPreflightResult'
        run:
          $ref: '#/components/schemas/AutomationRunView'
      required:
        - rule_id
        - trigger_kind
        - preflight
    DutyError:
      type: object
      description: >-
        Error payload inside the response envelope. Present only on non-2xx
        responses.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            Human-readable error message, localized by the caller's
            Accept-Language. May contain field names, IDs, or other context from
            the failing request.
      required:
        - code
        - message
    AutomationPreflightResult:
      type: object
      properties:
        ok:
          type: boolean
          description: 运行前检查是否通过。
        checks:
          type: array
          items:
            type: string
          description: 已执行的检查项。
        scope:
          type: string
          description: 规则运行作用域。
        owner_id:
          type: integer
          format: int64
          description: 规则创建者用户 ID。
        team_id:
          type: integer
          format: int64
          description: 规则所属团队 ID；0 表示个人规则。
        app_name:
          type: string
          description: 自动化所属应用名。
        warnings:
          type: array
          items:
            type: string
          description: 不阻止运行的检查警告。
      required:
        - ok
        - checks
        - scope
        - owner_id
        - team_id
        - app_name
    AutomationRunView:
      type: object
      properties:
        run_id:
          type: string
          description: 运行 ID。
        session_id:
          type: string
          description: 本次运行创建的隐藏会话 ID。
      required:
        - run_id
    ErrorResponse:
      type: object
      description: Response envelope for errors. `error` is required; `data` is absent.
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    ErrorCode:
      type: string
      description: >-
        Flashduty error code enum. Every failed API response sets `error.code`
        to one of these values. The value is a stable wire string — not a
        localized message and not a numeric status. HTTP status is
        informational.
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
  responses:
    BadRequest:
      description: Invalid request — usually a missing or malformed parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              summary: Missing required parameter
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter skill_id is not valid.
    Unauthorized:
      description: Missing or invalid 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: The app_key is valid but lacks permission for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            accessDenied:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: AccessDenied
                  message: Access Denied.
    TooManyRequests:
      description: Rate limit hit. Either the global API limit or a per-account limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: Unexpected server-side error. Include the request_id when reporting.
      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: >-
        App key issued from the Flashduty console. Required on every public API
        call. Keep it secret — it grants the same access as the owning account.

````