Skip to main content

POST /api/users

Creates a new user with the specified details. This endpoint requires write privileges or admin role.

Authentication

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

Request Body

name
string
required
User’s first name
lastName
string
required
User’s last name
secondName
string
User’s middle name or second last name (optional)
email
string
required
User’s email address. Must be a valid email format.
password
string
required
User’s password. Must be at least 8 characters long.

Response

id
UUID
Unique identifier for the created user
names
string
User’s full name
email
string
User’s email address
isEnabled
boolean
Whether the user account is enabled
accountNonExpired
boolean
Whether the user account has not expired
accountNonLocked
boolean
Whether the user account is not locked
credentialsNonExpired
boolean
Whether the user’s credentials have not expired
roles
array
List of roles assigned to the user
status
string
User status (ACTIVO or INACTIVO)

Error Codes

  • 201 - User created successfully
  • 400 - Bad Request: Invalid input data (e.g., invalid email format, password too short)
  • 401 - Unauthorized: Missing or invalid JWT token
  • 403 - Forbidden: Insufficient permissions
  • 409 - Conflict: User already exists with the given email

Example Request

curl -X POST https://api.example.com/api/users \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John",
    "lastName": "Doe",
    "secondName": "Michael",
    "email": "john.doe@example.com",
    "password": "SecureP@ssw0rd"
  }'

Example Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "names": "John Michael Doe",
  "email": "john.doe@example.com",
  "isEnabled": true,
  "accountNonExpired": true,
  "accountNonLocked": true,
  "credentialsNonExpired": true,
  "roles": [],
  "status": "ACTIVO"
}

Example Error Response

{
  "timestamp": "2026-03-04T10:30:00Z",
  "requestId": "abc123-def456",
  "message": "Validation failed",
  "detail": "El email es obligatorio"
}

Build docs developers (and LLMs) love