How to delete users from Grok server

Hi Datagrok team,

I was trying to programatically delete users from Grok server (via JS API) but received an 404 error every-time.

Can you explain me what I am doing wrong?

Example

const user = await grok.dapi.users.filter('login = "userId"').first();
grok.dapi.users.delete(user)

There is no such endpoint, because you can’t delete a user. You can block it (right in the next version, I will add this feature), user.status = DG.USER_STATUS.BLOCKED

1 Like

Hello! Any update on this? Still no way to delete the user?

I don’t think it would be ever available, because user record is connected with user activity and objects ownership.

I think we cand implement safe delete (just marking users as deleted), but it’s pretty mush the same as block.

What is the purpose to delete user from your side? Maybe I’m missing something important.

Hi @eyewing - complete deletion of users is not implemented yet (perhaps in the next version), but as Alex said you can disable the account.

To disable a user account, login as administrator, navigate to Browse | Platform | Users, right-click on the user, and select “Block”. This will prevent user from logging in and using the platform, and this user
will not count towards the license.

All assets that the user has created will continue to be available in the system.
Administrators can share them with others if necessary.

Got it, thank you! Just experementing with user management, trying to understand how to deal with

2 Likes

Dear Datagrok team,
Hi, I would like to ask a question about how to get a list of users who are not bloked status through dapi.

For example, I wrote sample code snipet below. If possible I would like to have only unblocked users information. I am sorry for bothing you but it would be very helpful if you share a tip to do that.

const allUsersGroup = await grok.dapi.groups.filter('friendlyName="All Users"').first();
const allUsersMembers = new Set([
            ...allUsersGroup.members.map(m => m.friendlyName),
            ...allUsersGroup.adminMembers.map(m => m.friendlyName)
        ]); 

Thank you for your help in advance.
Best,
Kosuke

Dear Kosuke,

Thank you for your question!

To get a list of users who are not blocked, you can filter users by status = "active" using the dapi.users endpoint. Here’s how you can do it specifically for the “All Users” group:

await grok.dapi.users
  .filter(`status = "active" and group.parents.id = "${DG.Group.allUsers.id}"`)
  .list();

Please note: at the moment, this approach relies on group.parents, which isn’t directly exposed in the JavaScript API. We’re aware of this limitation and plan to make it possible to use standard group.memberships instead — making this type of query more intuitive and officially supported.

Best regards,
Pavlo

2 Likes

Dear Pavlo,
I appreciate your prompt reply. I could get only active usernames. Thanks a lot!
Best,
Kosuke

1 Like