# Watches and Webhooks

Watch the facts your product relies on, and Conscius tells you when they change: a signed request to your server, or a list your code reads when it likes. Both need [an account key](/docs/keys).

> **Not on yet:** Watches aren't switched on at `mcp.consci.us` yet. This page describes them as they'll work.

## Start Watching

1. Make an endpoint: `POST /v1/watch-endpoints` with your URL. It must be https on the public internet, and Conscius doesn't follow redirects. The answer holds the endpoint's signing secret, shown only once, so keep it then.

2. Watch something: `POST /v1/watches` with the facts and your endpoint's ID. Name things and properties as you would in a lookup; each is matched to its ID once, here, and a name Conscius can't place exactly is refused with the reason.

3. Check it works: `POST /v1/watch-endpoints/<id>/test` sends your endpoint one signed `test` event.

## From the Command Line

```bash
curl https://mcp.consci.us/v1/watch-endpoints \
  -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/conscius", "description": "Release notes bot"}'

curl https://mcp.consci.us/v1/watches \
  -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"endpoint": "whe_…", "keys": [{"thing": "PostgreSQL", "property": "latest version"}], "things": ["Q319417"]}'
```

## What You Can Watch

| Watch | Example | What it gets |
| --- | --- | --- |
| `keys` | `{"thing": "PostgreSQL", "property": "latest version", "plan": "Pro"}` | One property of one thing, and, with `plan`, the values for that plan only. |
| `things` | `"PostgreSQL"` or `"Q192490"` | Every property of one thing. |
| `filters` | `{"vendor": "Q95"}`, `{"type": "Q3932296", "property": "P348"}` | What the [change feed](https://mcp.consci.us/v1/changes) would list for the same filters: `vendor` is everything a company develops, makes, publishes or owns, and the company itself; `type` is things of that kind; `property` one property across them. Changes on the log only, so no `stale`, `record_changed` or `removed`. |

Add `"events": ["value_changed", "stale"]` to get only those kinds. A watch matches what changes after it's made, never what came before.

## Events

| Kind | When |
| --- | --- |
| `new_value` | Someone shared a value for it, and it's past its hold. |
| `value_changed` | A newer value replaced one, with `previous` (the old value and why it changed). |
| `value_ended` | A value stopped holding, with its `end_time`. |
| `status_changed` | A value's status moved, say from `reported` to `agreed`, with `previous` and the cause. |
| `withdrawn` | A value was shown wrong, with the reason. |
| `reaffirmed` | Its owner said a value is still current. |
| `restated` | A value's dates were restated, with the dates it has now. |
| `removed` | A value was taken out: its claim ID and the reason's category only, never what it said. Keys and whole things get it (a whole thing for the properties Conscius had seen it with); filters don't. |
| `stale` | A value has gone past its age, or a newer reading suggests it changed. It's time to check it. |
| `record_changed` | Wikidata's record for it has different values after a monthly refresh, with `previous`. |

## What Arrives

A `POST` with a JSON body of up to 100 events: changes in the order they reached the public log, then any `stale` and `record_changed`. Each event's `id` is the same however you get it, so use it to skip one you've had: a retry sends the same IDs. `watch` says which of your watches it matched.

```json
{
  "events": [
    {
      "id": "evt_L5821",
      "kind": "value_changed",
      "at": "2026-12-02T14:03:11.932Z",
      "thing": { "id": "wd:Q192490", "name": "PostgreSQL" },
      "property": { "id": "wdt:P348", "name": "software version identifier" },
      "claim_id": "clm_f7e9f289d9d6822f6e2b",
      "claim": "https://consci.us/claim/clm_f7e9f289d9d6822f6e2b",
      "value": "18.2",
      "previous": { "claim_id": "clm_d9e45b6665557c1adc12", "value": "18.1", "reason": "changed" },
      "position": "L5821",
      "watch": "w_a31759accb1b5b620bec"
    }
  ]
}
```

Values are open data (CC0), as in a lookup. Look a value's sources up with its `claim_id`.

## Check the Signature

Every request carries `Conscius-Signature: t=<unix seconds>,v1=<hex>`, where `v1` is the HMAC-SHA256 of `<t>.<the raw body>` keyed with your endpoint's whole secret, `whsec_` included. Check it against the raw bytes you received, before parsing them, and refuse a `t` more than five minutes from your clock. `Conscius-Event-Ids` lists the batch's event IDs.

## In TypeScript

```text
import { createHmac, timingSafeEqual } from "node:crypto";

/** True when the Conscius-Signature header matches the raw body under your endpoint's secret. */
export function verify(header: string | null, body: string, secret: string, toleranceS = 300): boolean {
  const parts = Object.fromEntries((header ?? "").split(",").map((p) => p.trim().split("=")));
  const t = Number(parts.t);
  if (!Number.isInteger(t) || !parts.v1 || Math.abs(Date.now() / 1000 - t) > toleranceS) return false;
  const want = Buffer.from(createHmac("sha256", secret).update(`${t}.${body}`).digest("hex"));
  const got = Buffer.from(parts.v1);
  return want.length === got.length && timingSafeEqual(want, got);
}
```

## In Python

```text
import hashlib
import hmac
import time


def verify(header: str, body: bytes, secret: str, tolerance: int = 300) -> bool:
    """True when the Conscius-Signature header matches the raw body under your endpoint's secret."""
    parts = dict(p.strip().split("=", 1) for p in (header or "").split(",") if "=" in p)
    try:
        t = int(parts["t"])
    except (KeyError, ValueError):
        return False
    if abs(time.time() - t) > tolerance:
        return False
    want = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, parts.get("v1", ""))
```

## Retries and Failures

Answer with any 2xx within 10 seconds and the events are delivered. Anything else, a redirect included, is a failure, and the same events are tried again after 1, 5 and 15 minutes, then hourly. After 24 hours of failures the endpoint is marked failing and your account's members get one email. Three days after that it's turned off. An answer of `410 Gone` turns it off at once.

Your watches stay when an endpoint is off. `POST /v1/watch-endpoints/<id>/enable` turns it back on from now, and what it missed is in the list below. Deleting a watch stops its events at once, retries included.

## Read Them Instead

`GET /v1/watches/events` gives the same events, matched when you ask, so a watch needs no endpoint at all. Without `after`, it starts from when your watches began; pass the `next` it returns to read on. `endpoint=whe_…` reads one endpoint's watches.

```bash
curl -G https://mcp.consci.us/v1/watches/events \
  -H "Authorization: Bearer YOUR_KEY" \
  --data-urlencode "after=L5821.T40"
```

## Every Request

| Request | What it does |
| --- | --- |
| `POST /v1/watch-endpoints` | Makes an endpoint (`url`, `description`). Returns it and its secret, once. |
| `GET /v1/watch-endpoints` | Your endpoints, each with its state (`active`, `failing` or `disabled`) and its last attempt. |
| `GET` or `DELETE /v1/watch-endpoints/<id>` | One endpoint, or deletes it. Its watches stay, for reading. |
| `POST /v1/watch-endpoints/<id>/test` | Sends one signed `test` event. |
| `POST /v1/watch-endpoints/<id>/enable` | Turns a failing or disabled endpoint back on, from now. |
| `POST /v1/watches` | Adds watches: `keys`, `things` and `filters`, with `endpoint` and `events` if you like. |
| `GET /v1/watches` | Your watches, your account's limits, and today's deliveries. |
| `DELETE /v1/watches/<id>` | Stops a watch at once. |
| `GET /v1/watches/events` | Your events after a position (`after`, `limit` up to 500, `endpoint`). |

Each account has limits on how many keys, things, filters and endpoints it watches, and how many events it's sent a day (UTC); `GET /v1/watches` shows yours. Past the day's, events wait for the next day or for you to read them. The service's OpenAPI description at `https://mcp.consci.us/v1/openapi.json` lists every field.

## What Conscius Keeps, and Keeping Nothing

A watch list says what you rely on, so Conscius keeps it only while your account is active, deletes a watch the moment you do and everything with your account, and uses it for nothing but sending you its events. It never goes on the public log, the dumps, the change feed or exports. Conscius counts how many accounts watch a fact, to know what to keep fresh, and never records who. It keeps no copy of the events it sends, only how far each endpoint has got. See the [Privacy Policy](/privacy).

To have nothing kept at all, send the claim IDs you rely on to `POST /v1/subscriptions`: it returns them encrypted as a token, and stores nothing. Then read `GET /v1/corrections?token=…&after=…` when you like, for those claims corrected, replaced, withdrawn or removed. `GET /v1/corrections/digest?day=…` lets you test your claims against a day's corrections without naming them.

---

Source: https://consci.us/docs/watches
