Endpoint
This endpoint updates the authenticated user’s profile information. Requires a valid JWT token in the Authorization header.
Authentication
JWT token for authenticating the userExample: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
Request Body
JSON string containing the user fields to update
The JSON string should contain the following fields:
User’s first name (alphabetic characters only)
User’s last name (alphabetic characters only)
User’s email address (must be unique)
User’s profile description (optional)
The following fields are automatically excluded from updates and will be ignored if provided:
id - User ID cannot be changed
role - User role cannot be changed
password - Use a dedicated password change endpoint
created_at - Creation timestamp is immutable
remember_token - Token is managed internally
Response
HTTP status code (200 for success, 400 for unauthorized)
Status of the request: success or error
The authenticated user object (from JWT token)User’s ID from the JWT token
User’s email from the JWT token
Object containing the fields that were updated
Error message (only present when status is error)
Request Example
curl -X PUT "https://api.example.com/api/user/update" \
-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'json={"name":"John","surname":"Doe","email":"[email protected]","description":"Senior developer"}'
Response Examples
{
"code": 200,
"status": "success",
"user": {
"sub": 1,
"email": "[email protected]"
},
"changes": {
"name": "John",
"surname": "Doe",
"email": "[email protected]",
"description": "Senior developer"
}
}
Validation Rules
The endpoint validates the following rules:
- name: Required, must contain only alphabetic characters
- surname: Required, must contain only alphabetic characters
- email: Required, must be a valid email format, must be unique (excluding current user)
The email uniqueness check excludes the current user’s ID, allowing users to keep their existing email address.