Skip to main content
POST
/
users
/
edit
Edit User
curl --request POST \
  --url https://api.example.com/users/edit \
  --header 'Content-Type: application/json' \
  --data '
{
  "dni": "<string>",
  "nombre": "<string>",
  "apellidos": "<string>",
  "direccion": "<string>",
  "CP": "<string>",
  "provincia": "<string>",
  "poblacion": "<string>",
  "pais": "<string>",
  "email": "<string>",
  "telefono": "<string>",
  "fechaalta": "<string>",
  "fechabaja": "<string>",
  "formadepago": "<string>",
  "cuota": 123,
  "categoria": "<string>",
  "socio": "<string>"
}
'
{
  "IdUsuario": 123,
  "nombre": "<string>",
  "apellidos": "<string>",
  "password": "<string>",
  "dni": "<string>",
  "direccion": "<string>",
  "CP": "<string>",
  "provincia": "<string>",
  "poblacion": "<string>",
  "pais": "<string>",
  "email": "<string>",
  "telefono": "<string>",
  "fechaalta": "<string>",
  "fechabaja": "<string>",
  "formadepago": "<string>",
  "cuota": 123,
  "categoria": "<string>",
  "socio": "<string>",
  "isVerified": true,
  "verificationCode": "<string>",
  "verificationExpires": {}
}

Authentication

This endpoint requires JWT authentication and role-based authorization. Required Guards:
  • JwtAuthGuard - Valid JWT token required
  • RolesGuard - User must have one of the allowed roles
Allowed Roles:
  • monitor
  • admin

Request Body

dni
string
required
National identification number (DNI) - Used to identify which user to update
nombre
string
required
User’s first name
apellidos
string
required
User’s last name
direccion
string
required
Street address
CP
string
required
Postal code
provincia
string
required
Province
poblacion
string
required
City/town
pais
string
required
Country
email
string
required
User’s email address (must be valid email format)
telefono
string
required
Phone number
fechaalta
string
required
Registration date in ISO 8601 date format (YYYY-MM-DD)
fechabaja
string
Deactivation date in ISO 8601 date format (YYYY-MM-DD). Optional field.
formadepago
string
required
Payment method (e.g., “Transferencia”, “Tarjeta”, “Efectivo”)
cuota
number
required
Membership fee amount
categoria
string
required
User category (e.g., “monitor”, “admin”, “socio”)
socio
string
required
Membership status - Must be either “Socio” or “NoSocio”. Also accepts numeric values: 0 for “NoSocio”, 1 for “Socio”

Response

Returns the updated user object with all fields from the database entity.
IdUsuario
number
required
Unique user identifier
nombre
string
required
User’s first name
apellidos
string
required
User’s last name
password
string
required
Hashed password (unchanged unless explicitly updated)
dni
string
required
National identification number
direccion
string
required
Street address
CP
string
required
Postal code
provincia
string
required
Province
poblacion
string
required
City/town
pais
string
required
Country
email
string
required
User’s email address
telefono
string
required
Phone number
fechaalta
date
required
Registration date
fechabaja
date
Deactivation date (nullable)
formadepago
string
required
Payment method
cuota
number
required
Membership fee amount
categoria
string
required
User category
socio
string
required
Membership status - “Socio” or “NoSocio”
isVerified
boolean
required
Email verification status
verificationCode
string
Email verification code (nullable)
verificationExpires
timestamp
Verification code expiration (nullable)

Example Request

curl -X POST https://api.sociapp.com/users/edit \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "dni": "45678912C",
    "nombre": "María",
    "apellidos": "Rodríguez García",
    "direccion": "Calle Sol 89",
    "CP": "46002",
    "provincia": "Valencia",
    "poblacion": "Valencia",
    "pais": "España",
    "email": "[email protected]",
    "telefono": "633456789",
    "fechaalta": "2024-03-15",
    "fechabaja": null,
    "formadepago": "Tarjeta",
    "cuota": 30.00,
    "categoria": "socio",
    "socio": "Socio"
  }'

Example Response

{
  "IdUsuario": 15,
  "nombre": "María",
  "apellidos": "Rodríguez García",
  "password": "$2b$12$abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGH",
  "dni": "45678912C",
  "direccion": "Calle Sol 89",
  "CP": "46002",
  "provincia": "Valencia",
  "poblacion": "Valencia",
  "pais": "España",
  "email": "[email protected]",
  "telefono": "633456789",
  "fechaalta": "2024-03-15",
  "fechabaja": null,
  "formadepago": "Tarjeta",
  "cuota": 30.00,
  "categoria": "socio",
  "socio": "Socio",
  "isVerified": true,
  "verificationCode": null,
  "verificationExpires": null
}

Error Responses

User Not Found

If no user exists with the provided DNI:
{
  "statusCode": 500,
  "message": "User not found"
}

Notes

  • The user is identified by the dni field - this is the primary lookup key
  • All fields in the request body are merged with the existing user data
  • The password field is not included in EditUserDto, so passwords cannot be changed through this endpoint
  • The socio field accepts both string values (“Socio”/“NoSocio”) and numeric values (1/0)
  • Email format is validated
  • Dates must be in ISO 8601 format (YYYY-MM-DD)
  • If the user is not found, an error is thrown

Build docs developers (and LLMs) love