get-content-changes

Stream live content-change events for a website over Server-Sent Events

Opens a long-lived Server-Sent Events stream that emits one event every time content on your website changes. Use each event as a "revalidate now" signal in your renderer or cache.

Authentication

An API key, sent as the x-api-key header or the api_key query parameter. The key's organization must own the website.

Query parameters

ParameterTypeRequiredDescription
websiteIdUUIDNo*Website to watch
api_keystringNoAlternative to the x-api-key header

* When websiteId is omitted, the website is resolved from the request's Host / x-forwarded-host header matching a configured website domain.

Events

Each event's data is a JSON object:

{
  "website_id": "3bb98252-6f3b-48de-b61c-61f020b44828",
  "table": "documents",
  "event": "UPDATE"
}

Only events for the requested website are sent. A keep-alive comment is sent every 15 seconds. Events can be dropped under load; treat the stream as a hint and refetch on the next event.

Example

curl -N "$MEDIAN_API_URL/content-changes?websiteId=$WEBSITE_ID" \
  -H "x-api-key: $MEDIAN_API_KEY"
const source = new EventSource(
  `${MEDIAN_API_URL}/content-changes?websiteId=${websiteId}&api_key=${apiKey}`
);
source.onmessage = () => revalidate();

Errors

StatusCause
400Missing or invalid websiteId
401Missing or invalid API key
403API key has no organization