Skip to content

Get User

Retrieve detailed information about a specific user.

Endpoint

GET /v1/admin/users/:id

Authentication

  • Required: Yes
  • Type: Session-based authentication
  • Required Permission: users:read

Security

  • CSRF protection enabled (requires valid CSRF token)
  • Tenant isolation enforced (can only access users in the same organisation)

Request

Headers

HeaderRequiredDescription
CookieYesSession cookie (cerberus_session)
X-CSRF-TokenYesCSRF token for request validation

Path Parameters

ParameterTypeRequiredDescription
idstringYesUser identifier

Query Parameters

None

Request Body

None

Response

Success Response (200 OK)

json
{
  "id": "usr_01h2xz9k3m4n5p6q7r8s9t0v1w",
  "email": "[email protected]",
  "firstName": "John",
  "lastName": "Doe",
  "name": "John Doe",
  "phone": "+1234567890",
  "emailVerifiedAt": "2025-01-15T10:30:00.000Z",
  "mfaEnabled": true,
  "blockedAt": null,
  "blockedReason": null,
  "lastLoginAt": "2025-10-26T10:00:00.000Z",
  "createdAt": "2025-01-10T08:00:00.000Z",
  "updatedAt": "2025-10-26T11:45:00.000Z",
  "roles": [
    {
      "id": "rol_01h2xz9k3m4n5p6q7r8s9t0v1y",
      "name": "Administrator",
      "slug": "admin",
      "description": "Full system administrator access",
      "permissions": [
        {
          "id": "prm_01h2xz9k3m4n5p6q7r8s9t0v1z",
          "slug": "users:read",
          "name": "Read Users",
          "description": "View user information"
        },
        {
          "id": "prm_01h2xz9k3m4n5p6q7r8s9t0v2a",
          "slug": "users:create",
          "name": "Create Users",
          "description": "Create new users"
        }
      ]
    }
  ],
  "teams": [
    {
      "id": "tem_01h2xz9k3m4n5p6q7r8s9t0v1z",
      "name": "Engineering",
      "slug": "engineering",
      "description": "Engineering team"
    }
  ]
}

Response Fields

FieldTypeDescription
idstringUnique user identifier
emailstringUser's email address
firstNamestringUser's first name
lastNamestringUser's last name
namestringUser's full name
phonestring | nullUser's phone number
emailVerifiedAtstring | nullISO 8601 timestamp of email verification
mfaEnabledbooleanWhether MFA is enabled
blockedAtstring | nullISO 8601 timestamp when user was blocked
blockedReasonstring | nullReason for blocking the user
lastLoginAtstring | nullISO 8601 timestamp of last login
createdAtstringISO 8601 timestamp of user creation
updatedAtstringISO 8601 timestamp of last update
rolesarrayRoles assigned to the user with full details
roles[].idstringRole identifier
roles[].namestringRole display name
roles[].slugstringRole slug
roles[].descriptionstringRole description
roles[].permissionsarrayPermissions granted by this role
teamsarrayTeams the user belongs to with full details
teams[].idstringTeam identifier
teams[].namestringTeam display name
teams[].slugstringTeam slug
teams[].descriptionstringTeam description

Error Responses

401 Unauthorized

User is not authenticated.

json
{
  "type": "https://cerberus-iam.dev/problems/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication required",
  "instance": "/v1/admin/users/usr_01h2xz9k3m4n5p6q7r8s9t0v1w"
}

403 Forbidden

User lacks the required permission or CSRF token is invalid.

json
{
  "type": "https://cerberus-iam.dev/problems/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "Missing required permission: users:read",
  "instance": "/v1/admin/users/usr_01h2xz9k3m4n5p6q7r8s9t0v1w"
}

404 Not Found

User does not exist or does not belong to the same organisation.

json
{
  "type": "https://cerberus-iam.dev/problems/not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "User not found",
  "instance": "/v1/admin/users/usr_01h2xz9k3m4n5p6q7r8s9t0v1w"
}

Example Usage

cURL

bash
curl -X GET https://api.cerberus-iam.dev/v1/admin/users/usr_01h2xz9k3m4n5p6q7r8s9t0v1w \
  -H "Cookie: cerberus_session=abc123..." \
  -H "X-CSRF-Token: xyz789..."

JavaScript (fetch)

javascript
const userId = 'usr_01h2xz9k3m4n5p6q7r8s9t0v1w';

const response = await fetch(`https://api.cerberus-iam.dev/v1/admin/users/${userId}`, {
  method: 'GET',
  credentials: 'include',
  headers: {
    'X-CSRF-Token': getCsrfToken(),
  },
});

const user = await response.json();
console.log(`User: ${user.name} (${user.email})`);
console.log(`Roles: ${user.roles.map((r) => r.name).join(', ')}`);

Python (requests)

python
import requests

user_id = 'usr_01h2xz9k3m4n5p6q7r8s9t0v1w'

response = requests.get(
    f'https://api.cerberus-iam.dev/v1/admin/users/{user_id}',
    cookies={'cerberus_session': 'abc123...'},
    headers={'X-CSRF-Token': 'xyz789...'}
)

user = response.json()
print(f"User: {user['name']} ({user['email']})")
print(f"MFA Enabled: {user['mfaEnabled']}")
print(f"Roles: {', '.join(r['name'] for r in user['roles'])}")

Notes

  • This endpoint returns more detailed information than the list endpoint
  • Roles include their associated permissions
  • Teams include their descriptions
  • Tenant isolation ensures users can only access users within their organisation
  • Soft-deleted users will return a 404 error
  • The lastLoginAt field may be null if the user has never logged in

Released under the MIT License.