Skip to main content
PUT
/
users
/
:id
Update User (Admin)
curl --request PUT \
  --url https://api.example.com/users/:id \
  --header 'Content-Type: application/json' \
  --data '
{
  "first_name": "<string>",
  "last_name": "<string>",
  "email": "<string>",
  "password": "<string>",
  "role": {}
}
'
{
  "id_user": 123,
  "first_name": "<string>",
  "last_name": "<string>",
  "email": "<string>",
  "password": "<string>",
  "phone": "<string>",
  "mobile": "<string>",
  "birth_date": "<string>",
  "street": "<string>",
  "postal_code": "<string>",
  "city": "<string>",
  "country": "<string>",
  "biography": "<string>",
  "job": {},
  "portfolio": "<string>",
  "youtube": "<string>",
  "instagram": "<string>",
  "linkedin": "<string>",
  "facebook": "<string>",
  "tiktok": "<string>",
  "known_by_mars_ai": {},
  "role": {},
  "createdAt": {},
  "updatedAt": {}
}
Authentication Required: Bearer token
Role Required: ADMIN
Updates an existing user’s information. This endpoint is restricted to administrators and allows updating any user in the system.

Authentication

This endpoint requires a valid JWT Bearer token with ADMIN role.
Authorization: Bearer <your_jwt_token>

Path Parameters

id
integer
required
The id_user of the user to update

Request Body

first_name
string
User’s first name (or firstName in camelCase). If not provided, keeps existing value.
last_name
string
User’s last name (or lastName in camelCase). If not provided, keeps existing value.
email
string
User’s email address. If not provided, keeps existing value.
password
string
New password (will be hashed with bcrypt). Only updated if provided and non-empty.
role
enum
User role: ADMIN, JURY, PRODUCER. If not provided, keeps existing value.
The API accepts both snake_case (e.g., first_name) and camelCase (e.g., firstName) field names for compatibility. Only provided fields will be updated.

Request

cURL Example
curl -X PUT https://api.marsai.com/users/1 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Alice",
    "lastName": "Martin-Durand",
    "email": "alice.durand@example.com",
    "role": "JURY"
  }'
Update Password Example
curl -X PUT https://api.marsai.com/users/1 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "password": "NewSecurePassword123!"
  }'

Response

id_user
integer
Unique user identifier
first_name
string
User’s first name
last_name
string
User’s last name
email
string
User’s email address
password
string
Hashed password (bcrypt)
phone
string
Landline phone number
mobile
string
Mobile phone number
birth_date
date
Date of birth
street
string
Street address
postal_code
string
Postal code
city
string
City
country
string
Country
biography
string
Professional biography
job
enum
Professional role: ACTOR, DIRECTOR, PRODUCER, WRITER, OTHER
portfolio
string
Portfolio URL
youtube
string
YouTube profile
instagram
string
Instagram handle
linkedin
string
LinkedIn profile
facebook
string
Facebook profile
tiktok
string
TikTok handle
known_by_mars_ai
enum
How user discovered MarsAI
role
enum
User role: ADMIN, JURY, PRODUCER
createdAt
datetime
Timestamp of user creation
updatedAt
datetime
Timestamp of last update

Success Response

200 OK
{
  "id_user": 1,
  "first_name": "Alice",
  "last_name": "Martin-Durand",
  "email": "alice.durand@example.com",
  "password": "$2b$10$XYZ...",
  "phone": "+33123456789",
  "mobile": "+33612345678",
  "birth_date": "1990-05-15T00:00:00.000Z",
  "street": "123 Rue de la Paix",
  "postal_code": "75001",
  "city": "Paris",
  "country": "France",
  "biography": "Award-winning independent filmmaker",
  "job": "DIRECTOR",
  "portfolio": "https://alicemartin.com",
  "instagram": "@alicemartin",
  "linkedin": "alice-martin",
  "known_by_mars_ai": "Par un ami",
  "role": "JURY",
  "createdAt": "2025-01-15T10:30:00.000Z",
  "updatedAt": "2025-03-07T14:45:00.000Z"
}

Error Responses

401 Unauthorized
{
  "error": "Token invalide ou manquant"
}
403 Forbidden
{
  "error": "Accès interdit. Rôle ADMIN requis."
}
404 Not Found
{
  "error": "Utilisateur non trouvé"
}
500 Internal Server Error
{
  "error": "Erreur base de données",
  "details": "Validation error message"
}

Update Behavior

  • Partial updates: Only fields included in the request body are updated
  • Omitted fields: Keep their existing values
  • Password: Only updated if provided and non-empty; automatically hashed with bcrypt
  • Empty strings: Whitespace-only passwords are ignored