Platform Management Queries
The Platform Management API is useful for Tenant Administration and Management of Poly Lens accounts. Some examples include tenant name, device user count, device count, and room & site information. Keep in mind that the Lens API Playground uses a clientID
and clientSecret
for Authorization. So even if you have have admin access to multiple tenants, you'll only see data results from the tenant your cliendID
and clientSecret
map back to.
We'll start by running a query to find the tenant ID, name, device user count (memberCount), device count, and room count.
It's important to note that memberCount
in this query refers to Tenant Users, i.e., members that have access to the Poly Lens Admin Portal.
query tenantInfo {
tenants {
id
name
memberCount
deviceCount
roomData {
total
}
}
}
In the sample output below you'll see that the data returned matches the structure of the query - this predictability is one of the benefits of GraphQL.
The tenantID
is redacted, but take note of your tenantID
as you'll need it for the next query.
{
"data": {
"tenants": [
{
"id": "695xxx-bxxx-4xxx-axxx-1xxxxx",
"name": "DFossDemo",
"memberCount": 15,
"deviceCount": 84,
"roomData": {
"total": 15
}
}
]
}
}
Now that we have the tenantID
, we can run a query to return details for Tenant Users. In this instance, Tenant Users refer to Account Members (users with account management access) not Device Users (users associated through a Poly Lens App).
We'll need to pass two variables into the users
: roles
and resourceID
.
If you've spent time in the ACCOUNT > Manage Accounts > Accounts Members section of the Poly Lens UI, you've likely noticed these roles listed as: Admin, Device Manager, and Guest. When you're passing these roles into the Lens API, you'll need to use admin
(Admin), it-admin
(Device Manager), or user
(Guest) or device_user
(Poly Lens App Users). The resourceID
field is your tenantID
.
We'll target Tenant Admins in this query and give it a name that reflects its scope. We're only using a subset of the available fields in Root/users/edge/node
- head over to the Lens API Playground to see the full list.
query tenantAdmins($params: UserSearchParams!) {
users(params: $params) {
count
edges {
node {
email
email_verified
last_ip
last_login
app_metadata {
info {
authedClients
}
}
}
}
}
}
Variables
{
"params": {
"grants": [
{
"roles": "admin",
"resourceId": "695xxx-bxxx-4xxx-axxx-1xxxxx"
}
]
}
}
This is a sample of the result from the query above (reduced to 1 user for conciseness). You'll notice count
returned 6 users - this is because we limited the scope to the admin
role.
{
"data": {
"users": {
"count": 6,
"edges": [
{
"node": {
"email": "danny.reed@poly.com",
"email_verified": true,
"last_ip": "8x.x1xx.1xx.1xx",
"last_login": "2023-01-30T03:52:43.684Z",
"app_metadata": {
"info": {
"authedClients": [
"Poly Lens Desktop",
"RapidAPI Developer Portal",
"Poly Lens",
"GraphQL Playground"
]
}
}
}
}
]
}
}
}
The queries above are just a small subset of the power of the Platform and Management APIs - enough to hopefully get you started with exploring the Poly Lens API Marketplace. We'll be updating this article with more examples over time. If you have specific requests reach out to mailto: DL-DeveloperSupport@poly.com.