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


Also, more details in the current API documentation:{id}~1suspend%2Fput


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.