---
agent:
  instructions: "Search the SocialTap docs with keywords or a question instead of crawling pages: GET https://socialtap.dev/.well-known/search?q={query} returns the best sections as Markdown (JSON with Accept: application/json), free and without a key."
  endpoint: "https://socialtap.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://socialtap.dev/docs/agents/#docs-for-agents"
---
# Monitors

> Setting SocialTap up for your user? Follow https://socialtap.dev/setup.md.

Jobs and events

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.

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:

```shell
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:

```typescript
// 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:

```python
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.

| Route | What it does | Key scope |
| --- | --- | --- |
| `POST /v1/monitors` | Create a monitor | `jobs` |
| `GET /v1/monitors` | List monitors, newest first | `jobs:read` |
| `GET /v1/monitors/{id}` | Get a monitor | `jobs:read` |
| `PATCH /v1/monitors/{id}` | Update, pause or resume a monitor | `jobs` |
| `DELETE /v1/monitors/{id}` | Delete a monitor | `jobs` |
| `POST /v1/monitors/{id}/run` | Run a monitor now | `jobs` |
| `GET /v1/monitors/{id}/runs` | List a monitor's runs, newest first | `jobs:read` |
| `GET /v1/monitors/{id}/changes` | List what a monitor found, newest first | `jobs:read` |
| `GET /v1/monitor_runs/{id}` | Get a monitor run (free to poll) | `jobs:read` |
| `GET /v1/monitor_runs/{id}/changes` | List a run's changes | `jobs:read` |
| `GET /v1/monitor_runs/{id}/changes.jsonl` | Download a run's changes (JSON Lines) | none (signed URL) |

## Lists and single items

An endpoint's [API reference](https://socialtap.dev/docs/reference/index.md) 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:

```json
{
  "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
}
```

| Rule | Reported when the number |
| --- | --- |
| none | differs from the value last reported |
| `min_change` | moved at least this much since the value last reported |
| `min_change_percent` | moved at least this percent of the value last reported |
| `above` | rises above this, from at or below it |
| `below` | falls 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](https://socialtap.dev/docs/webhooks/index.md) 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:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `string` | Always monitor_change.<br>One of `monitor_change` |
| `id` | `string` | The change ID (mchg_…). |
| `monitor_id` | `string` |  |
| `run_id` | `string` |  |
| `endpoint` | `string` | The monitor's endpoint: what item holds (its resource's schema). |
| `kind` | `string` | new: an item the monitor hadn't seen. changed: watched fields changed (fields says which).<br>One of `new`, `changed` |
| `item_key` | `string` | The item's id (its url when it has none): what the monitor remembers it by. |
| `item` | `any` | The item as the endpoint returned it in that run (a list's item, or the single item's data). |
| `fields` | `object[]` | The watched fields that changed; \[\] for a new item. |
| `fields[].field` | `string` |  |
| `fields[].before` | `any` | The value last reported (for above and below: last seen). |
| `fields[].after` | `any` | The value now. |
| `detected_at` | `string` (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](https://socialtap.dev/docs/events/index.md#monitor-changed)).

## What a monitor costs

Each page a run reads is one request of the endpoint, charged at the endpoint's price ([credits](https://socialtap.dev/docs/credits/index.md)). 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_reason` | What happened | What to do |
| --- | --- | --- |
| `user` | Someone paused it. | Resume it. |
| `key_revoked`, `key_expired`, `key_forbidden` | The 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. |
| `failing` | Its runs failed for 1 day, at least 3 in a row. | Read `last_run.error`, fix the cause, resume it. |
| `endpoint_retired` | Its 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`](https://socialtap.dev/docs/errors/index.md#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.

---

[HTML version](https://socialtap.dev/docs/monitors/) · [Docs index for AI agents](https://socialtap.dev/llms.txt) · [All docs in one file](https://socialtap.dev/llms-full.txt)
