# Request: separate API granular API scope for 'suspend user"

**URL:** https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928
**Category:** Feature
**Tags:** rest-api
**Created:** [December 27, 2022, 1:31am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928 "2022-12-27T01:31:05Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [December 27, 2022, 1:31am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/1 "2022-12-27T01:31:05Z")

</div>

This is hopefully a small one. I would like to have a script which runs periodically and automatically suspends users whose accounts are disabled, locked, or otherwise removed in our centralized account system.

This is easily done through the API [Discourse API Docs](https://docs.discourse.org/#tag/Admin/operation/suspendUser). However, there appears to be no granular API scope covering just this. Since there _are_ scopes for Delete and Anonymize, hopefully this would not be too hard to add.

With this limitated scope, compromise of this key could let someone be annoying — but not incredibly disruptive otherwise.

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [December 27, 2022, 1:33am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/2 "2022-12-27T01:33:47Z")

</div>

There is already an [suspend user scope](https://docs.discourse.org/#tag/Users/operation/suspendUser) unless I don’t understand you correctly.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [December 27, 2022, 1:40am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/3 "2022-12-27T01:40:29Z")

</div>

Hi Ethan (or is it not-ethan?). There is an API endpoint. What I am looking for is an authorization scope for the corresponding API key. I want to be able to create an API key which can _only_ access this endpoint.

Take a look in the admin user interface. You will find something like this. (It continues on down the page with some more, but no “suspend” in the user section, unless I am missing something.)

 ![Screenshot_20221226-203520](https://global.discourse-cdn.com/meta/original/4X/1/8/9/189022a189a11b59d8d96b87d24594ea5d6cce19.png)

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [December 27, 2022, 1:45am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/4 "2022-12-27T01:45:55Z")

</div>

> [@mattdm](#):
>
> Hi Ethan (or is it not-ethan?).

I am anybody but Ethan.

* * *

~~I believe the scope would be updating users.~~

> [@mattdm](#):
>
> I want to be able to create an API key which can _only_ access this endpoint.

This is not possible. The closes is granting update user but that would also allow for other things like silencing (de)activating and other things I belive.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [December 27, 2022, 2:22am UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/5 "2022-12-27T02:22:04Z")

</div>

> [@not-ethan](#):
>
> This is not possible. The closes is granting update user but that would also allow for other things like silencing (de)activating and other things I belive.

I am not sure if the “update” endpoint and scope even cover this. But, yes, right — this would be too broad. Hence the request.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [January 23, 2023, 10:03pm UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/8 "2023-01-23T22:03:49Z")

</div>

Thanks for bringing this up @mattdm!

I just created a PR that adds the api scope for suspending users.

[https://github.com/discourse/discourse/pull/19965](https://github.com/discourse/discourse/pull/19965)

Pending any feedback it should get merged in soon.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [February 28, 2023, 7:44pm UTC](https://meta.discourse.org/t/request-separate-api-granular-api-scope-for-suspend-user/249928/9 "2023-02-28T19:44:54Z")

</div>


