basePath: /api/v1/alertstore
definitions:
  agent.DayCoverage:
    properties:
      alerts:
        type: integer
      covered:
        type: integer
      day:
        type: string
    required:
    - alerts
    - covered
    - day
    type: object
  agent.Run:
    properties:
      agent:
        type: string
      alert_id:
        type: string
      detail:
        type: object
      disclosure:
        enum:
        - shown
        - held
        type: string
      finished_at:
        type: string
      id:
        type: integer
      parent_run_id:
        type: integer
      session_ref:
        type: string
      started_at:
        type: string
      status:
        enum:
        - dispatched
        - running
        - succeeded
        - failed
        type: string
      summary:
        type: string
      trigger_kind:
        enum:
        - alert_created
        - manual
        - handoff
        type: string
      verdict:
        enum:
        - noise
        - self_recovered
        - mitigated
        - escalation
        - unknown
        type: string
    type: object
  agent.RunCounts:
    properties:
      dispatched:
        type: integer
      failed:
        type: integer
      running:
        type: integer
      succeeded:
        type: integer
    required:
    - dispatched
    - failed
    - running
    - succeeded
    type: object
  agent.Stats:
    properties:
      agreement_rate:
        description: |-
          Share of diagnoses (noise / self_recovered / escalation) matching the
          resolution a human recorded. Nil when nothing was scoreable; mitigated,
          unknown and expired never are.
        type: number
      agreement_total:
        type: integer
      alerts:
        type: integer
      coverage:
        items:
          $ref: '#/definitions/agent.DayCoverage'
        type: array
      covered:
        description: alerts with at least one run
        type: integer
      runs:
        $ref: '#/definitions/agent.RunCounts'
      verdicts:
        description: |-
          One row per verdict, always all five in vocabulary order; the last
          verdict-bearing run per alert counts.
        items:
          $ref: '#/definitions/agent.VerdictOutcome'
        type: array
    required:
    - agreement_total
    - alerts
    - coverage
    - covered
    - runs
    - verdicts
    type: object
  agent.VerdictOutcome:
    properties:
      expired:
        type: integer
      handled:
        type: integer
      noise:
        type: integer
      open:
        type: integer
      self_recovered:
        type: integer
      total:
        type: integer
      verdict:
        type: string
    required:
    - expired
    - handled
    - noise
    - open
    - self_recovered
    - total
    - verdict
    type: object
  alert.Alert:
    properties:
      ack_source:
        type: string
      acked_at:
        type: string
      acked_by:
        type: string
      alertname:
        type: string
      assigned_to:
        type: string
      attrs:
        type: object
      biz_region:
        type: string
      call_delay_until:
        type: string
      classification:
        type: string
      cluster_id:
        type: string
      created_at:
        type: string
      customer_type:
        type: string
      external_issue_key:
        type: string
      fingerprint:
        description: Generated columns (read-only, populated by DB).
        type: string
      id:
        description: ALT-2607-42
        type: string
      im_channel_id:
        type: string
      im_message_id:
        type: string
      im_thread_id:
        type: string
      recovery_deadline:
        type: string
      region:
        type: string
      resolution:
        type: string
      resolution_note:
        type: string
      resolved_at:
        type: string
      response_deadline:
        type: string
      state:
        type: string
      tenant_id:
        type: string
      tenant_kind:
        type: string
      updated_at:
        type: string
    required:
    - ack_source
    - acked_by
    - alertname
    - assigned_to
    - attrs
    - biz_region
    - classification
    - cluster_id
    - created_at
    - customer_type
    - external_issue_key
    - fingerprint
    - id
    - im_channel_id
    - im_message_id
    - im_thread_id
    - region
    - resolution
    - resolution_note
    - state
    - tenant_id
    - tenant_kind
    - updated_at
    type: object
  alert.AlertCounts:
    properties:
      acked:
        type: integer
      all:
        type: integer
      open:
        type: integer
      pages:
        type: integer
      resolved:
        type: integer
      tickets:
        type: integer
    required:
    - acked
    - all
    - open
    - pages
    - resolved
    - tickets
    type: object
  alert.AlertDetail:
    properties:
      ack_source:
        type: string
      acked_at:
        type: string
      acked_by:
        type: string
      alertname:
        type: string
      am_status:
        description: firing / resolved / unknown
        type: string
      assigned_to:
        type: string
      attrs:
        type: object
      audit:
        items:
          $ref: '#/definitions/alert.AuditEntry'
        type: array
      biz_region:
        type: string
      call_delay_until:
        type: string
      classification:
        type: string
      cluster_id:
        type: string
      common_facts:
        additionalProperties:
          type: string
        description: |-
          CommonFacts holds the label-derived header fields resolved across every
          occurrence (see CommonFact), so a UI does not have to present the frozen
          attrs of the occurrence that opened the alert as the aggregate's own.
        type: object
      common_labels:
        additionalProperties:
          type: string
        description: |-
          CommonLabels holds the labels every occurrence agrees on (see
          CommonLabels), printed once for the whole alert. Each occurrence in
          Instances carries only its distinct labels (see DistinctLabels), so the
          shared set is not repeated on every row; merge the two to recover an
          occurrence's full label set.
        type: object
      created_at:
        type: string
      customer_type:
        type: string
      external_issue_key:
        type: string
      external_issue_url:
        type: string
      fingerprint:
        description: Generated columns (read-only, populated by DB).
        type: string
      id:
        description: ALT-2607-42
        type: string
      im_channel_id:
        type: string
      im_message_id:
        type: string
      im_thread_id:
        type: string
      instance_counts:
        $ref: '#/definitions/alert.InstanceCounts'
      instances:
        items:
          $ref: '#/definitions/alert.InstanceDetail'
        type: array
      last_am_observed_at:
        type: string
      ops_portal_url:
        type: string
      receipts:
        items:
          $ref: '#/definitions/event.ReceiptInfo'
        type: array
      recovery_deadline:
        type: string
      region:
        type: string
      resolution:
        type: string
      resolution_note:
        type: string
      resolved_at:
        type: string
      response_deadline:
        type: string
      state:
        type: string
      tenant_id:
        type: string
      tenant_kind:
        type: string
      updated_at:
        type: string
    required:
    - ack_source
    - acked_by
    - alertname
    - am_status
    - assigned_to
    - attrs
    - audit
    - biz_region
    - classification
    - cluster_id
    - created_at
    - customer_type
    - external_issue_key
    - fingerprint
    - id
    - im_channel_id
    - im_message_id
    - im_thread_id
    - instance_counts
    - instances
    - region
    - resolution
    - resolution_note
    - state
    - tenant_id
    - tenant_kind
    - updated_at
    type: object
  alert.AuditEntry:
    properties:
      actor:
        type: string
      alert_id:
        type: string
      created_at:
        type: string
      detail:
        type: object
      event:
        type: string
      id:
        type: integer
      new_state:
        type: string
      old_state:
        type: string
      source:
        type: string
    required:
    - actor
    - alert_id
    - created_at
    - detail
    - event
    - id
    - new_state
    - old_state
    - source
    type: object
  alert.DailyResolutionMix:
    properties:
      day:
        description: YYYY-MM-DD, UTC+8 calendar day
        type: string
      expired:
        type: integer
      handled:
        type: integer
      noise:
        type: integer
      self_recovered:
        type: integer
      total:
        type: integer
    required:
    - day
    - expired
    - handled
    - noise
    - self_recovered
    - total
    type: object
  alert.DurationPercentiles:
    properties:
      p50_seconds:
        type: integer
      p90_seconds:
        type: integer
    type: object
  alert.HourlyBucket:
    properties:
      count:
        type: integer
      hour:
        type: integer
    required:
    - count
    - hour
    type: object
  alert.InstanceCounts:
    properties:
      firing:
        type: integer
      resolved:
        type: integer
      unknown:
        type: integer
    required:
    - firing
    - resolved
    - unknown
    type: object
  alert.InstanceDetail:
    properties:
      alertname:
        type: string
      annotations:
        type: object
      classification:
        type: string
      created_at:
        type: string
      ends_at:
        type: string
      fingerprint:
        type: string
      first_observed_at:
        type: string
      generator_url:
        type: string
      history_incomplete:
        type: boolean
      id:
        type: integer
      labels:
        type: object
      last_observed_at:
        type: string
      observation_count:
        type: integer
      observations:
        items:
          $ref: '#/definitions/event.Event'
        type: array
      occurrence_key:
        type: string
      resolved_observed_at:
        type: string
      starts_at:
        type: string
      state:
        type: string
      updated_at:
        type: string
    required:
    - observations
    type: object
  alert.NowStats:
    properties:
      remain_in_jira:
        description: |-
          RemainInJira is open (not yet acked), *not* owned pages: shadow alerts
          (see docs/design.md, "The Cutover") whose response is jiralert's,
          already ticketed and paged over there. Recorded here for visibility,
          not waiting on anyone in alertstore. A shadow alert someone acks here
          anyway drops out of this count — correct, since it is being handled
          here now.
        type: integer
      remain_in_jira_url:
        description: |-
          RemainInJiraURL is a Jira issue-search link for the deployment's
          project, filtered to unresolved issues — not resolved by the Store
          itself, which is DB-only and has no Jira client. The handler fills it
          in from s.jira, the same way getAlert fills in ExternalIssueURL.
          Empty when Jira is unconfigured; the client renders the tile as plain
          text rather than a dead link in that case.
        type: string
      unacked_pages:
        description: |-
          UnackedPages is the subset of UnresolvedPages still open — nobody has
          picked them up.
        type: integer
      unresolved_alerts:
        description: |-
          UnresolvedAlerts is every unresolved alert alertstore owns the response
          for, of any classification: owned, non-internal tenant. Shadow alerts
          (response is jiralert's — see RemainInJira) and internal-tenant test
          traffic are excluded, since nobody here is waiting on them.
        type: integer
      unresolved_pages:
        description: UnresolvedPages is the page subset of UnresolvedAlerts — same
          scoping.
        type: integer
    required:
    - remain_in_jira
    - unacked_pages
    - unresolved_alerts
    - unresolved_pages
    type: object
  alert.ResolutionCounts:
    properties:
      expired:
        type: integer
      handled:
        type: integer
      noise:
        type: integer
      self_recovered:
        type: integer
      total:
        type: integer
    required:
    - expired
    - handled
    - noise
    - self_recovered
    - total
    type: object
  alert.RuleResolution:
    properties:
      alertname:
        type: string
      expired:
        type: integer
      handled:
        type: integer
      noise:
        type: integer
      self_recovered:
        type: integer
      total:
        type: integer
    required:
    - alertname
    - expired
    - handled
    - noise
    - self_recovered
    - total
    type: object
  alert.SLA:
    properties:
      acked_within_deadline_rate:
        type: number
      acked_within_deadline_total:
        type: integer
      mtta:
        $ref: '#/definitions/alert.DurationPercentiles'
      mtta_trend:
        items:
          $ref: '#/definitions/alert.SLADayPoint'
        type: array
      mttr:
        $ref: '#/definitions/alert.DurationPercentiles'
      mttr_trend:
        items:
          $ref: '#/definitions/alert.SLADayPoint'
        type: array
    required:
    - acked_within_deadline_total
    - mtta
    - mtta_trend
    - mttr
    - mttr_trend
    type: object
  alert.SLADayPoint:
    properties:
      day:
        type: string
      p50_seconds:
        type: integer
      p90_seconds:
        type: integer
    required:
    - day
    - p50_seconds
    - p90_seconds
    type: object
  alert.TeamLoad:
    properties:
      day_page:
        type: integer
      night_page:
        type: integer
      oncall_team:
        type: string
      ticket:
        type: integer
      total:
        type: integer
    required:
    - day_page
    - night_page
    - oncall_team
    - ticket
    - total
    type: object
  api.ErrorResponse:
    properties:
      error:
        type: string
    required:
    - error
    type: object
  api.StatusResponse:
    properties:
      status:
        example: ok
        type: string
    required:
    - status
    type: object
  api.UsersResponse:
    properties:
      users:
        items:
          $ref: '#/definitions/directory.User'
        type: array
    required:
    - users
    type: object
  api.ackRequest:
    properties:
      user:
        type: string
    required:
    - user
    type: object
  api.agentReportRequest:
    properties:
      detail:
        items:
          type: integer
        type: array
      session_ref:
        type: string
      status:
        enum:
        - running
        - succeeded
        - failed
        type: string
      summary:
        type: string
      verdict:
        enum:
        - noise
        - self_recovered
        - mitigated
        - escalation
        - unknown
        type: string
    required:
    - status
    type: object
  api.assignRequest:
    properties:
      assignee:
        type: string
      reason:
        type: string
      user:
        type: string
    required:
    - assignee
    - user
    type: object
  api.channelResponse:
    properties:
      id:
        type: string
      name:
        type: string
    required:
    - id
    - name
    type: object
  api.commentRequest:
    properties:
      text:
        type: string
      user:
        type: string
    required:
    - text
    - user
    type: object
  api.createAgentRunRequest:
    properties:
      agent:
        type: string
    required:
    - agent
    type: object
  api.createAgentRunResponse:
    properties:
      agent:
        type: string
      alert_id:
        type: string
      callback_url:
        type: string
      detail:
        type: object
      disclosure:
        enum:
        - shown
        - held
        type: string
      finished_at:
        type: string
      id:
        type: integer
      parent_run_id:
        type: integer
      session_ref:
        type: string
      started_at:
        type: string
      status:
        enum:
        - dispatched
        - running
        - succeeded
        - failed
        type: string
      summary:
        type: string
      trigger_kind:
        enum:
        - alert_created
        - manual
        - handoff
        type: string
      verdict:
        enum:
        - noise
        - self_recovered
        - mitigated
        - escalation
        - unknown
        type: string
    type: object
  api.createMuteRuleRequest:
    properties:
      created_by:
        type: string
      duration:
        description: e.g. "2h", "30m"
        type: string
      filter:
        type: object
      reason:
        type: string
    required:
    - duration
    - filter
    type: object
  api.createSubscriptionRequest:
    properties:
      channel_id:
        type: string
      channel_name:
        type: string
      created_by:
        type: string
      filter:
        type: object
      mode:
        type: string
    required:
    - channel_id
    - filter
    - mode
    type: object
  api.previewFilterRequest:
    properties:
      filter:
        type: object
      mode:
        description: |-
          A subscription mode or preview.ModeMute. Required and with no default:
          it decides which history the filter is run over, and a guess would
          produce a confident count of the wrong thing.
        type: string
      windows:
        items:
          type: string
        type: array
    required:
    - filter
    - mode
    type: object
  api.resolveRequest:
    properties:
      note:
        type: string
      resolution:
        type: string
      user:
        type: string
    required:
    - resolution
    - user
    type: object
  api.statsResponse:
    properties:
      agent:
        $ref: '#/definitions/agent.Stats'
      daily_resolution_mix:
        items:
          $ref: '#/definitions/alert.DailyResolutionMix'
        type: array
      hourly_histogram:
        items:
          $ref: '#/definitions/alert.HourlyBucket'
        type: array
      night_pages:
        type: integer
      resolved_totals:
        allOf:
        - $ref: '#/definitions/alert.ResolutionCounts'
        description: |-
          ResolvedTotals is the window-wide sum of DailyResolutionMix, spelled out
          so the Alert Quality KPI tiles (resolved count, noise rate,
          self-recovered rate, handled rate) do not each re-sum the daily array.
      rule_mix:
        items:
          $ref: '#/definitions/alert.RuleResolution'
        type: array
      sla:
        allOf:
        - $ref: '#/definitions/alert.SLA'
        description: SLA is the Response SLA section's numbers — see SLA's own doc
          comment.
      team_load:
        items:
          $ref: '#/definitions/alert.TeamLoad'
        type: array
      teams:
        description: |-
          Teams is every distinct non-empty oncall_team label seen in the window,
          always computed unfiltered by the team the caller passed in — so the
          dropdown that reads it keeps every option even once one of them is
          selected, rather than collapsing to just the chosen team.
        items:
          type: string
        type: array
      total_alerts:
        type: integer
    required:
    - agent
    - daily_resolution_mix
    - hourly_histogram
    - night_pages
    - resolved_totals
    - rule_mix
    - sla
    - team_load
    - teams
    - total_alerts
    type: object
  api.updateMuteRuleRequest:
    properties:
      duration:
        type: string
      expires_at:
        type: string
      filter:
        type: object
      reason:
        type: string
    required:
    - filter
    type: object
  api.updateSubscriptionRequest:
    properties:
      filter:
        type: object
      mode:
        type: string
    required:
    - filter
    - mode
    type: object
  directory.User:
    properties:
      department:
        type: string
      email:
        type: string
      en_name:
        type: string
      name:
        type: string
    required:
    - department
    - email
    - en_name
    - name
    type: object
  event.Event:
    properties:
      alertname:
        type: string
      attrs:
        type: object
      biz_region:
        type: string
      classification:
        type: string
      cluster_id:
        type: string
      customer_type:
        type: string
      ends_at:
        type: string
      fingerprint:
        type: string
      group_key:
        type: string
      id:
        type: integer
      instance_id:
        type: integer
      observation_type:
        type: string
      receipt_id:
        type: integer
      received_at:
        type: string
      region:
        type: string
      starts_at:
        type: string
      status:
        description: firing / resolved
        type: string
      tenant_id:
        type: string
      tenant_kind:
        type: string
    required:
    - alertname
    - attrs
    - biz_region
    - classification
    - cluster_id
    - customer_type
    - fingerprint
    - group_key
    - id
    - observation_type
    - received_at
    - region
    - starts_at
    - status
    - tenant_id
    - tenant_kind
    type: object
  event.ReceiptInfo:
    properties:
      group_key:
        type: string
      id:
        type: integer
      notification_reason:
        type: string
      received_at:
        type: string
      receiver:
        type: string
      truncated_alerts:
        type: integer
    required:
    - group_key
    - id
    - notification_reason
    - received_at
    - receiver
    - truncated_alerts
    type: object
  mute.Rule:
    properties:
      created_at:
        type: string
      created_by:
        type: string
      expires_at:
        type: string
      filter:
        type: object
      id:
        type: string
      reason:
        type: string
    required:
    - created_at
    - created_by
    - expires_at
    - filter
    - id
    - reason
    type: object
  preview.DayCount:
    properties:
      count:
        type: integer
      date:
        description: YYYY-MM-DD, UTC
        type: string
      exact:
        type: boolean
    required:
    - count
    - date
    - exact
    type: object
  preview.NameCount:
    properties:
      alertname:
        type: string
      count:
        type: integer
    required:
    - alertname
    - count
    type: object
  preview.Result:
    properties:
      corpus:
        description: |-
          Corpus names what was counted — alerts, or raw observations — which the
          number alone cannot say.
        type: string
      daily:
        items:
          $ref: '#/definitions/preview.DayCount'
        type: array
      latest:
        items:
          $ref: '#/definitions/preview.Sample'
        type: array
      matches_everything:
        description: |-
          MatchesEverything marks a filter naming no field, which for a mute rule
          means the fleet.
        type: boolean
      scanned:
        description: |-
          Truncated says ScanLimit was reached, so counts reaching past
          ScannedSince are lower bounds.
        type: integer
      scanned_since:
        type: string
      top_alertnames:
        description: |-
          TopAlertnames catches what counts cannot: 300 matches where 290 are the
          intended alertname and 10 are not has a perfectly reasonable total.
        items:
          $ref: '#/definitions/preview.NameCount'
        type: array
      truncated:
        type: boolean
      windows:
        items:
          $ref: '#/definitions/preview.WindowCount'
        type: array
    required:
    - corpus
    - daily
    - latest
    - matches_everything
    - scanned
    - scanned_since
    - top_alertnames
    - truncated
    - windows
    type: object
  preview.Sample:
    properties:
      alertname:
        type: string
      at:
        type: string
      classification:
        type: string
      cluster_id:
        type: string
      id:
        type: string
      state:
        type: string
    required:
    - alertname
    - at
    - id
    type: object
  preview.WindowCount:
    properties:
      count:
        type: integer
      exact:
        description: |-
          Exact is false when the scan stopped short of this window's start,
          making Count a floor. Reporting a floor as a total is the failure the
          flag exists to prevent.
        type: boolean
      window:
        type: string
    required:
    - count
    - exact
    - window
    type: object
  subscription.Subscription:
    properties:
      channel_id:
        type: string
      channel_name:
        type: string
      created_at:
        type: string
      created_by:
        type: string
      filter:
        type: object
      id:
        type: string
      mode:
        description: topic_forward / card_only / event / customer
        type: string
      updated_at:
        type: string
    required:
    - channel_id
    - channel_name
    - created_at
    - created_by
    - filter
    - id
    - mode
    - updated_at
    type: object
  timeline.Entry:
    properties:
      actor:
        type: string
      alert_id:
        type: string
      created_at:
        type: string
      detail:
        type: object
      id:
        type: integer
      kind:
        type: string
      recalled_at:
        type: string
      ref_id:
        type: string
      source:
        type: string
      text:
        type: string
    required:
    - actor
    - alert_id
    - created_at
    - id
    - kind
    - source
    - text
    type: object
info:
  contact: {}
  description: |-
    Operational alert lifecycle for TiDB Cloud: alerts, the
    events they were raised from, subscriptions and mute rules.
  title: Alertstore API
  version: "1.0"
paths:
  /alerts:
    get:
      operationId: listAlerts
      parameters:
      - description: page or ticket; comma-separate to match any of several
        in: query
        name: classification
        type: string
      - description: open, acked or resolved; comma-separate to match any of several
        in: query
        name: state
        type: string
      - description: Alert name, exact match
        in: query
        name: alertname
        type: string
      - description: Cloud region
        in: query
        name: region
        type: string
      - description: Business region
        in: query
        name: biz_region
        type: string
      - description: Tenant kind
        in: query
        name: tenant_kind
        type: string
      - description: Customer type
        in: query
        name: customer_type
        type: string
      - description: Assignee email
        in: query
        name: assigned_to
        type: string
      - description: Cluster id
        in: query
        name: cluster_id
        type: string
      - description: Tenant id
        in: query
        name: tenant_id
        type: string
      - description: Oncall team (the alert's oncall_team label), exact match; comma-separate
          to match any of several
        in: query
        name: oncall_team
        type: string
      - default: 50
        description: Page size
        in: query
        name: limit
        type: integer
      - default: 0
        description: Page offset
        in: query
        name: offset
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/alert.Alert'
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List alerts
      tags:
      - Alerts
  /alerts/{id}:
    get:
      operationId: getAlert
      parameters:
      - description: Alert id, ALT-YYMM-NNNN
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/alert.AlertDetail'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Get one alert with its instances and labels
      tags:
      - Alerts
  /alerts/{id}/ack:
    post:
      consumes:
      - application/json
      operationId: ackAlert
      parameters:
      - description: Alert id
        in: path
        name: id
        required: true
        type: string
      - description: Actor
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.ackRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "409":
          description: Not a legal transition from the current state
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Acknowledge an alert
      tags:
      - Alerts
  /alerts/{id}/agent-runs:
    get:
      operationId: listAgentRuns
      parameters:
      - description: Alert ID
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/agent.Run'
            type: array
        "404":
          description: Not Found
          schema:
            additionalProperties:
              type: string
            type: object
      summary: List an alert's agent runs
      tags:
      - alerts
    post:
      consumes:
      - application/json
      operationId: createAgentRun
      parameters:
      - description: Alert ID
        in: path
        name: id
        required: true
        type: string
      - description: Agent
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.createAgentRunRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/api.createAgentRunResponse'
        "404":
          description: Not Found
          schema:
            additionalProperties:
              type: string
            type: object
      summary: Create a manual agent run
      tags:
      - alerts
  /alerts/{id}/agent-runs/{runId}:
    patch:
      consumes:
      - application/json
      operationId: reportAgentRun
      parameters:
      - description: Alert ID
        in: path
        name: id
        required: true
        type: string
      - description: Agent run ID
        in: path
        name: runId
        required: true
        type: integer
      - description: Report
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.agentReportRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/agent.Run'
        "404":
          description: Not Found
          schema:
            additionalProperties:
              type: string
            type: object
      summary: Report an agent run's progress or result
      tags:
      - alerts
  /alerts/{id}/assign:
    post:
      consumes:
      - application/json
      operationId: assignAlert
      parameters:
      - description: Alert id
        in: path
        name: id
        required: true
        type: string
      - description: New assignee and reason
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.assignRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Assign an alert to someone
      tags:
      - Alerts
  /alerts/{id}/comment:
    post:
      consumes:
      - application/json
      operationId: commentAlert
      parameters:
      - description: Alert id
        in: path
        name: id
        required: true
        type: string
      - description: Comment text
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.commentRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Add a comment to an alert's timeline
      tags:
      - Alerts
  /alerts/{id}/resolve:
    post:
      consumes:
      - application/json
      operationId: resolveAlert
      parameters:
      - description: Alert id
        in: path
        name: id
        required: true
        type: string
      - description: Resolution and optional note
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.resolveRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "400":
          description: Unknown resolution
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "409":
          description: Not a legal transition from the current state
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Resolve an alert
      tags:
      - Alerts
  /alerts/{id}/timeline:
    get:
      operationId: alertTimeline
      parameters:
      - description: Alert id
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/timeline.Entry'
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List an alert's timeline entries
      tags:
      - Alerts
  /bff/alerts/counts:
    get:
      operationId: alertCounts
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/alert.AlertCounts'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Alert counts per sidebar view
      tags:
      - Alerts
  /bff/alerts/now:
    get:
      operationId: alertNow
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/alert.NowStats'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Current alert state for the Dashboards page's "Now" strip
      tags:
      - Alerts
  /bff/alerts/stats:
    get:
      operationId: alertStats
      parameters:
      - description: Window start, RFC3339, exclusive
        in: query
        name: from
        required: true
        type: string
      - description: Window end, RFC3339, inclusive
        in: query
        name: to
        required: true
        type: string
      - description: Oncall team (the alert's oncall_team label), exact match; omitted
          or empty matches every team
        in: query
        name: team
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.statsResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Aggregated stats for the Dashboards page
      tags:
      - Alerts
  /bff/alerts/teams:
    get:
      operationId: alertTeams
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              type: string
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Distinct oncall teams
      tags:
      - Alerts
  /bff/users:
    get:
      operationId: searchUsers
      parameters:
      - description: Name or email fragment
        in: query
        name: q
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: Empty when the directory is disabled or unreachable
          schema:
            $ref: '#/definitions/api.UsersResponse'
      summary: Search the user directory for the assignee picker
      tags:
      - Users
  /channels:
    get:
      operationId: listChannels
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/api.channelResponse'
            type: array
        "502":
          description: IM provider unreachable
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List the IM channels the bot belongs to
      tags:
      - Subscriptions
  /events:
    get:
      operationId: listEvents
      parameters:
      - description: Alert name
        in: query
        name: alertname
        type: string
      - description: page or ticket; comma-separate to match any of several
        in: query
        name: classification
        type: string
      - description: Cluster id
        in: query
        name: cluster_id
        type: string
      - description: Tenant id
        in: query
        name: tenant_id
        type: string
      - description: Cloud region
        in: query
        name: region
        type: string
      - description: Business region
        in: query
        name: biz_region
        type: string
      - description: Tenant kind
        in: query
        name: tenant_kind
        type: string
      - description: Customer type
        in: query
        name: customer_type
        type: string
      - description: firing or resolved; comma-separate to match any of several
        in: query
        name: status
        type: string
      - description: first_firing, repeat_firing, or resolved; comma-separate to match
          any of several
        in: query
        name: observation_type
        type: string
      - default: 50
        description: Page size
        in: query
        name: limit
        type: integer
      - default: 0
        description: Page offset
        in: query
        name: offset
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/event.Event'
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List the monitor events alerts were raised from
      tags:
      - Events
  /events/{id}:
    get:
      operationId: getEvent
      parameters:
      - description: Event id
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/event.Event'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Get one monitor event
      tags:
      - Events
  /filter-preview:
    post:
      consumes:
      - application/json
      operationId: previewFilter
      parameters:
      - description: Mode, filter and windows
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.previewFilterRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/preview.Result'
        "400":
          description: Invalid mode, filter or window
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Count what a subscription or mute filter would have matched
      tags:
      - Preview
  /mute-rules:
    get:
      operationId: listMuteRules
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/mute.Rule'
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List the mute rules that have not expired
      tags:
      - MuteRules
    post:
      consumes:
      - application/json
      operationId: createMuteRule
      parameters:
      - description: Filter and lifetime
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.createMuteRuleRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/mute.Rule'
        "400":
          description: Invalid filter or duration
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Create a mute rule
      tags:
      - MuteRules
  /mute-rules/{id}:
    delete:
      operationId: deleteMuteRule
      parameters:
      - description: Mute rule id
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Delete a mute rule
      tags:
      - MuteRules
    put:
      consumes:
      - application/json
      operationId: updateMuteRule
      parameters:
      - description: Mute rule id
        in: path
        name: id
        required: true
        type: string
      - description: Updated filter, reason, and expiry
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.updateMuteRuleRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/mute.Rule'
        "400":
          description: Invalid filter, duration, or expires_at
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Update a mute rule
      tags:
      - MuteRules
  /subscriptions:
    get:
      operationId: listSubscriptions
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: '#/definitions/subscription.Subscription'
            type: array
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: List subscriptions
      tags:
      - Subscriptions
    post:
      consumes:
      - application/json
      operationId: createSubscription
      parameters:
      - description: Channel, mode and filter
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.createSubscriptionRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/subscription.Subscription'
        "400":
          description: Invalid mode or filter
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "409":
          description: Bot is not a member of the channel
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "422":
          description: Channel could not be validated
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Create a subscription
      tags:
      - Subscriptions
  /subscriptions/{id}:
    delete:
      operationId: deleteSubscription
      parameters:
      - description: Subscription id
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Delete a subscription
      tags:
      - Subscriptions
    put:
      consumes:
      - application/json
      operationId: updateSubscription
      parameters:
      - description: Subscription id
        in: path
        name: id
        required: true
        type: string
      - description: Mode and filter
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/api.updateSubscriptionRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.StatusResponse'
        "400":
          description: Invalid mode or filter
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "409":
          description: Bot is not a member of the channel
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "422":
          description: Channel could not be validated
          schema:
            $ref: '#/definitions/api.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/api.ErrorResponse'
      summary: Update a subscription's mode and filter
      tags:
      - Subscriptions
swagger: "2.0"
