Delete user from metabase db

I want to delete a user from the metabase database.
So not only deactivate, but I really want it completely gone.

Would it be enough to delete it from the table core_user ?
Nothing else has happend with the account, so there is nothing linked to it from the reporting side.
Account was just created and linked to a role group.

Hi @timothyv
You can delete users completely in core_user - there is a lot of constraints to group*, collection*, activity, report_* and other tables, so make sure those are resolved too, since you’ll otherwise leave the application database in a corrupted state, which might be a problem in the future during upgrades.

Hmm seems a bit risky then if I oversee one record/table.

@timothyv There should be constraints prohibiting you from deleting the user before the constraints.
But any manual changes to the application database needs to be done with a lot of caution.

So there is a delete button normally?

@timothyv No, there’s no actual delete API:
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#delete-apiuserid
How about you just rename the user and change the email, and then deactivate?

That’s idd what I did for now.
Seems like a safer thing to do.

hello @flamber is it possible delete the user (using api) that the last login is more than 6 months?

@herrsiqueira I don't understand. Like I wrote; there is not a way to delete a user via the API.
If you need to delete the users, then you would have to do that in the database.

Sorry @flamber,

I want to implement a code in python using the api to disable all users who have not logged in for more than 6 months.
Is there anything in the api to help me with this?

@herrsiqueira Yes, you would get all the metadata of the users:
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apiuser
And then loop through all of them and deactivate the ones that hasn't logged in for 6 months:
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#delete-apiuserid