Skip to main content

DELETE /api/users//roles/

Revokes a role from a user, removing the associated permissions. This endpoint requires write privileges or admin role.

Authentication

This endpoint requires JWT authentication with one of the following:
  • WRITE_PRIVILEGES authority
  • ADMIN role

Path Parameters

id
UUID
required
The unique identifier of the user
roleId
UUID
required
The unique identifier of the role to revoke

Response

This endpoint returns no content on success (HTTP 204).

Error Codes

  • 204 - Role revoked successfully (no content returned)
  • 401 - Unauthorized: Missing or invalid JWT token
  • 403 - Forbidden: Insufficient permissions
  • 404 - Not Found: User or role does not exist

Example Request

curl -X DELETE https://api.example.com/api/users/550e8400-e29b-41d4-a716-446655440000/roles/660e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Success Response

HTTP/1.1 204 No Content

Example Error Response

{
  "timestamp": "2026-03-04T10:30:00Z",
  "requestId": "abc123-def456",
  "message": "User not found",
  "detail": "Usuario con id 550e8400-e29b-41d4-a716-446655440000 no encontrado"
}

Notes

  • Revoking a role removes all permissions associated with that role from the user
  • If the user does not have the role assigned, the operation will succeed without changes
  • This action is logged in the audit log with module “USUARIOS” and action “REVOCAR_ROL”
  • Be careful when revoking roles, as it may prevent users from accessing resources they previously could access

Example: Verifying Role Removal

After revoking a role, you can verify the change by retrieving the user:
# Revoke role
curl -X DELETE https://api.example.com/api/users/550e8400-e29b-41d4-a716-446655440000/roles/660e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

# Get user to verify roles
curl -X GET https://api.example.com/api/users/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Build docs developers (and LLMs) love