Jobs and events

Monitors

Run an endpoint on a schedule and get only what is new or changed, by webhook, email or a pull: new posts, new search results, a count that moves.

On this page
  1. Lists and single items
  2. Watch a field
  3. Choose what the first run reports
  4. Read what a monitor found
  5. What a monitor costs
  6. Set how often it runs
  7. Why a monitor pauses
  8. Limits

A monitor runs one endpoint on a schedule and records what changed since its last run: new items on a list, or the fields you watch on a single item. Create one with the endpoint and the params you would send it:

cURL
curl -X POST 'https://socialtap.dev/v1/monitors' \
  -H "x-api-key: $SOCIALTAP_API_KEY" \
  -H "idempotency-key: $(uuidgen)" \
  -H 'content-type: application/json' \
  --data '{
  "endpoint": "tiktok.posts",
  "params": {
    "handle": "@khaby.lame"
  },
  "interval_s": 3600,
  "webhook_url": "https://example.com/webhooks/socialtap"
}'
TypeScript SDK
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap } from "socialtap";

const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY

const res = await client.monitors.create({
  "endpoint": "tiktok.posts",
  "params": {
    "handle": "@khaby.lame"
  },
  "interval_s": 3600,
  "webhook_url": "https://example.com/webhooks/socialtap"
});
// webhook_secret signs its webhook: it is shown only in this answer.
console.log(res.data.id, res.data.next_run_at, res.data.webhook_secret);
Python SDK
from socialtap import SocialTap

client = SocialTap()  # api_key defaults to os.environ["SOCIALTAP_API_KEY"]

res = client.monitors.create(
    endpoint="tiktok.posts",
    params={"handle": "@khaby.lame"},
    interval_s=3600,
    webhook_url="https://example.com/webhooks/socialtap",
)
# webhook_secret signs its webhook: it is shown only in this answer.
print(res.data.id, res.data.next_run_at, res.data.webhook_secret)

The first run starts at once, and later runs keep to the interval. POST /v1/monitors/{id}/run runs one now. Each run calls the endpoint as a direct request would.

RouteWhat it doesKey scope
POST /v1/monitorsCreate a monitorjobs
GET /v1/monitorsList monitors, newest firstjobs:read
GET /v1/monitors/{id}Get a monitorjobs:read
PATCH /v1/monitors/{id}Update, pause or resume a monitorjobs
DELETE /v1/monitors/{id}Delete a monitorjobs
POST /v1/monitors/{id}/runRun a monitor nowjobs
GET /v1/monitors/{id}/runsList a monitor's runs, newest firstjobs:read
GET /v1/monitors/{id}/changesList what a monitor found, newest firstjobs:read
GET /v1/monitor_runs/{id}Get a monitor run (free to poll)jobs:read
GET /v1/monitor_runs/{id}/changesList a run's changesjobs:read
GET /v1/monitor_runs/{id}/changes.jsonlDownload a run's changes (JSON Lines)none (signed URL)

Lists and single items

An endpoint's API reference page says under "Monitoring" whether a monitor can run it. A transcript, a download and other answers that never change can't be monitored.

  • A list (a profile's posts, a post's comments, a search): each run reads the first page and reports every item it hasn't seen. It knows an item by its id, or its url when it has none. On a search or a ranked list, new means new to that list. pages_per_run (up to 10) reads on while every item of a page is new, so a burst between runs isn't missed. The monitor remembers the 2,000 items it saw most recently: an older one that comes back is new again.
  • A single item (a profile, a post, a repository): each run checks the fields you watch. It needs at least one.

Create and change monitors with a key that has the jobs scope, and read them with jobs:read. A monitor runs as the key that created it, so that key also needs the endpoints scope. Its runs count toward that key's spend limit.

Watch a field

watch takes up to 16 fields, each by the path fields= takes on that endpoint. For a number, a rule says when a change counts:

POST /v1/monitors
{
  "endpoint": "tiktok.post",
  "params": {
    "url": "https://www.tiktok.com/@scout2015/video/6718335390845095173"
  },
  "interval_s": 3600,
  "watch": [
    {
      "field": "metrics.view_count",
      "min_change_percent": 10
    }
  ],
  "email": true
}
RuleReported when the number
nonediffers from the value last reported
min_changemoved at least this much since the value last reported
min_change_percentmoved at least this percent of the value last reported
aboverises above this, from at or below it
belowfalls below this, from at or above it

A change rule compares with the value last reported, so slow drift adds up until it passes the threshold. A crossing (above, below) compares with the value last seen, so each crossing is reported once. A rule is one or the other, not both. A string, a boolean or an array changes when its JSON differs.

null is unknown, never a change: the monitor keeps the last known value and compares the next known one with it. A field's first known value is remembered, not reported.

On a list, watched fields are checked on items the monitor has already seen. A new post comes as a new change, and its views passing your threshold later as a changed one.

Choose what the first run reports

With first_run baseline (the default), the first run only remembers what is there, so you hear about what comes after it. With report, it reports every item it finds as new. first_run is for lists: a single item's first run records the values your watch rules compare with.

Read what a monitor found

A run's changes are stored once and kept 30 days. Read them any of these ways:

  • Pull. GET /v1/monitors/{id}/changes lists changes newest first. Pass since with the time you last looked to get only what came after.
  • The monitor's own webhook. Its webhook_url receives only its monitor.changed and monitor.paused events, signed as every webhook is. It needs no admin key and doesn't count toward your webhook endpoints. Send your own webhook_secret, or store the one the create answer shows once.
  • Your webhook endpoints. Subscribe one to monitor.* to get every monitor's events at one URL.
  • Email. With email true, the account's owner gets a summary of what the monitor found, with at least 1 hour between two emails.
  • MCP. An agent creates a monitor with create_monitor and reads what it found with list_monitor_changes. A client with the MCP Events extension (io.modelcontextprotocol/events) waits for monitor.changed instead: events/poll from a cursor, or events/subscribe with its own URL and secret.
  • CLI. socialtap monitors changes <id> --follow prints what a monitor finds as JSON Lines until you stop it.

Each change holds the item as that run read it:

FieldTypeDescription
objectstringAlways monitor_change.
One of monitor_change
idstringThe change ID (mchg_…).
monitor_idstring
run_idstring
endpointstringThe monitor's endpoint: what item holds (its resource's schema).
kindstringnew: an item the monitor hadn't seen. changed: watched fields changed (fields says which).
One of new, changed
item_keystringThe item's id (its url when it has none): what the monitor remembers it by.
itemanyThe item as the endpoint returned it in that run (a list's item, or the single item's data).
fieldsobject[]The watched fields that changed; [] for a new item.
fields[].fieldstring
fields[].beforeanyThe value last reported (for above and below: last seen).
fields[].afteranyThe value now.
detected_atstring (date-time)

An event carries the counts and the items' keys, not the items. Its changes_url downloads the run's changes as JSON Lines without an API key for 1 day, and its url reads them with your key while they are kept (event data).

What a monitor costs

Each page a run reads is one request of the endpoint, charged at the endpoint's price (credits). There is no monitor fee. Failed runs are free, and with max_age a run may take a cached answer, also free. Each run states its credits_charged, and the monitor's totals add them up.

A monitor's spend is its price times its runs: one that reads one page every hour makes 24 requests a day.

Set how often it runs

interval_s is a whole number of minutes, from 5 minutes (1 hour until the account has paid: GET /v1/account says which as monitor_min_interval_s) to 30 days. Each monitor runs at a fixed offset within its interval, so runs don't all start on the minute: next_run_at says when.

A monitor runs one run at a time. A run still going when the next is due skips that one, and after an outage a monitor runs once, then on schedule. GET /v1/monitors/{id} returns the monitor with its last_run and totals, and GET /v1/monitors/{id}/runs lists its runs, each with its pages, credits and error.

Why a monitor pauses

A paused monitor doesn't run on its schedule, and paused_reason says why. POST /v1/monitors/{id}/run still runs it once, as the key that asks, without resuming it.

paused_reasonWhat happenedWhat to do
userSomeone paused it.Resume it.
key_revoked, key_expired, key_forbiddenThe key it runs as was revoked, expired or lost the endpoints scope. A revoked key or a lost scope pauses it at once; an expired key at its next run.Resume it with another key, or from the dashboard.
failingIts runs failed for 1 day, at least 3 in a row.Read last_run.error, fix the cause, resume it.
endpoint_retiredIts endpoint was retired.Create a monitor of the replacement.

Every reason but user emits monitor.paused and emails the owner. Running out of credits, a key's spend limit and capacity errors never pause a monitor: those runs fail, free, and the monitor carries on by itself.

Resume a monitor with PATCH /v1/monitors/{id} and status active. It then runs as the key that resumed it. An agent's app that connects again gets a new key in place of its old one, and its monitors move to the new key without pausing. Its endpoint and params never change: create another monitor for other ones.

Limits

  • Monitors. 1,000 per account (10 until it has paid). Past that, a create fails with forbidden and details.reason monitor_limit.
  • Runs at once. Up to 20 of an account's runs at a time (2 until it has paid).
  • A run's time. A run that hasn't ended after 15 minutes ends failed, free.
  • History. Runs are kept 30 days, and so are changes.

Last updated