# Zetlyn

> Zetlyn watches public web pages for a person and tells them when something changes: one
> place on a page (a price, a version, a date) or the whole page. It reports the value before
> and after, not a diff. An LLM or agent can do everything a person does on https://zetlyn.com
> through the MCP server or the HTTP API described here, acting for the person who connected it.

## How to connect

The simplest way: the MCP server at `https://zetlyn.com/mcp`, connected by OAuth. The client
needs nothing but that address. It discovers how to sign in (`/.well-known/oauth-protected-resource`,
then `/.well-known/oauth-authorization-server`), registers itself (dynamic client registration),
and opens a browser where the person signs in to Zetlyn (email link, Google or Apple; the
account is made then if there is none) and allows the client. Authorization code flow with PKCE
(S256); access tokens last an hour and come with a refresh token.

- Claude (web, desktop, mobile): Settings → Connectors → Add custom connector, URL
  `https://zetlyn.com/mcp`.
- Claude Code: `claude mcp add --transport http --scope user zetlyn https://zetlyn.com/mcp`, then
  `/mcp` to sign in.
- ChatGPT, Cursor, VS Code and other clients: add an MCP server by the URL `https://zetlyn.com/mcp`.

Where a client cannot sign in, or for a program: an API key of the person's account. Only the
person can make one, under Account, API keys (https://zetlyn.com/account/keys); it starts with
`zk_` and is shown once. Send it with every request as `Authorization: Bearer zk_…`. Never put
the key in a page, a commit or a message to anyone else.

## How watching works

- Zetlyn reads the page every hour from its own servers; with a subscription a watch can be read
  every 15, 5 or 1 minutes instead (`every_minutes`). Changes go by email to the account's
  address; the API shows the same, and Telegram, Slack, Discord or a webhook can be told too (see below).
- A **place** is named by a CSS selector. Get the selectors from `preview` (below) instead of
  writing your own: Zetlyn finds the place again by its selector and by the text beside it, so a
  selector from `preview` survives small changes to the page.
- **When to tell** (`notify_when`): without it, every change is told. With it, only the change
  that makes a condition come true: `{"below": 400}` or `{"above": 1000}` (the amount of money in
  the place, a number beside €, $, EUR and the like, as the page writes it, e.g. `1.299,00 €`;
  without money, its first number; needs a selector; a place showing two different amounts, such
  as "RRP 999 € now 799 €", is refused: mark the one amount meant),
  `{"contains": "In stock"}`, `{"not_contains": "Sold out"}` (case aside). It is told once when
  it comes true, and again only after it was false in between. Every change still goes into the
  history. A watch says its `notify_when` and whether it holds now (`condition_met_now`).
- Without a selector the **whole page** is watched, as text; clocks, counters and adverts that
  change on their own are recognised and not reported.
- **Not only web pages:** JSON (an API's answer), RSS and Atom feeds, other XML and plain text
  (CSV among it) are read too, as a page of their own: one line per value, each value a place
  with its path beside it (`tag_name`, `assets[0].size`, `catalog.book[1].price`), so a field is
  watched like any place, with a condition if wanted; `find` with the field's name finds it. A
  whole JSON or XML document is compared line by line ("tag_name: 1.99.0"). A feed watched whole
  is told by its new entries only (title and link), not by entries that drop off its end. PDFs
  and images are not read.
- Only public pages that show their content without signing in are read. A page whose content
  its scripts make is read in a browser on Zetlyn's server (a watch's `rendered` says so). Pages
  behind a login, a paywall or a captcha are not read, and a site that refuses Zetlyn is not
  worked around.
- The account's **first watch is free for 3 days**. After that, and for a second watch, the
  person needs a subscription: 9.99 € a month for up to 10 watches, 0.50 € a month for each one
  more, VAT included. Get a link for them with `subscribe_link` (an hour long, it opens the
  subscription for their account without signing in) and give it to them with the price; they
  agree and pay at Stripe themselves. You cannot pay or agree for them.
  A watch made without a subscription is kept in state `waiting` and starts once they subscribe.
- A watch beyond the subscription's 10 costs 0.50 € a month more. Creating one is refused (402,
  with the price) until the person agreed and the call says `"confirm_cost": true`.

## MCP server

Endpoint: `https://zetlyn.com/mcp` (Streamable HTTP, JSON-RPC by POST). Without a token it
answers 401 with `WWW-Authenticate: Bearer resource_metadata="https://zetlyn.com/.well-known/oauth-protected-resource/mcp"`;
an MCP client follows that to sign in (see How to connect). With a key instead:

    claude mcp add --transport http --scope user zetlyn https://zetlyn.com/mcp --header "Authorization: Bearer zk_…"

    { "mcpServers": { "zetlyn": { "type": "http", "url": "https://zetlyn.com/mcp",
                                  "headers": { "Authorization": "Bearer zk_…" } } } }

Tools:

| Tool | Arguments | Does |
|---|---|---|
| `preview_page` | `url`, optional `find` | Reads the page and lists the places on it, each with `selector`, `text` and the text `beside` it: the page's own content first, menus and footers last. With `find` (e.g. `"€"`, `"In stock"`), only the places that say it, from the whole page |
| `watch_page` | `url`, optional `selector`, optional `every_minutes` (60, or 15/5/1 with a subscription), `notify_when`, `confirm_cost` (see How watching works) | Starts watching that place, or the whole page without a selector |
| `read_place` | `url`, `selectors` (up to 10) | Reads what those places say now, twice seconds apart, without watching; `steady: false` means a place flips on its own |
| `update_watch` | `id`, optional `selector` or `whole_page: true`, optional `every_minutes`, optional `notify_when` | Watches another place on the same page, or at another interval; keeps the watch and its history |
| `list_changes` | optional `since` (RFC 3339; 7 days without) | The changes on all the account's watches since then, newest first |
| `subscribe_link` | – | A link for the person to subscribe by, in their own browser; they pay at Stripe themselves |
| `list_watches` | – | The account's watches |
| `get_watch` | `id` | One watch with its last 20 changes and recent checks |
| `end_watch` | `id` | Ends a watch; it is deleted with its history |
| `get_account` | – | Subscription, watches running, watches in the plan |

## HTTP API

Base: `https://zetlyn.com/api/v1`. JSON in, JSON out. An error has a status ≥ 400 and a body
`{"error": "…"}` that says what to do.

| Call | Body | Answer |
|---|---|---|
| `GET /account` | – | `email`, `subscribed`, `watches_in_plan`, `watches_running`, `free_trial_used`, `subscribe_url` |
| `POST /preview` | `{"url": "…", "find": "€"}` (`find` optional) | `places`: `[{"selector", "text", "beside"}]`, `whole_page_lines`, `find` |
| `POST /read` | `{"url": "…", "selectors": ["…"]}` | `places`: `[{"selector", "text", "beside", "steady", "second_read"}]`; nothing is watched |
| `POST /watches` | `{"url": "…", "selector": "…", "every_minutes": 60, "notify_when": {"below": 400}}` (all but url optional; 15, 5 or 1 need a subscription, else 403; a watch beyond the plan needs `"confirm_cost": true`, else 402) | 201 `{"watch": {…}, "note": "…"}` |
| `GET /watches` | – | `{"watches": [ … ]}` |
| `GET /watches/{id}` | – | `{"watch", "changes": [{"at", "before", "after", "complete", "gone", "came"}], "recent_checks"}` (before and after at most 2,000 characters each; `gone` and `came`: the lines that went and came, for values of many lines) |
| `PATCH /watches/{id}` | `{"selector": "…"}` or `{"whole_page": true}`, and/or `{"every_minutes": 15}`, `{"notify_when": …}` | `{"watch", "note"}` |
| `GET /changes?since=…` | – | `{"since", "changes": [{"watch", "url", "at", "before", "after"}]}` |
| `POST /subscribe-link` | – | `{"url", "price", "expires_in_minutes"}`, or `{"subscribed": true, "billing_url"}` |
| `DELETE /watches/{id}` | – | `{"ended": id}` |

A watch: `id` (a short string such as `k3x9tq2mfa`), `url`, `what`, `selector` (null for the whole page), `beside`, `state`
(`pending`, `waiting`, `running`, `ended`), `last_outcome` (`same`, `changed`, `unclear`, `gone`,
`failed`), `value` (what it read last: up to 2,000 characters in lists, 20,000 for one watch; `value_length` and `value_complete` say whether all of it is there), `checked_every_minutes`, `notify_when`, `condition_met_now`, `rendered`, `learned_flips`, `free_until`, `last_checked`,
`created`. Times are RFC 3339 in UTC.

`unclear` or `gone` means the page was rebuilt and Zetlyn cannot be sure where the place is now;
it does not report a change then. Call `preview` again and move the watch to the place with
`PATCH /watches/{id}` (`update_watch`).

A place that changed is read once more seconds later before the change is believed. A place that
says one thing on one read and another on the next (an A/B test, a box that guesses where the
reader is) is learned as flipping between those texts (`learned_flips`), and moving between them
is not reported; a new number in the same text always is. Try places with `read_place` first and
prefer a narrow one (the availability line, not the whole buy box).

## Webhooks and other channels

Besides the account's email, the person can have changes told to Telegram, Slack, Discord or a
webhook of their own, under Account, Notifications (https://zetlyn.com/account/notifications).
A webhook gets each change as a POST of JSON:

    {"event": "change", "at": "2026-10-20T09:00:00Z",
     "watch": {"id": "k3x9tq2mfa", "url": "…", "what": "…", "notify_when": {"below": 400}},
     "before": "429,00 €", "after": "389,00 €", "condition": "Now below 400",
     "link": "https://zetlyn.com/watches/k3x9tq2mfa"}

`event` is `change`, `unclear` (the place cannot be found any more; `link` is where to mark it
again) or `test`. Each request carries `Zetlyn-Event` and
`Zetlyn-Signature: t=<unix time>,v1=<hex>`, where the hex is the HMAC-SHA256 of `<t>.<body>`
with the webhook's signing secret (shown with it, `zws_…`). Check it, and refuse a `t` more than
five minutes old. An answer other than 2xx is tried again once, a minute later.

## Example: watch a price

    curl -s https://zetlyn.com/api/v1/preview \
      -H "Authorization: Bearer $ZETLYN_KEY" -H "Content-Type: application/json" \
      -d '{"url": "https://example.com/pricing"}'

    # pick the place whose text is the price and whose "beside" names the plan, then:
    curl -s https://zetlyn.com/api/v1/watches \
      -H "Authorization: Bearer $ZETLYN_KEY" -H "Content-Type: application/json" \
      -d '{"url": "https://example.com/pricing", "selector": "html > body:nth-of-type(1) > … > span:nth-of-type(1)"}'

## Limits

600 requests per 10 minutes per account; of them 60 that read a page (`preview`, `read`, creating
or changing a watch). Beyond that the answer is 429; wait a few minutes.

## Contact

hello@zetlyn.com · Terms: https://zetlyn.com/terms · Privacy: https://zetlyn.com/privacy

## MCP tools, as the server lists them

```json
[
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": true,
      "readOnlyHint": true,
      "title": "Preview a page"
    },
    "description": "Read a public web page (or JSON, an RSS or Atom feed, XML or plain text, each read as a page of its own: one line per value, the field's path beside it) and list the places on it that can be watched, each with the selector that marks it, what it says now, and the text beside it: the page's own content first, its menus, header and footer last. Call this before watch_page to choose a place. If the place the person means is not among them, call it again with find (a word or sign the place says, such as \"€\", \"In stock\" or \"Version\"), which searches the whole page. If it fails saying the site does not let programs read the page, that page cannot be watched: tell the person, and do not call watch_page for it.",
    "inputSchema": {
      "properties": {
        "find": {
          "description": "Only the places whose text, or the text beside them, says this (case aside), from the whole page.",
          "type": "string"
        },
        "url": {
          "description": "The page's address, e.g. https://example.com/pricing",
          "type": "string"
        }
      },
      "required": [
        "url"
      ],
      "type": "object"
    },
    "name": "preview_page",
    "title": "Preview a page"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": false,
      "openWorldHint": true,
      "readOnlyHint": false,
      "title": "Watch a page"
    },
    "description": "Start watching a page: one place on it (give the selector from preview_page) or the whole page (no selector). A JSON field is a place like any other; a feed watched whole is told by its new entries. Zetlyn checks it every hour (with a subscription as often as every minute, see every_minutes) and notifies the account when it changes.",
    "inputSchema": {
      "properties": {
        "confirm_cost": {
          "description": "Only when the person agreed: a watch beyond the 10 in the subscription costs 0.50 € a month more. Without it such a watch is refused with the price, to ask them first.",
          "type": "boolean"
        },
        "every_minutes": {
          "description": "How often to check, in minutes. 60 if left out; 15, 5 and 1 need a subscription.",
          "enum": [
            60,
            15,
            5,
            1
          ],
          "type": "integer"
        },
        "notify_when": {
          "description": "Tell the person only when the value comes to meet this, not on every change: {\"below\": 400} or {\"above\": 1000} (the amount of money in the place, a number beside €, $, EUR and the like, else its first number; needs a selector; a place showing two different amounts is refused, mark a narrower one), {\"contains\": \"In stock\"} or {\"not_contains\": \"Sold out\"} (case does not matter). Told once when it comes true, again only after it stopped being true. Leave out to be told of every change.",
          "type": "object"
        },
        "selector": {
          "description": "The selector of the place to watch, from preview_page. Leave out to watch the whole page.",
          "type": "string"
        },
        "url": {
          "description": "The page's address.",
          "type": "string"
        }
      },
      "required": [
        "url"
      ],
      "type": "object"
    },
    "name": "watch_page",
    "title": "Watch a page"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": true,
      "readOnlyHint": true,
      "title": "Read places on a page"
    },
    "description": "Read what one or more places on a page say now, without watching anything. Use it to try selectors before watch_page or update_watch instead of making and ending watches. Each place is read twice a few seconds apart; steady: false means the site shows something else on its own from one read to the next (an A/B test, a box that guesses where the reader is), so prefer a narrower place inside it.",
    "inputSchema": {
      "properties": {
        "selectors": {
          "description": "Selectors from preview_page.",
          "items": {
            "type": "string"
          },
          "maxItems": 10,
          "type": "array"
        },
        "url": {
          "description": "The page's address.",
          "type": "string"
        }
      },
      "required": [
        "url",
        "selectors"
      ],
      "type": "object"
    },
    "name": "read_place",
    "title": "Read places on a page"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": true,
      "readOnlyHint": false,
      "title": "Change a watch"
    },
    "description": "Change a watch in place: watch another place on the same page (selector), the whole page (whole_page: true), or check it at another interval (every_minutes). The watch keeps its id and history and does not start a new free trial. To watch a different page, make a new watch.",
    "inputSchema": {
      "properties": {
        "every_minutes": {
          "description": "How often to check; 15, 5 and 1 need a subscription.",
          "enum": [
            60,
            15,
            5,
            1
          ],
          "type": "integer"
        },
        "id": {
          "description": "The watch's id, as list_watches gives it.",
          "type": "string"
        },
        "notify_when": {
          "description": "As in watch_page: {\"below\": n}, {\"above\": n}, {\"contains\": \"text\"}, {\"not_contains\": \"text\"}; null to be told of every change again.",
          "type": [
            "object",
            "null"
          ]
        },
        "selector": {
          "description": "The new place's selector, from preview_page or read_place.",
          "type": "string"
        },
        "whole_page": {
          "description": "Watch the whole page instead of one place.",
          "type": "boolean"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "update_watch",
    "title": "Change a watch"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false,
      "readOnlyHint": true,
      "title": "List recent changes"
    },
    "description": "The changes on all of the account's watches since a moment, newest first: which watch, when, before and after. Use it to answer what changed lately.",
    "inputSchema": {
      "properties": {
        "since": {
          "description": "A moment in RFC 3339, e.g. 2026-10-20T08:00:00Z. The last 7 days if left out.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "list_changes",
    "title": "List recent changes"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": false,
      "openWorldHint": false,
      "readOnlyHint": true,
      "title": "Get a link to subscribe"
    },
    "description": "A link for the person to subscribe to Zetlyn by (9.99 € a month for up to 10 watches, 0.50 € for each one more). Call it when a watch is waiting for a subscription or the person wants one. Give the person the link and the price; they open it themselves and pay at Stripe. You cannot pay or agree for them. Afterwards get_account says subscribed: true and waiting watches run.",
    "inputSchema": {
      "properties": {},
      "type": "object"
    },
    "name": "subscribe_link",
    "title": "Get a link to subscribe"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false,
      "readOnlyHint": true,
      "title": "List watches"
    },
    "description": "List the account's watches: what each watches, what it read last, its state and when it was checked.",
    "inputSchema": {
      "properties": {},
      "type": "object"
    },
    "name": "list_watches",
    "title": "List watches"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false,
      "readOnlyHint": true,
      "title": "Get a watch"
    },
    "description": "One watch with its last 20 changes (before and after) and its recent checks.",
    "inputSchema": {
      "properties": {
        "id": {
          "description": "The watch's id, as list_watches gives it.",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "get_watch",
    "title": "Get a watch"
  },
  {
    "annotations": {
      "destructiveHint": true,
      "idempotentHint": true,
      "openWorldHint": false,
      "readOnlyHint": false,
      "title": "End a watch"
    },
    "description": "End a watch. It is deleted with its history.",
    "inputSchema": {
      "properties": {
        "id": {
          "description": "The watch's id, as list_watches gives it.",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "end_watch",
    "title": "End a watch"
  },
  {
    "annotations": {
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false,
      "readOnlyHint": true,
      "title": "Get the account"
    },
    "description": "The account: its address, how many watches it has and runs, and on zetlyn.com its subscription and how many watches the plan holds.",
    "inputSchema": {
      "properties": {},
      "type": "object"
    },
    "name": "get_account",
    "title": "Get the account"
  }
]
```

## OpenAPI

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Zetlyn API",
    "version": "1",
    "summary": "Watch public web pages and be told when they change.",
    "description": "Zetlyn watches one place on a page (a price, a version, a date) or a whole page, and tells the account when it changes, or only when a condition comes true (a number below a mark, a text there or gone). Everything a person does on zetlyn.com can be done here, acting as the account the key or token belongs to. The same operations are tools of the MCP server at https://zetlyn.com/mcp. Guide for LLMs and agents: https://zetlyn.com/llms.txt",
    "contact": {
      "email": "hello@zetlyn.com",
      "url": "https://zetlyn.com"
    },
    "termsOfService": "https://zetlyn.com/terms"
  },
  "servers": [
    {
      "url": "https://zetlyn.com/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "externalDocs": {
    "url": "https://zetlyn.com/docs"
  },
  "paths": {
    "/account": {
      "get": {
        "operationId": "getAccount",
        "summary": "The account: subscription, watches running, watches in the plan",
        "responses": {
          "200": {
            "description": "The account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/preview": {
      "post": {
        "operationId": "previewPage",
        "summary": "Read a page and list the places on it that can be watched",
        "description": "Each place comes with the selector that marks it, what it says now and the text beside it. Pick the place that matters and pass its selector to create a watch.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "examples": [
                      "https://example.com/pricing"
                    ]
                  },
                  "find": {
                    "type": "string",
                    "description": "Only the places that say this (case aside), from the whole page"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The places",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "rendered": {
                      "type": "boolean",
                      "description": "Read in a browser after the page's scripts ran"
                    },
                    "whole_page_lines": {
                      "type": "integer"
                    },
                    "places": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Place"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/read": {
      "post": {
        "operationId": "readPlaces",
        "summary": "Read what places say now, twice, without watching anything",
        "description": "For trying selectors before watching. steady: false means the place said something else on a second read seconds later: the site changes it on its own.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "selectors"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "selectors": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What each place says",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "rendered": {
                      "type": "boolean"
                    },
                    "places": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "selector": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "beside": {
                            "type": "string"
                          },
                          "empty": {
                            "type": "boolean"
                          },
                          "steady": {
                            "type": [
                              "boolean",
                              "null"
                            ]
                          },
                          "second_read": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/watches": {
      "get": {
        "operationId": "listWatches",
        "summary": "The account's watches",
        "responses": {
          "200": {
            "description": "The watches",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "watches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Watch"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "watchPage",
        "summary": "Start watching a place on a page, or the whole page",
        "description": "Without a selector the whole page is watched. The account's first watch is free for 3 days; after that a watch waits in state `waiting` until the person subscribes (see /subscribe-link). A watch beyond the subscription's 10 costs 0.50 € a month and is refused with 402 until confirm_cost is true.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "selector": {
                    "type": "string",
                    "description": "From preview or read"
                  },
                  "every_minutes": {
                    "type": "integer",
                    "enum": [
                      60,
                      15,
                      5,
                      1
                    ],
                    "default": 60,
                    "description": "15, 5 and 1 need a subscription"
                  },
                  "notify_when": {
                    "$ref": "#/components/schemas/Condition"
                  },
                  "confirm_cost": {
                    "type": "boolean",
                    "description": "The person agreed to 0.50 € a month for a watch beyond the plan"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Made",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "watch": {
                      "$ref": "#/components/schemas/Watch"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/watches/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The watch's id, e.g. k3x9tq2mfa"
        }
      ],
      "get": {
        "operationId": "getWatch",
        "summary": "One watch with its last 20 changes and recent checks",
        "responses": {
          "200": {
            "description": "The watch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "watch": {
                      "$ref": "#/components/schemas/Watch"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Change"
                      }
                    },
                    "recent_checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "outcome": {
                            "type": "string"
                          },
                          "found_again": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "patch": {
        "operationId": "updateWatch",
        "summary": "Watch another place on the same page, the whole page, at another interval, or with another condition",
        "description": "The watch keeps its id and history.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "selector": {
                    "type": "string"
                  },
                  "whole_page": {
                    "type": "boolean"
                  },
                  "every_minutes": {
                    "type": "integer",
                    "enum": [
                      60,
                      15,
                      5,
                      1
                    ]
                  },
                  "notify_when": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/Condition"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "null: told of every change again"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "watch": {
                      "$ref": "#/components/schemas/Watch"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "endWatch",
        "summary": "End a watch; it is deleted with its history",
        "responses": {
          "200": {
            "description": "Ended",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ended": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/changes": {
      "get": {
        "operationId": "listChanges",
        "summary": "The changes on all the account's watches since a moment, newest first",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "RFC 3339; the last 7 days without it"
          }
        ],
        "responses": {
          "200": {
            "description": "The changes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "since": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Change"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "watch": {
                                "type": "string"
                              },
                              "url": {
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/subscribe-link": {
      "post": {
        "operationId": "subscribeLink",
        "summary": "A link for the person to subscribe by, in their own browser",
        "description": "Valid for an hour. The person agrees and pays at Stripe themselves; a program cannot pay for them.",
        "responses": {
          "200": {
            "description": "The link, or that the account subscribes already",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "subscribed": {
                      "type": "boolean"
                    },
                    "url": {
                      "type": "string"
                    },
                    "price": {
                      "type": "string"
                    },
                    "expires_in_minutes": {
                      "type": "integer"
                    },
                    "billing_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key of the account (zk_…, made under Account, API keys) or an OAuth access token (zat_…; discovery at https://zetlyn.com/.well-known/oauth-authorization-server)."
      }
    },
    "responses": {
      "Error": {
        "description": "What went wrong and what to do",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "error"
              ],
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Account": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "watches": {
            "type": "integer"
          },
          "watches_running": {
            "type": "integer"
          },
          "subscribed": {
            "type": "boolean"
          },
          "watches_in_plan": {
            "type": "integer"
          },
          "free_trial_used": {
            "type": "boolean"
          },
          "subscribe_url": {
            "type": "string"
          },
          "price": {
            "type": "string"
          }
        }
      },
      "Place": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "beside": {
            "type": "string"
          }
        }
      },
      "Condition": {
        "description": "Tell only when this comes true: a number in the place below or above a mark, or a text there or gone (case aside).",
        "oneOf": [
          {
            "type": "object",
            "required": [
              "below"
            ],
            "properties": {
              "below": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "above"
            ],
            "properties": {
              "above": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "contains"
            ],
            "properties": {
              "contains": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "not_contains"
            ],
            "properties": {
              "not_contains": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "Change": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "before": {
            "type": "string"
          },
          "after": {
            "type": "string"
          },
          "complete": {
            "type": "boolean",
            "description": "Whether before and after are whole (each carries up to 2,000 characters)"
          },
          "gone": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For a value of many lines: the lines that went"
          },
          "came": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For a value of many lines: the lines that came"
          }
        }
      },
      "Watch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "what": {
            "type": "string"
          },
          "selector": {
            "type": [
              "string",
              "null"
            ],
            "description": "null for the whole page"
          },
          "beside": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "waiting",
              "running",
              "ended"
            ]
          },
          "last_outcome": {
            "type": "string",
            "enum": [
              "new",
              "same",
              "changed",
              "unclear",
              "gone",
              "failed"
            ]
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it read last"
          },
          "checked_every_minutes": {
            "type": "integer"
          },
          "notify_when": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Condition"
              },
              {
                "type": "null"
              }
            ]
          },
          "condition_met_now": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "rendered": {
            "type": "boolean"
          },
          "learned_flips": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "free_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_checked": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "value_length": {
            "type": "integer",
            "description": "How long the value is, in characters"
          },
          "value_complete": {
            "type": "boolean",
            "description": "Whether value is all of it (lists carry up to 2,000 characters, one watch up to 20,000)"
          }
        }
      }
    }
  }
}

```
