{"openapi":"3.1.0","info":{"title":"Keybeat API","version":"1.0.0","description":"Key transaction and availability monitoring with Playwright. See https://keybeat.dev/docs."},"servers":[{"url":"https://api.keybeat.dev"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"A Supabase access token (dashboard) or an API key `kb_...`."}},"schemas":{},"parameters":{}},"paths":{"/health":{"get":{"tags":["System"],"summary":"Liveness check (no database)","responses":{"200":{"description":"Alive","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"version":{"type":"string"},"time":{"type":"string"}},"required":["ok","version","time"]}}}}}}},"/health/db":{"get":{"tags":["System"],"summary":"Database connectivity check","responses":{"200":{"description":"Database reachable","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"db_time":{"type":"string"}},"required":["ok","db_time"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/me":{"get":{"tags":["Account"],"summary":"Who am I","description":"The authenticated user or API key, the active org, its plan limits and current usage.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Identity, org, limits and usage","content":{"application/json":{"schema":{"type":"object","properties":{"principal":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["user"]},"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":["string","null"]}},"required":["id","email"]}},"required":["type","user"]},{"type":"object","properties":{"type":{"type":"string","enum":["api_key"]},"api_key":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string"}},"required":["id","name","prefix"]}},"required":["type","api_key"]}]},"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"allowlist_token":{"type":"string"},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","slug","plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","allowlist_token","created_at"]},"role":{"type":["string","null"],"enum":["owner","member",null]},"limits":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"max_monitors":{"type":["integer","null"]},"included_monitors":{"type":"integer"},"allowed_intervals":{"type":"array","items":{"type":"integer"}},"retention_days":{"type":"integer"},"manual_runs_per_month":{"type":"integer"},"sms_per_month":{"type":"integer"}},"required":["plan","max_monitors","included_monitors","allowed_intervals","retention_days","manual_runs_per_month","sms_per_month"]},"usage":{"type":"object","properties":{"month":{"type":"string","format":"date"},"monitors":{"type":"integer","minimum":0},"manual_runs":{"type":"integer","minimum":0},"sms_sent":{"type":"integer","minimum":0}},"required":["month","monitors","manual_runs","sms_sent"]}},"required":["principal","org","role","limits","usage"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/orgs":{"get":{"tags":["Org"],"summary":"Orgs of the signed-in user","description":"User token only. Ordered by membership date; the first one is the default org.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Orgs","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"allowlist_token":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"role":{"type":"string","enum":["owner","member"]}},"required":["id","name","slug","plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","allowlist_token","created_at","role"]}}},"required":["data"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org":{"patch":{"tags":["Org"],"summary":"Rename the org","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"slug":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"}}}}}},"responses":{"200":{"description":"Updated org","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"allowlist_token":{"type":"string"},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","slug","plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","allowlist_token","created_at"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org/members":{"get":{"tags":["Org"],"summary":"List members","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Members","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid"},"email":{"type":["string","null"]},"role":{"type":"string","enum":["owner","member"]},"created_at":{"type":"string","format":"date-time"}},"required":["user_id","email","role","created_at"]}}},"required":["data"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org/invites":{"get":{"tags":["Org"],"summary":"List pending invites","description":"Owner only, user token only. Invites that were not accepted yet, newest first, including expired ones. Tokens are never returned.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Pending invites","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"email":{"type":"string"},"role":{"type":"string","enum":["owner","member"]},"expires_at":{"type":"string","format":"date-time"},"accepted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","org_id","email","role","expires_at","accepted_at","created_at"]}}},"required":["data"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"tags":["Org"],"summary":"Invite a member by email","description":"Owner only, user token only. Emails a one-time link valid for 7 days; the token is never returned by the API. A new invite for the same email replaces the pending one.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["owner","member"],"default":"member"}},"required":["email"]}}}},"responses":{"201":{"description":"Invite sent","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"email":{"type":"string"},"role":{"type":"string","enum":["owner","member"]},"expires_at":{"type":"string","format":"date-time"},"accepted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","org_id","email","role","expires_at","accepted_at","created_at"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org/invites/{id}":{"delete":{"tags":["Org"],"summary":"Revoke a pending invite","description":"Owner only, user token only. The emailed link stops working at once. Accepted invites are not pending and return 404.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org/members/{user_id}":{"delete":{"tags":["Org"],"summary":"Remove a member","description":"Owner only, user token only. The last owner cannot be removed. API keys the removed user created in this org are revoked.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"user_id","in":"path"}],"responses":{"200":{"description":"Removed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/invites/accept":{"post":{"tags":["Org"],"summary":"Accept an invite","description":"User token only. The signed-in email must match the invited email. Accepting twice is harmless.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","minLength":16,"maxLength":256}},"required":["token"]}}}},"responses":{"200":{"description":"Joined org","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"allowlist_token":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"role":{"type":"string","enum":["owner","member"]}},"required":["id","name","slug","plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","allowlist_token","created_at","role"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/org/allowlist-token/rotate":{"post":{"tags":["Org"],"summary":"Rotate the allowlist token","description":"Generates a new `X-Keybeat-Token` value. Runs started after this send the new token; update your allowlist rules.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"New token","content":{"application/json":{"schema":{"type":"object","properties":{"allowlist_token":{"type":"string"}},"required":["allowlist_token"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/api-keys":{"get":{"tags":["API keys"],"summary":"List API keys","description":"User token only. Key secrets are never returned after creation.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"API keys","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"last_used_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","org_id","name","prefix","created_by","last_used_at","revoked_at","created_at"]}}},"required":["data"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"tags":["API keys"],"summary":"Create an API key","description":"User token only. The `key` field is shown once; store it safely.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100}},"required":["name"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"last_used_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"key":{"type":"string"}},"required":["id","org_id","name","prefix","created_by","last_used_at","revoked_at","created_at","key"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/api-keys/{id}":{"delete":{"tags":["API keys"],"summary":"Revoke an API key","description":"User token only. Revoking twice is harmless.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"last_used_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","org_id","name","prefix","created_by","last_used_at","revoked_at","created_at"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors":{"get":{"tags":["Monitors"],"summary":"List monitors","description":"Monitors of the org with their state and last run summary, oldest first.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"}],"responses":{"200":{"description":"Monitors","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at"]}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"tags":["Monitors"],"summary":"Create a monitor","description":"The first run starts within a minute when enabled. On a free org, a paid-only change returns 402 `payment_required` with `error.details.checkout_url`.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":120},"script":{"type":"string","minLength":1},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean","default":true},"env":{"type":"object","additionalProperties":{"type":"string"}},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"},"maxItems":50,"default":null},"on_status_page":{"type":"boolean","default":false}},"required":["slug","name","script","interval_seconds"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"402":{"description":"Payment required or plan limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"422":{"description":"Unprocessable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}":{"get":{"tags":["Monitors"],"summary":"Get a monitor","description":"`:id` accepts the monitor id or its slug. Includes the script and env var names (never values).","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Monitor","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"patch":{"tags":["Monitors"],"summary":"Update a monitor","description":"Env vars are changed with PUT /v1/monitors/:id/env.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":120},"script":{"type":"string","minLength":1},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"},"maxItems":50},"on_status_page":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"402":{"description":"Payment required or plan limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"422":{"description":"Unprocessable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"delete":{"tags":["Monitors"],"summary":"Delete a monitor","description":"Deletes the monitor with its runs, incidents and env vars. Artifacts are removed by a scheduled job.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"deleted":{"type":"boolean","enum":[true]},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]}},"required":["id","deleted","billing_change"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"402":{"description":"Payment required or plan limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{slug}":{"put":{"tags":["Monitors"],"summary":"Create or update a monitor by slug","description":"Idempotent upsert used by `keybeat deploy`. Returns 201 when created, 200 when updated. On update, `enabled`, `alert_channel_ids` and `on_status_page` keep their current values when absent from the body, and `env` sets the given names without removing others.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"},"required":true,"name":"slug","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"script":{"type":"string","minLength":1},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean","default":true},"env":{"type":"object","additionalProperties":{"type":"string"}},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"},"maxItems":50,"default":null},"on_status_page":{"type":"boolean","default":false}},"required":["name","script","interval_seconds"]}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]},"created":{"type":"boolean"}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change","created"]}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]},"created":{"type":"boolean"}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change","created"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"402":{"description":"Payment required or plan limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"422":{"description":"Unprocessable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}/pause":{"post":{"tags":["Monitors"],"summary":"Pause a monitor","description":"Paused monitors keep their plan slot.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Paused","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}/resume":{"post":{"tags":["Monitors"],"summary":"Resume a monitor","description":"The next run starts within a minute. Plan limits are checked again.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Resumed","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"interval_seconds":{"type":"integer"},"enabled":{"type":"boolean"},"paused_reason":{"type":["string","null"],"enum":["user","billing",null]},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"next_run_at":{"type":["string","null"],"format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_run_id":{"type":["string","null"],"format":"uuid"},"last_run":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]},"alert_channel_ids":{"type":["array","null"],"items":{"type":"string","format":"uuid"}},"on_status_page":{"type":"boolean"},"consecutive_slow":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script":{"type":"string"},"env_names":{"type":"array","items":{"type":"string"}},"billing_change":{"type":["object","null"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"previous_quantity":{"type":"integer","minimum":0},"amount_delta_cents":{"type":"integer"}},"required":["item","quantity","previous_quantity","amount_delta_cents"]}},"amount_delta_cents":{"type":"integer"},"interval":{"type":"string","enum":["month","year"]}},"required":["items","amount_delta_cents","interval"]}},"required":["id","org_id","slug","name","interval_seconds","enabled","paused_reason","state","perf_state","next_run_at","last_run_at","last_run_id","last_run","alert_channel_ids","on_status_page","consecutive_slow","created_at","updated_at","script","env_names","billing_change"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"402":{"description":"Payment required or plan limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}/env":{"get":{"tags":["Monitors"],"summary":"List env var names","description":"Values are write-only and never returned.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Env var names","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["name","updated_at"]}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"put":{"tags":["Monitors"],"summary":"Set or unset env vars","description":"Values are encrypted with AES-256-GCM. Names not mentioned are left as they are.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"set":{"type":"object","additionalProperties":{"type":"string"}},"unset":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[A-Z_][A-Z0-9_]*$"},"maxItems":50}}}}}},"responses":{"200":{"description":"Env var names after the change","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["name","updated_at"]}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/validate":{"post":{"tags":["Monitors"],"summary":"Validate a script","description":"Static checks only: size (100 KB), parses as TypeScript or JavaScript, at least one test() call, and only @playwright/test, otpauth and Node built-in imports. Nothing is run.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"script":{"type":"string"}},"required":["script"]}}}},"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"valid":{"type":"boolean"},"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"},"line":{"type":["integer","null"],"exclusiveMinimum":0},"column":{"type":["integer","null"],"exclusiveMinimum":0}},"required":["message","line","column"]}},"warnings":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"},"line":{"type":["integer","null"],"exclusiveMinimum":0},"column":{"type":["integer","null"],"exclusiveMinimum":0}},"required":["message","line","column"]}},"size_bytes":{"type":"integer","minimum":0},"test_count":{"type":"integer","minimum":0}},"required":["valid","errors","warnings","size_bytes","test_count"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}/runs":{"post":{"tags":["Runs"],"summary":"Run a monitor now","description":"Starts an on-demand run in a random region (or `region` from the body). Counts toward the monthly on-demand cap (429 `manual_run_limit` when exceeded; a run that cannot start because of an infrastructure error is not counted). With `?wait=true` the request blocks up to 90 seconds; `waited` is true when the run reached a final status. Manual runs never change monitor state or alert.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["0","1","true","false"]},"required":false,"name":"wait","in":"query"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"region":{"type":"string","enum":["iad","fra","sin"]}},"default":{}}}}},"responses":{"201":{"description":"Run created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"monitor_slug":{"type":"string"},"monitor_name":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"duration_ms":{"type":"integer","minimum":0},"status":{"type":"string","enum":["passed","failed","skipped"]},"error":{"type":["string","null"]}},"required":["title","duration_ms","status","error"]}},"logs":{"type":["string","null"]},"has_trace":{"type":"boolean"},"has_screenshot":{"type":"boolean"},"url":{"type":"string","format":"uri"},"waited":{"type":"boolean"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at","monitor_slug","monitor_name","steps","logs","has_trace","has_screenshot","url","waited"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"get":{"tags":["Runs"],"summary":"Run history of a monitor","description":"Newest first. Filter with `status` and `trigger`.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["schedule","retry","manual"]},"required":false,"name":"trigger","in":"query"}],"responses":{"200":{"description":"Runs","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at"]}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/runs/{id}":{"get":{"tags":["Runs"],"summary":"Get a run","description":"Full detail with steps and logs. Artifact URLs come from GET /v1/runs/:id/artifacts.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Run","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"trigger":{"type":"string","enum":["schedule","retry","manual"]},"retry_of":{"type":["string","null"],"format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"status":{"type":"string","enum":["queued","starting","running","passed","failed","error"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"monitor_slug":{"type":"string"},"monitor_name":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"duration_ms":{"type":"integer","minimum":0},"status":{"type":"string","enum":["passed","failed","skipped"]},"error":{"type":["string","null"]}},"required":["title","duration_ms","status","error"]}},"logs":{"type":["string","null"]},"has_trace":{"type":"boolean"},"has_screenshot":{"type":"boolean"},"url":{"type":"string","format":"uri"}},"required":["id","monitor_id","org_id","trigger","retry_of","region","status","started_at","finished_at","duration_ms","error_code","error_message","created_at","monitor_slug","monitor_name","steps","logs","has_trace","has_screenshot","url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/monitors/{id}/stats":{"get":{"tags":["Runs"],"summary":"Monitor stats","description":"Uptime and p50/p95 durations per day and per region over `days` (default 30). Uptime counts checks: a scheduled run whose retry passed counts as passed; error and manual runs are excluded.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"Stats","content":{"application/json":{"schema":{"type":"object","properties":{"monitor_id":{"type":"string","format":"uuid"},"days":{"type":"integer"},"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"},"total":{"type":"object","properties":{"checks":{"type":"integer","minimum":0},"passed":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"uptime_pct":{"type":["number","null"]},"p50_ms":{"type":["integer","null"]},"p95_ms":{"type":["integer","null"]}},"required":["checks","passed","failed","uptime_pct","p50_ms","p95_ms"]},"daily":{"type":"array","items":{"type":"object","properties":{"checks":{"type":"integer","minimum":0},"passed":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"uptime_pct":{"type":["number","null"]},"p50_ms":{"type":["integer","null"]},"p95_ms":{"type":["integer","null"]},"day":{"type":"string","format":"date"}},"required":["checks","passed","failed","uptime_pct","p50_ms","p95_ms","day"]}},"regions":{"type":"array","items":{"type":"object","properties":{"checks":{"type":"integer","minimum":0},"passed":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"uptime_pct":{"type":["number","null"]},"p50_ms":{"type":["integer","null"]},"p95_ms":{"type":["integer","null"]},"region":{"type":"string","enum":["iad","fra","sin"]},"baseline":{"type":["object","null"],"properties":{"median_ms":{"type":"integer"},"mad_ms":{"type":"integer"},"threshold_ms":{"type":"integer"},"samples":{"type":"integer"}},"required":["median_ms","mad_ms","threshold_ms","samples"]}},"required":["checks","passed","failed","uptime_pct","p50_ms","p95_ms","region","baseline"]}}},"required":["monitor_id","days","from","to","total","daily","regions"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/incidents":{"get":{"tags":["Incidents"],"summary":"List incidents","description":"Newest first. `monitor_id` accepts a monitor id or slug; `open=true` returns only unresolved incidents.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"monitor_id","in":"query"},{"schema":{"type":"string","enum":["0","1","true","false"]},"required":false,"name":"open","in":"query"},{"schema":{"type":"string","enum":["down","slow"]},"required":false,"name":"kind","in":"query"}],"responses":{"200":{"description":"Incidents","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"monitor_slug":{"type":"string"},"monitor_name":{"type":"string"},"kind":{"type":"string","enum":["down","slow"]},"opened_at":{"type":"string","format":"date-time"},"resolved_at":{"type":["string","null"],"format":"date-time"},"duration_seconds":{"type":"integer","minimum":0},"opening_run_id":{"type":["string","null"],"format":"uuid"},"resolving_run_id":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"}},"required":["id","monitor_id","org_id","monitor_slug","monitor_name","kind","opened_at","resolved_at","duration_seconds","opening_run_id","resolving_run_id","created_at"]}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/alert-channels":{"get":{"tags":["Alert channels"],"summary":"List alert channels","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Channels","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["email","webhook","sms"]},"target":{"type":"string"},"enabled":{"type":"boolean"},"has_secret":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"}},"required":["id","org_id","type","target","enabled","has_secret","created_at"]}}},"required":["data"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"post":{"tags":["Alert channels"],"summary":"Create an alert channel","description":"Webhook channels get a signing secret (`secret`), returned only in this response.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["email"]},"target":{"type":"string","format":"email"},"enabled":{"type":"boolean","default":true}},"required":["type","target"]},{"type":"object","properties":{"type":{"type":"string","enum":["webhook"]},"target":{"type":"string","format":"uri"},"enabled":{"type":"boolean","default":true}},"required":["type","target"]},{"type":"object","properties":{"type":{"type":"string","enum":["sms"]},"target":{"type":"string","pattern":"^\\+[1-9]\\d{6,14}$"},"enabled":{"type":"boolean","default":true}},"required":["type","target"]}]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["email","webhook","sms"]},"target":{"type":"string"},"enabled":{"type":"boolean"},"has_secret":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"secret":{"type":["string","null"]}},"required":["id","org_id","type","target","enabled","has_secret","created_at","secret"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/alert-channels/{id}":{"patch":{"tags":["Alert channels"],"summary":"Update an alert channel","description":"`rotate_secret: true` (webhook only) returns the new secret once in `secret`; otherwise `secret` is null.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"target":{"type":"string","minLength":1,"maxLength":2048},"enabled":{"type":"boolean"},"rotate_secret":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["email","webhook","sms"]},"target":{"type":"string"},"enabled":{"type":"boolean"},"has_secret":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"secret":{"type":["string","null"]}},"required":["id","org_id","type","target","enabled","has_secret","created_at","secret"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"delete":{"tags":["Alert channels"],"summary":"Delete an alert channel","description":"Also removes the channel from monitors that listed it explicitly.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/alert-channels/{id}/test":{"post":{"tags":["Alert channels"],"summary":"Send a test notification","description":"Sends a test message to this channel and reports the outcome.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Outcome","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["sent","failed","skipped"]},"error":{"type":["string","null"]}},"required":["status","error"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/status-page":{"get":{"tags":["Status page"],"summary":"Get the status page","description":"404 `not_found` when the org has no status page yet.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status page","content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string"},"title":{"type":"string"},"enabled":{"type":"boolean"},"monitor_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"url":{"type":"string","format":"uri"}},"required":["slug","title","enabled","monitor_ids","url"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}},"put":{"tags":["Status page"],"summary":"Create or update the status page","description":"One page per org, at `https://status.keybeat.dev/<slug>`. Slugs are globally unique (409 `slug_taken`). `monitor_ids` replaces the list of monitors shown.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"},"title":{"type":"string","minLength":1,"maxLength":120},"enabled":{"type":"boolean"},"monitor_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}},"required":["slug","title","enabled","monitor_ids"]}}}},"responses":{"200":{"description":"Status page","content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string"},"title":{"type":"string"},"enabled":{"type":"boolean"},"monitor_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"url":{"type":"string","format":"uri"}},"required":["slug","title","enabled","monitor_ids","url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/public/status/{slug}":{"get":{"tags":["Status page"],"summary":"Public status page data","description":"No authentication, readable from any origin. Monitors on the page, their current state and 30 days of daily uptime (UTC, oldest first). 404 when the page does not exist or is disabled.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"},"required":true,"name":"slug","in":"path"}],"responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"type":"object","properties":{"slug":{"type":"string"},"title":{"type":"string"},"overall_state":{"type":"string","enum":["up","degraded","down","unknown"]},"updated_at":{"type":"string","format":"date-time"},"monitors":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"state":{"type":"string","enum":["unknown","up","down"]},"perf_state":{"type":"string","enum":["normal","slow"]},"uptime_30d":{"type":["number","null"]},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","format":"date"},"runs":{"type":"integer","minimum":0},"passed":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"uptime":{"type":["number","null"]}},"required":["day","runs","passed","failed","uptime"]}}},"required":["name","state","perf_state","uptime_30d","days"]}}},"required":["slug","title","overall_state","updated_at","monitors"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/auth/device":{"post":{"tags":["Auth"],"summary":"Start a CLI login (device flow)","description":"Returns a device code for polling and a user code to show. Open `verification_url`, sign in and approve, while polling POST /v1/auth/device/token every `interval` seconds.","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"client_name":{"type":"string","minLength":1,"maxLength":100}},"default":{}}}}},"responses":{"200":{"description":"Device code","content":{"application/json":{"schema":{"type":"object","properties":{"device_code":{"type":"string"},"user_code":{"type":"string"},"verification_url":{"type":"string","format":"uri"},"interval":{"type":"integer","exclusiveMinimum":0},"expires_in":{"type":"integer","exclusiveMinimum":0}},"required":["device_code","user_code","verification_url","interval","expires_in"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/auth/device/token":{"post":{"tags":["Auth"],"summary":"Poll for the CLI API key","description":"While waiting: 400 `authorization_pending`, or `slow_down` when polled faster than `interval`. Final errors: `access_denied` (refused) and `expired_token` (expired, unknown or already used). On success the API key is returned once.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"device_code":{"type":"string","minLength":1}},"required":["device_code"]}}}},"responses":{"200":{"description":"API key","content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string"},"api_key_id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"user_id":{"type":"string","format":"uuid"}},"required":["api_key","api_key_id","org_id","user_id"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/auth/approvals/{id}":{"get":{"tags":["Auth"],"summary":"Approval details for the consent screen","description":"User token only. `:id` is the approval id (MCP) or the user code shown by the CLI. Decided approvals are only visible to the user who decided them.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Approval","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["cli","mcp"]},"status":{"type":"string","enum":["pending","approved","denied","redeemed"]},"client_name":{"type":["string","null"]},"user_code":{"type":["string","null"]},"redirect_host":{"type":["string","null"]},"org_id":{"type":["string","null"],"format":"uuid"},"expires_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","kind","status","client_name","user_code","redirect_host","org_id","expires_at","created_at"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/auth/approvals/{id}/approve":{"post":{"tags":["Auth"],"summary":"Approve a CLI or MCP login","description":"User token only. Creates an API key in `org_id` (you must be a member), held encrypted until the CLI or MCP server collects it once.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"org_id":{"type":"string","format":"uuid"}},"required":["org_id"]}}}},"responses":{"200":{"description":"Approved","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["cli","mcp"]},"status":{"type":"string","enum":["pending","approved","denied","redeemed"]},"client_name":{"type":["string","null"]},"user_code":{"type":["string","null"]},"redirect_host":{"type":["string","null"]},"org_id":{"type":["string","null"],"format":"uuid"},"expires_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"code":{"type":["string","null"]}},"required":["id","kind","status","client_name","user_code","redirect_host","org_id","expires_at","created_at","code"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/auth/approvals/{id}/deny":{"post":{"tags":["Auth"],"summary":"Refuse a CLI or MCP login","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Denied","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["cli","mcp"]},"status":{"type":"string","enum":["pending","approved","denied","redeemed"]},"client_name":{"type":["string","null"]},"user_code":{"type":["string","null"]},"redirect_host":{"type":["string","null"]},"org_id":{"type":["string","null"],"format":"uuid"},"expires_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"code":{"type":["string","null"]}},"required":["id","kind","status","client_name","user_code","redirect_host","org_id","expires_at","created_at","code"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/approvals":{"post":{"tags":["Internal"],"summary":"Create an MCP approval","security":[{"bearerAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["mcp"],"default":"mcp"},"client_name":{"type":"string","minLength":1,"maxLength":100},"redirect_host":{"type":"string","minLength":1,"maxLength":255}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"expires_at":{"type":"string","format":"date-time"},"approval_url":{"type":"string","format":"uri"}},"required":["id","expires_at","approval_url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/approvals/{id}/redeem":{"post":{"tags":["Internal"],"summary":"Redeem an approved MCP approval","description":"Returns the API key exactly once, only with the one-time `code` that approving returned to the dashboard. 400 `authorization_pending` while pending, `access_denied` when refused or when the code is wrong (which burns the approval), `expired_token` when expired; 409 `approval_not_pending` when already redeemed.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":200}},"required":["code"]}}}},"responses":{"200":{"description":"API key","content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string"},"org_id":{"type":"string","format":"uuid"},"user_id":{"type":"string","format":"uuid"}},"required":["api_key","org_id","user_id"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/dispatch":{"post":{"tags":["Internal"],"summary":"Start Fly machines for queued runs","description":"Called by pg_cron through pg_net with chunks of up to 50 run ids. Each queued run becomes `starting` (machine created) or `error`; other runs are skipped.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"run_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":1000}},"required":["run_ids"]}}}},"responses":{"200":{"description":"Per-run outcome","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"run_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["starting","error","skipped"]},"error_code":{"type":["string","null"]}},"required":["run_id","status","error_code"]}}},"required":["results"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/runs/{id}/job":{"get":{"tags":["Internal"],"summary":"Runner job","description":"Run token only. Marks the run `running` and returns the job with decrypted env vars and presigned upload URLs. Fetching again while the run is active returns the same job; 409 once the run is final.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Job","content":{"application/json":{"schema":{"type":"object","properties":{"run_id":{"type":"string","format":"uuid"},"monitor_id":{"type":"string","format":"uuid"},"region":{"type":"string","enum":["iad","fra","sin"]},"script":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"timeout_ms":{"type":"integer","exclusiveMinimum":0},"extra_http_headers":{"type":"object","additionalProperties":{"type":"string"}},"user_agent_suffix":{"type":"string"},"uploads":{"type":"object","properties":{"trace_url":{"type":"string","format":"uri"},"screenshot_url":{"type":"string","format":"uri"}},"required":["trace_url","screenshot_url"]}},"required":["run_id","monitor_id","region","script","env","timeout_ms","extra_http_headers","user_agent_suffix","uploads"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/runs/{id}/result":{"post":{"tags":["Internal"],"summary":"Runner result","description":"Run token only. Stores the result once; a repeat for a finished run returns 409 (the runner treats 2xx and 409 as stored). Then updates the monitor and runs the alerting logic.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["passed","failed"]},"duration_ms":{"type":"integer","minimum":0},"started_at":{"type":"string","format":"date-time"},"finished_at":{"type":"string","format":"date-time"},"error_message":{"type":["string","null"]},"steps":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"duration_ms":{"type":"integer","minimum":0},"status":{"type":"string","enum":["passed","failed","skipped"]},"error":{"type":["string","null"]}},"required":["title","duration_ms","status","error"]},"maxItems":500},"logs":{"type":"string"},"artifacts":{"type":"object","properties":{"trace":{"type":"boolean"},"screenshot":{"type":"boolean"}},"required":["trace","screenshot"]}},"required":["status","duration_ms","started_at","finished_at","error_message","steps","logs","artifacts"]}}}},"responses":{"200":{"description":"Stored","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/runs/{id}/artifacts":{"get":{"tags":["Runs"],"summary":"Artifact download URLs","description":"Short-lived (5 minute) signed URLs for the Playwright trace and the final screenshot, kept only for failed runs. A URL is null when the artifact does not exist. Traces can contain values typed into pages, including secrets: share them with care.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Signed URLs","content":{"application/json":{"schema":{"type":"object","properties":{"trace_url":{"type":["string","null"],"format":"uri"},"screenshot_url":{"type":["string","null"],"format":"uri"},"expires_at":{"type":"string","format":"date-time"}},"required":["trace_url","screenshot_url","expires_at"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/billing":{"get":{"tags":["Billing"],"summary":"Plan, items, quantities, next invoice estimate, limits and usage","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Billing overview","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"unit_amount_cents":{"type":"integer","minimum":0}},"required":["item","quantity","unit_amount_cents"]}},"recurring_amount_cents":{"type":"integer","minimum":0},"next_invoice":{"type":["object","null"],"properties":{"amount_due_cents":{"type":"integer"},"currency":{"type":"string"},"period_end":{"type":["string","null"],"format":"date-time"}},"required":["amount_due_cents","currency","period_end"]},"limits":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"max_monitors":{"type":["integer","null"]},"included_monitors":{"type":"integer"},"allowed_intervals":{"type":"array","items":{"type":"integer"}},"retention_days":{"type":"integer"},"manual_runs_per_month":{"type":"integer"},"sms_per_month":{"type":"integer"}},"required":["plan","max_monitors","included_monitors","allowed_intervals","retention_days","manual_runs_per_month","sms_per_month"]},"usage":{"type":"object","properties":{"month":{"type":"string","format":"date"},"monitors":{"type":"integer","minimum":0},"manual_runs":{"type":"integer","minimum":0},"sms_sent":{"type":"integer","minimum":0}},"required":["month","monitors","manual_runs","sms_sent"]}},"required":["plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","items","recurring_amount_cents","next_invoice","limits","usage"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/billing/checkout":{"post":{"tags":["Billing"],"summary":"Start a subscription with Stripe Checkout","description":"Returns a Stripe hosted Checkout URL for the base plan plus the add-ons the org's current monitors need. Tax is calculated by Stripe Tax.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"interval":{"type":"string","enum":["month","year"]}},"required":["interval"]}}}},"responses":{"200":{"description":"Checkout URL","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/billing/portal":{"post":{"tags":["Billing"],"summary":"Open the Stripe Customer Portal (payment methods, invoices, cancellation)","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Portal URL","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/billing/cancel":{"post":{"tags":["Billing"],"summary":"Cancel the subscription at the end of the current period","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Billing after the change","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"unit_amount_cents":{"type":"integer","minimum":0}},"required":["item","quantity","unit_amount_cents"]}},"recurring_amount_cents":{"type":"integer","minimum":0},"next_invoice":{"type":["object","null"],"properties":{"amount_due_cents":{"type":"integer"},"currency":{"type":"string"},"period_end":{"type":["string","null"],"format":"date-time"}},"required":["amount_due_cents","currency","period_end"]},"limits":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"max_monitors":{"type":["integer","null"]},"included_monitors":{"type":"integer"},"allowed_intervals":{"type":"array","items":{"type":"integer"}},"retention_days":{"type":"integer"},"manual_runs_per_month":{"type":"integer"},"sms_per_month":{"type":"integer"}},"required":["plan","max_monitors","included_monitors","allowed_intervals","retention_days","manual_runs_per_month","sms_per_month"]},"usage":{"type":"object","properties":{"month":{"type":"string","format":"date"},"monitors":{"type":"integer","minimum":0},"manual_runs":{"type":"integer","minimum":0},"sms_sent":{"type":"integer","minimum":0}},"required":["month","monitors","manual_runs","sms_sent"]}},"required":["plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","items","recurring_amount_cents","next_invoice","limits","usage"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/v1/billing/resume":{"post":{"tags":["Billing"],"summary":"Undo a pending cancellation","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Billing after the change","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"billing_interval":{"type":["string","null"],"enum":["month","year",null]},"billing_status":{"type":"string","enum":["none","active","past_due","canceled"]},"grace_until":{"type":["string","null"],"format":"date-time"},"current_period_end":{"type":["string","null"],"format":"date-time"},"cancel_at_period_end":{"type":"boolean"},"items":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string","enum":["base","monitor_15m","monitor_5m","monitor_1m"]},"quantity":{"type":"integer","minimum":0},"unit_amount_cents":{"type":"integer","minimum":0}},"required":["item","quantity","unit_amount_cents"]}},"recurring_amount_cents":{"type":"integer","minimum":0},"next_invoice":{"type":["object","null"],"properties":{"amount_due_cents":{"type":"integer"},"currency":{"type":"string"},"period_end":{"type":["string","null"],"format":"date-time"}},"required":["amount_due_cents","currency","period_end"]},"limits":{"type":"object","properties":{"plan":{"type":"string","enum":["free","paid"]},"max_monitors":{"type":["integer","null"]},"included_monitors":{"type":"integer"},"allowed_intervals":{"type":"array","items":{"type":"integer"}},"retention_days":{"type":"integer"},"manual_runs_per_month":{"type":"integer"},"sms_per_month":{"type":"integer"}},"required":["plan","max_monitors","included_monitors","allowed_intervals","retention_days","manual_runs_per_month","sms_per_month"]},"usage":{"type":"object","properties":{"month":{"type":"string","format":"date"},"monitors":{"type":"integer","minimum":0},"manual_runs":{"type":"integer","minimum":0},"sms_sent":{"type":"integer","minimum":0}},"required":["month","monitors","manual_runs","sms_sent"]}},"required":["plan","billing_interval","billing_status","grace_until","current_period_end","cancel_at_period_end","items","recurring_amount_cents","next_invoice","limits","usage"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"403":{"description":"Not allowed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/webhooks/stripe":{"post":{"tags":["Billing"],"summary":"Stripe webhook receiver","description":"Verified with the Stripe-Signature header against the raw body. Idempotent per event id.","responses":{"200":{"description":"Event accepted","content":{"application/json":{"schema":{"type":"object","properties":{"received":{"type":"boolean","enum":[true]},"duplicate":{"type":"boolean"}},"required":["received","duplicate"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}},"/internal/billing/enforce":{"post":{"tags":["Internal"],"summary":"Apply grace period expiry (pg_cron, hourly)","responses":{"200":{"description":"What was paused","content":{"application/json":{"schema":{"type":"object","properties":{"paused_orgs":{"type":"integer","minimum":0},"paused_monitors":{"type":"integer","minimum":0}},"required":["paused_orgs","paused_monitors"]}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]}}}}}}}},"webhooks":{}}