Skip to main content

POST /api/users/{user_id}/deactivate

Sets a user’s is_active flag to false, immediately preventing the user from authenticating. This endpoint is restricted to administrators. Restriction: Administrators cannot deactivate other administrator accounts. Attempting to deactivate an admin user returns 403.

Authentication

Requires a valid Bearer access token. The authenticated user must have the admin role.
Authorization: Bearer <access_token>

Path Parameters

user_id
integer
required
The ID of the user to deactivate.

Request Body

No request body is required.

Response

success
boolean
true when the deactivation succeeds.
message
string
Human-readable confirmation message.
data
object
The updated user object with is_active: false.

Errors

StatusDescription
401Missing or invalid access token.
403The authenticated user is not an admin, or the target user is an administrator.
404No user exists with the given user_id.

Example

curl -X POST "https://task-forge-gbd6h8gtg8hchve9.chilecentral-01.azurewebsites.net/api/users/42/deactivate" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
{
  "success": true,
  "message": "Usuario desactivado con exito",
  "data": {
    "id": 42,
    "username": "jdoe",
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "full_name": "John Doe",
    "is_active": false,
    "role": {
      "id": 2,
      "name": "user",
      "description": "Standard user"
    },
    "created_at": "2024-01-15T10:30:00",
    "updated_at": "2024-03-17T14:00:00"
  }
}

Build docs developers (and LLMs) love