Monitors API and webhook

Get each run’s new results at your own address by webhook, check its signature, and read monitors with an API key or from an MCP client.

Goal: get what your monitors find into your own system, pushed to your address after each run or read with an API key whenever you want. Neither costs anything.

ACTION FOR THE HUMAN: open https://app.anysite.io/monitors (Open Monitors).

Steps

  1. Set the webhook. Open the monitor, click Edit, go to the last step and fill in Webhook URL with your receiver’s https:// address. Click Save changes. Every monitor type takes it, People under post links included. Saving only the webhook charges nothing.
  2. Copy the secret. On the monitor’s Settings tab, Webhook secret shows the start of the secret; click Copy and store it in your receiver.
  3. Check every call’s signature (below) before you use its body.
  4. Drop repeats by id. Every post, change, person and item carries its id. The same item can come again, by the webhook and by the API; keep the first one.
  5. Read what you missed with the API (below). The webhook makes one attempt per run and is not sent again; a run whose call failed reads Webhook failed · … in Run history, and its results are in the news feed.
  6. Or ask an MCP client. The Anysite MCP server lists your monitors and reads a monitor’s news after a cursor: Monitor tools.

To stop the calls, clear Webhook URL and save. Regenerate secret on Settings makes a new secret; the old one stops working at once, so update your receiver.

The webhook call

After each run that found something, one POST goes to your address, beside the results e-mail:

Header Value
Content-Type application/json
User-Agent Anysite-Webhook/1.0
X-Webhook-Signature sha256= and the hex HMAC-SHA256 of the raw body, keyed with the secret
{
  "monitor_id": "<monitor id>",
  "runs": [
    {
      "id": "<run id>",
      "status": "done",
      "result_count": 2,
      "person_count": 1,
      "started_at": 1764000000,
      "finished_at": 1764000300,
      "posts": [],
      "changes": [],
      "people": [],
      "items": []
    }
  ],
  "has_more": false,
  "next_cursor": "<cursor>"
}

posts, changes, people and items hold the same items as the monitor’s tabs. items is a Custom flow’s, as its Items tab shows them, and is empty on every other type: kind is item for a new item or item_change for a watched field’s change, fields the fields you chose to show (each with its step, path and value), and change, on an item_change, the field’s path, old and new value and the threshold it crossed (null when the watch has none); null on a new item. A Custom flow’s run:

{
  "id": "<run id>",
  "status": "done",
  "result_count": 2,
  "person_count": 0,
  "started_at": 1764000000,
  "finished_at": 1764000300,
  "posts": [],
  "changes": [],
  "people": [],
  "items": [
    {
      "id": "<item id>",
      "kind": "item",
      "item_url": "https://jp.mercari.com/item/m2",
      "title": "Switch 2",
      "fields": [
        { "step": 2, "path": "name", "value": "Switch 2" },
        { "step": 2, "path": "price", "value": 30002 }
      ],
      "change": null,
      "is_new": true,
      "found_at": 1764000120
    },
    {
      "id": "<item id>",
      "kind": "item_change",
      "item_url": "https://jp.mercari.com/item/m1",
      "title": "Switch 1",
      "fields": [
        { "step": 2, "path": "name", "value": "Switch 1" },
        { "step": 2, "path": "price", "value": 27500 }
      ],
      "change": { "path": "price", "old": 30001, "new": 27500, "threshold": null },
      "is_new": true,
      "found_at": 1764000180
    }
  ]
}

A call carries at most 100 items of its run; when has_more is true, read the rest from the news feed with after=<next_cursor>. Times are Unix seconds. A redirect is not followed, and a call with no answer in 10 seconds counts as failed.

Check the signature over the bytes you received, never over re-encoded JSON:

import hashlib, hmac

def is_signed(secret: str, raw_body: bytes, header: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header)

Reading monitors with an API key

Send your API key in the access-token header, as for every Anysite API call. Results are kept for 30 days.

List your monitors with their ids:

curl https://api.anysite.io/monitors \
  -H "access-token: YOUR_API_KEY"

ACTION FOR THE HUMAN: copy your API key at https://app.anysite.io/billing — an agent cannot obtain it.

Read a monitor’s news: its finished runs that found something, oldest first, each with its new posts, changes and people, or a Custom flow’s items.

curl "https://api.anysite.io/monitors/<monitor id>/news?limit=100" \
  -H "access-token: YOUR_API_KEY"

ACTION FOR THE HUMAN: copy your API key at https://app.anysite.io/billing — an agent cannot obtain it.

The answer has the shape of the webhook body without monitor_id. Store next_cursor and pass it back unchanged as after=<next_cursor> on the next read to get only what is new; without after the feed starts from the oldest results kept. While has_more is true, read again at once. limit is 1 to 100, 100 by default.

How to verify

Troubleshooting