Skip to content

Get statistics by label

GET
/api/v1/groups/by-label/{key}
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.

key
required
string
Example
environment

Label key to group by

x-organization-id
string format: uuid

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.

Statistics retrieved successfully

Media typeapplication/json
object
labelKey
required

The label key used for grouping

string
groups
required

Statistics for each label value

Array<object>
object
value
required

Label value

string
count
required

Number of devices with this label value

number
byStatus
required

Status breakdown for this group

object
online
required

Number of online devices

number
offline
required

Number of offline devices

number
pending
required

Number of pending devices

number
error
required

Number of devices in error state

number
total
required

Total number of devices across all groups

number
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