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

# モニターの更新

> 頻度、メタデータ、通知、および/またはWebhookを更新します。頻度の変更はスケジュールを再作成します。ステータスがプロビジョニング中の場合は409を返します。

<Tip>
  **マージセマンティクス:** メタデータの更新はStripeのアプローチに従います — 新しいキーは追加され、既存のキーは更新され、空の文字列 `""` に設定されたキーは削除されます。
</Tip>


## OpenAPI

````yaml ja/openapi/monitors.json POST /v1/monitors/{monitor_id}
openapi: 3.0.3
info:
  title: Monitors API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/monitors/{monitor_id}:
    post:
      summary: モニター更新
      description: >-
        `frequency`, `metadata`, `notification`, および/または `webhook`
        を更新します。頻度の変更は基礎となるスケジュールを削除して再作成します。`webhook` を削除するには `null`
        に設定します。`status` が `provisioning` の間は `409` を返します。
      parameters:
        - name: monitor_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^monitor_
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                frequency:
                  type: string
                  description: 自然言語のスケジュールテキスト。内部スケジュールを再作成します。
                metadata:
                  type: object
                  additionalProperties: true
                  description: 既存のメタデータとマージされます。空の文字列値はキーを削除します。
                notification:
                  $ref: '#/components/schemas/MonitorNotification'
                webhook:
                  allOf:
                    - $ref: '#/components/schemas/MonitorWebhook'
                  nullable: true
                  description: webhook を削除するには `null` を渡します。
      responses:
        '200':
          description: モニターが更新されました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Monitor'
        '400':
          description: 無効なリクエストまたはモニターが削除されました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 無効なAPIキー。
        '404':
          description: モニターが見つかりません。
        '409':
          description: モニターはまだプロビジョニング中です。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 内部サーバーエラー。
      security:
        - Authorization: []
components:
  schemas:
    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: メール、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スキーマ。
        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: モニターが動的な結果セットを追跡する際に使用されるウェブ検索クエリ。
    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
    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 <token>形式のBearer認証ヘッダー。<token>はあなたの認証トークンです。

````