[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationHTTP API

HTTP API

The collect event contract, its guards and limits, and every route under /api/marketing with its access level.

All routes live under /api/marketing. The public routes serve tracked sites. Every other route needs a DMS JWT.

Event contract

POST /api/marketing/collect is public and takes batches of 1 to 25 events, validated with zod. It answers { accepted, dropped }.

Guards

The endpoint is public, and these checks run in order before any event is stored:

  1. Collection switch. While collection is paused in Settings, every batch answers 200 with all events counted as dropped.
  2. Website. An unknown website ID, or a site whose own tracking switch is off, answers 404.
  3. Browser origin. The Origin hostname, or the Referer hostname when Origin is absent, must be the website's domain, a subdomain of it, or one of its extraDomains. Any other host answers 403, including the literal null that sandboxed frames send. Page script cannot set these headers, so a tracker copied onto a foreign site reports that site and is refused. A request with neither header is dropped silently. Every browser sets Origin on a POST, so only hand-made clients send none.
  4. Declared automation. Crawlers, CLIs, HTTP libraries, fetchers and headless engines that announce themselves (the ua-parser-js lists), and requests with no user agent, answer 200 with all events counted as dropped.
  5. Per-source rate. A fixed one-minute window allows 600 events per website and IP, in memory on each instance. The budget is an order of magnitude above a heavy visitor, so carrier-grade NAT does not trip it. A refusal answers 200 with all events counted as dropped.

The IP is the one the DMS resolves with getClientIp from @antelopejs/interface-dms/client-ip. X-Forwarded-For is read only behind the reverse proxies that the DMS trusts (auth.trustedProxies), at the entry the outermost trusted proxy appended. Entries to the left of it are client claims, which could create a visitor, avoid the rate budget or spend another visitor's budget.

A refused host is remembered for the install guide's Allow this host action only when it looks like a browser's: a valid hostname, from a request that carries Sec-Fetch-Mode. The memory keeps up to 5 hosts per website for an hour.

The guards do not stop a scripted client that forges a browser user agent and a matching Origin. No public analytics product authenticates its ingestion. The remedy for such data is detection and the per-site purge (POST /websites/:id/purge).

Request body

@RawBody reads the body under MAX_COLLECT_BODY_BYTES (256 KiB) and answers 413 past it. The body must be JSON, whatever its content type, or the request answers 400. Only the envelope, a website ID and 1 to 25 events, can fail the request with a 400.

Each event is then validated on its own. A failing event is dropped and counted in dropped, and the rest of its batch is kept. The module logs drops once a minute per site. An event fails when:

  • its url is neither an http or https URL nor a path
  • its name is missing where required, or longer than 50 characters (64 for the experiment key of an exposure)
  • its data does not match its kind's shape, or a custom event's data is over 4,096 characters of serialized JSON

Context text is cut to its cap instead of failing: url and referrer at 500 characters, title at 200, and screen and language at 16.

jsonc
{
  "website": "<website id>",
  "events": [
    {
      "kind": "pageview | custom | exposure | click | scroll",
      "url": "https://example.com/pricing?utm_source=newsletter",
      "referrer": "https://example.org/",        // optional
      "title": "Pricing",                        // optional
      "screen": "1920x1080",                     // optional
      "language": "fr-FR",                       // optional
      "name": "signup_submitted",                // required for custom (event name) and exposure (experiment key)
      "data": { "plan": "pro" },                 // kind-specific, at most 4,096 characters of JSON for custom
      "at": 1754500000000                        // optional client ms, ignored past 5 minutes of skew
    }
  ]
}

Event data by kind

Kinddata payload
click{x, y, dx, dy, selector, ox, oy, nth}. x and y are required and viewport-normalized (where on the screen). dx and dy are document-normalized. selector, ox, oy and nth are the element anchor that heatmaps project from: the nearest short CSS path (at most 120 characters), the offset inside that element's box, and the element's index among the selector's matches. x, y, dx and dy are fallbacks, see Heatmap anchoring. Every fraction lies in 0 to 1.
pageview{sample}, optional. The heatmap sampling rate (0 to 1) that the tracker applied to the view. Pages and heatmaps reports "recorded on N % of page loads" as the average of these declared rates. Counting scroll events against pageviews would undercount views left before their depth is sent. Any other payload is dropped and the pageview kept.
scroll{depth}, the maximum percentage of the page reached, an integer from 0 to 100. Every sampled view sends one, 0 when it never scrolled.
exposure{experiment, variation}, each at most 64 characters, the arm that the page applied. name carries the experiment key. Nothing re-derives the arm, so the page's claim stands. The key is checked. An exposure for anything but a running split is dropped at ingestion, see Assignment contract.

HTTP surface

Public routes

RoutePurpose
POST /collectEvent ingestion, see Event contract. Answers {accepted, dropped}.
GET /tracker.jsThe first-party tracker script, cached for an hour. While collection is paused it publishes only a no-op window.dmsMarketing, cached for a minute, so page code keeps working.
GET /experiments.js?website=The per-visitor assignment script for the site's funnels whose A/B split is running, see Assignment contract.
GET /snapshot.js?website=&path=&width=Snapshot negotiation. The capture script when the backend wants a snapshot of that path at that viewport width, an empty script otherwise, see Snapshot contract.
POST /snapshotSnapshot upload. One serialized page rendering, capped and rate-limited, accepted only with the token its negotiation handed out.

The module declares these five routes to the DMS as its publicEndpoints (src/routes/public-endpoints.ts). The install guide's snippet points at the dashboard's origin, and the DMS frontend server lets a tracked site's scripts and beacons through without a session only for declared routes.

Websites

RouteAuthPurpose
GET /websitestenant memberThe tenant's websites, most recently active first, so a dashboard that opens the first entry opens one with data.
POST /websites, PUT /websites/:idtenant ownerCreate or update a website. snapshotsEnabled and snapshotMaskText are the page-snapshot opt-in and masking options. Changing either discards the site's snapshots. Changing snapshotsEnabled sets snapshotsSetBy: "owner", which configuration never overrides.
DELETE /websites/:idtenant ownerDeletes the site and purges its tracking data, see Website deletion and purge. Answers 409 for the dashboard's own site (dashboardTracking), which is never deleted.
GET /websites/:id/deletiontenant ownerCounts what a delete or a purge discards.
POST /websites/:id/purgetenant ownerBody { scope: "heatmaps" | "all" }, required (400 without it). heatmaps deletes the site's clicks, scroll depths and page snapshots. all deletes everything it collected: events, sessions, rollups, snapshots and applied imports. Keeps the site, its settings and its funnels. Works on any site, the dashboard's own included, and is idempotent. Answers { purged, scope, deleted: { events, sessions, days, snapshots, imports } } and publishes on marketing.websites.
GET /websites/:id/connectiontenant memberThe install guide's check: the site's state, its most recent visit (URL, browser and device) and its recently refused hosts.
POST /websites/:id/allow-hosttenant ownerAdds a refused host to the site's extraDomains and forgets its refusals.
POST /dashboard-trackingtenant memberWith dashboardTracking on, the website that the dashboard's own tag reports to, { websiteId }. Created for the caller's tenant on the first call, with an ID derived from the tenant and snapshots per dashboardTracking.snapshots until an owner changes them. snapshotsSetBy records whether config or the owner set them. The request's Origin host (else Referer) is added to the site's extraDomains when it is new. When dashboardTracking.snapshots changes the switch of an existing site that no owner has set, the call discards that site's snapshots. 404 while the option is off, 400 without a usable host.

Context and blocks

RouteAuthPurpose
GET /context, PUT /contexttenant memberThe context bar: the tenant's websites with their live state and the caller's selection. PUT {website} stores the selection, see Context and period.
GET /blocks/kpi?metric=tenant memberOne KpiCard: pageviews, sessions, new-visitors or custom-events, with its change and sparkline.
GET /blocks/traffic?metric=tenant memberThe traffic ChartCard, with the comparison window as a second series.
GET /blocks/qualitytenant memberBounce rate, average session duration and pages per session, with their change.
GET /blocks/devicestenant memberThe devices TopListCard.
GET /blocks/tops?group=tenant memberOne tabbed top-list card: content, acquisition, audience or events (goal events flagged).
GET /blocks/top?dimension=&limit=tenant memberOne TopListCard over a rollup dimension, such as referrers or UTM contents and terms. limit defaults to 5, at most 50.
GET /blocks/channelstenant memberSessions per channel, with share and change.
GET /blocks/campaigns/rows?search=&filter_channel=is:<channel>tenant memberThe UTM campaign table (TableView.fromSource), { results, total }, paged. Per (source, medium, campaign, channel) key: share, daily sessions, derived channel and the missing-medium flag.
GET /blocks/campaigns/notice?kind=tagged|missingtenant memberThe notice beside the campaign table, for a stock Banner: the share of sessions tagged, or the sessions tagged without a medium. null when there is none.
GET /blocks/collection-noticetenant memberThe "collection paused" notice over the Websites grid and in the install guide, for a stock Banner. null while the module collects.
GET /blocks/website-noticetenant memberThe notice over an analytics page while its website has sent nothing yet, linking to the install guide, for a stock Banner. null in every other state, so once the first event arrived, and also for a paused or an imported-only site.

Statistics

RouteAuthPurpose
GET /stats/overview?website=&from=&to=tenant memberThe dashboard read, from rollups.
GET /stats/pages?website=&from=&to=&search=&limit=&sort=&workspace=tenant memberThe inventory of observed paths, { pages, total, truncated, sampleRate, trackerEnabled, snapshotsEnabled }, so the caller can explain an empty heatmap. limit defaults to 100 and is capped at 200. sort=clicks orders by clicks, anything else by views. workspace lets a platform owner read another workspace's dashboard site, or every workspace's with all.
GET /stats/heatmap?website=&path=&from=&to=tenant memberThe click heatmap, also served through the interface. website is optional and merges the tenant's sites when omitted, so pass it.
GET /stats/scroll?website=&path=&from=&to=tenant memberThe scroll-depth distribution of one path, with the same window, sampling and website rule as the clicks.
GET /stats/snapshot?website=&path=&layout=tenant memberThe page snapshot that the heatmap is drawn over: the capture at that layout, else the nearest one (exact: false), else null. layout is desktop, tablet or phone, and desktop when absent or empty. Any other value, Desktop included, answers 400. A document always wins over a row that records an oversize capture, which comes back as html: null with the bytes it reached.
GET /stats/workspaces?website=tenant memberThe workspace selector of the Pages view, read with the page (server render included) so the panel never grows after the first paint. The DMS core tenants that have a dashboard website, the caller's first. Only for a platform owner on their own dashboard website, and only with two or more. [] otherwise.
/stats/pages, /stats/heatmap, /stats/scroll, /stats/snapshot with &workspace=<tenantId>|allplatform ownerThe same reads for another workspace's dashboard website, or every workspace's. Each read runs in its own tenant, then the results merge: cells re-keyed by anchor or grid cell, counts summed, and the sampling share over all declared pageviews. 404 for anyone else, or from a customer website. The snapshot is the newest capture in the scope, with its text masked server-side (masked: true).
GET /stats/heatmap/count?website=&path=tenant ownerWhat the reset below would delete, {events, snapshots} over every period, for its confirmation dialog.
DELETE /stats/heatmap?website=&path=tenant ownerHeatmap reset. Deletes the clicks, scroll depths and snapshots of one path, or of the whole site without path. website is required. Answers {events, snapshots} deleted. The dashboard purges a whole site through POST /websites/:id/purge.

Funnels

RouteAuthPurpose
GET /funnels/rows?filter_kind=is:funnel|abtenant memberThe funnels table (TableView.fromSource), { results, total }. Per funnel: sessions entered, conversion and its change in points, or the A/B test's state.
GET /funnels/winnertenant memberThe banner above the funnels table, for a stock Banner. In order: the days of the period that raw events do not cover, else the running test ready to decide (significant, leader ahead, 7 days served, 50 conversions per arm), else a comparison left out. null otherwise.
GET /funnels/templates?website=tenant memberFirst-run templates from the period's raw journeys: the top custom events, each led by the page viewed most often before it, with the sessions that would enter.
GET /funnels/:id/delete-confirmationtenant memberThe list's delete dialog worded for the row. A running test says that it stops.
GET /funnels/suggestionstenant memberThe site's top pages and custom events of the last 30 days, for the builder's autocomplete.
POST /funnels/previewtenant memberScores unsaved steps and a window over the last 30 days, for the builder.
GET /funnels/:id/resultstenant memberThe funnel computed at read time. Each step lists the events it matches, 0 for a step never sent. previous is the same computation over the comparison window, for plain funnels and drafts, and only when raw events cover it (coverage says what they cover). When the funnel carries an A/B split, the per-arm read uses the same steps over the split's runs: exposed sessions, conversion, z-test verdicts with the lift interval (Bonferroni past two arms), the SRM check, decision (days served, ready) and verdict. verdict is the one reading that the report, its stop dialog and the list share: kind (winner, loser, flat, early or withheld) and the leader arm it names.

Data controllers and settings

RouteAuthPurpose
/tables/funnels/*platform ownerThe funnels DataController (TableView CRUD, scoped to the tenant instance with @TenantScopedModel). It enforces the split's draft → running ⇄ stopped lifecycle, stamps the runs it produces, and freezes the key and variations outside draft.
/tables/websites/*platform ownerThe read-only websites DataController behind the Websites page's table and the relation pickers. Global table, scoped by column. list and get answer each row with its card: state, sessions, pages and funnels over 30 days, accepted hosts, snapshot and sampling state, and recently refused hosts. The /websites writes publish on marketing.websites, the table's realtimeTopic.
GET /settings, PUT /settingsplatform ownerThe settings form. PUT merges a partial body: a key left out keeps its value, and null or the default itself resets it to the config default. It refuses with 400, with the issue under the field, a snapshot retention longer than the raw-event retention or a statistics retention shorter than it. It answers 409 to the first save of a retention cut that deletes data, and saving again confirms.
GET /settings/collection, POST /settings/collectionplatform ownerThe master switch, the websites and their 30-day sessions. POST {enabled} flips the switch.
GET /settings/collection/bannerplatform ownerThe Collection section, for a stock Banner: state, coverage, and the pause (confirmed) or resume action.
GET /settings/glance?item=platform ownerOne Meter of At a glance: raw, statistics or snapshots retention, on a shared scale.

Period parameters

The tenant-member routes under /blocks, /stats, /funnels/rows, /funnels/winner, /funnels/templates and /funnels/:id/results read their window from the period scope, see Context and period. Without from and to, they read the last 7 days.

Cross-origin requests

Tracked sites need no CORS grant. The tracker posts text/plain, a CORS-safelisted type that sends no preflight. The backend parses the JSON body whatever its content type, and gates on the Origin header that the browser sets instead. The assignment read keeps the same property the other way round. It is a script that the page loads with <script src>, not JSON that a page would need CORS to read. The @antelopejs/api CORS configuration matters only for the authenticated console origins.