API reference
Manage monitors, incidents, alert channels and status pages programmatically. The API is JSON over HTTPS.
Getting started
Base URL: https://openuptime.app/api
Create an API key in the app under API keys, then send it with every request, either as an x-api-key header or as Authorization: Bearer <key>. A key belongs to one workspace and can optionally be limited to specific projects.
curl https://openuptime.app/api/monitors \
-H "x-api-key: ou_..."Connecting an AI agent? See the MCP guide.
Project scoping
Most resources live in a project. Choose the project with the x-project-id header (a project id from GET /projects). If it is missing or unknown, the key's first permitted project, or else the workspace's oldest project, is used. A key limited to some projects gets 403 for others.
Errors
Errors return a JSON body { "error": "message" } with a matching status: 400 invalid request, 401 missing or invalid credentials, 403 not permitted, 404 not found or not in your project, 409 conflict, 429 too many requests, 5xx server error. Request bodies that fail validation return 400 with a JSON description of the invalid fields. Deletes return 204 with no body. Timestamps are ISO 8601 UTC; ids are UUIDs.
Rate limiting
Authenticated endpoints have no fixed per-key quota at the application level, but please be considerate and avoid tight polling; use the monitor's interval and alert channels instead. Public subscription requests are limited (see below).
Examples
Create a monitor
curl -X POST https://openuptime.app/api/monitors \
-H "x-api-key: ou_..." \
-H "x-project-id: <project id>" \
-H "content-type: application/json" \
-d '{"name":"Homepage","type":"http","target":"https://example.com","intervalSec":60}'List monitors
curl https://openuptime.app/api/monitors \
-H "Authorization: Bearer ou_..."Send a heartbeat ping
Create a monitor with "type":"heartbeat" and call its URL from your job. No API key is needed; the token is the secret. Use GET or POST.
curl https://openuptime.app/api/heartbeat/<heartbeatToken>Returns {"ok":true}, or 404 for an unknown token. A ping resolves an open incident for that monitor.
API 参考
通过程序管理监控项、事件、告警渠道和状态页。API 基于 HTTPS 与 JSON。
快速开始
基础地址:https://openuptime.app/api
在应用的 API 密钥 页面创建密钥,并在每个请求中携带:使用 x-api-key 请求头,或 Authorization: Bearer <key>。密钥属于某个工作区,并可限定到特定项目。
curl https://openuptime.app/api/monitors \
-H "x-api-key: ou_..."要接入 AI Agent?请看 MCP 文档。
项目范围
大多数资源属于某个项目。通过 x-project-id 请求头指定项目(取自 GET /projects 的项目 id)。缺失或无效时,使用该密钥被授权的第一个项目,否则使用工作区最早创建的项目。受限密钥访问其他项目将返回 403。
错误
错误响应为 JSON { "error": "message" },并带有对应状态码:400 请求无效,401 缺少或无效的凭证,403 无权限,404 不存在或不在你的项目内,409 冲突,429 请求过多,5xx 服务器错误。请求体校验失败返回 400 及无效字段的 JSON 描述。删除成功返回 204,无响应体。时间为 ISO 8601 UTC,id 为 UUID。
限流
需认证的接口在应用层没有固定的按密钥配额,但请合理使用,避免高频轮询;建议依靠监控项的检测间隔和告警渠道。公开的订阅接口有限流(见下文)。
示例
创建监控项
curl -X POST https://openuptime.app/api/monitors \
-H "x-api-key: ou_..." \
-H "x-project-id: <project id>" \
-H "content-type: application/json" \
-d '{"name":"Homepage","type":"http","target":"https://example.com","intervalSec":60}'列出监控项
curl https://openuptime.app/api/monitors \
-H "Authorization: Bearer ou_..."发送心跳
创建 "type":"heartbeat" 的监控项,并在你的任务中请求其地址。无需 API 密钥,令牌本身即是凭证。可使用 GET 或 POST。
curl https://openuptime.app/api/heartbeat/<heartbeatToken>成功返回 {"ok":true},令牌无效返回 404。收到心跳会关闭该监控项未结束的事件。
Monitors监控项
/monitorsList the project's monitors, with 24-hour uptime, average latency and a latency sparkline.列出当前项目的监控项,附带 24 小时可用率、平均延迟和延迟走势。
[{ id, name, type, target, method, expectedStatus, intervalSec, timeoutMs, failureThreshold, regions,
status, consecutiveFailures, lastCheckedAt, nextCheckAt, paused, heartbeatToken, keyword, keywordMode,
headers, graceSec, ..., uptime24h, avgLatency24h, spark }]/monitorsCreate a monitor. Omitted fields take their defaults. Returns 201 with the monitor; heartbeat monitors get a heartbeatToken.创建监控项,省略的字段使用默认值。返回 201 和监控项;心跳类型会生成 heartbeatToken。
name string, 1-120 chars (required)
type "http" | "tcp" | "dns" | "heartbeat" | "postgres" | "mysql" | "redis" (default "http"; cannot be changed later)
target string, max 2048 (URL for http, host:port for tcp/postgres/mysql/redis, hostname for dns)
method "GET" | "HEAD" | "POST" (default "GET")
expectedStatus integer 100-599 (default 200)
intervalSec integer 60-86400 (default 60)
timeoutMs integer 1000-30000 (default 10000)
failureThreshold integer 1-10 consecutive failures before an incident opens (default 3)
regions string[] (default ["auto"])
keyword string | null, max 500 (default null)
keywordMode "contains" | "absent" (default "contains")
headers { [name: string]: string } (default {})
graceSec integer 0-86400, heartbeat grace period (default 0)
channelIds uuid[], max 50 (default [])
tags string[], max 20 items of up to 32 chars (default [])
slowThresholdMs integer 100-60000, latency above this marks the monitor "degraded" (default 1500)
slowAlertAfter integer 0-20, open a latency incident after this many consecutive slow checks; 0 = never (default 0)/monitors/exportDownload the project's monitors as JSON ({ version, exportedAt, monitors }). Request headers are included, so treat the file as sensitive.以 JSON 导出当前项目的监控项({ version, exportedAt, monitors })。文件包含请求头,请当作敏感文件保管。
/monitors/importCreate monitors from a JSON array (or an object with a monitors array), up to 500 per call. Accepts our export plus common aliases from other tools (name/friendly_name, target/url/hostname, interval in seconds, type https/keyword/port). Invalid items are skipped and reported; returns 201 { created, skipped: [{ index, name, error }] }, or 400 when nothing was created.从 JSON 数组(或含 monitors 数组的对象)批量创建监控项,单次最多 500 个。支持本产品的导出格式,以及其他工具常见的字段别名(name/friendly_name、target/url/hostname、interval 秒、type https/keyword/port)。无效项会被跳过并返回;成功时 201 { created, skipped: [{ index, name, error }] },一个都没创建时 400。
{ "monitors": [ { "name": "API", "type": "http", "target": "https://api.example.com", "tags": ["prod"] } ] }{ created: 1, skipped: [] }/monitors/:idOne monitor with its last 120 check results, last 5 incidents and stats.获取单个监控项,含最近 120 条检测结果、最近 5 个事件和统计数据。
{ ...monitor, results: [{ id, region, ok, statusCode, latencyMs, error, checkedAt }],
incidents: [...], stats: { uptime24h, uptime7d, avg24h, p95 } }/monitors/:idUpdate the named fields only (same fields as create, except type). Also accepts paused (boolean) to pause or resume. At least one field is required.仅更新传入的字段(与创建相同,但不含 type),另可传 paused(布尔)暂停或恢复。至少需要一个字段。
any of the create fields except "type", plus:
paused boolean/monitors/:idDelete a monitor and its results. Returns 204.删除监控项及其检测结果。返回 204。
/monitors/:id/checkRun a check immediately. Returns { ok: true }.立即执行一次检测。返回 { ok: true }。
Incidents事件
/incidentsThe latest 100 incidents of the project (plus workspace-level incidents not tied to a monitor), newest first.当前项目最新的 100 个事件(含未关联监控项的工作区级事件),按时间倒序。
[{ id, monitorId, title, status, severity, auto, assigneeId, startedAt, acknowledgedAt, resolvedAt, monitorName }]/incidentsOpen an incident manually. Returns 201.手动创建事件。返回 201。
title string, 1-200 (required)
body string, max 4000 first update, optional
severity "minor" | "major" (default "major")
monitorId uuid | null optional/incidents/:idAn incident with its updates, monitor, assignee and up to 8 failing checks.获取事件详情,含更新记录、监控项、负责人和最多 8 条失败检测。
{ ...incident, updates: [{ id, status, body, authorId, createdAt }], monitor, assignee, checks }/incidents/:id/updatesPost an update and set the incident status. Subscribers and alert channels are notified. Status "resolved" closes the incident. Returns 201.发布更新并设置事件状态,并通知订阅者和告警渠道。状态为 "resolved" 时事件关闭。返回 201。
status "investigating" | "identified" | "monitoring" | "resolved"
body string, 1-4000/incidents/:id/ackAcknowledge an incident and assign it to the caller. Returns the incident.确认事件并指派给调用者。返回该事件。
Channels告警渠道
config depends on type: email { to }, slack { url }, lark { url, secret? }, webhook { url }, telegram { botToken, chatId }, pagerduty { routingKey }. Channel configs contain secrets and are returned as stored. A channel with autoEnable is added to the channelIds of every monitor created afterwards (in its project, or in any project for a workspace-wide channel), on top of any ids given; a monitor whose channelIds is empty alerts every enabled channel.config 取决于 type:email { to }、slack { url }、lark { url, secret? }、webhook { url }、telegram { botToken, chatId }、pagerduty { routingKey }。渠道配置含敏感信息,按存储内容原样返回。
/channelsList the alert channels available in the project: workspace-wide ones (projectId null) and the project's own.列出当前项目可用的告警渠道:工作区级渠道(projectId 为 null)和项目自己的渠道。
[{ id, type, name, config, enabled, autoEnable, createdAt, projectId }]/channelsCreate a channel. Returns 201.创建渠道。返回 201。
type "email" | "slack" | "telegram" | "webhook" | "pagerduty" | "lark"
name string, 1-80
config object (default {})
enabled boolean (default true)
autoEnable boolean (default false) new monitors start out alerting this channel
scope "workspace" | "project" (default "workspace"; a project-limited key always creates a project channel)/channels/:idUpdate name, enabled, autoEnable or config.更新名称、启用状态、autoEnable 或配置。
name string, 1-80
enabled boolean
autoEnable boolean
config object/channels/:id/testSend a test message. Returns { ok: true }, or 502 with the delivery error.发送测试消息。成功返回 { ok: true },失败返回 502 及错误信息。
/channels/:idDelete a channel. Returns 204, or 409 (code "channel_in_use", with the monitors) while a monitor still lists it in channelIds.删除渠道。返回 204;仍有监控在 channelIds 中选用它时返回 409(code 为 "channel_in_use",并附监控列表)。
Status pages状态页
/status-pagesList the project's status pages.列出当前项目的状态页。
[{ id, slug, title, theme, showLatency, customDomain, externalUrl, createdAt, projectId }]/status-pagesCreate a status page. The slug must be unused (409 otherwise). Returns 201.创建状态页。slug 不能被占用(否则 409)。返回 201。
slug string, /^[a-z0-9-]{3,40}$/ (required)
title string, 1-120 (required)
externalUrl string | null, http(s) URL up to 2048 (a link shown beside the title, rel=nofollow)
theme "light" | "dark" | "auto"
showLatency boolean
monitorIds uuid[]
components [{ monitorId: uuid, groupName?: string 1-60 }], max 200 (takes precedence over monitorIds)/status-pages/:idA status page with its ordered components.获取状态页及其有序组件。
{ ...page, monitorIds: uuid[], components: [{ monitorId, groupName }] }/status-pages/:idUpdate title, theme, showLatency or replace the components. Slug cannot be changed. Returns { ok: true }.更新标题、主题、延迟显示,或替换组件。slug 不可修改。返回 { ok: true }。
title, theme, showLatency, externalUrl, monitorIds, components (all optional, as in create)/status-pages/:idDelete a status page. Returns 204.删除状态页。返回 204。
/status-pages/:id/subscribersUp to 1000 subscribers, newest first.最多 1000 位订阅者,按时间倒序。
[{ id, email, confirmedAt, createdAt }]/status-pages/:id/subscribers/:sidRemove a subscriber. Returns 204.移除订阅者。返回 204。
Maintenance维护窗口
While a window is active, the monitors it covers keep being checked but open no incidents and send no alerts. An empty monitorIds list covers every monitor in the workspace.维护窗口生效期间,所覆盖的监控项仍会被检测,但不会创建事件或发送告警。monitorIds 为空表示覆盖工作区内所有监控项。
/maintenanceThe project's latest 200 windows, by start time descending.当前项目最新的 200 个维护窗口,按开始时间倒序。
[{ id, name, startsAt, endsAt, monitorIds, createdAt, projectId }]/maintenanceSchedule a window. Returns 201.创建维护窗口。返回 201。
name string, 1-120
startsAt ISO 8601 date-time
endsAt ISO 8601 date-time, after startsAt
monitorIds uuid[], max 500 (default [])/maintenance/:idDelete a window. Returns 204.删除维护窗口。返回 204。
Projects项目
Creating, renaming and deleting projects is not available to API keys that are limited to specific projects (403).限定了特定项目的 API 密钥不能创建、重命名或删除项目(403)。
/projectsThe workspace's projects (only the permitted ones for a limited key).列出工作区的项目(受限密钥只能看到被授权的项目)。
[{ id, name, createdAt }]/projectsCreate a project. Returns 201.创建项目。返回 201。
name string, 1-60/projects/:idRename a project.重命名项目。
name string, 1-60/projects/:idDelete a project and everything in it. A workspace must keep at least one project (400). Returns 204.删除项目及其全部内容。工作区至少保留一个项目(否则 400)。返回 204。
Settings设置
/settingsWorkspace preferences.工作区偏好设置。
{ alertLogRetentionDays: 30, checkRetentionDays: 90 }/settingsUpdate preferences. Not available to project-limited keys (403).更新偏好设置。受限于项目的密钥不可用(403)。
alertLogRetentionDays integer 1-365
checkRetentionDays integer 1-365 (raw check results; hourly rollups are kept for a year)Alert log告警日志
/alert-logAlert delivery history, newest first. Query: limit (1-200, default 50) and before (ISO 8601 date-time cursor, the createdAt of the last row of the previous page).告警投递历史,按时间倒序。查询参数:limit(1-200,默认 50)和 before(ISO 8601 时间游标,取上一页最后一条的 createdAt)。
[{ id, channelId, channelName, channelType, kind, incidentId, monitorName, ok, error, createdAt }]
kind: "incident.opened" | "incident.resolved" | "test" | "subscribers"Me and counts当前用户与计数
/meThe caller, the workspace and the active project.当前调用者、工作区和当前项目。
{ userId, user: { name, email, locale }, organization, projectId }/me/exportDownload everything held about the caller as JSON: profile, sessions and the workspaces they own or administer.以 JSON 下载与调用者相关的全部数据:资料、会话,以及其拥有或管理的工作区内容。
/me/localeSet the language used for emails to this user.设置发给该用户的邮件所使用的语言。
locale "en" | "zh-CN"{ locale }/countsSidebar counts for the active project.当前项目的侧边栏计数。
{ monitors, incidents, "status-pages", alerting }Public status endpoints公开状态接口
These endpoints need no authentication and are what powers public status pages. Paths are under /api/public/status; <slug> is the status page address. Unknown slugs return 404.这些接口无需认证,用于驱动公开状态页。路径位于 /api/public/status 之下,<slug> 为状态页地址。slug 不存在时返回 404。
/api/public/status/<slug>Current status, 90 buckets of uptime history per component (daily, or hourly while history is under four days) and open incidents.当前状态、每个组件 90 个时间桶的可用率历史(按天,历史不足四天时按小时)以及未结束的事件。
{ page: { slug, title, theme, showLatency },
overall: "operational" | "degraded" | "outage",
bucket: "day" | "hour",
components: [{ id, name, group, status, uptime90d, days: [{ day, uptime }] }],
incidents: [{ id, title, status, severity, startedAt, resolvedAt,
updates: [{ id, body, status, createdAt }] }] }/api/public/status/<slug>/incidents?before=<ISO date>Incident history, newest first, 15 per page. Pass the returned next as before to continue; next is null on the last page.事件历史,按时间倒序,每页 15 条。将返回的 next 作为 before 传入即可翻页;最后一页 next 为 null。
{ items: [{ id, title, status, severity, startedAt, resolvedAt, updates: [...] }], next }/api/public/status/<slug>/rssRSS 2.0 feed of the latest 30 incidents (application/rss+xml).最新 30 个事件的 RSS 2.0 订阅源(application/rss+xml)。
/api/public/status/<slug>/subscribeSubscribe an email address to incident updates. A confirmation email is sent; the response is { "ok": true } either way, so it does not reveal who is subscribed. Limited to 10 requests per hour per client IP, 3 per address per page per hour and 200 per page per hour (429), and 5000 subscribers per page (409).订阅事件通知邮件。系统会发送确认邮件;无论是否已订阅,响应都是 { "ok": true },不会泄露订阅情况。限流:每个客户端 IP 每小时 10 次、每个邮箱每个状态页每小时 3 次、每个状态页每小时 200 次(429),每个状态页最多 5000 位订阅者(409)。
{ "email": "you@example.com" }/api/public/status/_/confirm?token=<token>/api/public/status/_/unsubscribe?token=<token>Links used in subscription emails. Both redirect to the status page.订阅邮件中使用的链接,均会重定向到状态页。
Last updated 2026-10-10最后更新:2026-10-10