# Remove users script either via API or PG available?

**URL:** https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194
**Category:** Support
**Created:** [March 17, 2016, 1:59pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194 "2016-03-17T13:59:19Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Jared\_Needell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jared_needell/32/116554_2.png) [@Jared\_Needell](https://meta.discourse.org/u/Jared_Needell)
#### Post date: [March 17, 2016, 1:59pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/1 "2016-03-17T13:59:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [March 17, 2016, 2:02pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/2 "2016-03-17T14:02:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Jared\_Needell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jared_needell/32/116554_2.png) [@Jared\_Needell](https://meta.discourse.org/u/Jared_Needell)
#### Post date: [March 17, 2016, 2:05pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/3 "2016-03-17T14:05:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [March 17, 2016, 2:07pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/4 "2016-03-17T14:07:43Z")

</div>

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.

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![Jared\_Needell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jared_needell/32/116554_2.png) [@Jared\_Needell](https://meta.discourse.org/u/Jared_Needell)
#### Post date: [March 17, 2016, 2:18pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/5 "2016-03-17T14:18:52Z")

</div>

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…

> <https://pastebin.com/Etugzdfa>

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [March 17, 2016, 2:25pm UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/6 "2016-03-17T14:25:58Z")

</div>

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

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

```

As a form data of

```plaintext
context=/admin/users/_your_users_userid_/_username_

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 29, 2018, 4:28am UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/7 "2018-12-29T04:28:49Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 27, 2021, 4:56am UTC](https://meta.discourse.org/t/remove-users-script-either-via-api-or-pg-available/41194/8 "2021-11-27T04:56:43Z")

</div>


