{
  "openapi": "3.1.0",
  "info": {
    "title": "ch 34 · reflex watcher — ch21.ai channel API",
    "version": "1.0.0",
    "description": "Watches live feeds and instantly takes actions based on your rules.\n\nInputs: A target webpage or feed to monitor and your list of if-then rules.\nOutputs: A timestamped log table of detected events, matched rules, and actions.\n\nSend a plain-english brief in `notes`. The channel plans its own sub-goals, runs its\ntools (web crawl, archive recall, extraction, measurement, frames), scores the result\nand hands back the take with its sources, grade and trace.\nAuthenticate with a channel feed key: `Authorization: Bearer ch21_...`."
  },
  "servers": [
    {
      "url": "https://ch21.ai"
    }
  ],
  "security": [
    {
      "feedKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "feedKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ch21 feed key"
      }
    },
    "schemas": {
      "TakeRequest": {
        "type": "object",
        "required": [
          "notes"
        ],
        "properties": {
          "notes": {
            "type": "string",
            "description": "the brief for this take, in plain english"
          },
          "prior": {
            "type": "object",
            "nullable": true,
            "description": "the take this call picks up from, so the channel adds ground instead of repeating it",
            "properties": {
              "brief": {
                "type": "string"
              },
              "output": {
                "type": "string"
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "skipRetrieval": {
            "type": "boolean",
            "description": "reason only — skip the crawl lane"
          }
        }
      },
      "RunAgentInput": {
        "type": "object",
        "required": [
          "messages"
        ],
        "description": "AG-UI RunAgentInput. The last user message is the brief for the take.",
        "properties": {
          "threadId": {
            "type": "string",
            "description": "conversation id — omit and one is cut for you"
          },
          "runId": {
            "type": "string",
            "description": "this run's id — omit and one is cut for you"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant",
                    "system",
                    "tool"
                  ]
                },
                "content": {
                  "type": "string"
                },
                "toolCallId": {
                  "type": "string"
                }
              }
            }
          },
          "state": {
            "type": "object",
            "nullable": true,
            "description": "shared state from the front end"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "front-end tools offered to the channel"
          },
          "context": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          },
          "forwardedProps": {
            "type": "object",
            "nullable": true,
            "description": "`skipRetrieval: true` reasons without crawling; `prior: { brief, output, links }` picks up an earlier take"
          }
        }
      },
      "TakeResponse": {
        "type": "object",
        "properties": {
          "channel": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "number": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "takeNo": {
            "type": "integer",
            "description": "this channel's take counter"
          },
          "output": {
            "type": "string",
            "description": "the finished take"
          },
          "grade": {
            "type": "string",
            "description": "A–F deterministic score"
          },
          "overall": {
            "type": "number"
          },
          "links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "verified sources cited"
          },
          "table": {
            "type": "object",
            "nullable": true,
            "description": "structured rows when the plan called for a table"
          },
          "stills": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "frames this take made"
          },
          "plan": {
            "type": "object",
            "description": "sub-goals the channel decomposed the brief into"
          },
          "lifecycle": {
            "type": "object",
            "description": "service state, recovery path and anything the channel needs from you"
          },
          "asks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "ask": {
                  "type": "string"
                },
                "blocking": {
                  "type": "boolean"
                }
              }
            },
            "description": "data the channel is asking for to continue"
          },
          "creditsLeft": {
            "type": "integer",
            "nullable": true
          },
          "latencyMs": {
            "type": "integer"
          }
        }
      }
    }
  },
  "paths": {
    "/api/public/channel/reflex-watcher/spec": {
      "get": {
        "summary": "this channel's interface, machine readable",
        "security": [],
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "openapi",
                "mcp",
                "markdown"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "spec document"
          }
        }
      }
    },
    "/api/public/channel/reflex-watcher/agui": {
      "get": {
        "summary": "ag-ui handshake — protocol version, transport and the events this channel emits",
        "security": [],
        "responses": {
          "200": {
            "description": "ag-ui descriptor"
          }
        }
      },
      "post": {
        "summary": "run ch 34 over AG-UI (server-sent events)",
        "operationId": "agui_run_34",
        "description": "The Agent-User Interaction protocol. POST an AG-UI `RunAgentInput` and read back a `text/event-stream` of typed AG-UI events: RUN_STARTED, STEP_STARTED/FINISHED, TOOL_CALL_START/ARGS/END/RESULT, TEXT_MESSAGE_START/CONTENT/END, STATE_SNAPSHOT, CUSTOM (ch21.ask), RUN_FINISHED or RUN_ERROR. The last user message is the brief.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunAgentInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AG-UI event stream",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "missing or revoked feed key"
          },
          "402": {
            "description": "the operator's wallet is out of credits"
          },
          "404": {
            "description": "no channel on that frequency"
          }
        }
      }
    },
    "/api/public/channel/reflex-watcher/take": {
      "post": {
        "summary": "roll a take on ch 34",
        "operationId": "roll_take_34",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TakeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "the take",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TakeResponse"
                }
              }
            }
          },
          "401": {
            "description": "missing or revoked feed key"
          },
          "402": {
            "description": "the operator's wallet is out of credits"
          },
          "404": {
            "description": "no channel on that frequency"
          }
        }
      }
    }
  }
}