How to get User Role?

Hello!

I need to get the role of a user, but I can;t find a way to do it. I have read those two threads, but there is no solution.

In the API documentation only two entries are shown when I search for “ROLE”:

Remove user’s manager role

Give user manager role

The User Role does not exist as a parameter in all data, returned by the API:
id=000000;
email=000000@gmail.com;
name=My_Name;
memberships=System.Object;
profilePicture=https://img.clockify.me/no-user-image.png;
activeWorkspace=0000;
defaultWorkspace=0000;
settings=;
status=ACTIVE;
customFields=System.Object

The “memberships” is empty, “customFields” is also empty.

Hello,

You would be able to get a user’s role by using the Filter workspace users call

METHOD: POST
URL: https://api.clockify.me/api/v1/workspaces/{workspaceId}/users/info
Headers:
X-Api-Key - your api key
Content/Type - application/json

Body:

{
    "email": "input users email here",
    "includeRoles": true
}

You can also use “name” key instead of “email”.

The roles will be displayed in the payload:

"roles": [
            {
                "formatterRoleName": "Admin",
                "role": "WORKSPACE_ADMIN",

Hope this helps. Cheers!

1 Like

Thank you, Aleksandar.