Developer docs / Integrations
Observability hooks and API
The events, read endpoints and alerts that let your own systems follow what happens in a store: what each sends or answers, and how the data is collected.
Why and what there is
Why: a store owner sees the summary, traffic, reports, alerts and usage in Admin, Observability; a team that runs its own tools should get the same facts where they work, without scraping the dashboard. How: two kinds of hooks, both available.
- Events: delivered like store webhooks, to a URL or to an alert channel plug-in.
- Read endpoints: the numbers behind each Observability page, in the owner API.
Events
Each event is a POST of { id, type, created_at, data } from the store, signed and retried the same way as every store webhook (see Webhooks) and listed by the events API (GET /api/owner/events). Subscribe a webhook to them under Admin, Webhooks, or a plug-in with the observability.read permission.
Why through the store: a store's webhooks and plug-ins live in the store, so these events reach them exactly like order and product events. How: the platform records each event, with its own id, and hands it to the store, which signs and sends it; the same id sent twice is recorded once. While a store does not answer (an outage), its events wait at Commernauts and arrive when it answers again, for up to a day. The alert channels do not wait: Commernauts sends those itself.
| Event | When it is sent, and its data | Status |
|---|---|---|
| observability.alert.opened | An alert rule fired: { alert: { id, rule, subject, state, title, detail, opened_at, resolved_at, url } } | Available |
| observability.alert.resolved | The rule holds again; the same alert with state resolved and resolved_at | Available |
| observability.threshold | A rule's number was crossed (page views drop, sold-out landings, plan limits, few orders): { threshold: { rule, subject, metric, value, limit, at } } | Available |
| observability.daily_summary | Every day after 07:00 UTC, for every live store: { summary: { day, page_views, visitors, orders, revenue_minor, currency, failed_requests, requests, uptime } } (orders, revenue and currency null where the app does not sell; failed_requests, requests and uptime are always null) | Available |
| observability.event | Every event the store counted, in the batches they arrived in (up to 25): { events: [{ id, name, at, channel, channel_group, visitor, session, path, device, country, value_minor, tags }] }. visitor is the daily hash (d_) or, with consent, the visitor id (v_). A stream; a plug-in needs the observability.events permission, which the owner grants at install | Available |
Alert channels are plug-ins: Email is the default, Slack and Microsoft Teams ship as plug-ins, and a plug-in you build can send alerts anywhere else (see Build an alert channel). An admin chooses which alerts go to which channel.
The stream. observability.event comes with every counted event, so a webhook subscribed to every event ("*") does not get it: tick it by name under Admin, Webhooks, or name it in a plug-in's events. The store sends it itself, at once, to the webhooks and plug-ins that name it.
Permissions
Why: usage and plan, and the alert rules, are the business of fewer people than the counts. How: three store permissions, given like any other on a role, a person or an API token. The dashboard checks them on the Admin pages, and the read endpoints and alerts check the same names.
| Permission | What it opens | Held by default |
|---|---|---|
| observability.read | Summary, Traffic, Products, Search terms and Reports, and their read endpoints | Every role |
| usage.read | Usage and plan, and its read endpoint | Superadmin, Admin, Viewer |
| alerts.manage | Creating and changing alert rules and channels | Superadmin, Admin |
A store's own roles hold none of them until the owner ticks them under Admin, Team, Roles and permissions. An API token holds the ones picked for it on Admin, API access.
Alerts: rules, channels and each person's choices
Why: an agency or a script may set alerts up for many stores, and read what fired. How: the platform's own owner API, answered by Commernauts, with the owner session or an API token. Reading needs observability.read or alerts.manage; changing rules, channels and the self-service switch needs alerts.manage. A person's own choice is set only by that person: there is no endpoint that sets another person's, and an API token has none.
| Endpoint | What it does |
|---|---|
| GET /v1/stores/:id/admin/platform/alerts | Every rule (id, enabled, threshold and its unit and range; with alerts.manage also recipients, people, email and channels), your own choice and whether each reaches you, self_service, the channels (id, plugin, label, host, last_status; never the webhook address), the people, and the last 50 alerts |
| PUT /v1/stores/:id/admin/platform/alerts/rules/:rule | { enabled, threshold, recipients (admins, team or people), people, email, channels }; any field may be left out |
| PUT /v1/stores/:id/admin/platform/alerts/settings | { self_service: true or false }: whether people may turn alerts on for themselves |
| PUT /v1/stores/:id/admin/platform/alerts/mine/:rule | { choice: on, off or default } for the caller only; :rule may be * for every rule; off always works, on needs self_service |
| POST /v1/stores/:id/admin/platform/alerts/channels | { plugin: slack or teams, label, webhook_url }: the address must be a Slack (hooks.slack.com) or Teams (logic.azure.com, powerplatform.com, webhook.office.com) incoming webhook; it is sealed and never returned |
| POST .../alerts/channels/:id/test, DELETE .../alerts/channels/:id | Send a test message; remove the channel (and from every rule) |
| POST .../alerts/test-email | A test email to the caller's own address |
Rule ids: page_drop (percent, default 50), out_of_stock_landing (count, default 3, shops only), usage (percent, default 80), orders_low (count, default 5, shops only), daily_summary. On by default: usage.
How the data is collected. The rules run on the platform's five-minute cron: for each live store it asks the store's own numbers (GET /api/owner/observability/signals, platform only) for the parts an active rule needs, hourly, and the daily summary once after 07:00 UTC. An alert opens once per rule and subject and resolves when the rule holds again. At most 40 alert messages a store an hour; beyond that an alert is recorded as held. Resolved alerts are kept 90 days.
Build an alert channel
Why: Email, Slack and Teams cover most teams; a plug-in can send alerts to a pager, a ticket system or anything else. How: a plug-in (commernauts.plugin/2) that asks for the observability.read permission and subscribes to the observability events. When the owner installs it, the store sends it those events like any other: alert opened and resolved, thresholds and the daily summary.
{ "format": "commernauts.plugin/2", "permissions": ["observability.read"], "events": ["observability.alert.opened", "observability.alert.resolved"], "settings": [{ "key": "token", "label": "Pager token", "type": "secret", "required": true }], "worker": { "main": "..." } }
In the Worker, read event.type and event.data.alert (title, rule, subject, url) and call your service with fetch; answer { actions: [] }. With @commernauts/plugin the events and their data are typed (Event.AlertOpened, AlertData). A plug-in channel gets every alert of the store; the store sends to it when the store answers, so while a store does not answer its alerts reach plug-ins once it answers again, and Email, Slack and Teams get them at once.
Read endpoints
Each Observability page reads from an owner API endpoint, with an API token or the owner session. Usage and plan needs usage.read, and every other page needs observability.read.
| Endpoint | What it answers | Status |
|---|---|---|
| GET /api/owner/observability/today?range= | A range (default the last 24 hours) against the period before it of the same length: revenue over the range, top channels, landing pages losing visits and the biggest drop in the purchase journey (see Summary below) | Available |
| GET /api/owner/observability/reports/:report | One report for a range (traffic, devices, countries, pages, landing, search, events, paths, visitor_cohorts, products, funnel, funnel_builder, attribution, revenue, customer_retention, abandoned, sold_out, coupons, sales, product_sales), with ?format=csv for a file | Available |
| GET /api/owner/observability/reports | The report collections | Available |
| GET /api/owner/observability/usage | This month's events, requests, picture copies and assistant answers against the plan's limits, storage now, day by day, and the days of history kept | Available |
Reports: the read endpoints
Why: your own dashboards, a data warehouse or a script should read the same numbers the owner sees, from the store's own data. How: GET /api/owner/observability/reports/:report with an API token or the owner session holding observability.read. Every report answers the same shape; add ?format=csv for a CSV file (key, label and every column, up to 10,000 rows).
| Query | What it does |
|---|---|
| from, to | YYYY-MM-DD, or YYYY-MM-DDTHH:MM, in the store's time zone; default the last 24 hours. Cut to the plan's history, except for revenue, coupons, customer_retention, abandoned, sales and product_sales, which read orders. |
| range | Instead of from and to: 1h, 3h, 24h (the default), today, yesterday, 7d, 28d, 30d, 90d, 365d, month or last_month, counted in the store's time zone, or custom with from and to |
| compare | none, previous (the same number of days before) or year (the same days a year earlier); tables only |
| dim | The dimension, for example channel_group, source_medium, source, medium or campaign on traffic; the first is the default |
| channel, device, country, market | Filters: online_store or ch_ + 20 hex; phone, tablet or desktop; an ISO 3166-1 alpha-2 code; a market id from GET /api/owner/consent |
| sort, dir, q, limit | A column id (or key), asc or desc, a text the row's name holds, 1 to 1,000 rows (default 100) |
| chart | The column the series draws |
| model | attribution: last, first, linear or position |
| breakdown | funnel and funnel_builder: none, device or channel_group |
| steps | funnel_builder: 2 to 6 event names, comma-separated, in order |
| start | paths: the page the paths start from |
| event, tag | events with dim=tag: the event and the tag whose values are counted |
| Field | What it holds |
|---|---|
| report, from, to, dimension, currency | What was answered; money is in the currency's minor unit (cents) |
| compare | The comparison range, or null |
| columns | The column ids this report answers |
| rows | key, label (a product's title, a market's name) and values by column id; with a comparison, before holds the same columns for the comparison range. A rate with nothing to measure is null, not 0 |
| total_rows, totals | Rows before q and limit, and the totals (values, before) |
| series | The chart: metric, days and lines (key, label, points per day); null for reports without one |
| funnel | funnel and funnel_builder: breakdown, steps, and groups (all first) with sessions per step |
| cohorts | visitor_cohorts and customer_retention: grain (week or month), periods and rows (cohort, size, cells: the share returning per period) |
| limited | Set when the report or a column reads single events and the range starts earlier than they are kept: raw_days and raw_from |
| note | paths: visitor_id_only with the number of visits followed; capped when a report read its maximum of single events |
| annotations | Notes on the days of the range: id, day, text, by, auto (true for the store's own marks) |
Reports from the daily totals (traffic, devices by device, countries, pages views, landing, search, events by name, products, sold_out) reach as far back as the plan keeps totals. Reports and columns from single events (visitors, browser and operating system, paths, visitor_cohorts, funnel, funnel_builder, attribution, events by tag, revenue on pages) reach 90 days at most.
| Endpoint | What it does | Permission |
|---|---|---|
| GET /api/owner/observability/report-views?report= | Your saved views of a report and those your team shared | observability.read |
| POST /api/owner/observability/report-views | Save a view: report, name, query (the report's query string), shared, is_default | observability.read |
| PATCH, DELETE /api/owner/observability/report-views/:id | Change or delete one of your own views | observability.read |
| POST /api/owner/observability/annotations | A note on a day: day, text (1 to 200 characters) | observability.read |
| DELETE /api/owner/observability/annotations/:id | Delete your own note, or any as the owner | observability.read |
| PUT /api/owner/observability/report-collections | Arrange the collections: collections (id, name, hidden, reports), or reset: true | settings.write |
How the data gets there: as the store counts an event it also adds it to event_dim_daily, its daily totals per page, product, search term (with its group), visit source, campaign and landing page, each split by channel, channel group, device and country. Purchases add their value to the visit's source, campaign and landing page, and to each search the visit made. Saved views, notes and the collections are rows in the store's own database too.
Summary: the read endpoint
Why: a report or a chat bot should say what changed over the hours or days it asks about, including a moment ago. How: GET /api/owner/observability/today with observability.read and a range: range=1h, 3h or 24h (the default, counted back from now), today, yesterday, 7d, 28d, 30d, 90d, 365d, month or last_month, or range=custom with from= and to= (YYYY-MM-DD, or YYYY-MM-DDTHH:MM in the store's time zone). Whole days are read from the daily totals; any other range from single events. It reads the same reports as GET /api/owner/observability/reports/:report, which take the same range keys. The daily summary email always covers yesterday.
| Field | What it holds |
|---|---|
| day, before, range, previous, kept | The first day of the range and of the period before (YYYY-MM-DD); range: the range as answered (from_at and to_at in ms, exact when read from single events, grain minute, hour or day, the store's time zone); previous: the period before; kept: set when the range reaches back further than the plan keeps |
| currency, commerce | The store's currency; false for a content site or docs app (no orders, revenue or funnel) |
| totals | day (the range) and before (the period before): sessions, visitors, page_views, orders, revenue (net sales, minor units), conversion_rate |
| revenue | Each chart bucket of the range (a day, or an hour or minutes for a short range): key, revenue, orders |
| channels | Up to 5 channel groups by visits: key, label, sessions, before, purchases, revenue |
| landing | Up to 5 landing pages with fewer visits than in the period before: path, sessions, before |
| funnel | steps (session_start, view_item, add_to_cart, begin_checkout, purchase with sessions) and drop: the step pair with the lowest share going on (from, to, reached, went_on, rate) |
The Daily summary alert email lists the same highlights (top channel, landing loss, funnel drop).
Usage and plan: the read endpoint and the limits
Why: a store, an agency or a monitoring tool should see how close a store is to its plan's limits before anything is turned away. How: GET /api/owner/observability/usage, with an API token or the owner session holding usage.read.
| Field | What it holds |
|---|---|
| month, resets | The month shown (YYYY-MM, UTC) and the day the counts start again (YYYY-MM-DD) |
| plan, tier, overridden | The plan's name, its tier (starter, growth, scale, custom) and whether Commernauts set limits for this account alone |
| events | used, limit (null: no limit), refused (turned away this month) and paused (true once the month's events are used up) |
| requests | used and limit (null: no limit); requests are never refused |
| copies | used, limit (null: no limit) and paused (the month's copies are used up): picture sizes the store made with Cloudflare Images |
| storage | used and limit in bytes, databaseBytes and picturesBytes, pictures (how many), complete (false while the pictures are still being measured for the first time) and countedAt (ms) |
| assistant | used and limit this month, added by Commernauts (null when the store is asked directly) |
| historyDays | Days of history: daily totals for all of them, single events and visits for at most 90 |
| days | Each day of the month so far: day, requests, events, refused, copies |
| source | platform (limits checked within the hour), kept (the platform could not be asked; the last limits apply), starter (no answer yet) or self_hosted (no platform) |
At the events limit, POST /api/events answers each event from a front end with status rejected and reason monthly_limit, and stores nothing of it, until the month ends (UTC). The store's own records (cart, checkout, payments, refunds and searches through its API) are always kept. A front end should not retry these: the answer is final for the month.
At the other limits: storage is counted and never refused; past the month's picture copies a page gets the nearest size the store has; past the month's assistant answers POST /v1/stores/:id/ai-usage answers 429 assistant_quota until the month ends.