Set User's Status Active

Prev Next
Post
/api/v1/users.setActiveStatus

Activate or deactivate a user in the workspace.

Any one of the following permissions is required:

  • edit-other-user-active-status: Change another user's active status.
  • manage-moderation-actions: Manage moderation actions on reported users.

When a user is deactivated (activeStatus=false), Rocket.Chat revokes all of the user's login tokens and OAuth access tokens, refresh tokens, and authorization codes. The user can no longer call the REST API with previously issued OAuth credentials.

Changelog

Version Description
8.5.0 Added OAuth access token, refresh token, and authorization code revocation on deactivation.
3.7.0 Added confirmRelinquish to the payload.
0.75.0 Added
Header parameters
X-User-Id
stringRequired

The authenticated user ID.

ExamplerbAXPnMktTFbNpwtJ
X-Auth-Token
stringRequired

The authenticated user token.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
Body parameters

When deactivating a user (activeStatus=false) and confirmRelinquish=true:

  • If the user is the last owner of a room that has other active members, the member who joined earliest becomes the new owner.
  • If the user is the only member of a private room, or no other active member can take ownership, that room is deleted, together with every discussion that belongs to it, regardless of who is a member of those discussions. Public channels are not deleted.

When confirmRelinquish is omitted or false and the user is the last owner of any room, or the only member of a private room, the request fails with user-last-owner and no change is made. details.shouldBeRemoved names the rooms that would be deleted. details.shouldChangeOwner names the rooms that would get a new owner. Child discussions that the user is not subscribed to are not listed; any room in shouldBeRemoved also takes its discussions with it.

object
activeStatus
boolean Required

The value of the active status.

Defaulttrue
userId
string Required

The user ID whose status value is to be changed.

Example5HmCfpoB7jp2uibTC
confirmRelinquish
boolean

Only used when activeStatus is false. Set to true to deactivate the user even if they are the last owner of a room, or the only member of a private room. If omitted or false and the user is the last owner of any room, the request fails with user-last-owner.

Defaultfalse
Responses
200
Success Example
{
  "user": {
    "_id": "jJNyu4BQFqdgEcqnR",
    "active": false
  },
  "success": true
}
Expand All
object
user
object
_id
string
active
boolean
success
boolean
400

Bad Request

Example 1
{
  "success": false,
  "error": "must have required property 'activeStatus'\n[invalid-params]",
  "errorType": "invalid-params"
}
user-last-owner
{
  "success": false,
  "error": "[user-last-owner]",
  "errorType": "user-last-owner",
  "details": {
    "shouldBeRemoved": [
      "cascade-test-group"
    ],
    "shouldChangeOwner": []
  }
}
Expand All
object
success
boolean
error
string
errorType
string
details
object
shouldBeRemoved
Array of string
string
shouldChangeOwner
Array of string
string
401

Unauthorized

Authorization Error
{
  "status": "error",
  "message": "You must be logged in to do this."
}
object
status
string
message
string