页面简介
Change a monitor with PATCH /v1/monitors/{id}: send only what changes, or set status to paused or active to pause or resume it.
正文摘录
TypeScriptTypeScriptimport { Keenable } from "keenable"; async function main() { // reads KEENABLE_API_KEY from the environment const client = new Keenable(); const monitor = await client.monitors.update("mon_3kq9z2c8f1a04b7d9e6f5a21", { schedule: { type: "interval", value: "6h" }, }); console.log(monitor.id, monitor.schedule?.type, monitor.schedule?.value); } main(); 200400401403404409429503{ "id": "mon_3kq9z2c8f1a04b7d9e6f5a21", "object": "monitor", "name": "Open-weights LLM releases", "type": "search", "status": "active", "disabled_reason": { "code": "runs_failed", "message": "<string>" }, "search": { "query": "<string>", "max_results": 123, "include_domains": [ "<string>" ], "exclude_domains": [ "<string>" ], "content": { "text": false } }, "page": { "url": "https://example.com/pricing", "watch_for": "price changes and new plans", "sensitivity": "meaningful" }, "schedule": { "type": "cron", "value": "0 9 * * 1-5", "timezone": "Europe/Paris" }, "webhook": { "url": "<string>", "events": [ "monitor.created" ], "secret": "whsec_example" }, "metadata": {}, "last_run_at": "2023-11-07T05:31:56Z", "next_run_at": "2023-11-07T05:31:56Z", "upcoming_runs": [ "2023-11-07T05:31:56Z" ], "created_at": "2023-11-07T05:31:56Z", "updated_at": "2023-11-07T05:31:56Z", "output_schema": {} }PATCH/v1/monitors/{id}Try itTypeScriptTypeScriptimport { Keenable } from "keenable"; async function main() { // reads KEENABLE_API_KEY from the environment const client = new Keenable(); const monitor = await client.monitors.update("mon_3kq9z2c8f1a04b7d9e6f5a21", { schedule: { type: "interval", value: "6h" }, }); console.log(monitor.id, monitor.schedule?.type, monitor.schedule?.value); } main(); 200400401403404409429503{ "id": "mon_3kq9z2c8f1a04b7d9e6f5a21", "object": "monitor", "name": "Open-weights LLM releases", "type": "search", "status": "active", "disabled_reason": { "code": "runs_failed", "message": "<string>" }, "search": { "query": "<string>", "max_results": 123, "include_domains": [ "<string>" ], "exclude_domains": [ "<string>" ], "content": { "text": false } }, "page": { "url": "https://example.com/pricing", "watch_for": "price changes and new plans", "sensitivity": "meaningful" }, "schedule": { "type": "cron", "value": "0 9 * * 1-5", "timezone": "Europe/Paris" }, "webhook": { "url": "<string>", "events": [ "monitor.created" ], "secret": "whsec_example" }, "metadata": {}, "last_run_at": "2023-11-07T05:31:56Z", "next_run_at": "2023-11-07T05:31:56Z", "upcoming_runs": [ "2023-11-07T05:31:56Z" ], "created_at": "2023-11-07T05:31:56Z", "updated_at": "2023-11-07T05:31:56Z", "output_schema": {} }Change a monitor. Send only the fields that change: search, page and webhook are merged into the stored ones, so {"search": {"max_results": 5}} keeps the query. A new page.url deletes the page monitor’s versions and starts a new baseline run. type can’t be changed. To pause a monitor, send {"status": "paused"}. To resume it, or to turn a disabled monitor back on, send {"status": "active"}. Resuming doesn’t start a catch-up run: the monitor runs at the next time its schedule gives. A resume past your organization’s active monitor limit returns 403 with monitor_limit_reached. A page monitor disabled with data_policy can’t be resumed while your organization has zero data retention: the update returns 400 with monitor_option_not_supported. Common changes GoalBodyPause the monitor{"status": "paused"}Resume it, or turn a disabled monitor back on{"status": "active"}Return fewer pages per run, keep the query{"search": {"max_results": 5}}Run every 6 hours{"schedule": {"type": "interval", "value": "6h"}}Run only when triggered{"schedule": null} schedule replaces the stored schedule instead of merging into it. A new once schedule makes a completed monitor active again. Resuming a monitor counts toward your organization’s active monitors. See Limits. Schedules lists the schedule rules and Webhook events lists the event names. When the request adds a webhook to a monitor that had none, the response carries webhook.secret, once, as the create response does. Store it: before this change, such an update returned no secret, so the webhook couldn’t be verified. An update that only changes the url or events of an existing webhook, and every GET, never shows the secret. SDK, CLI and MCP ClientCallPython, TypeScriptclient.monitors.update(monitor_id, ...), pause(monitor_id), resume(monitor_id)Goclient.Monitors.Update(ctx, monitorID, params), Pause, ResumeRustclient.monitors().update(monitor_id, ¶ms), pause, resumeCLIkeenable monitors update <id> with the flags that change, plus --no-schedule and --no-webhook; keenable monitors pause <id> and resume <id>MCPNo tool. Use the API, an SDK or the CLI. The SDK methods need SDK 0.2.0 or later. pause and resume send status for you. See SDKs → Monitors and CLI → Monitors. Related operations Get a monitor shows the stored values before you change them. Bulk actions pauses or resumes many monitors in one request. Delete a monitor removes a monitor for good. AuthorizationsapiKeybearerAuthX-API-KeystringheaderrequiredAPI key for authentication. Obtain one from the Keenable dashboard.Path ParametersidstringrequiredThe monitor's ID, such as mon_3kq9z2c8f1a04b7d9e6f5a21.Bodyapplication/jsonSend only what changes.namestringMaximum string length: 200statusenum<string>paused stops runs. active resumes a paused monitor and turns a disabled one back on; it does not run at once but at the next time its schedule gives. Activating a monitor counts toward the active monitor limit: An organization can have up to 100 active monitors (search and page together); going over returns 403 with monitor_limit_reached.Available options: active, paused searchobjectOnly on a search monitor; on a page monitor it returns 400 with invalid_request.Show child attributespageobjectOnly on a page monitor; on a search monitor it returns 400 with invalid_request.Show child attributesscheduleobjectReplaces the schedule. null removes it. A new once schedule makes a completed monitor active again.Option 1Option 2Show child attributeswebhookobjectMerged into the stored webhook. Send null instead of an object to remove the webhook.Option 1Option 2Show child attributesoutput_schemaobject | nullA JSON Schema for output.structured. The supported subset: object, array, string, number, integer, boolean, enum, nullable, anyOf, properties, items, required and description. The special case {"type": "text"} asks for a plain-text output in output.text instead of a structure. $ref, oneOf, allOf and additionalProperties are refused. At most 16 KB, 6 levels deep and 100 properties. A schema outside these rules returns 400 with invalid_request, and message names the path of the part that broke one. On a search monitor, each run that finds pages returns a summary of them in this shape; on a page monitor, the first run and every run that finds a change return the fields read from the page.metadataobject | nullYour own string tags, at most 50 keys. Every webhook event carries them. For example {"team": "research"}.Show child attributesResponse200application/jsonThe updated monitor. When the request added a webhook to a monitor that had none, it carries webhook.secret, once: store it to verify deliveries.idstringrequiredExample:"mon_3kq9z2c8f1a04b7d9e6f5a21"objectenum<string>requiredAvailable options: monitor namestring | nullrequiredExample:"Open-weights LLM releases"typeenum<string>requiredsearch: new pages on the web about a topic. page: changes to one page.Available options: search, page statusenum<string>requiredactive and paused are set by you. completed: a once monitor after its run. disabled: set by Keenable after 10 failed runs in a row, when no webhook delivery succeeded for 3 days; disabled_reason says which. Only an active monitor runs.Available options: active, paused, disabled, completed disabled_reasonobjectrequiredSet while status is disabled, null otherwise.Option 1Option 2Show child attributessearchobject | nullrequiredThe search a search monitor runs. null on a page monitor.Show child attributespageobjectrequiredThe page a page monitor watches. null on a search monitor.Option 1Option 2Show child attributesscheduleobjectrequiredAll three keys are always present. timezone is UTC for a cron schedule sent without one, and null for interval and once.Option 1Option 2Show child attributeswebhookobject | nullrequiredShow child attributesmetadataobject | nullrequiredShow child attributeslast_run_atstring<date-time> | nullrequiredWhen the last run ended.next_run_atstring<date-time> | nullrequiredThe next scheduled run. null without a schedule or while the monitor isn't active.upcoming_runsstring<date-time>[]requiredThe next three run times, in UTC. Empty without a schedule or while the monitor isn't active.created_atstring<date-time>requiredupdated_atstring<date-time>requiredoutput_schemaobject | nullThe output_schema you set, null without one.