Skip to main content

Audience:

Developers

Deactivate a user using the API

You can call the API to deactivate a user.

Prerequisites

All of the following conditions must be met:

  1. All the user's account memberships are disabled.
  2. The user isn't the legal representative for any account.
  3. The user doesn't have a team membership to any of your projects.
    • Go to Dashboard > your profile > Team management to confirm the user isn't a team member.

You also need a project access token to call the mutation.

Guide

  1. Call the deactivateUser mutation.
  2. Add the user ID for the user you need to deactivate.
  3. Add success payload (line 3) and all rejections (lines 6, 11, 16).

Mutation

Open in API Explorer
mutation DeactivateUser {
deactivateUser(input: { userId: "$USER_ID" }) {
... on DeactivateUserSuccess {
__typename
}
... on UserCannotBeDeactivatedRejection {
__typename
message
userId
}
... on UserAlreadyDeactivatedRejection {
__typename
message
userId
}
... on UserNotFoundRejection {
id
message
}
}
}

Success payload

The following payload shows a successful deactivation.

{
"data": {
"deactivateUser": {
"__typename": "DeactivateUserSuccess"
}
}
}

Rejection payload

The following payload shows an unsuccessful deactivation. This user couldn't be deactivated because they're a legal representative.

{
"data": {
"deactivateUser": {
"__typename": "UserCannotBeDeactivatedRejection",
"message": "User with id '$USER_ID' can't be deactivated (reason=The user is a legal representative)",
"userId": "$USER_ID"
}
}
}