Get statistics by label
const url = 'http://localhost:3000/api/v1/groups/by-label/environment';const options = {method: 'GET', headers: {'X-API-Key': '<X-API-Key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url http://localhost:3000/api/v1/groups/by-label/environment \ --header 'X-API-Key: <X-API-Key>'Retrieves device statistics grouped by a specific label key.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
environmentLabel key to group by
Header Parameters
Section titled “Header Parameters”UUID of the organization (tenant) the request acts in. It selects the tenant and grants nothing: the server checks membership or an open tenant switch. Not needed for global operations. A malformed value returns 400. API keys are fixed to their own organization; another organization returns 403. The x-organization-source header grants nothing.
Responses
Section titled “Responses”Statistics retrieved successfully
object
The label key used for grouping
Statistics for each label value
object
Label value
Number of devices with this label value
Status breakdown for this group
object
Number of online devices
Number of offline devices
Number of pending devices
Number of devices in error state
Total number of devices across all groups
Example
{ "labelKey": "environment", "groups": [ { "value": "production", "count": 25, "byStatus": { "online": 45, "offline": 5, "pending": 2, "error": 1 } } ], "total": 53}Unauthorized
Forbidden — caller lacks required permission