Skip to main content

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 elementServed by
Filter bar vocabulary (customers, regions, tags, device types, period presets), plant count, installed capacityHTTP — H07 (this page)
Energy/yield/power charts, KPIs, comparisons, rankings, time seriesTCP (cse-tcp-be)
Report library, generation, schedules, downloadsHTTP — Reports (planned)
Rendering report files from telemetryTCP 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, else 403 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[].group is a TagGroup (SEGMENT, COMMERCIAL, SERVICE, COMPLIANCE); REGION tags appear in regions, not tags. scope is { kind, ids? } with kind ALL|CUSTOMER|REGION|TAG|PLANTS. totals.approximate is false only for PLANTS-scoped members (summed exactly); otherwise true.

Behaviour by caller​

CallerListsTotalsscope
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 ALLcustomers ≤ 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 / TAGonly the member's own targets of that kindsummed from each target's counter; a plant in two targets counts twice; pvCapacityKwp always omitted{kind, ids}
Operator member, scope PLANTSempty customers/tagsexact, from the plants themselves{kind:"PLANTS", ids}
Operator member, scope NONEempty0{kind:"PLANTS", ids: []}
Customer portalcustomers, regions, tags all emptyown plants (≤ 500 read, else approximate){kind:"PLANTS"}
Partner orgemptyzero{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) · 403 FORBIDDEN · 500 INTERNAL · 503 DEPENDENCY_UNAVAILABLE.