openapi: 3.1.0
info:
  title: OttoBet Agent API
  version: "1"
  summary: Read-only published fight analyses.
  description: |
    Published fight analyses as JSON, for agents and apps.
    An unpublished fight returns "not released yet" and the release time.
    The caller's own price is used only by POST /fights/{id}/price.
    Informational only. Not betting advice. No wagers are placed.
  license:
    name: Beta terms (draft, pending legal review)
    url: /agents/terms
servers:
  - url: /
    description: The host serving this file.
security:
  - bearerAuth: []
tags:
  - name: cards
  - name: fights
  - name: price
paths:
  /api/agent/v1/events:
    get:
      operationId: listCards
      tags: [cards]
      summary: Upcoming and past cards
      description: id, title, date, release time, and whether the analysis is published.
      responses:
        "200":
          description: Card list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EventList"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
  /api/agent/v1/events/{id}:
    get:
      operationId: getCard
      tags: [cards]
      summary: Fights on one card
      parameters:
        - $ref: "#/components/parameters/eventId"
      responses:
        "200":
          description: The card
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Card"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
  /api/agent/v1/fights/{id}:
    get:
      operationId: getFightAnalysis
      tags: [fights]
      summary: Pinned published analysis
      description: |
        Win, method, and round probabilities, cohort size and base rates,
        career summaries, sentiment summary and source count, SWOT, and confidence tier.
      parameters:
        - $ref: "#/components/parameters/fightId"
        - $ref: "#/components/parameters/responseMode"
      responses:
        "200":
          description: The pinned analysis. response=concise returns ConciseFight.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/FightAnalysis"
                  - $ref: "#/components/schemas/ConciseFight"
        "403":
          $ref: "#/components/responses/NotReleased"
        "404":
          $ref: "#/components/responses/NotFound"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
  /api/agent/v1/fights/{id}/compare:
    get:
      operationId: compareFighters
      tags: [fights]
      summary: Side-by-side career summaries and matchup factors
      description: Taken from the same stored run as the analysis. Records are what that analysis used (as_of = analysis_published_at).
      parameters:
        - $ref: "#/components/parameters/fightId"
      responses:
        "200":
          description: The comparison
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FightCompare"
        "403":
          $ref: "#/components/responses/NotReleased"
        "404":
          $ref: "#/components/responses/NotFound"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
  /api/agent/v1/fights/{id}/price:
    post:
      operationId: priceBet
      tags: [price]
      summary: Price the caller's own number against the stored win probability
      description: |
        Returns the implied probability of the caller's price, the edge, and EV per $100.
        When bankroll and risk are sent and EV is positive, also returns Kelly sizing.
        When EV is zero or negative, stake is 0 and reason is "no value at this price".
        Bankroll is not stored.
      parameters:
        - $ref: "#/components/parameters/fightId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PriceRequest"
      responses:
        "200":
          description: The quote
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceQuote"
        "400":
          $ref: "#/components/responses/BadRequest"
        "403":
          $ref: "#/components/responses/NotReleased"
        "404":
          $ref: "#/components/responses/NotFound"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
  /api/agent/mcp:
    post:
      operationId: mcp
      tags: [fights]
      summary: Stateless MCP server
      description: |
        Streamable HTTP, one JSON-RPC 2.0 object per POST. No session. GET and DELETE are 405.
        Tools, each annotated read-only: list_cards, get_card, get_fight_analysis,
        compare_fighters, price_bet. Pass response "concise" (default) or "detailed".
        A tool error the agent can act on is HTTP 200 with result.isError true.
        A missing, unknown, or revoked key stays HTTP 401. The monthly limit stays HTTP 429.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              jsonrpc: "2.0"
              id: 1
              method: tools/call
              params:
                name: list_cards
                arguments:
                  response: concise
      responses:
        "200":
          description: JSON-RPC result, or a tool error the agent can act on
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        "202":
          description: Accepted notification. Empty body.
        "401":
          $ref: "#/components/responses/Unauthorized"
        "405":
          description: Use POST
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key issued once. Sent as Authorization Bearer. Stored as a hash.
  parameters:
    eventId:
      name: id
      in: path
      required: true
      description: Event id, or a title when more than one card shares a name.
      schema:
        type: string
    fightId:
      name: id
      in: path
      required: true
      schema:
        type: integer
    responseMode:
      name: response
      in: query
      required: false
      description: Pass concise for the short fight object. Omit it for the full analysis.
      schema:
        type: string
        enum: [concise, detailed]
  responses:
    Unauthorized:
      description: Missing, unknown, or revoked key. Do not retry a revoked key.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorBody"
    RateLimited:
      description: Monthly limit reached.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds until the next UTC month.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorBody"
    Unavailable:
      description: The read failed, or the key tables are not installed. Nothing else was written.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorBody"
    NotReleased:
      description: The fight is not released yet. The message includes the release time.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/NotReleased"
    NotFound:
      description: No such event or fight.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorBody"
    BadRequest:
      description: The arguments need a change. The message says what to send.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorBody"
  schemas:
    Envelope:
      type: object
      required: [api_version, as_of, run_id, model_version, event_id, disclaimer]
      properties:
        api_version:
          type: string
          const: "1"
        as_of:
          type: string
          description: When this response was sealed, or the request time for a list.
        run_id:
          type: [integer, "null"]
        model_version:
          type: [string, "null"]
          description: OttoBet engine version. cohort-settings is the stored cohort settings id. prompts/distribution is the stored probability schema. The upstream model name is not served.
        event_id:
          type: [integer, "null"]
        disclaimer:
          type: string
          const: Informational only. Not betting advice. No wagers are placed.
    Event:
      type: object
      required: [id, title, date, release_time, published]
      properties:
        id:
          type: integer
        title:
          type: string
        date:
          type: string
        release_time:
          type: [string, "null"]
        published:
          type: boolean
    EventList:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [events]
          properties:
            events:
              type: array
              items:
                $ref: "#/components/schemas/Event"
    FightOnCard:
      type: object
      required: [id, corners, weight_class, rounds, published, release_time]
      properties:
        id:
          type: integer
        corners:
          type: object
          required: [favorite, underdog]
          properties:
            favorite:
              type: string
            underdog:
              type: string
        weight_class:
          type: [string, "null"]
        rounds:
          type: [integer, "null"]
        published:
          type: boolean
        release_time:
          type: [string, "null"]
    Card:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [title, date, published, fights]
          properties:
            title:
              type: string
            date:
              type: string
            published:
              type: boolean
            fights:
              type: array
              items:
                $ref: "#/components/schemas/FightOnCard"
    WinProbability:
      type: object
      additionalProperties: false
      required: [fighter, corner, pct]
      properties:
        fighter:
          type: string
        corner:
          type: string
          enum: [favorite, underdog]
        pct:
          type: [number, "null"]
    MethodProbability:
      type: object
      additionalProperties: false
      required: [fighter, corner, method, pct]
      properties:
        fighter:
          type: string
        corner:
          type: string
          enum: [favorite, underdog]
        method:
          type: string
        pct:
          type: number
    RoundProbability:
      type: object
      additionalProperties: false
      required: [fighter, corner, round, pct]
      properties:
        fighter:
          type: string
        corner:
          type: string
          enum: [favorite, underdog]
        round:
          type: string
        pct:
          type: number
    RateRow:
      type: object
      additionalProperties: false
      required: [label, pct]
      properties:
        label:
          type: string
        pct:
          type: number
    RateTable:
      type: object
      additionalProperties: false
      required: [basis, rows]
      properties:
        basis:
          type: string
          description: cohort_fights is every fight in the cohort. fights_won_by_favorite is the favorite's wins. decisions_won_by_favorite is the favorite's decision wins. A round row is the share of favorite wins whose finish round is that round. A decision is stored with finish_round equal to the scheduled rounds, so R3 includes a three-round decision as well as a finish in round 3. R3 overlaps the Decision method rate.
        rows:
          type: array
          items:
            $ref: "#/components/schemas/RateRow"
    BaseRates:
      type: object
      additionalProperties: false
      required: [overall, method, round]
      properties:
        overall:
          $ref: "#/components/schemas/RateTable"
        method:
          allOf:
            - $ref: "#/components/schemas/RateTable"
            - type: object
              additionalProperties: false
              required: [decision]
              properties:
                decision:
                  $ref: "#/components/schemas/RateTable"
        round:
          $ref: "#/components/schemas/RateTable"
    RecordTally:
      type: object
      additionalProperties: false
      required: [wins, losses, draws, no_contests]
      properties:
        wins:
          type: integer
        losses:
          type: integer
        draws:
          type: integer
        no_contests:
          type: integer
    UfcRecord:
      type: object
      additionalProperties: false
      required: [wins, losses, draws, ufc_debut]
      properties:
        wins:
          type: integer
        losses:
          type: integer
        draws:
          type: integer
        ufc_debut:
          type: boolean
    RecordCoverage:
      type: object
      additionalProperties: false
      required: [ufc_bouts_in_data]
      properties:
        ufc_bouts_in_data:
          type: integer
        ufc_bouts_known_missing:
          type: integer
          description: Omitted on analyses published before 2026-11-23. That field was a parse of an old free-text note and is not a verified gap count.
    AgentBout:
      type: object
      additionalProperties: false
      required: [date, result, opponent, opponent_record, promotion, tier, level, method, method_class, round, time, event]
      properties:
        date:
          type: [string, "null"]
        result:
          type: [string, "null"]
          enum: [W, L, D, NC, null]
        opponent:
          type: [string, "null"]
        opponent_record:
          type: [string, "null"]
        promotion:
          type: [string, "null"]
        tier:
          type: [integer, "null"]
          description: 1 is UFC. 2 and 3 are meaningful. 4 is weak. Null is not a level. Read level.
        level:
          type: string
          enum: [pro, amateur]
        method:
          type: [string, "null"]
          description: Method text stored for the bout.
        method_class:
          type: string
          enum: [ko_tko, submission, decision, other]
        round:
          type: [integer, "null"]
        time:
          type: [string, "null"]
        event:
          type: [string, "null"]
    FighterRecord:
      type: object
      additionalProperties: false
      required: [name, pro_record, ufc_record, record_complete, coverage, bouts]
      properties:
        name:
          type: string
        pro_record:
          description: from bouts in our data
          $ref: "#/components/schemas/RecordTally"
        ufc_record:
          description: from bouts in our data
          $ref: "#/components/schemas/UfcRecord"
        record_complete:
          type: boolean
          description: False when the stored analysis noted known-missing UFC bouts. Kept even when ufc_bouts_known_missing is omitted on pre-2026-11-23 analyses.
        coverage:
          $ref: "#/components/schemas/RecordCoverage"
        bouts:
          type: array
          items:
            $ref: "#/components/schemas/AgentBout"
    AnalysisRecords:
      type: object
      additionalProperties: false
      required: [as_of, note, favorite, underdog]
      properties:
        as_of:
          type: [string, "null"]
          description: Same instant as analysis_published_at. The record the analysis used.
        note:
          type: string
          description: Record as used in this analysis (pre-event). Later fixes to historical data do not change published analyses.
        favorite:
          $ref: "#/components/schemas/FighterRecord"
        underdog:
          $ref: "#/components/schemas/FighterRecord"
    SwotQuadrant:
      type: object
      additionalProperties: false
      required: [strengths, weaknesses, opportunities, threats]
      properties:
        strengths:
          type: array
          items:
            type: string
        weaknesses:
          type: array
          items:
            type: string
        opportunities:
          type: array
          items:
            type: string
        threats:
          type: array
          items:
            type: string
    Swot:
      type: object
      additionalProperties: false
      required: [matchup_dynamic, favorite, underdog]
      properties:
        matchup_dynamic:
          type: [string, "null"]
        favorite:
          oneOf:
            - type: "null"
            - $ref: "#/components/schemas/SwotQuadrant"
        underdog:
          oneOf:
            - type: "null"
            - $ref: "#/components/schemas/SwotQuadrant"
    Career:
      $ref: "#/components/schemas/FighterRecord"
    FightAnalysis:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [fight_id, analysis_published_at, event_first_bout_start, fight_start, analysis_version, fighters, corners, probabilities, cohort, records, sentiment, confidence_tier]
          properties:
            fight_id:
              type: integer
            analysis_published_at:
              type: [string, "null"]
              description: When the pinned analysis was first published, UTC.
            event_first_bout_start:
              type: [string, "null"]
              description: Card-level first bout start, UTC, from the publish log. A reader compares this with analysis_published_at.
            fight_start:
              type: [string, "null"]
              description: This fight's start, UTC, when a per-fight start is stored. Null when it is not stored.
            analysis_version:
              type: integer
              description: Increments when the fight is re-run. Omit version to read the published one. Older versions stay at ?version=N.
            event:
              type: string
            fighters:
              type: array
              items:
                type: string
            corners:
              type: object
              properties:
                favorite:
                  type: string
                underdog:
                  type: string
            weight_class:
              type: [string, "null"]
            rounds:
              type: [integer, "null"]
            probabilities:
              type: object
              additionalProperties: false
              required: [win, method, round]
              properties:
                win:
                  type: array
                  items:
                    $ref: "#/components/schemas/WinProbability"
                method:
                  type: array
                  items:
                    $ref: "#/components/schemas/MethodProbability"
                round:
                  type: array
                  items:
                    $ref: "#/components/schemas/RoundProbability"
            cohort:
              type: object
              additionalProperties: false
              required: [size, sex, weight_classes, year_min, year_max, favorite_win_pct, base_rates]
              properties:
                size:
                  type: [integer, "null"]
                sex:
                  type: [string, "null"]
                  enum: [F, M, null]
                weight_classes:
                  type: array
                  items:
                    type: string
                year_min:
                  type: [integer, "null"]
                year_max:
                  type: [integer, "null"]
                favorite_win_pct:
                  type: [number, "null"]
                base_rates:
                  $ref: "#/components/schemas/BaseRates"
            records:
              $ref: "#/components/schemas/AnalysisRecords"
            sentiment:
              type: object
              properties:
                summary:
                  type: [string, "null"]
                source_count:
                  type: integer
            swot:
              oneOf:
                - type: "null"
                - $ref: "#/components/schemas/Swot"
            confidence_tier:
              type: [string, "null"]
              enum: [low, medium, high, unrated, null]
    ConciseFighter:
      type: object
      additionalProperties: false
      required: [fighter, corner, win_pct, top_method]
      properties:
        fighter:
          type: string
        corner:
          type: string
          enum: [favorite, underdog]
        win_pct:
          type: [number, "null"]
        top_method:
          type: [string, "null"]
    ConciseFight:
      type: object
      additionalProperties: false
      required: [fight_id, analysis_published_at, fighters, confidence_tier, cohort_size, disclaimer]
      properties:
        fight_id:
          type: integer
        analysis_published_at:
          type: [string, "null"]
          description: When the pinned analysis was first published, UTC.
        fighters:
          type: array
          items:
            $ref: "#/components/schemas/ConciseFighter"
        confidence_tier:
          type: [string, "null"]
          enum: [low, medium, high, unrated, null]
        cohort_size:
          type: [integer, "null"]
        disclaimer:
          type: string
          const: Informational only. Not betting advice. No wagers are placed.
    FightCompare:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [fight_id, analysis_published_at, event_first_bout_start, fight_start, as_of, note, fighters, corners]
          properties:
            fight_id:
              type: integer
            analysis_published_at:
              type: [string, "null"]
            event_first_bout_start:
              type: [string, "null"]
              description: Card-level first bout start, UTC, from the publish log.
            fight_start:
              type: [string, "null"]
              description: This fight's start, UTC, when a per-fight start is stored.
            as_of:
              type: [string, "null"]
              description: Same instant as analysis_published_at. The record the analysis used.
            note:
              type: string
              description: Record as used in this analysis (pre-event). Later fixes to historical data do not change published analyses.
            fighters:
              type: array
              items:
                type: string
            corners:
              type: array
              items:
                allOf:
                  - $ref: "#/components/schemas/Career"
                  - type: object
                    properties:
                      corner:
                        type: string
                      swot:
                        type: [object, "null"]
            matchup_dynamic:
              type: [string, "null"]
    PriceRequest:
      type: object
      required: [side, price]
      properties:
        side:
          type: string
          description: Fighter name, or favorite, or underdog.
        price:
          type: number
          description: American price such as -102, or a decimal such as 1.98.
        price_format:
          type: string
          enum: [american, decimal]
        bankroll:
          type: number
          description: Dollars. Optional. Never stored or logged.
        risk:
          type: string
          enum: [conservative, moderate, aggressive]
          description: Multipliers are 1/2, 5/8, and 3/4.
    PriceQuote:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [fight_id, analysis_published_at, event_first_bout_start, fight_start, side, caller_price, implied_probability, model_probability, edge, ev_per_100, sizing]
          properties:
            fight_id:
              type: integer
            analysis_published_at:
              type: [string, "null"]
            event_first_bout_start:
              type: [string, "null"]
            fight_start:
              type: [string, "null"]
            side:
              type: string
            caller_price:
              type: object
              properties:
                american:
                  type: number
                decimal:
                  type: number
            implied_probability:
              type: number
              description: Implied probability of the caller's price.
            model_probability:
              type: number
              description: Stored win probability for that side.
            edge:
              type: number
            ev_per_100:
              type: number
            sizing:
              oneOf:
                - type: "null"
                - type: object
                  required: [stake]
                  properties:
                    stake:
                      type: number
                    reason:
                      type: string
                    kelly_fraction_full:
                      type: number
                    kelly_multiplier:
                      type: number
                    risk:
                      type: string
    ErrorBody:
      allOf:
        - $ref: "#/components/schemas/Envelope"
        - type: object
          required: [error, message]
          properties:
            error:
              type: string
            message:
              type: string
              description: What the caller should change or when to retry.
    NotReleased:
      allOf:
        - $ref: "#/components/schemas/ErrorBody"
        - type: object
          properties:
            error:
              const: not_released
            release_time:
              type: [string, "null"]
            fight_id:
              type: integer
            fighters:
              type: array
              items:
                type: string
