Worked stats samples
The endpoint list below documents every operation’s parameters; this overlay walks the carbon analytics read the way an ESG-conscious integration actually uses it: read the tenant’s carbon figure → export it for a ledger or a ToS-respecting disclosure. Success envelopes are{ data, meta }, error envelopes { error, meta } — see How to read a
worked sample. The carbon metric is
aggregated, not real-time — expect the poll cadence of a nightly rollup
when you poll from a dashboard.
Every response carries meta.request_id. Quote the request id when you
report a number that drifts from what the CSV shows or a window that
rounds differently than the dashboard read.
1. Read the carbon figure
GET /api/v1/stats/analytics/carbon returns your tenant’s platform-side
carbon metric for the analytics window. The response is a single
aggregate calculable off the same time-series the rest of the analytics
stack reads — a dashboard, a BI export, and this read all agree.
200
per_channellists one line per channel — a message channel counts outbound messages (unit: "message"); voice counts connected minutes (unit: "minute", read from call logs, never the message table).total_kg_co2eis the same total expressed in kilograms of CO₂-equivalent for ESG reporting;factors_versionnames the emission-factor set so downstream reports document provenance.
2. Export the carbon figure
GET /api/v1/stats/analytics/carbon/export returns the same report in a
ledger-friendly export format (?format=csv). Use it for the annual
disclosure bundle or a regulator-side CSV handoff.
200
#-prefixed header lines carry the factor-set version and the window so
the exported numbers are self-describing; the TOTAL row closes the report.
2b. The per-period rollup shape
The same window also reduces to the compact per-period rollup{ data: { period, totals: { co2e_grams }, by_channel: [...] }, meta }:
200
totals.co2e_grams sums the per-channel lines (rounded to one decimal); a
channel with no traffic in the period is absent rather than zero, so
by_channel can legitimately be an empty array for a quiet tenant.
3. Errors
Errors follow the{ error, meta } envelope. The failure every exporter
hits:
422 — malformed export format. An unsupported format query value
never reaches the renderer:
422