# Deleting a user via discourse api

**URL:** <https://meta.discourse.org/t/deleting-a-user-via-discourse-api/348202>\
**Category:** Product Support\
**Created:** [January 20, 2025, 1:42pm UTC](https://meta.discourse.org/t/deleting-a-user-via-discourse-api/348202 "2025-01-20T13:42:53Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![gormus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gormus/32/428592_2.png) [@gormus](https://meta.discourse.org/u/gormus)\
**Post date:** [January 20, 2025, 1:42pm UTC](https://meta.discourse.org/t/deleting-a-user-via-discourse-api/348202/1 "2025-01-20T13:42:53Z")

</div>

User accounts can be deleted via [Discourse API](https://docs.discourse.org/#tag/Admin/operation/deleteUser) as well.

For example;

```http
DELETE /admin/users/{id}.json HTTP/1.1

Content-Type: application/json
Api-Username: system
Api-Key: 1234 *******

{
  "delete_posts": true,
  "block_email": false,
  "block_urls": false,
  "block_ip": false
}

```

\* _The request is simplified for readability._

As you can see the payload options allows deleting the user generated posts in the same requests, as opposed to deleting the posts prior to account deletion when accounts are deleted manually in the admin page.

* * *

However, I’m getting a 403 access denied error for this request, even though the API key has a _global_ scope, and the user is `system`:

```json
{
  "errors": ["You are not permitted to view the requested resource."],
  "error_type": "invalid_access"
}

```

---

_[View the full topic](https://meta.discourse.org/t/deleting-a-user-via-discourse-api/348202)._
