Skip to main content
POST
/
api
/
management
/
users
Create user
curl --request POST \
  --url https://api.example.com/api/management/users
{
  "success": true,
  "timestamp": "<string>",
  "data": {
    "id": 123,
    "email": "<string>",
    "firstName": "<string>",
    "lastName": "<string>",
    "roles": [
      {}
    ]
  }
}

Endpoint

POST /api/management/users

Authentication

Requires ADMIN role. Include a valid JWT access token in the Authorization header.
Authorization: Bearer <admin_access_token>

Request Body

email
string
required
User’s email addressValidation:
  • Not blank
  • Valid email format
  • Must match pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
  • Must be unique in the system
password
string
required
User’s passwordValidation:
  • Not blank
  • Minimum 8 characters
firstName
string
required
User’s first nameValidation:
  • Not blank
  • 2-50 characters
  • Letters, spaces, periods, hyphens, and apostrophes only
lastName
string
required
User’s last nameValidation:
  • Not blank
  • 2-50 characters
  • Letters, spaces, periods, hyphens, and apostrophes only
roles
array
required
Array of role strings to assign to the userValidation:
  • At least one role required
  • Valid values: MEMBER, ADMIN

Response

Returns the created user’s information (excluding password).
success
boolean
Indicates if the request was successful
timestamp
string
ISO 8601 timestamp of the response
data
object
Created user data

Example Request

curl -X POST http://localhost:8080/api/management/users \
  -H "Authorization: Bearer <admin_access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePass123!",
    "firstName": "Jane",
    "lastName": "Smith",
    "roles": ["MEMBER"]
  }'

Example Response

{
  "success": true,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": {
    "id": 15,
    "email": "[email protected]",
    "firstName": "Jane",
    "lastName": "Smith",
    "roles": ["MEMBER"]
  }
}

Error Responses

{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": "Validation failed",
  "details": {
    "password": "Password must be at least 8 characters long",
    "roles": "At least one role must be assigned"
  }
}
The request body failed validation.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": "Unauthorized"
}
No valid access token provided.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": "Forbidden"
}
The authenticated user does not have ADMIN role.
{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "error": "Email already exists"
}
A user with the specified email already exists.

Source Reference

This endpoint is implemented in:
  • UserManagementController.java:34-39
  • Request DTO: UserCreateRequest.java:12-33

Build docs developers (and LLMs) love