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

# Live Monitor

> Start a continuous monitoring job that checks for a condition

Starts a continuous job that checks a stream until your condition is met, the job is stopped, or limits are reached.

## Key Request Fields

* `monitor_duration_seconds` (default `600`): per-job runtime limit in seconds.
* `trigger_cooldown_seconds` (default `0`): minimum seconds between trigger alerts.
* `max_triggers` (default `1`): number of trigger alerts before auto-stop.
  * `1` keeps legacy first-match behavior.
  * `>1` allows repeated alerts, then stops.
  * `null` means unlimited alerts until duration/cancel.

## Delivery Mode Selection

`POST /live-monitor` selects response mode by request shape:

1. `webhook_url` present -> webhook mode
2. `Accept: text/event-stream` and no `webhook_url` -> SSE mode
3. otherwise -> polling mode

## Response Semantics by Mode

### Polling mode

Returns a job response (`job_id`, `status`, `created_at`, `job_type`, `stream_url`, optional `message`).

Use `GET /jobs/{job_id}` to track runtime and terminal state.

### Webhook mode

Returns a job response immediately, then sends async webhook events.

Common webhook `type` values:

* `job_started`
* `watch_triggered`
* `job_stopped`
* `error`

### SSE mode

Returns a text event stream.

Common event names:

* `started`
* `progress`
* `triggered` (non-terminal trigger event in multi-trigger mode)
* `stopped`
* `error`

Treat `stopped` and `error` as terminal events for that stream session.
Treat `triggered` as non-terminal.

## Status Semantics

For polling or post-hoc inspection:

* `running`: active checks in progress
* `completed`: condition matched and job completed
* `stopped`: ended without failure (cancelled or auto-stop)
* `failed`: ended due to runtime/stream failure

Use [Get Job Details](/api-reference/jobs-get) for final runtime fields.

Common stop reasons in `stats.reason` include:

* `condition_triggered`
* `max_triggers_reached`
* `max_duration_reached`
* `cancelled`

## Typical Usage

1. Validate URL: [Validate Stream](/api-reference/streams-validate)
2. Validate wording: [Check Once](/api-reference/check-once)
3. Start `POST /live-monitor`
4. Track via polling, webhook, or SSE

## Related

* Workflow chooser: [Choose Your Workflow](/start-here/choose-workflow)
* Job state details: [Get Job Details](/api-reference/jobs-get)
* Webhook implementation: [Use Webhooks](/guides/webhooks)


## OpenAPI

````yaml POST /live-monitor
openapi: 3.1.0
info:
  title: Trio API
  description: Reality as an API - Monitor YouTube Live streams with vision models
  version: 1.0.0
servers:
  - url: https://trio.machinefi.com/api
security: []
paths:
  /live-monitor:
    post:
      tags:
        - Monitoring
      summary: Live Monitor
      description: Start a continuous monitoring job that checks for a condition
      operationId: start_live_monitor_live_monitor_post
      parameters:
        - name: accept
          in: header
          required: false
          schema:
            type: string
            default: application/json
            title: Accept
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LiveMonitorRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobResponse'
        '400':
          description: Stream offline, invalid URL, or invalid input mode
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/plain:
              example: Invalid HTTP request received.
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Maximum concurrent jobs reached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - HTTPBearer: []
components:
  schemas:
    LiveMonitorRequest:
      properties:
        stream_url:
          type: string
          maxLength: 500
          minLength: 1
          title: Stream Url
          description: YouTube Live URL or RTSP stream to monitor
        condition:
          type: string
          maxLength: 1000
          minLength: 1
          title: Condition
          description: Natural language condition to watch for
        webhook_url:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Webhook Url
          description: Webhook URL for notifications
        interval_seconds:
          type: integer
          maximum: 300
          minimum: 5
          title: Interval Seconds
          description: Polling interval in seconds
          default: 10
        input_mode:
          type: string
          enum:
            - frames
            - clip
            - hybrid
          title: Input Mode
          description: >-
            Input mode: 'frames' for single frame, 'clip' for video clip,
            'hybrid' for frame+clip combined
          default: clip
        clip_duration_seconds:
          type: integer
          maximum: 10
          minimum: 1
          title: Clip Duration Seconds
          description: >-
            Duration of video clip in seconds (used when input_mode is 'clip' or
            'hybrid')
          default: 3
        monitor_duration_seconds:
          type: integer
          minimum: 5
          title: Monitor Duration Seconds
          description: Maximum monitoring duration in seconds
          default: 600
        trigger_cooldown_seconds:
          type: integer
          maximum: 3600
          minimum: 0
          title: Trigger Cooldown Seconds
          description: Minimum time in seconds between trigger alerts
          default: 0
        max_triggers:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Triggers
          description: Maximum trigger alerts before auto-stop. Null means unlimited.
          default: 1
      type: object
      required:
        - stream_url
        - condition
      title: LiveMonitorRequest
      description: Request to start a live monitor job.
    JobResponse:
      properties:
        job_id:
          type: string
          format: uuid
          title: Job Id
        status:
          $ref: '#/components/schemas/JobStatus'
        created_at:
          type: string
          title: Created At
        stream_url:
          type: string
          title: Stream Url
        job_type:
          type: string
          title: Job Type
        details:
          additionalProperties: true
          type: object
          title: Details
          default: {}
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
      type: object
      required:
        - job_id
        - status
        - created_at
        - stream_url
        - job_type
      title: JobResponse
      description: Response containing job information.
    ErrorResponse:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorResponse
      description: Wrapper for error responses.
    JobStatus:
      type: string
      enum:
        - pending
        - running
        - stopped
        - completed
        - failed
      title: JobStatus
      description: Job status enum.
    ErrorDetail:
      properties:
        code:
          type: string
          title: Code
        message:
          type: string
          title: Message
        remediation:
          type: string
          title: Remediation
      type: object
      required:
        - code
        - message
        - remediation
      title: ErrorDetail
      description: Standardized error response for better DX.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````