Suspend a user via the API

I spent quite some time to figure this out so I thought I’ll share it for the next person who want to do this: suspend a user via the API.

If you use Discourse web interface, you can go to the route /admin/users/:username and then use the suspend button. You can find the suspend method in UsersController. Well turns out that you should not use :username in the route but the user_id.

To conclude, to disable a user via the API, use /admin/users/:user_id/suspend

8 Likes

Also, more details in the current API documentation: http://docs.discourse.org/#tag/Admin%2Fpaths%2F~1admin~1users~1{id}~1suspend%2Fput

3 Likes

I think a good v2 for this article would be a “Common API operations” article that incorporates several of the usual suspects.

We’d be willing to pay for this rewrite so please send me a PM if you’re interested.

6 Likes