{
  "openapi": "3.0.3",
  "info": {
    "title": "UpConduit API",
    "version": "1.0.0",
    "description": "Programmatic access to UpConduit monitors, maintenance windows and daily uptime data. Authenticate with an API key created in your dashboard, sent as `Authorization: Bearer uc_live_...`. Rate limit: 60 requests per minute per key.",
    "contact": { "url": "https://upconduit.io/" }
  },
  "servers": [{ "url": "https://cj0dxr3cke.execute-api.eu-west-2.amazonaws.com/v1" }],
  "security": [{ "apiKey": [] }],
  "components": {
    "securitySchemes": { "apiKey": { "type": "http", "scheme": "bearer", "description": "An UpConduit API key (uc_live_...)" } },
    "schemas": {
      "Monitor": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "name": { "type": "string" },
          "type": { "type": "string", "enum": ["https", "tcp", "mailhealth", "domain", "heartbeat", "provider", "perf", "dns", "ssh", "ftp", "imap", "pop3", "mysql", "postgres", "redis"] },
          "target": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } },
          "slowMs": { "type": "integer", "nullable": true },
          "status": { "type": "string", "enum": ["up", "down", "pending", "maintenance", "unknown"] },
          "since": { "type": "string", "format": "date-time" }, "lastMs": { "type": "number", "nullable": true },
          "uptime24h": { "type": "number", "nullable": true }, "avgMs24h": { "type": "number", "nullable": true },
          "certDaysLeft": { "type": "integer", "nullable": true }, "lastError": { "type": "string", "nullable": true },
          "pingUrl": { "type": "string", "description": "Heartbeat monitors only" }
        }
      },
      "NewMonitor": {
        "type": "object", "required": ["name", "type", "target"],
        "properties": {
          "name": { "type": "string", "maxLength": 60 },
          "type": { "$ref": "#/components/schemas/Monitor/properties/type" },
          "target": { "type": "string", "description": "URL for https/perf; host or host:port for tcp/ssh/ftp/imap/pop3/mysql/postgres/redis; domain for mailhealth/domain/dns; provider key for provider; minutes for heartbeat" },
          "tags": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
          "slowMs": { "type": "integer", "minimum": 50, "maximum": 60000 },
          "expectStatus": { "type": "integer" }, "keyword": { "type": "string" }, "keywordAbsent": { "type": "string" },
          "recordType": { "type": "string", "enum": ["A", "AAAA", "CNAME", "MX", "TXT", "NS"] }, "expect": { "type": "string" },
          "dependsOn": { "type": "array", "items": { "type": "string", "enum": ["aws", "azure", "gcp", "cloudflare"] } },
          "intervalMin": { "type": "integer", "description": "Heartbeat monitors: expected interval" }, "graceMin": { "type": "integer" }
        }
      },
      "Day": {
        "type": "object",
        "properties": {
          "day": { "type": "string", "format": "date" }, "checks": { "type": "integer" }, "ok": { "type": "integer" }, "failed": { "type": "integer" },
          "uptimePct": { "type": "number", "nullable": true }, "avgMs": { "type": "integer", "nullable": true }, "maxMs": { "type": "integer", "nullable": true },
          "incidents": { "type": "integer" }, "downtimeMinApprox": { "type": "integer" }, "partial": { "type": "boolean", "description": "true for today, still in progress" }
        }
      },
      "Window": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "name": { "type": "string" }, "mode": { "type": "string", "enum": ["once", "weekly"] },
          "start": { "type": "string", "format": "date-time", "description": "once" },
          "days": { "type": "array", "items": { "type": "integer", "minimum": 0, "maximum": 6 }, "description": "weekly, 0 = Sunday" },
          "time": { "type": "string", "example": "02:00" }, "tz": { "type": "string", "example": "Europe/London" },
          "durationMin": { "type": "integer" }, "monitorIds": { "type": "array", "items": { "type": "string" }, "description": "empty = all monitors" },
          "active": { "type": "boolean" }
        }
      },
      "Error": { "type": "object", "properties": { "error": { "type": "string" }, "code": { "type": "string" } } }
    }
  },
  "paths": {
    "/account": { "get": { "summary": "Plan and usage for the account", "responses": { "200": { "description": "OK" } } } },
    "/monitors": {
      "get": { "summary": "List monitors with current status", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "monitors": { "type": "array", "items": { "$ref": "#/components/schemas/Monitor" } } } } } } } } },
      "post": { "summary": "Create a monitor", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewMonitor" } } } }, "responses": { "200": { "description": "Created" }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }
    },
    "/monitors/{id}": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
      "get": { "summary": "One monitor", "responses": { "200": { "description": "OK" }, "404": { "description": "Not found" } } },
      "put": { "summary": "Edit name, tags or slow threshold", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } }, "slowMs": { "type": "integer", "nullable": true } } } } } }, "responses": { "200": { "description": "OK" } } },
      "delete": { "summary": "Delete a monitor", "responses": { "200": { "description": "Deleted" } } }
    },
    "/monitors/{id}/daily": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "days", "in": "query", "schema": { "type": "integer", "default": 30, "maximum": 400 } }],
      "get": { "summary": "Daily uptime and latency roll-ups", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "days": { "type": "array", "items": { "$ref": "#/components/schemas/Day" } } } } } } } } }
    },
    "/maintenance": {
      "get": { "summary": "List maintenance windows", "responses": { "200": { "description": "OK" } } },
      "post": { "summary": "Create a maintenance window", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Window" } } } }, "responses": { "200": { "description": "Created; returns the full list" } } }
    },
    "/maintenance/{id}": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
      "delete": { "summary": "Remove a maintenance window", "responses": { "200": { "description": "Removed; returns the full list" } } }
    }
  }
}
