Skip to main content
PATCH
/
monitors
/
{monitor_id}
JavaScript
import ContextDev from 'context.dev';

const client = new ContextDev({
  apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted
});

const monitor = await client.monitors.update('mon_123', {
  name: 'Acme pricing monitor',
  schedule: {
    type: 'interval',
    frequency: 1,
    unit: 'hours',
  },
  status: 'active',
  webhook: { url: 'https://example.com/webhook' },
});

console.log(monitor.id);
import os
from context.dev import ContextDev

client = ContextDev(
api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted
)
monitor = client.monitors.update(
monitor_id="mon_123",
name="Acme pricing monitor",
schedule={
"type": "interval",
"frequency": 1,
"unit": "hours",
},
status="active",
webhook={
"url": "https://example.com/webhook"
},
)
print(monitor.id)
package main

import (
"context"
"fmt"

"github.com/context-dot-dev/context-go-sdk"
"github.com/context-dot-dev/context-go-sdk/option"
)

func main() {
client := contextdev.NewClient(
option.WithAPIKey("My API Key"),
)
monitor, err := client.Monitors.Update(
context.TODO(),
"mon_123",
contextdev.MonitorUpdateParams{
Name: contextdev.String("Acme pricing monitor"),
Schedule: contextdev.MonitorUpdateParamsSchedule{
Type: "interval",
Frequency: 1,
Unit: "hours",
},
Status: contextdev.MonitorUpdateParamsStatusActive,
Webhook: contextdev.MonitorUpdateParamsWebhook{
URL: "https://example.com/webhook",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", monitor.ID)
}
require "context_dev"

context_dev = ContextDev::Client.new(api_key: "My API Key")

monitor = context_dev.monitors.update("mon_123")

puts(monitor)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use ContextDev\Client;
use ContextDev\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');

try {
$monitor = $client->monitors->update(
'mon_123',
changeDetection: ['type' => 'exact'],
name: 'Acme pricing monitor',
schedule: ['frequency' => 1, 'type' => 'interval', 'unit' => 'hours'],
status: 'active',
tags: ['pricing', 'competitor'],
target: [
'type' => 'page',
'url' => 'https://acme.com/pricing',
'normalizeWhitespace' => true,
],
webhook: ['url' => 'https://example.com/webhook'],
);

var_dump($monitor);
} catch (APIException $e) {
echo $e->getMessage();
}
context-dev monitors update \
--api-key 'My API Key' \
--monitor-id mon_123
curl --request PATCH \
--url https://api.context.dev/v1/monitors/{monitor_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme pricing monitor",
"status": "active",
"schedule": {
"type": "interval",
"frequency": 1,
"unit": "hours"
},
"webhook": {
"url": "https://example.com/webhook"
}
}
'
HttpResponse<String> response = Unirest.patch("https://api.context.dev/v1/monitors/{monitor_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme pricing monitor\",\n \"status\": \"active\",\n \"schedule\": {\n \"type\": \"interval\",\n \"frequency\": 1,\n \"unit\": \"hours\"\n },\n \"webhook\": {\n \"url\": \"https://example.com/webhook\"\n }\n}")
.asString();
{
  "mode": "web",
  "id": "mon_123",
  "name": "Acme pricing monitor",
  "target": {
    "type": "page",
    "url": "https://acme.com/pricing",
    "normalize_whitespace": true
  },
  "change_detection": {
    "type": "exact"
  },
  "schedule": {
    "type": "interval",
    "frequency": 6,
    "unit": "hours"
  },
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "webhook": {
    "url": "https://example.com/webhook",
    "secret": "whsec_8f3a…"
  },
  "last_run_at": "2023-11-07T05:31:56Z",
  "last_change_at": "2023-11-07T05:31:56Z",
  "next_run_at": "2023-11-07T05:31:56Z",
  "last_error": {
    "code": "fetch_failed",
    "message": "The target URL could not be fetched."
  },
  "tags": [
    "pricing",
    "competitor"
  ],
  "baseline": {
    "text": "Acme Pricing\nStarter $9/mo…",
    "captured_at": "2023-11-07T05:31:56Z"
  }
}
{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
0 Credits
Updating target or change_detection resets the monitor’s baseline: the next run re-captures it instead of reporting a spurious change. Unsupported target/change detection combinations are rejected.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

monitor_id
string
required

Body

application/json

Shared monitor update fields. target and change_detection can be updated, but the final combination must be supported.

name
string
Required string length: 1 - 200
status
enum<string>
Available options:
active,
paused
target
Page target · object

Discriminated union describing what the monitor watches.

change_detection
Exact · object

Discriminated union describing how changes are detected.

schedule
Interval · object

Discriminated union describing how the monitor is scheduled. Only interval is supported today; cron and exact_time are reserved for future use.

webhook
object | null

Set to null to remove the webhook.

tags
string[]

User-defined tags for grouping and filtering monitors and their changes.

Maximum array length: 20
Required string length: 1 - 50
Example:
["pricing", "competitor"]

Response

Updated monitor

A web monitor. mode is the constant web; behavior is described by target (page/sitemap/extract) and change_detection (exact/semantic).

mode
enum<string>
required

Top-level monitor category. Always web today; the concrete behavior is described by target and change_detection.

Available options:
web
id
string
required
Example:

"mon_123"

name
string
required
Example:

"Acme pricing monitor"

target
Page target · object
required

Discriminated union describing what the monitor watches.

change_detection
Exact · object
required

Discriminated union describing how changes are detected.

schedule
Interval · object
required

Discriminated union describing how the monitor is scheduled. Only interval is supported today; cron and exact_time are reserved for future use.

status
enum<string>
required

Monitor lifecycle status. failed means the most recent run failed (see the monitor's last_error); failed monitors keep running on schedule and flip back to active on the next successful run. Monitors are auto-paused after repeated consecutive failures or insufficient-credit skips; resume by PATCHing status to active.

Available options:
active,
paused,
failed
created_at
string<date-time>
required
updated_at
string<date-time>
required
webhook
object | null
last_run_at
string<date-time> | null
last_change_at
string<date-time> | null
next_run_at
string<date-time> | null

When the next scheduled run is due.

last_error
object | null

Error from the most recent failed run; null when the last run succeeded.

tags
string[]

User-defined tags for grouping and filtering monitors and their changes.

Maximum array length: 20
Required string length: 1 - 50
Example:
["pricing", "competitor"]
baseline
Page baseline · object

Current baseline: the last observed value the monitor compares new snapshots against. Its shape follows target.type (page/sitemap/extract). Only populated on GET /monitors/{monitor_id}; null until the first baseline run completes (and after a target or change_detection update, which resets the baseline).