Skip to main content
PUT
/
api
/
usuarios
/
{username}
Update User
curl --request PUT \
  --url https://api.example.com/api/usuarios/{username} \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "email": {},
  "nombre": "<string>",
  "apellidos": "<string>",
  "direccion_envio": "<string>",
  "fecha_nacimiento": "<string>",
  "activo": true,
  "password": "<string>",
  "rol": {}
}
'
{
  "200": {},
  "400": {},
  "401": {},
  "403": {},
  "404": {},
  "409": {},
  "usuario_id": 123,
  "username": "<string>",
  "email": {},
  "nombre": "<string>",
  "apellidos": "<string>",
  "rol": {},
  "direccion_envio": "<string>",
  "fecha_nacimiento": "<string>",
  "activo": true
}

Authentication

Required: Authenticated user (own account) or Admin Users can update their own account information. Administrators can update any user’s information.

Path Parameters

username
string
required
The username of the user to update

Request Body

username
string
required
User’s unique username (max 100 characters)
email
object
required
User’s email address. Must be unique across the system.
{
  "value": "[email protected]"
}
nombre
string
required
User’s first name (max 100 characters)
apellidos
string
required
User’s last name(s) (max 150 characters)
direccion_envio
string
required
User’s shipping address
fecha_nacimiento
date
required
User’s date of birth in ISO 8601 format (YYYY-MM-DD)
activo
boolean
required
Whether the user account is active
password
string
User’s password. Only include if changing the password. Will be securely hashed before storage.
rol
enum
required
User role. Possible values:
  • ADMIN - Administrator with full access
  • CLIENTE - Regular customer (default)
Only administrators can change user roles

Request

curl -X PUT https://api.iquea.com/api/usuarios/johndoe \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "email": {
      "value": "[email protected]"
    },
    "nombre": "John",
    "apellidos": "Doe Smith",
    "direccion_envio": "456 New Address, Madrid, Spain",
    "fecha_nacimiento": "1990-05-15",
    "activo": true,
    "rol": "CLIENTE"
  }'

Example Request Body

{
  "username": "johndoe",
  "email": {
    "value": "[email protected]"
  },
  "nombre": "John",
  "apellidos": "Doe Smith",
  "direccion_envio": "456 New Address, Madrid, Spain",
  "fecha_nacimiento": "1990-05-15",
  "activo": true,
  "rol": "CLIENTE"
}

Response

Returns the updated user object.
usuario_id
long
Unique identifier for the user
username
string
User’s unique username (max 100 characters)
email
object
User’s email address (unique across the system)
nombre
string
User’s first name (max 100 characters)
apellidos
string
User’s last name(s) (max 150 characters)
rol
enum
User role (ADMIN or CLIENTE)
direccion_envio
string
User’s shipping address
fecha_nacimiento
date
User’s date of birth (ISO 8601 format: YYYY-MM-DD)
activo
boolean
Whether the user account is active

Example Response

{
  "usuario_id": 1,
  "username": "johndoe",
  "email": {
    "value": "[email protected]"
  },
  "nombre": "John",
  "apellidos": "Doe Smith",
  "rol": "CLIENTE",
  "direccion_envio": "456 New Address, Madrid, Spain",
  "fecha_nacimiento": "1990-05-15",
  "activo": true
}

Status Codes

200
OK
User successfully updated
400
Bad Request
Invalid request body or validation errors (e.g., invalid email format, missing required fields)
401
Unauthorized
Missing or invalid authentication token
403
Forbidden
User attempting to update another user’s account without admin privileges, or non-admin trying to change user role
404
Not Found
User with the specified username does not exist
409
Conflict
Email address already in use by another user

Security Notes

Password Security: When updating a user, passwords are securely hashed before being stored in the database. Passwords are never returned in API responses.
Role Changes: Only administrators can modify the rol field. Regular users attempting to change their own role or another user’s role will receive a 403 Forbidden error.
Access Control: Users can only update their own account information (identified by their JWT token username). Administrators can update any user’s information.
Partial Updates: To change only the password, include all current user information in the request body with the new password field. To update other fields without changing the password, omit the password field entirely.

Build docs developers (and LLMs) love