Remove users script either via API or PG available?

AI-generated summary

Jared_Needell asked about deleting users via Postgres or API. cpradio replied that it’s possible via API and recommended using the browser’s Dev Tools/Console to reverse-engineer the API calls. cpradio shared a link on how to reverse-engineer the Discourse API and advised Jared_Needell to monitor API calls in the Network tab while deleting a user. After Jared_Needell shared the API calls he captured, cpradio pointed out the correct request: a DELETE method to https://_your_discourse_instance_/admin/users/18.json with form data context=/admin/users/_your_users_userid_/_username_.

I’m curious if it’s possible to delete users via Postgres or API?

API definitely, you simply have to open the Dev Tools/Console of your browser, go to the Network tab, perform the action in the browser and see what calls show up in the Network tab, that will tell you how to implement it via API.

You should be able to do it via Rails Console too

I don’t see any documentation on what the API methods are to remove a user.

The entire Discourse platform uses the API, so if you watch what the web application does, you can see what API calls to make. Which is where the Dev Tools/Console comes in play on your browser.

So I’m using firefox with the Network tab open, I got the users page in the admin console, selected to open the user then clicked clear on the Network console to only monitor API calls when I click delete.

I noticed I got one GET and 2 POSTs…

I don’t think you caught the request, it was this one

Request URL:https://_your_discourse_instance_/admin/users/18.json
Request Method:DELETE
Status Code:200 OK

As a form data of

context=/admin/users/_your_users_userid_/_username_