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

# 创建监控器

> 从自然语言查询创建一个监控器。配置一个影子代理，生成工作流规范，排队DAG规划，并安排定期运行。通过notification.channels和/或webhook配置交付。返回202状态为provisioning，或使用?stream=1流式传输进度。



## OpenAPI

````yaml zh/openapi/monitors.json POST /v1/monitors
openapi: 3.0.3
info:
  title: Monitors API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/monitors:
    post:
      summary: 创建监控
      description: >-
        从自然语言`query`创建一个监控，配置一个内部代理和计划，生成一个工作流规范，并排队DAG规划。当请求完成且不进行流式传输时，返回HTTP
        `202`，状态为`provisioning`。传递`?stream=1`或`Accept:
        text/event-stream`以接收服务器发送的事件，用于配置阶段和规范推理令牌。监控在规划解决跟踪目标后变为`active`。
      parameters:
        - name: stream
          in: query
          required: false
          schema:
            type: string
            enum:
              - '1'
              - 'true'
          description: >-
            设置时，响应为`text/event-stream`，包含`phase`，`reasoning_token`，`complete`和`error`事件。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - query
              properties:
                query:
                  type: string
                  description: 用自然语言描述要监控的内容。
                source_policy:
                  $ref: '#/components/schemas/MonitorSourcePolicy'
                frequency:
                  type: string
                  maxLength: 50
                  default: every hour
                  description: 自然语言计划（例如`every day at 9am`）。最小间隔为每10分钟。计划使用UTC。
                notification:
                  $ref: '#/components/schemas/MonitorNotification'
                webhook:
                  $ref: '#/components/schemas/MonitorWebhook'
                metadata:
                  type: object
                  additionalProperties: true
                output_schema:
                  type: object
                  additionalProperties: true
                  description: 用于结构化提取输出的JSON Schema。
      responses:
        '200':
          description: 配置流（`text/event-stream`），当`stream=1`时。以包含监控对象的`complete`事件结束。
          content:
            text/event-stream:
              schema:
                type: string
        '202':
          description: 监控已接受；配置已开始（非流式传输）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Monitor'
        '400':
          description: >-
            请求无效（query, frequency, source_policy, notification, webhook,
            metadata, 或 output_schema）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 无效的 API 密钥。
        '500':
          description: 创建监控时发生内部服务器错误。
        '503':
          description: 在配置期间，FDA 主代理不可用。
      security:
        - Authorization: []
components:
  schemas:
    MonitorSourcePolicy:
      type: object
      description: 在规划和执行期间应用的可选 URL/域名允许和拒绝列表。
      properties:
        include_urls:
          type: array
          items:
            type: string
            format: uri
        exclude_urls:
          type: array
          items:
            type: string
            format: uri
        include_domains:
          type: array
          items:
            type: string
        exclude_domains:
          type: array
          items:
            type: string
    MonitorNotification:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - changed
              - first_snapshot
          description: >-
            何时通知。`changed` — 当检测到与前一个快照的变化时传递。`first_snapshot` — 当拍摄第一个基线快照时传递。当
            `channels` 非空且 `events` 为空时，默认为两者。
        channels:
          type: array
          items:
            $ref: '#/components/schemas/NotificationChannel'
          description: Email、Slack 或 SMS 传递目标。在运行时由监控管道解析。
    MonitorWebhook:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: 接收监控负载的 HTTP/HTTPS URL（与 `notification.channels` 分开）。
    Monitor:
      type: object
      properties:
        id:
          type: string
          description: 唯一的监控器标识符 (`monitor_…`)。
        object:
          type: string
          example: monitor
        query:
          type: string
          description: 自然语言中的监控意图。
        tracked:
          $ref: '#/components/schemas/MonitorTracked'
        source_policy:
          $ref: '#/components/schemas/MonitorSourcePolicy'
        schedule:
          $ref: '#/components/schemas/MonitorSchedule'
        notification:
          $ref: '#/components/schemas/MonitorNotification'
        webhook:
          allOf:
            - $ref: '#/components/schemas/MonitorWebhook'
          nullable: true
        output_schema:
          type: object
          additionalProperties: true
          nullable: true
          description: 可选的JSON Schema用于结构化提取输出。
        status:
          type: string
          enum:
            - provisioning
            - active
            - paused
            - failed
            - deleted
          description: 监控生命周期状态。
        error_message:
          type: string
          nullable: true
          description: 当`status`为`failed`时出现。
        last_run:
          allOf:
            - $ref: '#/components/schemas/MonitorLastRun'
          nullable: true
          description: 最新快照摘要。包含在`GET /v1/monitors/{monitor_id}`中。
        agent:
          $ref: '#/components/schemas/MonitorAgent'
        metadata:
          type: object
          additionalProperties: true
        created:
          type: integer
          description: Unix时间戳（秒）。
        updated:
          type: integer
          description: Unix时间戳（秒）。
        total_count:
          type: integer
          description: >-
            快照总数。除非`include_total_count=false`，否则包含在`GET
            /v1/monitors/{monitor_id}`中。
        mermaid_diagram:
          type: string
          description: 监控DAG的Mermaid流程图。当`include-diagram=true`时包含在获取中。
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        monitor_id:
          type: string
          description: 在某些创建/更新错误响应中出现。
    NotificationChannel:
      type: object
      required:
        - type
        - target
      properties:
        type:
          type: string
          enum:
            - email
            - slack
            - sms
          description: 传递渠道类型。
        target:
          type: string
          description: 电子邮件地址、Slack webhook URL 或 E.164 电话号码（用于 SMS）。
        events:
          type: array
          items:
            type: string
            enum:
              - changed
              - first_snapshot
          description: 可选的每渠道事件过滤器。当省略时，渠道传递遵循顶级 `notification.events`（或在设置渠道时使用默认值）。
    MonitorTracked:
      type: object
      description: 规划完成后监控器跟踪的已解决目标。
      properties:
        type:
          type: string
          nullable: true
          description: 跟踪的表面类型（例如 `url` 或 `web_query`）。
        urls:
          type: array
          items:
            type: string
            format: uri
          description: 正在监控的具体 URL。
        web_query:
          type: string
          nullable: true
          description: 当监控器跟踪动态结果集时使用的网页搜索查询。
    MonitorSchedule:
      type: object
      properties:
        frequency:
          type: string
          nullable: true
          description: 自然语言的计划文本（例如 `every hour`）。
        cron:
          type: string
          nullable: true
          description: 从 `frequency` 派生的 Cron 表达式。
        timezone:
          type: string
          example: UTC
          description: 计划时区。目前监控计划使用 `UTC`。
        next_run_at:
          type: string
          format: date-time
          nullable: true
          description: 下次计划运行时间（ISO 8601）。当监控器不是 `active` 时为 `null`。
    MonitorLastRun:
      type: object
      properties:
        id:
          type: string
          nullable: true
          description: 最新快照的运行 ID (`run_…`)。
        status:
          type: string
          example: completed
        change_detected:
          type: boolean
          nullable: true
        ran_at:
          type: string
          format: date-time
          nullable: true
    MonitorAgent:
      type: object
      properties:
        id:
          type: string
          nullable: true
          description: 用于执行监控 DAG 的内部影子代理 ID。
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer认证头格式为Bearer <token>，其中<token>是你的认证令牌。

````