Get users without licenses

Hello,

Is it possible, using Cryptlex API, to get the list of users without any licenses?

Thanks

Hi,

Can you please mention your use case?

Regards,
Adnan

Hello,

The use case is to clean expired licenses.
We were thinking of 2 steps:

  1. Delete expired licenses (with some time delta)
  2. Delete users without licenses (i.e. a user might have another active license, in that case user is not deleted)

Regards

Hi,

You can filter licenses using the email address and if it returns an empty array that means the user has no license.

Ok thank you.

So, with that solution we need to loop over all users. That is what we were thinking of. We were just wondering if there was a one call solution.

You don’t have to loop over all the users. At the time of deletion of the expired license,

const expiredLicenses = GET /v3/licenses?expired=true

for (let license in expiredLicenses)
{
DELETE /v3/licenses/license.id
GET /v3/licenses?email=license.user.email
If the above GET returns an empty array
DELETE /v3/users/<license.user.id>
}

Hello,

Indeed, it’s a better solution.

Thanks!