{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lastping-dev/json-schema/lastping-dev-check-patch-schema.json",
  "title": "CheckPatch",
  "description": "Body for updating a check (PATCH /api/v1/checks/{id}), using JSON Merge\nPatch semantics (RFC 7396).\n\nThis is deliberately NOT `CheckCreate`: on create an omitted field means\n\"use the default\", so `name` is required and nothing is nullable; on\nupdate an omitted field means \"leave the stored value unchanged\", and\nan explicit `null` is the only way to clear a value.\n\n- **No field is required** — a body may contain a single key.\n- **Omitted field** — the stored value is left unchanged.\n- **Explicit `null`** — clears the value. Accepted only by\n  `runaway_ceiling`, `max_runtime_s`, `step_timeout_s`,\n  `blocked_timeout_s`, `expect_every_s`, `notify_min_run_s`,\n  `monitor_from`, `ci_workflow`, `ci_branch`,\n  `tags`, `agent_id`, `source_kind` and `source_ref`; those are the\n  thirteen properties typed to\n  allow `null` below. `ci_workflow`, `ci_branch`, `source_kind` and\n  `source_ref` treat an explicit empty string `\"\"` as **omission**, not\n  as a clear — see the operation description for `PATCH\n  /api/v1/checks/{id}`. For `agent_id`, explicit `null` detaches the monitor\n  from its agent — it does not delete the agent or the monitor. For\n  `blocked_timeout_s`, explicit `null` does NOT mean \"wait forever\" —\n  it restores the fallback to the default (24h),\n  same as omitting the field entirely. `source_kind` and `source_ref`\n  are cleared as a PAIR — nulling one alone is a 400\n  (`SOURCE_INCOMPLETE`), because half a discovery identity reconciles\n  against nothing.\n- **Any other value** — replaces the stored value.\n\n`slug`, `monitor_type` and `ci_secret` are immutable on update and are\nignored if present.\n\n`ci_provider` is immutable too, but it is **not** ignored: it is not a\nmember of this schema, so shape validation sees it.  On a monitor that\nalready has a CI binding it is part of the shape and accepted as a\nno-op; on a monitor with **no** binding the shape is `heartbeat`, which\ndoes not declare it, so `{\"ci_provider\":\"github\"}` is rejected with 400\n(`FIELD_NOT_IN_SHAPE`).  Rebinding a monitor to a CI system means\ndeleting and recreating it; PATCH was never able to do it, and now\nsays so instead of returning 200 as though it had.\n\n**Every field you send is validated against the monitor's SHAPE**, the\nsame way it is on create: a field the stored `monitor_type` and the\nresulting `schedule_kind` have no place for is rejected with 400\n(`FIELD_NOT_IN_SHAPE`) rather than merged and discarded.  So\n`schedule_kind`/`period_s`/`cron_expr`/`tz` are refused on an `http`\nmonitor (its schedule is re-derived from `probe_interval_s` on every\nPATCH) and `ci_workflow`/`ci_branch` are refused on a monitor with no\n`ci_provider` bound.\n\nThis is keyed off **what you send**, never off the stored row: `null`,\n`\"\"`, `0`, `false` and empty collections carry no intent and are\nignored, so a client that PATCHes a full document — an explicit `null`\nfor every clearable field, `\"\"` for every unset string — keeps applying\ncleanly, and no stored value can strand a monitor on a later rename.\n\n**A value equal to the one `GET` already reports is also ignored.**  A\nmonitor whose `probe_timeout_s` is 10 accepts `{\"probe_timeout_s\": 10}`\nwhatever its type: the request asks for no change, so nothing can be\naccepted and discarded.  This matters because every monitor carries\nprobe defaults (`probe_method` `\"GET\"`, `probe_expected_status`\n200, `probe_timeout_s` 10, `probe_follow_redirects` `true`) that a `GET`\nreturns for **every** monitor type, and a client that round-trips a `GET`\ninto a `PATCH` — Terraform does exactly this, carrying prior state into\nthe plan for every attribute the configuration leaves unset — would\notherwise be refused over keys it never chose.  A value that **differs**\nfrom the stored one is still rejected, and `POST /api/v1/checks` has no\nsuch tolerance: on create there is nothing to echo.\n\nThe schedule kind is the **merged** one, so a PATCH that switches a\nmonitor from `simple` to `cron` is validated against `cron` and may\ncarry `cron_expr`.\n",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lastping-dev-openapi.yaml#/components/schemas/CheckPatch",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 200,
      "description": "Human-readable name for the check. A new name must be at most 200\ncharacters (not bytes) and free of control and invisible\ncharacters (400 `INVALID_NAME`); sending the stored name unchanged\nis always accepted. Bytes that are not valid UTF-8 are\nreplaced with U+FFFD when the request is decoded, and accepted.\n"
    },
    "schedule_kind": {
      "type": "string",
      "enum": [
        "simple",
        "cron",
        "on_demand"
      ],
      "description": "`simple` uses a fixed period; `cron` uses a cron expression;\n`on_demand` means the check has no cadence at all — it is driven\nentirely by run events, never arms an absence deadline, and\nsilence between runs never alerts. Run-scoped detection\n(`max_runtime_s`, `step_timeout_s`) still applies once a run\nstarts, and `expect_every_s` — the silence floor — is the only way\nto detect absence between runs.\nIgnored when the monitor's type is `http` (schedule is driven by\n`probe_interval_s`).\n"
    },
    "period_s": {
      "type": "integer",
      "format": "int64",
      "description": "Expected ping interval in seconds.  Applies when schedule_kind is `simple`.\n\n**Must be absent when the resolved schedule_kind is `on_demand`**\n— sending it in the same request that sets (or leaves) the check\nat `on_demand` is rejected with 400 (`ON_DEMAND_SCHEDULE_CONFLICT`).\n"
    },
    "cron_expr": {
      "type": "string",
      "description": "Cron expression (5-field).  Applies when schedule_kind is `cron`.\n\n**Must be absent when the resolved schedule_kind is `on_demand`**\n— sending it in the same request that sets (or leaves) the check\nat `on_demand` is rejected with 400 (`ON_DEMAND_SCHEDULE_CONFLICT`).\n"
    },
    "tz": {
      "type": "string",
      "description": "IANA timezone for cron evaluation."
    },
    "grace_s": {
      "type": "integer",
      "format": "int64",
      "description": "Grace period in seconds after a ping is due before the check is\nconsidered late.  For an `http` monitor the effective grace is\nderived as 2 × `probe_interval_s`; a larger explicit `grace_s` sent\nin the same request is honoured instead.\n\n`grace_s` is the silence tolerance and the first-run deadline; the\noverrun deadline uses `max_runtime_s` when that is set.\n"
    },
    "max_runtime_s": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 60,
      "maximum": 31536000,
      "description": "Run-duration budget in seconds for the **overrun deadline only**;\nthe silence rule and the first-run seed keep using `grace_s`.\nTime a run spends `blocked` does not count toward it.\n\nExplicit `null` clears it, restoring the fallback to `grace_s`;\nomitting the field leaves it as stored.\n\n**Rejected with 400 (`MAX_RUNTIME_NOT_SUPPORTED`) on an `http`\nmonitor** when sent with a non-null value — an HTTP probe has no\nstart/success pair, so the overrun rule can never fire.  An\nexplicit `null` on an `http` monitor is accepted as a no-op.\n"
    },
    "step_timeout_s": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 10,
      "maximum": 86400,
      "description": "Progress budget in seconds for the **stall rule only**.\n\nExplicit `null` disables stall detection; omitting the field leaves\nit as stored.\n\nStall detection needs your job to call /step: the Claude Code hook\nand the reporting prompt do not send steps, so leave step_timeout_s\nunset for them.\n\nThe merged value must stay strictly below the merged effective run\nbudget `COALESCE(max_runtime_s, grace_s)`, and this is checked from\nBOTH directions: a PATCH that only raises `grace_s`, or only clears\n`max_runtime_s`, is rejected with 400\n(`STEP_TIMEOUT_EXCEEDS_BUDGET`) when it would push the stored\n`step_timeout_s` out of the window.\n\n**Rejected with 400 (`STEP_TIMEOUT_NOT_SUPPORTED`) on an `http`\nmonitor** when sent with a non-null value.  An explicit `null` on an\n`http` monitor is accepted as a no-op.\n"
    },
    "expect_every_s": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 60,
      "maximum": 31536000,
      "description": "**Silence floor** in seconds: alert if no ping of any kind arrives\nwithin this window, regardless of the schedule.\n\nExplicit `null` turns the floor off; omitting the field leaves it\nas stored.  On an `on_demand` monitor, clearing it returns the\nmonitor to arming **no absence deadlines at all** between runs.\n\nAccepted on every `monitor_type`, including `http`.\n"
    },
    "notify_min_run_s": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 60,
      "maximum": 31536000,
      "description": "**Notification duration floor**: a run shorter than this many\nseconds does not produce an INFO-CLASS notification (`success`,\n`started`, `every-run`, `note`). Never suppresses `down`, `fail`,\n`recovery` or `blocked`, and never suppresses `started` or an\nevent whose duration is unknown.\n\nExplicit `null` turns the floor off; omitting the field leaves it\nas stored.\n\n**Rejected with 400 (`NOTIFY_MIN_RUN_NOT_SUPPORTED`) on an `http`\nmonitor** when sent with a non-null value — an HTTP probe has no\nstart/success pair, so its run duration is never measured. An\nexplicit `null` on an `http` monitor is accepted as a no-op.\n"
    },
    "blocked_timeout_s": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "How long (in seconds) a check may sit `blocked` before a `blocked`\nincident opens.\n\n**Explicit `null` does NOT mean \"wait forever\"** — it clears the\nstored value and falls back to the default\n(24 hours), same as omitting the field on a check that never set\nit. There is no way to disable the blocked timeout entirely.\n\nAccepted on every `monitor_type`, including `http`.\n"
    },
    "failure_threshold": {
      "type": "integer",
      "format": "int64",
      "minimum": 1,
      "maximum": 100,
      "description": "Consecutive explicit failures required before an incident opens.\nApplies to the `fail` cause ONLY — `silence`, `overrun`,\n`never_started`, `runaway`, `stalled` and `blocked` are time- or\nrate-based and are never gated by it.  A run that ends on the\nmodel provider's API error (`upstream`) neither counts toward it\nnor resets it: those page on their own count of runs in a row,\nwhich is 3 or this threshold, whichever is higher.\n\nNot nullable: it always has a value (default 1), so there is no\n\"unset\" state to return to.  An omitted field (or an explicit\n`null`, treated the same as omission) leaves the stored value\nunchanged.\n\n**Changing it does NOT reset `consecutive_failures`.**  With the\ncounter at 3 and the threshold lowered from 5 to 2, the very next\nfailure opens an incident.  This is deliberate: the counter is a\nfactual record of failures that really happened, and lowering the\nthreshold means \"that many is now enough\" — resetting would discard\ntrue information.  Raising it likewise keeps the counter, so a\nmonitor already past the new threshold alerts on its next failure.\n"
    },
    "success_threshold": {
      "type": "integer",
      "format": "int64",
      "minimum": 1,
      "maximum": 10,
      "description": "Successes in a row a monitor down on a failure needs before its\nincident closes (1 to 10); other incidents close on the first\nsuccess.  Not nullable: an omitted field, or an explicit\n`null` treated the same as omission, leaves the stored value\nunchanged.  Changing it keeps the successes already counted.  An\nout-of-range value is a 400 with code `INVALID_SUCCESS_THRESHOLD`.\n"
    },
    "remind_every": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 900,
      "maximum": 604800,
      "description": "Seconds between reminders while an incident stays open (900 to\n604800).  An explicit `null` turns reminders off; an omitted\nfield leaves the stored value unchanged.  A value out of range,\nor not a whole number, is a 400 with code `INVALID_REMIND_EVERY`.\nAn incident already open keeps the reminders it has sent and\nfollows the new interval from its last one.\n"
    },
    "max_reminders": {
      "type": "integer",
      "format": "int64",
      "minimum": 1,
      "maximum": 100,
      "description": "The most reminders one incident sends (1 to 100).  Not nullable:\nan omitted field, or `null`, leaves the stored value unchanged.\nAn out-of-range value is a 400 with code `INVALID_MAX_REMINDERS`.\n"
    },
    "cert_expiry_days": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 90
      },
      "maxItems": 4,
      "uniqueItems": true,
      "description": "Days before the TLS certificate expires to warn, for `http`\nmonitors with an `https` URL only (ignored on every other kind\nof monitor), up to 4 different whole numbers from 1 to 90.  A list replaces\nthe stored one, `[]` turns the warnings off, and an omitted field\nor `null` leaves it unchanged.  Any other value is a 400 with code\n`INVALID_CERT_EXPIRY_DAYS`.  Thresholds already warned for the\ncurrent certificate are not warned again.\n"
    },
    "domain_expiry_days": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 90
      },
      "maxItems": 4,
      "uniqueItems": true,
      "description": "Days before the domain registration expires to warn, for `http`\nmonitors only (ignored on every other kind of monitor), with the\nsame rules as `cert_expiry_days`.  Any other value is a\n400 with code `INVALID_DOMAIN_EXPIRY_DAYS`.\n"
    },
    "monitor_from": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "RFC 3339 timestamp.  Deadlines are not computed before this time.\nExplicit `null` clears it.\n"
    },
    "probe_url": {
      "type": "string",
      "format": "uri",
      "description": "Absolute `http` or `https` URL for LastPing to probe (`http` monitors).\n**Must not carry a username or password** (`https://user:pass@host`):\none is rejected with 400 (`PROBE_URL_HAS_CREDENTIALS`), since it would\nbe stored and shown in the clear.\n"
    },
    "probe_method": {
      "type": "string",
      "enum": [
        "GET",
        "HEAD",
        "POST"
      ],
      "description": "HTTP method for the probe request."
    },
    "probe_expected_body": {
      "type": "string",
      "description": "Substring that must appear in the response body for the probe to be\nconsidered successful.  Send `\"\"` to skip body matching.\n"
    },
    "probe_interval_s": {
      "type": "integer",
      "format": "int64",
      "description": "How often (in seconds) LastPing should probe the URL.\nMust be between 30 and 86400.\n"
    },
    "probe_expected_status": {
      "type": "integer",
      "format": "int64",
      "description": "HTTP status code the probe must receive to count as success.\n`0` means \"any 2xx response counts as success\".\n"
    },
    "probe_timeout_s": {
      "type": "integer",
      "format": "int64",
      "description": "Probe HTTP request timeout in seconds.  Must be between 1 and 30."
    },
    "probe_follow_redirects": {
      "type": "boolean",
      "description": "Whether the probe should follow HTTP redirects."
    },
    "ci_workflow": {
      "type": [
        "string",
        "null"
      ],
      "description": "CI workflow name to filter inbound webhooks by (provider-specific).\nDeliberately deviates from strict RFC 7396: an explicit empty string\n`\"\"` preserves the stored value, the same as omitting the field, so\nthat full-body clients (e.g. Terraform) which always send `\"\"` for an\nunset filter cannot silently unbind a live filter.  Explicit `null`\nclears it.\n"
    },
    "ci_branch": {
      "type": [
        "string",
        "null"
      ],
      "description": "Branch name to filter inbound webhooks by.  Same empty-string\npreservation rule as `ci_workflow`; explicit `null` clears it.\n"
    },
    "runaway_ceiling": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Maximum pings allowed in a rolling 1-hour window. Exceeding it opens a\n`runaway`-cause incident, which detects a looping agent or job pinging\nabnormally fast.  Explicit `null` disables the check; omitting the\nfield leaves it as stored.\n"
    },
    "tags": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "maxItems": 20,
      "description": "Labels for namespace scoping and auditing.  Replaced wholesale, not\nmerged. Max 20 tags; each tag max 50 characters. Duplicate tags are\nsilently deduplicated.  Send `[]` or `null` to remove all tags;\nomitting the field leaves the stored tags alone.\n"
    },
    "agent_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The agent that owns this monitor, by `id` or `slug`. Omitting the\nfield preserves the current attachment; an explicit `null`\ndetaches the monitor (sets its `agent_id` to null) without\ndeleting anything; any other non-empty value re-attaches it,\nresolved fresh on every request. An explicit empty string `\"\"`\nis rejected with 400 — unlike `ci_workflow`/`ci_branch`, it is\nNOT treated as \"leave unchanged\"; omit the field or send `null`\ninstead.\n\n**An unknown or foreign agent reference is rejected with 400\n(`UNKNOWN_AGENT`)** and never implicitly creates the agent.\n"
    },
    "source_kind": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 64,
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "description": "The scanner that discovered this monitor. Omitting the field —\n**or sending an explicit empty string `\"\"`** — leaves the stored\nvalue alone; only an explicit `null` clears it, and only together\nwith `source_ref`.\n\nThe `\"\"`-preserves rule matches `ci_workflow`/`ci_branch` and\nexists for the same full-body clients, with a sharper consequence:\nevery other clearable field here is a *setting*, but this pair is\nan *identity*. A source cleared by accident is a monitor the next\ndiscovery scan no longer recognises, so the scan reports the source\nas unmonitored and creates a **second** monitor for it — the exact\nduplicate the reconcile key exists to prevent.\n\n**PATCH is the only surface that can change a monitor's source\nafter create.** That is deliberate: a slug upsert body cannot tell\n\"omitted\" from \"clear\", so allowing it to write here would let a\nslug collision silently adopt a hand-made monitor into discovery.\nA PATCH names a specific monitor and a specific field, which makes\nadoption an explicit act — and is exactly what Terraform's\nimport-then-apply flow performs.\n"
    },
    "source_ref": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 512,
      "description": "The stable path within `source_kind`. Same merge-patch rules as\n`source_kind` above.\n\n**The two are resolved as a pair.** Whatever the request and the\nstored row combine to, the result must be either both set or both\nempty — `{\"source_ref\": null}` alone is rejected with 400\n(`SOURCE_INCOMPLETE`), not applied as a half-cleared identity.\n**Clearing therefore takes an explicit `null` on both keys.**\n\nA pair another monitor in this project already claims is rejected\nwith 409 (`SOURCE_ALREADY_MONITORED`): two monitors reconciling to\none source would make every later discovery run ambiguous.\n\nA PATCH that mentions neither key issues no source write at all, so\na discovered monitor cannot lose its identity to an unrelated edit\nsuch as a rename.\n"
    },
    "trace_content": {
      "type": "string",
      "enum": [
        "redacted",
        "dropped"
      ],
      "description": "What this monitor's traces keep of prompt, command and tool\ncontent. `dropped` (the default) removes the content attributes\n(prompts, completions, commands, tool arguments, results and\ndefinitions, retrieved documents, working directories) of every\nrecognised vocabulary entirely; lengths such as\n`user_prompt_length`, token counts and cost are kept. Error text\n(`error`, `error.message`, `exception.message`,\n`exception.stacktrace` and the span's status message) is kept at\n`dropped`, redacted and then cut to 512 characters, and a cut\nmarks the span or log event truncated. `redacted`\nopts in to storing that content, with every secret-shaped value\nreplaced by `[REDACTED:<class>]` at ingest, before anything is\nqueued or stored: API keys (LastPing, Anthropic, OpenAI, GitHub,\nGitLab, npm, AWS access key ids, Slack, Stripe, Google, Hugging\nFace, Perplexity, Fireworks, Supabase, New Relic, Airtable,\nTerraform Cloud, Firebase), HashiCorp Vault tokens, age secret\nkeys, Discord bot tokens, Slack, Discord and Teams webhook URLs,\n`Authorization` header values, JWTs, private key blocks,\n`password=`/`token=`/`api_key=` style assignments (subscripted\nones such as `os.environ[\"API_KEY\"] = ...` and Dockerfile\n`ENV`/`ARG` lines included), SQL `PASSWORD '...'` and\n`IDENTIFIED BY` clauses, the Redis `AUTH` command, `.netrc`\npasswords, command-line password flags and the argument after\nthem (any secret-named `--flag`, `-p` after a login subcommand,\n`redis-cli -a`), cookies, credentials in URLs, the value of any\nattribute or JSON field whose name is secret-named (password,\ntoken, api_key, secret, the same word in several other\nlanguages, an `Authorization` or `X-Api-Key` header and the\nlike; `Idempotency-Key` and request, correlation and trace ids\nare not secrets), including JSON carried inside another JSON\nstring such as tool-call arguments, and long high-entropy\ntokens. A bytes attribute that is valid UTF-8 is scanned and\nstored as its text. A span that had a value redacted carries\n`lastping.redacted_values`. A request whose\nredaction work exceeds a fixed budget stores\n`[REDACTED:over_budget]` for the values it could not scan, never\nthe values themselves. In both modes every remaining value is\nredacted the same way. There is no setting that stores content\nunredacted. A change reaches ingest within 60 seconds: ingest\ncaches each monitor's setting for up to a minute, so an export\nsent just after the change may still be handled the old way.\n\nAbsent leaves the stored value alone. `null` and any other value\nare rejected with 400 (`INVALID_TRACE_CONTENT`): the setting has no\nunset state. A change reaches the ingest host within a minute.\n"
    },
    "split_by_repo": {
      "type": "boolean",
      "description": "Whether runs from a hook (Claude Code, Codex, Antigravity) are\nfiled under one monitor per git repository (see the Check\nschema). True splits from the next run on; false files every\nnew run on this monitor again and deletes nothing: the\nrepository monitors keep their history, and a run already open\non one ends there. Absent leaves it alone, and so does the value\nthe monitor already has, which is always accepted. A change is\nrejected with 400 (`SPLIT_BY_REPO_ON_CHILD`) on a repository's\nown monitor, and with 400 (`SPLIT_BY_REPO_NOT_ON_DEMAND`) on a\nmonitor that is on_demand neither before nor after the request\n(scheduled, HTTP or CI). `null` is\nrejected with 400 (`INVALID_SPLIT_BY_REPO`).\n"
    }
  }
}