{
  "openapi": "3.1.1",
  "info": {
    "title": "QAudit Status API",
    "description": "Service health across QAudit: the current status of every service and feature, the per-hour green/orange/red availability grid, and the incident timeline. A caller with no token sees the public rows; an operator or organization session presenting a QAudit access token additionally sees the rows scoped to it.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.status.nightly.qaudit.cloud.serensia.net/"
    }
  ],
  "paths": {
    "/status/current": {
      "get": {
        "tags": [
          "Status"
        ],
        "summary": "Current status",
        "description": "The latest health sample for each service and feature visible to the caller.",
        "operationId": "GetCurrentStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StatusCurrentEntry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/status/history": {
      "get": {
        "tags": [
          "Status"
        ],
        "summary": "Hour-grid history",
        "description": "The per-hour availability and green/orange/red verdict over the requested window (windowHours, default 24, capped at 2160 = 90 days). The final entry is the current hour so far, flagged partial; its counts cover only the elapsed time.",
        "operationId": "GetStatusHistory",
        "parameters": [
          {
            "name": "windowHours",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StatusHistoryEntry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/status/incidents": {
      "get": {
        "tags": [
          "Status"
        ],
        "summary": "Incident timeline",
        "description": "Incidents (contiguous unhealthy runs) overlapping the requested window (from/to, default the last 7 days). An open incident has no end.",
        "operationId": "GetStatusIncidents",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StatusIncidentView"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceHealth": {
        "enum": [
          "healthy",
          "degraded",
          "unhealthy"
        ],
        "description": "The health of a single polled service or feature at a point in time, as reported\nby a service's `/status` document. Recorded on every StatusSampleEntity\nand used to classify hour rollups."
      },
      "StatusCurrentEntry": {
        "required": [
          "service",
          "checkName",
          "feature",
          "status",
          "ready",
          "scope",
          "organizationId",
          "reachable",
          "polledAt"
        ],
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "description": "The polled service's resource name."
          },
          "checkName": {
            "type": "string",
            "description": "The health check's name within that service."
          },
          "feature": {
            "type": "string",
            "description": "The bare feature name the check reports on; empty when it carries none."
          },
          "status": {
            "description": "The latest observed health.",
            "$ref": "#/components/schemas/ServiceHealth"
          },
          "ready": {
            "type": "boolean",
            "description": "Whether the check gates the service's readiness."
          },
          "scope": {
            "description": "Who the row is visible to.",
            "$ref": "#/components/schemas/StatusScope"
          },
          "organizationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The organization a per-org row belongs to; null for platform-wide rows.",
            "format": "uuid"
          },
          "reachable": {
            "type": "boolean",
            "description": "Whether the latest poll reached the service."
          },
          "polledAt": {
            "type": "string",
            "description": "When the latest sample was taken.",
            "format": "date-time"
          }
        },
        "description": "The latest known status of one service or feature: the most recent sample for a\n`(service, check)`, as served by `/status/current`."
      },
      "StatusHistoryEntry": {
        "required": [
          "service",
          "checkName",
          "feature",
          "scope",
          "organizationId",
          "hourStart",
          "verdict",
          "availability",
          "sampleCount",
          "degradedCount",
          "unhealthyCount",
          "partial"
        ],
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "description": "The service this rollup covers."
          },
          "checkName": {
            "type": "string",
            "description": "The health check within that service."
          },
          "feature": {
            "type": "string",
            "description": "The bare feature name the check reports on; empty when it carries none."
          },
          "scope": {
            "description": "Who the row is visible to.",
            "$ref": "#/components/schemas/StatusScope"
          },
          "organizationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The organization a per-org row belongs to; null for platform-wide rows.",
            "format": "uuid"
          },
          "hourStart": {
            "type": "string",
            "description": "Inclusive UTC start of the hour.",
            "format": "date-time"
          },
          "verdict": {
            "description": "The hour's classification.",
            "$ref": "#/components/schemas/StatusVerdict"
          },
          "availability": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "description": "The share of the hour's samples that were not unhealthy, in `[0, 1]`; degraded samples\ncount as available. Sample-weighted so a period figure is the count-weighted mean.",
            "format": "double"
          },
          "sampleCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "How many samples the verdict was derived from.",
            "format": "int32"
          },
          "degradedCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "How many of those samples were degraded.",
            "format": "int32"
          },
          "unhealthyCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "How many of those samples were unhealthy.",
            "format": "int32"
          },
          "partial": {
            "type": "boolean",
            "description": "True for the current, still-open hour, whose counts cover only the time elapsed so far."
          }
        },
        "description": "One hour's availability and green/orange/red verdict for a service or feature, as served by\n`/status/history`. The verdict is derived from the sample counts against the configured\nred threshold at read time, so retuning the threshold reclassifies history without a re-rollup."
      },
      "StatusIncidentView": {
        "required": [
          "service",
          "checkName",
          "feature",
          "scope",
          "organizationId",
          "startedAt",
          "endedAt",
          "peakStatus"
        ],
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "description": "The service the incident is on."
          },
          "checkName": {
            "type": "string",
            "description": "The health check within that service."
          },
          "feature": {
            "type": "string",
            "description": "The bare feature name the check reports on; empty when it carries none."
          },
          "scope": {
            "description": "Who the incident is visible to.",
            "$ref": "#/components/schemas/StatusScope"
          },
          "organizationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The organization a per-org incident belongs to; null for platform-wide rows.",
            "format": "uuid"
          },
          "startedAt": {
            "type": "string",
            "description": "When the unhealthy run began.",
            "format": "date-time"
          },
          "endedAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "When the service recovered, or null while the incident is open.",
            "format": "date-time"
          },
          "peakStatus": {
            "description": "The worst health observed during the run.",
            "$ref": "#/components/schemas/ServiceHealth"
          }
        },
        "description": "An incident on a service or feature, as served by `/status/incidents`. An open\nincident has a null DateTimeOffset? StatusIncidentView.EndedAt."
      },
      "StatusScope": {
        "enum": [
          "public",
          "operators",
          "per-org"
        ],
        "description": "Who a status sample or rollup is visible to. The read API filters on it: anonymous\ncallers see StatusScope.Public only, operators add StatusScope.Operators, and an\norganization session adds its own StatusScope.PerOrg rows. Mapped from the\n`scope` field of a service's `/status` document."
      },
      "StatusVerdict": {
        "enum": [
          "green",
          "orange",
          "red"
        ],
        "description": "The classification of an hour of samples for one service or feature: green when\nevery sample was healthy, orange on partial or degraded availability, red on\nmajority unavailability. The thresholds between orange and red are configured on\nthe aggregator."
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "QAudit access token minted by the auth service, presented as `Authorization: Bearer <jwt>`. An operator token additionally reveals the operator rows; an organization token reveals that organization's per-org rows.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "ClientCredentials": {
        "type": "oauth2",
        "description": "Mint a QAudit access token from an organization credential: present its id as `client_id` and its secret as `client_secret`. The token carries the organization and a read scope, revealing that organization's per-org status rows.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.nightly.qaudit.cloud.serensia.net/token",
            "scopes": { }
          }
        }
      }
    }
  },
  "security": [
    { },
    {
      "Bearer": [ ]
    },
    {
      "ClientCredentials": [ ]
    }
  ],
  "tags": [
    {
      "name": "Status",
      "description": "Current status, the hour-grid history, and the incident timeline."
    }
  ]
}