{
  "openapi": "3.1.0",
  "info": {
    "title": "Infrastructure Monitors API",
    "version": "1.0.0",
    "description": "REST API of Infrastructure Monitors: uptime (`http`), web performance (`web`, Lighthouse) and user journey (`journey`, Playwright) monitors, check history, incidents, alert channels (webhook, e-mail, Discord, Telegram) and public status pages.\n\nAuthentication: send the account key in `x-api-key: mk_…` (canonical) or `Authorization: Bearer mk_…`. Data routes also accept an Infrastructure Auth JWT as `Authorization: Bearer <jwt>` (RS256, issuer `riligar-auth`). The owner is always derived from the credential. Get the key from the dashboard settings, or from `GET /me` with an Auth JWT.\n\nErrors use `{ \"error\": { \"code\", \"message\", \"details\"? } }`; collections use `{ \"items\", \"page\": { \"limit\", \"offset\", \"total\", \"hasMore\" } }`. Request bodies are capped at 256 KB. Human-facing strings are in Portuguese.\n\nAgents: the MCP server at `/mcp` (OAuth 2.1 only) is documented separately in https://myinfrastructure.click/products/monitors/llms-mcp.txt.",
    "contact": {
      "name": "Infrastructure",
      "url": "https://myinfrastructure.click/contact"
    },
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://monitors.manager.myinfrastructure.click",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Full product guide for agents (llms.txt)",
    "url": "https://myinfrastructure.click/products/monitors/llms.txt"
  },
  "tags": [
    {
      "name": "Service",
      "description": "Public health."
    },
    {
      "name": "Account",
      "description": "Identity, plan and the Command Center."
    },
    {
      "name": "Monitors",
      "description": "Monitor CRUD, manual checks, history and reports."
    },
    {
      "name": "Journeys",
      "description": "Journey variables and live steps."
    },
    {
      "name": "Incidents",
      "description": "Incidents derived from checks."
    },
    {
      "name": "Alert channels",
      "description": "Where incident alerts are delivered."
    },
    {
      "name": "Status pages",
      "description": "Status page management and custom domains."
    },
    {
      "name": "Public status pages",
      "description": "Anonymous status page and subscription routes."
    }
  ],
  "paths": {
    "/status": {
      "get": {
        "operationId": "getServiceStatus",
        "tags": [
          "Service"
        ],
        "summary": "Service health",
        "description": "Public health of the Monitors manager: scheduler role, audit queue, pools, alert and plan-gate telemetry, and clock health (`checksLastHour`, `oldestOverdueS`). Never reports commercial volume.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceStatus"
                }
              }
            }
          },
          "500": {
            "description": "Database read failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/s/{slug}": {
      "get": {
        "operationId": "getPublicStatusPage",
        "tags": [
          "Public status pages"
        ],
        "summary": "Public status page (HTML)",
        "description": "Server-rendered public status page. Only pages with `is_public` resolve; anything else is the same 404 page. Served with `x-robots-tag: noindex, nofollow` and a strict CSP. HEAD is accepted too. The same page is served at `/` on a verified custom domain.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The status page slug.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Page not found or not public (HTML).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/s/{slug}/data.json": {
      "get": {
        "operationId": "getPublicStatusPageData",
        "tags": [
          "Public status pages"
        ],
        "summary": "Public status page data",
        "description": "The data the public page renders, as JSON (CORS `*`, cached 15 s). Also served at `/data.json` on a verified custom domain.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The status page slug.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicStatusData"
                }
              }
            }
          },
          "404": {
            "description": "Page not found or not public (HTML 404 page).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/s/{slug}/inscricao/assinar": {
      "post": {
        "operationId": "subscribeToStatusPage",
        "tags": [
          "Public status pages"
        ],
        "summary": "Subscribe to status notices",
        "description": "Anonymous subscription to a public status page, by e-mail (confirmation link) or webhook (verification handshake). The response is the same whatever the prior state of the address. Rate limited per client IP. Also served at `/inscricao/assinar` on a verified custom domain.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The status page slug.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscribeInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted (or silently ignored).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscribeAccepted"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Page not found, or it does not accept subscriptions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/s/{slug}/inscricao/confirmar": {
      "get": {
        "operationId": "confirmStatusPageSubscription",
        "tags": [
          "Public status pages"
        ],
        "summary": "Confirm a subscription",
        "description": "The link sent by e-mail. The token identifies the subscription; the slug is not validated. Returns an HTML notice.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The status page slug.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "t",
            "in": "query",
            "required": true,
            "description": "The 64-character hex subscription token sent in the confirmation e-mail or webhook handshake.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed (HTML).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Invalid or unknown token (HTML).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/s/{slug}/inscricao/cancelar": {
      "get": {
        "operationId": "cancelStatusPageSubscription",
        "tags": [
          "Public status pages"
        ],
        "summary": "Cancel a subscription",
        "description": "Unsubscribe link. Deletes the subscription identified by the token. Returns an HTML notice.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The status page slug.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "t",
            "in": "query",
            "required": true,
            "description": "The 64-character hex subscription token sent in the confirmation e-mail or webhook handshake.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled (HTML).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Invalid or unknown token (HTML).",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Account"
        ],
        "summary": "Current user and account key",
        "description": "Exchanges an Infrastructure Auth JWT for the account identity and its `mk_` API key. The full key is returned only on the call that creates it (the first visit); afterwards `apiKey` is null and only `keyPrefix` identifies it. An `mk_` sent here is not accepted as identity.",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "The user and key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/plan": {
      "get": {
        "operationId": "getPlan",
        "tags": [
          "Account"
        ],
        "summary": "Plan notice",
        "description": "The account plan state as resolved from Infrastructure Payments, plus how many monitors exist. Never fails on a Payments outage: `state` becomes `unknown`.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Plan state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanNotice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/overview": {
      "get": {
        "operationId": "getOverview",
        "tags": [
          "Account"
        ],
        "summary": "Command Center",
        "description": "The whole account in one call: every monitor with window stats, a summary (HTTP up/down, web audits in progress, global uptime, open incidents) and the 20 latest incidents.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "Window size in hours. Any value that is not a positive number falls back to 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Overview.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Overview"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/monitors": {
      "get": {
        "operationId": "listMonitors",
        "tags": [
          "Monitors"
        ],
        "summary": "List monitors",
        "description": "Lists the account monitors with 24 h stats. Pagination is opt-in: without `limit`/`offset` the whole account is returned (`page.total`/`hasMore` null) ordered by creation date; with either one, the page is filtered/ordered server-side and `counts`, `accountTotal` and `orderInPage` are added.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/MonitorKind"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Enables pagination. Default 50, max 200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Enables pagination.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "[paginated] Case-insensitive match on name or URL.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "[paginated] State filter.",
            "schema": {
              "type": "string",
              "enum": [
                "down",
                "degraded",
                "up",
                "paused"
              ]
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "[paginated] Ordering. `uptime`/`latencia` are applied by the client within the page (reported in `orderInPage`).",
            "schema": {
              "type": "string",
              "enum": [
                "problemas",
                "nome",
                "recentes",
                "uptime",
                "latencia"
              ],
              "default": "problemas"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Monitors.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MonitorListItem"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    },
                    "counts": {
                      "type": "object",
                      "description": "[paginated] Per-state counts over the filtered set (state filter ignored).",
                      "properties": {
                        "todos": {
                          "type": "integer"
                        },
                        "down": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "degraded": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "up": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "paused": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        }
                      }
                    },
                    "accountTotal": {
                      "type": "integer",
                      "description": "[paginated] All monitors in the account."
                    },
                    "orderInPage": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "[paginated] Ordering the client still has to apply."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "createMonitor",
        "tags": [
          "Monitors"
        ],
        "summary": "Create a monitor",
        "description": "Creates an `http`, `web` (Lighthouse) or `journey` (Playwright) monitor and arms its schedule. `journey` requires `config.script`. Subject to the plan monitor limit; `web` additionally requires a plan with Web Performance.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MonitorCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Monitor"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A monitor with this name already exists in the account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/monitors/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getMonitor",
        "tags": [
          "Monitors"
        ],
        "summary": "Get a monitor",
        "description": "Monitor detail with stats compared to the previous window, the chart series, the next scheduled run and the open incident, if any.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "Window size in hours. Any value that is not a positive number falls back to 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The monitor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MonitorDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateMonitor",
        "tags": [
          "Monitors"
        ],
        "summary": "Update a monitor",
        "description": "Edits name, URL, interval, tags, config, or pauses/resumes. The schedule is re-armed (or disarmed when paused).",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MonitorUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Monitor"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteMonitor",
        "tags": [
          "Monitors"
        ],
        "summary": "Delete a monitor",
        "description": "Deletes the monitor and, by cascade, its checks, reports, incidents, rollups, journey variables and status page entries. See `getMonitorDeletionImpact` first.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/impact": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getMonitorDeletionImpact",
        "tags": [
          "Monitors"
        ],
        "summary": "Deletion impact",
        "description": "Read-only: counts what a DELETE of this monitor would remove, including the status pages that show it.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Impact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MonitorImpact"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/check": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "runMonitorCheck",
        "tags": [
          "Monitors"
        ],
        "summary": "Check now",
        "description": "Runs a check outside the schedule (recorded with `source: \"manual\"`). `http` and `journey` answer synchronously with the result; `web` answers 202 and audits in the background (follow `running_since` in the listing), or 409 if an audit is already running. Refused with 402 when the monitor is outside the account plan.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Check result (http/journey).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpCheckResult"
                }
              }
            }
          },
          "202": {
            "description": "Web audit started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditAccepted"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "A web audit for this monitor is already running (`aceito: false`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditAccepted"
                }
              }
            }
          }
        }
      }
    },
    "/monitors/{id}/checks": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "listMonitorChecks",
        "tags": [
          "Monitors"
        ],
        "summary": "Check history",
        "description": "Raw checks, newest first, with optional time window and ok filter. `total` is counted with the same filters. Retention is 30 days.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Epoch ms (inclusive lower bound). Unparseable values are ignored.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "Epoch ms upper bound. Unparseable values are ignored.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "ok",
            "in": "query",
            "required": false,
            "description": "Only good (`true`) or bad (`false`) checks.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Checks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Check"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/episodes": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "listMonitorEpisodes",
        "tags": [
          "Monitors"
        ],
        "summary": "State episodes",
        "description": "Checks in the window grouped into contiguous same-state episodes, newest first (up to 200). Not paginated.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "Window size in hours. Any value that is not a positive number falls back to 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Episodes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Episode"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/series": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getMonitorSeries",
        "tags": [
          "Monitors"
        ],
        "summary": "Chart series",
        "description": "Uptime and mean latency per bucket (1 h, or 6 h for windows above 48 h), empty buckets included. Not paginated.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "Window size in hours. Any value that is not a positive number falls back to 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Series.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SeriesPoint"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/report/{checkId}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "checkId",
          "in": "path",
          "required": true,
          "description": "The check id of a web audit.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getMonitorReport",
        "tags": [
          "Monitors"
        ],
        "summary": "Lighthouse report",
        "description": "The full Lighthouse report of a `web` audit check. Reports are kept for 7 days.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "The report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LighthouseReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Monitor or report not found, or the report expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/monitors/{id}/live": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "streamMonitorLiveSteps",
        "tags": [
          "Journeys"
        ],
        "summary": "Live journey steps (SSE)",
        "description": "Server-Sent Events stream. Every second it sends `data: {running, startedAt, steps}` with the full current state; a `: ping` comment every 20 s. The connection stays open when nothing is running.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Event stream; each `data:` line is a JSON `LiveSteps` object.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE frames: `data: <LiveSteps JSON>` every second, `: ping` every 20 s."
                },
                "x-event-data-schema": {
                  "type": "object",
                  "description": "Payload of each SSE `data:` event.",
                  "properties": {
                    "running": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "startedAt": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "steps": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/monitors/{id}/variables": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "listJourneyVariables",
        "tags": [
          "Journeys"
        ],
        "summary": "List journey variables",
        "description": "Variables exposed to the journey script as `env`. Secret values never come back (`value: null`). Returns `{items}` without a `page` block.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Variables.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/JourneyVariable"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "operationId": "putJourneyVariable",
        "tags": [
          "Journeys"
        ],
        "summary": "Create or replace a journey variable",
        "description": "Upserts one variable by name. Secrets are encrypted at rest (AES-GCM) and require the server to have secrets enabled (503 otherwise).",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyVariableInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "isSecret": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/monitors/{id}/variables/{name}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Monitor id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "name",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "operationId": "deleteJourneyVariable",
        "tags": [
          "Journeys"
        ],
        "summary": "Delete a journey variable",
        "description": "Removes one variable by name.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Monitor or variable not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/incidents": {
      "get": {
        "operationId": "listIncidents",
        "tags": [
          "Incidents"
        ],
        "summary": "List incidents",
        "description": "The account incidents, newest first. Incidents are derived from checks (confirmation rule), never written by hand.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "parameters": [
          {
            "name": "monitorId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Incidents.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Incident"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/channels": {
      "get": {
        "operationId": "listChannels",
        "tags": [
          "Alert channels"
        ],
        "summary": "List alert channels",
        "description": "Alert channels with masked destinations. Not paginated.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Channels.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Channel"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "createChannel",
        "tags": [
          "Alert channels"
        ],
        "summary": "Create an alert channel",
        "description": "Creates a `webhook`, `email`, `discord` or `telegram` channel. Destinations are validated at registration (internal networks refused, Discord URL format, up to 50 e-mail addresses).",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChannelCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/channels/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Channel id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "delete": {
        "operationId": "deleteChannel",
        "tags": [
          "Alert channels"
        ],
        "summary": "Delete an alert channel",
        "description": "Removes the channel.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/channels/{id}/test": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Channel id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "testChannel",
        "tags": [
          "Alert channels"
        ],
        "summary": "Send a test alert",
        "description": "Sends the same message a real incident would send, now, to the real destination (generic webhooks get `test: true`). Returns the body that was sent.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Delivered.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelTestResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "502": {
            "description": "The destination refused the message (`UPSTREAM_ERROR`); `details` carries `kind` and `texto`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/status-pages": {
      "get": {
        "operationId": "listStatusPages",
        "tags": [
          "Status pages"
        ],
        "summary": "List status pages",
        "description": "The account status pages, newest first, with the number of monitors on each. Not paginated.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StatusPageListItem"
                      }
                    },
                    "page": {
                      "$ref": "#/components/schemas/PageInfo"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "createStatusPage",
        "tags": [
          "Status pages"
        ],
        "summary": "Create a status page",
        "description": "Creates a status page. The slug is generated with a random suffix unless given; slugs are globally unique. Subject to the plan status page limit.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatusPageCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "Slug already in use.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/status-pages/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Status page id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getStatusPage",
        "tags": [
          "Status pages"
        ],
        "summary": "Get a status page",
        "description": "Page detail with its monitors, the CNAME target for a custom domain and the subscriber count.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "The page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusPageDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateStatusPage",
        "tags": [
          "Status pages"
        ],
        "summary": "Update a status page",
        "description": "Partial update of content, visibility, subscriptions and branding. Custom CSS is pruned, not refused; dropped fragments return in `cssRemovido`.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatusPageUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Slug already in use.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteStatusPage",
        "tags": [
          "Status pages"
        ],
        "summary": "Delete a status page",
        "description": "Deletes the page; its custom-domain certificate is revoked first.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/status-pages/{id}/monitors": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Status page id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "put": {
        "operationId": "setStatusPageMonitors",
        "tags": [
          "Status pages"
        ],
        "summary": "Set the page monitors",
        "description": "Replaces the whole selection of monitors shown on the page (max 50), each with a mandatory public name. Atomic: an unknown monitor leaves the previous selection intact.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatusPageMonitorsInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, or a monitor not in this account (`details.monitorId`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/status-pages/{id}/domain": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Status page id (plain UUID).",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getStatusPageDomain",
        "tags": [
          "Status pages"
        ],
        "summary": "Custom domain state",
        "description": "Checks the certificate with Fly and returns the domain state; `active` only once the certificate is issued.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Domain state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainState"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "operationId": "claimStatusPageDomain",
        "tags": [
          "Status pages"
        ],
        "summary": "Claim a custom domain",
        "description": "Registers a custom domain for the page and requests its certificate. Point a CNAME at `alvoCNAME`. Platform domains are refused. Requires a plan with custom domains.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "type": "string",
                    "description": "e.g. status.example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pending certificate issuance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainState"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Domain already used by another page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Fly refused to register the certificate (`UPSTREAM_ERROR`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "releaseStatusPageDomain",
        "tags": [
          "Status pages"
        ],
        "summary": "Release the custom domain",
        "description": "Revokes the certificate and clears the custom domain.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {
            "OAuth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "Released.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Account API key, prefix `mk_`. An unknown key is 403 (never falls back to another credential)."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer` with either an `mk_` API key (recognised by prefix, same as `x-api-key`) or an Infrastructure Auth session JWT (RS256, issuer `riligar-auth`, verified against https://auth.worker.myinfrastructure.click/.well-known/jwks.json). On `GET /me` only the JWT form is accepted."
      },
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.1 authorization code with PKCE (S256), issued by Infrastructure Auth. Use it to act on behalf of a person; scopes are listed in the authorization server metadata.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://auth.worker.myinfrastructure.click/oauth/authorize",
            "tokenUrl": "https://auth.worker.myinfrastructure.click/oauth/token",
            "refreshUrl": "https://auth.worker.myinfrastructure.click/oauth/token",
            "scopes": {
              "auth:read": "Read access (enforced by MCP tools only).",
              "auth:write": "Write access (enforced by MCP tools only)."
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "The stack-wide error envelope. `code` is stable and machine-readable; `message` is human text (Portuguese) and may change.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "UNAUTHORIZED",
                  "FORBIDDEN",
                  "WRONG_AUDIENCE",
                  "INSUFFICIENT_SCOPE",
                  "NOT_FOUND",
                  "CONFLICT",
                  "NAME_TAKEN",
                  "EXPIRED",
                  "HAS_RESOURCES",
                  "VALIDATION_ERROR",
                  "UNPROCESSABLE",
                  "RATE_LIMITED",
                  "PAYLOAD_TOO_LARGE",
                  "PLAN_LIMIT",
                  "SUBSCRIPTION_REQUIRED",
                  "INTERNAL_ERROR",
                  "SERVICE_UNAVAILABLE",
                  "UPSTREAM_ERROR"
                ],
                "description": "Closed vocabulary from @ciromaciel/contract. Derived from the HTTP status: 400 VALIDATION_ERROR, 401 UNAUTHORIZED, 402 PLAN_LIMIT or SUBSCRIPTION_REQUIRED, 403 FORBIDDEN, 404 NOT_FOUND, 409 CONFLICT, 429 RATE_LIMITED, 500 INTERNAL_ERROR, 502 UPSTREAM_ERROR, 503 SERVICE_UNAVAILABLE."
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true,
                "description": "Extra context; present only when there is some."
              },
              "retriable": {
                "type": "boolean",
                "const": true,
                "description": "Present (true) only for RATE_LIMITED, SERVICE_UNAVAILABLE and UPSTREAM_ERROR."
              }
            }
          }
        }
      },
      "PlanLimitError": {
        "type": "object",
        "description": "402 refusal from the plan gate.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "details"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "PLAN_LIMIT",
                  "SUBSCRIPTION_REQUIRED"
                ],
                "description": "`PLAN_LIMIT`: the current plan ran out (upgrade). `SUBSCRIPTION_REQUIRED`: no Monitors plan (subscribe)."
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "resource": {
                    "type": "string",
                    "enum": [
                      "monitors",
                      "status_pages",
                      "web_performance",
                      "custom_domain"
                    ]
                  },
                  "current": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "limit": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "plan": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "PageInfo": {
        "type": "object",
        "required": [
          "limit",
          "offset",
          "total",
          "hasMore"
        ],
        "description": "Pagination block. On routes that do not paginate, `limit` equals the number of items, `offset` is 0 and `total`/`hasMore` are null (\"not counted\").",
        "properties": {
          "limit": {
            "type": "integer",
            "description": "The applied (clamped) limit."
          },
          "offset": {
            "type": "integer"
          },
          "total": {
            "type": [
              "integer",
              "null"
            ]
          },
          "hasMore": {
            "type": [
              "boolean",
              "null"
            ]
          }
        }
      },
      "DeleteResult": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "MonitorKind": {
        "type": "string",
        "enum": [
          "http",
          "web",
          "journey"
        ]
      },
      "MonitorState": {
        "type": "string",
        "enum": [
          "up",
          "degraded",
          "down",
          "error"
        ]
      },
      "Assertion": {
        "type": "object",
        "description": "An HTTP assertion (kind `http`): where to read, how to compare, against what.",
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "json",
              "status",
              "responseTime",
              "header",
              "text"
            ],
            "default": "json"
          },
          "property": {
            "type": "string",
            "description": "JSONPath-like path for `json` (e.g. `$.checks[0].status`), header name for `header`."
          },
          "comparison": {
            "type": "string",
            "enum": [
              "eq",
              "neq",
              "lt",
              "lte",
              "gt",
              "gte",
              "contains",
              "notContains",
              "empty",
              "notEmpty"
            ],
            "default": "eq"
          },
          "target": {
            "description": "Value to compare against (unused for `empty`/`notEmpty`)."
          }
        }
      },
      "MonitorConfig": {
        "type": "object",
        "additionalProperties": true,
        "description": "Free-form object interpreted by the probe of the monitor kind. Unknown fields are ignored, not refused.",
        "properties": {
          "method": {
            "type": "string",
            "default": "GET",
            "description": "[http] Request method."
          },
          "expectStatus": {
            "type": "integer",
            "default": 200,
            "description": "[http] Exact expected status; anything else is `down`."
          },
          "expectBody": {
            "type": "string",
            "description": "[http] Substring the body must contain."
          },
          "assertions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Assertion"
            },
            "description": "[http] Structured assertions."
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "[http] Extra request headers (host, content-length, connection, transfer-encoding, x-forwarded*, fly-*, cf-* are dropped)."
          },
          "body": {
            "type": "string",
            "description": "[http] Request body (ignored for GET/HEAD)."
          },
          "timeoutMs": {
            "type": "integer",
            "default": 10000,
            "maximum": 30000,
            "description": "[http] Timeout; hard cap 30000."
          },
          "degradedMs": {
            "type": "integer",
            "description": "[http] Above this latency the result is `degraded`."
          },
          "followRedirects": {
            "type": "boolean",
            "default": false,
            "description": "[http] Without it a 3xx is `down`."
          },
          "device": {
            "type": "string",
            "enum": [
              "mobile",
              "desktop"
            ],
            "default": "mobile",
            "description": "[web] Lighthouse form factor."
          },
          "throttling": {
            "type": "string",
            "description": "[web] `none` disables simulated throttling."
          },
          "maxLcpMs": {
            "type": "number",
            "description": "[web] LCP budget; above it is `degraded`."
          },
          "maxTbtMs": {
            "type": "number",
            "description": "[web] TBT budget."
          },
          "maxCls": {
            "type": "number",
            "description": "[web] CLS budget."
          },
          "minScore": {
            "type": "number",
            "description": "[web] Minimum performance score."
          },
          "script": {
            "type": "string",
            "description": "[journey] Required. The Playwright script; receives page, context, step, expect, env, url."
          },
          "confirmations": {
            "type": "integer",
            "default": 2,
            "description": "Consecutive failures that open an incident."
          },
          "degradedConfirmations": {
            "type": "integer",
            "default": 3,
            "description": "Consecutive degraded checks that raise a degradation alert."
          }
        }
      },
      "Monitor": {
        "type": "object",
        "description": "A monitor row. Most column names come back in snake_case exactly as stored; `paused`, `planPaused`, `tags` and `config` are hydrated.",
        "required": [
          "id",
          "kind",
          "name",
          "url",
          "interval_s",
          "paused",
          "planPaused",
          "tags",
          "config",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "owner_id": {
            "type": "string",
            "description": "The owner (Auth user id)."
          },
          "kind": {
            "$ref": "#/components/schemas/MonitorKind"
          },
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "interval_s": {
            "type": "integer",
            "description": "Check interval in seconds."
          },
          "paused": {
            "type": "boolean",
            "description": "Paused by the owner."
          },
          "planPaused": {
            "type": "boolean",
            "description": "Paused by the plan gate (undone automatically when the plan covers it again)."
          },
          "plan_paused": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Raw column behind `planPaused`."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10
          },
          "config": {
            "$ref": "#/components/schemas/MonitorConfig"
          },
          "last_check_at": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Epoch ms."
          },
          "last_status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MonitorState"
              },
              {
                "type": "null"
              }
            ]
          },
          "consecutive_bad": {
            "type": "integer"
          },
          "consecutive_degraded": {
            "type": "integer"
          },
          "running_since": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Epoch ms when an audit/journey run started; null when idle."
          },
          "created_at": {
            "type": "integer",
            "description": "Epoch ms."
          },
          "updated_at": {
            "type": "integer",
            "description": "Epoch ms."
          }
        }
      },
      "WindowStats": {
        "type": "object",
        "description": "Uptime and latency over a window. `uptime` is null (never 100) when nothing was measured. In listings `p50`/`p95` are always null.",
        "properties": {
          "windowHours": {
            "type": "integer"
          },
          "total": {
            "type": "integer",
            "description": "Checks in the window."
          },
          "boas": {
            "type": "integer",
            "description": "Checks with ok = true."
          },
          "uptime": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percent, 3 decimals."
          },
          "average": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Mean duration (ms)."
          },
          "peak": {
            "type": [
              "integer",
              "null"
            ]
          },
          "p50": {
            "type": [
              "integer",
              "null"
            ]
          },
          "p95": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "ComparedStats": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WindowStats"
          },
          {
            "type": "object",
            "properties": {
              "anterior": {
                "type": "object",
                "description": "The previous window of the same size.",
                "properties": {
                  "total": {
                    "type": "integer"
                  },
                  "uptime": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "average": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "variacao": {
                "type": "object",
                "properties": {
                  "average": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Percent change of the mean latency."
                  },
                  "uptime": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Uptime difference in percentage points."
                  }
                }
              }
            }
          }
        ]
      },
      "MonitorListItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Monitor"
          },
          {
            "type": "object",
            "properties": {
              "stats": {
                "$ref": "#/components/schemas/WindowStats"
              },
              "proximaChecagem": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "Next scheduled run (ISO 8601), or null when unknown to the answering process."
              },
              "lastScore": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[web only] Latest Lighthouse performance score."
              },
              "lastLcp": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[web only] Latest LCP (ms)."
              }
            }
          }
        ]
      },
      "MonitorDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Monitor"
          },
          {
            "type": "object",
            "properties": {
              "stats": {
                "$ref": "#/components/schemas/ComparedStats"
              },
              "series": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SeriesPoint"
                }
              },
              "proximaChecagem": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "incidenteAberto": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "started_at": {
                        "type": "integer"
                      },
                      "cause": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        ]
      },
      "MonitorCreate": {
        "type": "object",
        "required": [
          "url",
          "name"
        ],
        "properties": {
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/MonitorKind"
              }
            ],
            "default": "http"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Unique per account (409 otherwise)."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "http(s), without embedded credentials."
          },
          "intervalS": {
            "type": "integer",
            "description": "Closed list per kind — http: 30, 60, 300, 600, 1800, 3600 (default 300); web: 3600, 21600, 43200, 86400 (default 86400); journey: 300, 600, 1800, 3600, 21600, 43200, 86400 (default 1800).",
            "enum": [
              30,
              60,
              300,
              600,
              1800,
              3600,
              21600,
              43200,
              86400
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Only the first 10 are kept."
          },
          "config": {
            "$ref": "#/components/schemas/MonitorConfig"
          }
        }
      },
      "MonitorUpdate": {
        "type": "object",
        "description": "Partial update. `kind` is not editable.",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "intervalS": {
            "type": "integer",
            "description": "Must belong to the closed list of the monitor kind."
          },
          "paused": {
            "type": "boolean"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "config": {
            "$ref": "#/components/schemas/MonitorConfig"
          }
        }
      },
      "MonitorImpact": {
        "type": "object",
        "description": "What a DELETE would take along with the monitor.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/MonitorKind"
          },
          "url": {
            "type": "string"
          },
          "checks": {
            "type": "integer"
          },
          "incidents": {
            "type": "integer"
          },
          "reports": {
            "type": "integer"
          },
          "dailyRollups": {
            "type": "integer"
          },
          "hourlyRollups": {
            "type": "integer"
          },
          "firstCheckAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "statusPages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "publicName": {
                  "type": "string"
                }
              }
            }
          },
          "running": {
            "type": "boolean"
          }
        }
      },
      "HttpCheckResult": {
        "type": "object",
        "description": "Synchronous result of a manual check (kinds http and journey).",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/MonitorState"
          },
          "ok": {
            "type": "boolean"
          },
          "durationMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "detail": {
            "description": "Probe-specific detail (e.g. journey steps), or null."
          },
          "checkId": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AuditAccepted": {
        "type": "object",
        "description": "Web audit accepted (202) or already running (409). Not the error envelope.",
        "properties": {
          "aceito": {
            "type": "boolean"
          },
          "rodando": {
            "type": "boolean"
          },
          "desde": {
            "type": "integer",
            "description": "Epoch ms."
          },
          "mensagem": {
            "type": "string"
          }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/MonitorState"
          },
          "ok": {
            "type": "boolean"
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "detail": {
            "description": "Parsed detail (web: scores/vitals; journey: steps), or null."
          },
          "source": {
            "type": "string",
            "description": "`cron` or `manual`."
          },
          "created_at": {
            "type": "integer",
            "description": "Epoch ms."
          }
        }
      },
      "Episode": {
        "type": "object",
        "description": "A contiguous stretch of checks in the same state.",
        "properties": {
          "estado": {
            "$ref": "#/components/schemas/MonitorState"
          },
          "ok": {
            "type": "boolean"
          },
          "inicio": {
            "type": "integer"
          },
          "fim": {
            "type": "integer"
          },
          "duracaoMs": {
            "type": "integer"
          },
          "checagens": {
            "type": "integer"
          },
          "mediaMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "erro": {
            "type": [
              "string",
              "null"
            ]
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "SeriesPoint": {
        "type": "object",
        "properties": {
          "t": {
            "type": "integer",
            "description": "Bucket start (epoch ms). Buckets are 1 h, or 6 h when hours > 48."
          },
          "checks": {
            "type": "integer"
          },
          "uptime": {
            "type": [
              "number",
              "null"
            ]
          },
          "average": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "LighthouseReport": {
        "type": "object",
        "additionalProperties": true,
        "description": "The stored Lighthouse report payload plus `created_at` (epoch ms). Kept for 7 days.",
        "properties": {
          "created_at": {
            "type": "integer"
          }
        }
      },
      "JourneyVariable": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "isSecret": {
            "type": "boolean"
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "Always null for secrets."
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "JourneyVariableInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{0,63}$"
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4096
          },
          "isSecret": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "Incident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "monitorId": {
            "type": "string"
          },
          "startedAt": {
            "type": "integer"
          },
          "resolvedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "cause": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "description": "`open` or `resolved`."
          },
          "monitorName": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/MonitorKind"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "Overview": {
        "type": "object",
        "properties": {
          "windowHours": {
            "type": "integer"
          },
          "monitors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonitorListItem"
            }
          },
          "summary": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "http": {
                "type": "object",
                "properties": {
                  "total": {
                    "type": "integer"
                  },
                  "online": {
                    "type": "integer"
                  },
                  "down": {
                    "type": "integer"
                  }
                }
              },
              "web": {
                "type": "object",
                "properties": {
                  "total": {
                    "type": "integer"
                  },
                  "averageScore": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "auditing": {
                    "type": "integer"
                  },
                  "auditingSince": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "uptimeGlobal": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "openIncidents": {
                "type": "integer"
              }
            }
          },
          "incidents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Incident"
            },
            "description": "The 20 most recent incidents."
          }
        }
      },
      "PlanNotice": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "unknown",
              "active",
              "free",
              "none"
            ]
          },
          "plan": {
            "type": [
              "string",
              "null"
            ]
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ]
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          },
          "used": {
            "type": "integer",
            "description": "Monitors in the account."
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "apiKey": {
            "type": [
              "string",
              "null"
            ],
            "description": "The full `mk_` key, only on the call that creates it (first visit); null afterwards."
          },
          "keyPrefix": {
            "type": "string",
            "description": "First 11 characters of the account key."
          },
          "mode": {
            "type": "string",
            "enum": [
              "auth",
              "dev-user"
            ]
          }
        }
      },
      "ChannelKind": {
        "type": "string",
        "enum": [
          "webhook",
          "email",
          "discord",
          "telegram"
        ]
      },
      "Channel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/ChannelKind"
          },
          "enabled": {
            "type": "boolean"
          },
          "created_at": {
            "type": "integer"
          },
          "preview": {
            "type": "string",
            "description": "Masked destination (URLs become `origin/…`, Telegram `chat <id>`, e-mail lists the first two addresses)."
          }
        }
      },
      "ChannelCreate": {
        "type": "object",
        "required": [
          "kind"
        ],
        "description": "Fields depend on `kind`: webhook/discord → `url`; email → `emails` (or `email`); telegram → `token` + `chatId`.",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/ChannelKind"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "webhook: public http(s) URL (internal networks refused). discord: a discord.com/api/webhooks/<id>/<token> URL (not the /slack or /github variant)."
          },
          "emails": {
            "oneOf": [
              {
                "type": "string",
                "description": "Separated by comma, semicolon or newline."
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                }
              }
            ],
            "description": "email: up to 50 addresses."
          },
          "email": {
            "type": "string",
            "description": "Alias of `emails`."
          },
          "token": {
            "type": "string",
            "description": "telegram: bot token."
          },
          "chatId": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ],
            "description": "telegram: chat id."
          }
        }
      },
      "ChannelCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/ChannelKind"
          }
        }
      },
      "ChannelTestResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "kind": {
            "$ref": "#/components/schemas/ChannelKind"
          },
          "texto": {
            "type": "string",
            "description": "The exact body that was sent."
          }
        }
      },
      "StatusPageMonitor": {
        "type": "object",
        "properties": {
          "monitor_id": {
            "type": "string"
          },
          "public_name": {
            "type": "string"
          },
          "public_group": {
            "type": [
              "string",
              "null"
            ]
          },
          "sort_order": {
            "type": "integer"
          },
          "kind": {
            "$ref": "#/components/schemas/MonitorKind"
          },
          "internal_name": {
            "type": "string"
          }
        }
      },
      "StatusPageBase": {
        "type": "object",
        "description": "A status page row (snake_case columns as stored).",
        "properties": {
          "id": {
            "type": "string"
          },
          "owner_id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "support_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "custom_domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "domain_status": {
            "type": "string",
            "description": "`none`, `pending`, `active` or `error`."
          },
          "domain_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "domain_checked_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "is_public": {
            "type": "boolean"
          },
          "show_latency": {
            "type": "boolean"
          },
          "allow_subscriptions": {
            "type": "boolean"
          },
          "brand_color": {
            "type": [
              "string",
              "null"
            ]
          },
          "font_family": {
            "type": [
              "string",
              "null"
            ]
          },
          "theme": {
            "type": "string",
            "enum": [
              "auto",
              "light",
              "dark"
            ]
          },
          "custom_css": {
            "type": [
              "string",
              "null"
            ]
          },
          "footer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "refresh_s": {
            "type": "integer"
          },
          "created_at": {
            "type": "integer"
          },
          "updated_at": {
            "type": "integer"
          }
        }
      },
      "StatusPageListItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StatusPageBase"
          },
          {
            "type": "object",
            "properties": {
              "monitors": {
                "type": "integer",
                "description": "Number of monitors on the page."
              }
            }
          }
        ]
      },
      "StatusPage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StatusPageBase"
          },
          {
            "type": "object",
            "properties": {
              "monitors": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/StatusPageMonitor"
                }
              },
              "cssRemovido": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "[PATCH only] What the CSS sanitizer dropped; present only when non-empty."
              }
            }
          }
        ]
      },
      "StatusPageDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StatusPage"
          },
          {
            "type": "object",
            "properties": {
              "alvoCNAME": {
                "type": "string",
                "description": "CNAME target for a custom domain."
              },
              "assinantes": {
                "type": "integer",
                "description": "Subscriber count (never the list)."
              }
            }
          }
        ]
      },
      "StatusPageCreate": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "slug": {
            "type": "string",
            "description": "Optional; generated with a random suffix when omitted. Pattern ^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$, reserved words refused."
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "supportUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "showLatency": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "StatusPageUpdate": {
        "type": "object",
        "description": "Partial update, including branding.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "supportUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "isPublic": {
            "type": "boolean"
          },
          "showLatency": {
            "type": "boolean"
          },
          "allowSubscriptions": {
            "type": "boolean"
          },
          "slug": {
            "type": "string"
          },
          "brandColor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Hex `#rgb`/`#rrggbb`; empty string or null removes it."
          },
          "fontFamily": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "brand",
              "humanista",
              "serifada",
              "mono",
              "marca",
              null
            ],
            "description": "`marca` is a legacy alias stored as `brand`."
          },
          "theme": {
            "type": "string",
            "enum": [
              "auto",
              "light",
              "dark"
            ]
          },
          "footerText": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200,
            "description": "Truncated to 200 characters."
          },
          "refreshS": {
            "type": "integer",
            "minimum": 15,
            "maximum": 3600,
            "description": "Clamped to 15–3600."
          },
          "customCss": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sanitized (HTML, @import, url(), expression(), behavior:, javascript: dropped); what was dropped comes back in `cssRemovido`."
          }
        }
      },
      "StatusPageMonitorsInput": {
        "type": "object",
        "required": [
          "monitors"
        ],
        "properties": {
          "monitors": {
            "type": "array",
            "maxItems": 50,
            "description": "Replaces the whole selection.",
            "items": {
              "type": "object",
              "required": [
                "monitorId",
                "publicName"
              ],
              "properties": {
                "monitorId": {
                  "type": "string"
                },
                "publicName": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80
                },
                "publicGroup": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "maxLength": 60
                },
                "sortOrder": {
                  "type": "integer",
                  "description": "Defaults to the array position."
                }
              }
            }
          }
        }
      },
      "DomainState": {
        "type": "object",
        "properties": {
          "domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "description": "`pending`, `active` or `error`."
          },
          "alvoCNAME": {
            "type": "string"
          },
          "detalhe": {
            "type": [
              "string",
              "null"
            ]
          },
          "erro": {
            "type": [
              "string",
              "null"
            ]
          },
          "aviso": {
            "type": "string"
          },
          "instrucoes": {
            "type": "string",
            "description": "[POST only] Human DNS instructions."
          }
        }
      },
      "PublicStatusData": {
        "type": "object",
        "description": "Exactly what the public HTML renders. No target URLs, internal names, ids or configs.",
        "properties": {
          "titulo": {
            "type": "string"
          },
          "descricao": {
            "type": [
              "string",
              "null"
            ]
          },
          "suporte": {
            "type": [
              "string",
              "null"
            ]
          },
          "geral": {
            "type": "string",
            "enum": [
              "operational",
              "degraded",
              "down",
              "unknown"
            ]
          },
          "janela": {
            "type": "string",
            "enum": [
              "dias",
              "horas"
            ]
          },
          "componentes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "nome": {
                  "type": "string"
                },
                "grupo": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "estado": {
                  "type": "string",
                  "description": "Monitor state, or `desconhecido`."
                },
                "uptime": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "days": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "dia": {
                        "type": "string"
                      },
                      "uptime": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "vazio": {
                        "type": "boolean"
                      }
                    }
                  }
                },
                "latencia": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "dia": {
                            "type": "string"
                          },
                          "p50": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "p95": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          }
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "horas": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "hora": {},
                      "uptime": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "average": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "incidents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "componente": {
                  "type": "string"
                },
                "inicio": {
                  "type": "integer"
                },
                "fim": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "duracaoMs": {
                  "type": "integer"
                },
                "aberto": {
                  "type": "boolean"
                },
                "causa": {
                  "type": "string",
                  "enum": [
                    "Tempo de resposta excedido",
                    "Resposta inesperada do serviço",
                    "Falha de conexão",
                    "Degradação de desempenho",
                    "Indisponibilidade"
                  ]
                }
              }
            }
          },
          "atualizadoEm": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "SubscribeInput": {
        "type": "object",
        "required": [
          "destino"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "email",
              "webhook"
            ],
            "default": "email",
            "description": "Anything other than `webhook` is treated as `email`."
          },
          "destino": {
            "type": "string",
            "description": "E-mail address or webhook URL."
          }
        }
      },
      "SubscribeAccepted": {
        "type": "object",
        "description": "Identical for new, pending and already-confirmed subscriptions (no oracle).",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "mensagem": {
            "type": "string"
          }
        }
      },
      "ServiceStatus": {
        "type": "object",
        "additionalProperties": true,
        "description": "Health only, no commercial figures.",
        "properties": {
          "service": {
            "type": "string",
            "const": "riligar-monitors"
          },
          "status": {
            "type": "string",
            "const": "ok"
          },
          "uptime_s": {
            "type": "integer"
          },
          "auth": {
            "type": "string",
            "enum": [
              "riligar-auth",
              "dev-user"
            ]
          },
          "scheduler": {
            "type": "string",
            "enum": [
              "primary",
              "worker"
            ]
          },
          "lighthouse_fila": {
            "type": "integer"
          },
          "lighthouse_modo": {
            "type": "string"
          },
          "lighthouse_pool": {
            "type": "string",
            "description": "`available/total`."
          },
          "sprite_pool": {},
          "journey_pool": {
            "type": "string"
          },
          "journey_slots_free": {
            "type": "integer"
          },
          "alertsSentLastHour": {
            "type": "integer"
          },
          "alertsFailedLastHour": {
            "type": "integer"
          },
          "planPaused": {
            "type": "integer"
          },
          "checksLastHour": {
            "type": "integer"
          },
          "oldestOverdueS": {
            "type": "integer"
          },
          "gateDecisionsLastHour": {
            "type": "integer"
          },
          "gateBlindLastHour": {
            "type": "integer"
          },
          "db_path": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid body, parameter or value (`VALIDATION_ERROR`). Bodies over 256 KB or non-JSON bodies are also 400.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing credential, or a Bearer JWT that is invalid or expired (`UNAUTHORIZED`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "An `mk_` API key that matches no account (`FORBIDDEN`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found in this account (`NOT_FOUND`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "Refused by the plan gate (`PLAN_LIMIT` or `SUBSCRIPTION_REQUIRED`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PlanLimitError"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limited (`RATE_LIMITED`); `details.retryAfter` carries the wait.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "A required capability is not configured in this deployment (`SERVICE_UNAVAILABLE`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
