Analytics scope options (H07)
:::caution Registered in code — live after the owner's next deploy
GET /v1/orgs/{orgId}/analytics/scope-options is the one 009 route
registered in lib/routes.ts. It becomes callable after the owner's next
deploy; until then the gateway answers 404.
:::
What this API serves and what TCP serves
Analytics and Compare charts are TCP-served. This HTTP API never connects to the telemetry store and never returns a telemetry value, KPI or aggregate.
| Screen element | Served by |
|---|---|
| Filter bar vocabulary (customers, regions, tags, device types, period presets), plant count, installed capacity | HTTP — H07 (this page) |
| Energy/yield/power charts, KPIs, comparisons, rankings, time series | TCP (cse-tcp-be) |
| Report library, generation, schedules, downloads | HTTP — Reports (planned) |
| Rendering report files from telemetry | TCP renderer — see Reports pipeline |
The TCP-side requirements are documented in the TCP Server docs and in TCP dependencies.
H07 — Analytics scope options
GET /v1/orgs/{orgId}/analytics/scope-options
- Auth: Cognito JWT. An access path to
{orgId}with plants ≥ VIEW or reports ≥ VIEW, else403 FORBIDDEN. - Query: none; any query parameter →
400 VALIDATION_FAILED. - Response 200 (illustrative example, not executed; operator member with scope ALL):
{ "customers": [{ "customerOrgId": "01J…", "code": "CU-1042", "name": "Regal Textiles Pvt Ltd" }],
"regions": [{ "tagId": "01J…", "label": "Lahore" }],
"tags": [{ "tagId": "01J…", "label": "VIP", "group": "COMMERCIAL" }],
"deviceTypes": [{ "key": "INVERTER", "label": "Inverter" }, { "key": "LOGGER", "label": "Data logger" },
{ "key": "METER", "label": "Meter" }, { "key": "BATTERY", "label": "Battery" },
{ "key": "OTHER", "label": "Other" }],
"periodPresets": ["TODAY","YESTERDAY","LAST_7_DAYS","LAST_30_DAYS","THIS_MONTH","LAST_MONTH","THIS_YEAR","LAST_YEAR","CUSTOM"],
"totals": { "plantCount": 1284, "pvCapacityKwp": 9800, "approximate": true },
"scope": { "kind": "ALL" },
"truncated": { "customers": false, "tags": false } }
- Fields:
tags[].groupis aTagGroup(SEGMENT,COMMERCIAL,SERVICE,COMPLIANCE);REGIONtags appear inregions, nottags.scopeis{ kind, ids? }with kindALL|CUSTOMER|REGION|TAG|PLANTS.totals.approximateisfalseonly for PLANTS-scoped members (summed exactly); otherwisetrue.
Behaviour by caller
| Caller | Lists | Totals | scope |
|---|---|---|---|
| Crown HQ (PLATFORM org) Super Admin / Administrator, built-in role, scope ALL (since 2026-11-27, AN-7) | customers = every ACTIVE customer on the platform (each Business's customers plus Independent End Users' personal orgs; name order, ≤ 200, then truncated.customers: true; since 2026-11-30, B-4 — before that the list was always empty); regions = every region tag holding an ACTIVE plant fleet-wide (label from the owning org); tags: [] | fleet-wide counters (FLEET#ALL, ADR 0024 — the same figures as the HQ dashboard); counts ACTIVE plant records, so it can differ from TCP rankings, which count plants with reporting devices | {kind:"ALL"} |
| Operator member, scope ALL | customers ≤ 200, tags ≤ 500 (then truncated.*: true; fall back to search) | org counters; pvCapacityKwp omitted when the sum counter is missing | {kind:"ALL"} |
| Operator member, scope CUSTOMER / REGION / TAG | only the member's own targets of that kind | summed from each target's counter; a plant in two targets counts twice; pvCapacityKwp always omitted | {kind, ids} |
| Operator member, scope PLANTS | empty customers/tags | exact, from the plants themselves | {kind:"PLANTS", ids} |
| Operator member, scope NONE | empty | 0 | {kind:"PLANTS", ids: []} |
| Customer portal | customers, regions, tags all empty | own plants (≤ 500 read, else approximate) | {kind:"PLANTS"} |
| Partner org | empty | zero | {kind:"PLANTS"} |
A caller with customers: NONE (every End User) gets customers: [] and truncated.customers: false on every row
of this table (RBAC-S13, 2026-11-23; built, not deployed): the response never carries other customers' names to
them. The filter bar should hide the customer filter when the list is empty.
Only ACTIVE plants are counted; negative capacities count as 0.
- Status codes: 200 · 400
VALIDATION_FAILED· 401 (gateway) · 403FORBIDDEN· 500INTERNAL· 503DEPENDENCY_UNAVAILABLE.