Skip to main content
POST
/
monitors
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.create({
  change_detection: { type: 'exact' },
  name: 'Acme pricing page',
  schedule: {
    type: 'interval',
    frequency: 6,
    unit: 'hours',
  },
  target: { type: 'page', url: 'https://acme.com/pricing' },
  mode: 'web',
  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.create(
change_detection={
"type": "exact"
},
name="Acme pricing page",
schedule={
"type": "interval",
"frequency": 6,
"unit": "hours",
},
target={
"type": "page",
"url": "https://acme.com/pricing",
},
mode="web",
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.New(context.TODO(), contextdev.MonitorNewParams{
ChangeDetection: contextdev.MonitorNewParamsChangeDetectionUnion{
OfExact: &contextdev.MonitorNewParamsChangeDetectionExact{},
},
Name: "Acme pricing page",
Schedule: contextdev.MonitorNewParamsSchedule{
Type: "interval",
Frequency: 6,
Unit: "hours",
},
Target: contextdev.MonitorNewParamsTargetUnion{
OfPage: &contextdev.MonitorNewParamsTargetPage{
URL: "https://acme.com/pricing",
},
},
Mode: contextdev.MonitorNewParamsModeWeb,
Webhook: contextdev.MonitorNewParamsWebhook{
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.create(
change_detection: {type: :exact},
name: "Acme pricing page",
schedule: {frequency: 6, type: :interval, unit: :hours},
target: {type: :page, url: "https://acme.com/pricing"}
)

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->create(
changeDetection: ['type' => 'exact'],
name: 'Acme pricing page',
schedule: ['frequency' => 6, 'type' => 'interval', 'unit' => 'hours'],
target: [
'type' => 'page',
'url' => 'https://acme.com/pricing',
'normalizeWhitespace' => true,
],
mode: 'web',
tags: ['pricing', 'competitor'],
webhook: ['url' => 'https://example.com/webhook'],
);

var_dump($monitor);
} catch (APIException $e) {
echo $e->getMessage();
}
context-dev monitors create \
--api-key 'My API Key' \
--change-detection '{type: exact}' \
--name 'Acme pricing page' \
--schedule '{frequency: 6, type: interval, unit: hours}' \
--target '{type: page, url: https://acme.com/pricing}'
curl --request POST \
--url https://api.context.dev/v1/monitors \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"mode": "web",
"name": "Acme pricing page",
"target": {
"type": "page",
"url": "https://acme.com/pricing"
},
"change_detection": {
"type": "exact"
},
"schedule": {
"type": "interval",
"frequency": 6,
"unit": "hours"
},
"webhook": {
"url": "https://example.com/webhook"
}
}
'
HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/monitors")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"mode\": \"web\",\n \"name\": \"Acme pricing page\",\n \"target\": {\n \"type\": \"page\",\n \"url\": \"https://acme.com/pricing\"\n },\n \"change_detection\": {\n \"type\": \"exact\"\n },\n \"schedule\": {\n \"type\": \"interval\",\n \"frequency\": 6,\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 1-10 Credits Per Run
Creating a monitor always triggers an immediate first run that captures the baseline: the snapshot every later run is compared against. Baseline runs perform no change detection and are billed like any other run.

Authorizations

Authorization
string
header
required

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

Body

application/json

Creates a web monitor. mode is the constant web; the behavior is described by target (page, sitemap, or extract) and change_detection (exact or semantic). Supported combinations: page + exact, sitemap + exact, extract + semantic.

name
string
required
Required string length: 1 - 200
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.

mode
enum<string>

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

Available options:
web
webhook
object | null
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

Monitor created

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).