Skip to main content

Update Profile

Update the current user's profile information.

Endpoint

PUT /api/v1/auth/me/profile

Headers

HeaderRequiredDescription
AuthorizationYesBearer <access_token>
Content-TypeYesapplication/json

Request Body

{
"display_name": "Jane Smith",
"profile_image_url": "data:image/png;base64,...",
"profile": {
"bio": "Software developer",
"location": "San Francisco"
}
}

Parameters

FieldTypeRequiredDescription
display_namestringNoUser's display name
profile_image_urlstringNoProfile image URL or base64 data URI
profileobjectNoAdditional profile properties (merged into profile JSON)

Validations

  • Display name length validation
  • Profile image URL format validation
  • Profile JSON schema validation
  • Authentication required

Response

Success (200)

{
"success": true,
"data": {
"user_id": 123,
"display_name": "Jane Smith",
"profile_image_url": "https://...",
"profile": {
"bio": "Software developer",
"location": "San Francisco"
},
"updated_at": "2024-01-01T13:00:00Z"
},
"message": "Profile updated successfully"
}

Error Codes

StatusCodeDescription
400PROFILE_UPDATE_FAILEDProfile update failed
401UNAUTHORIZEDInvalid or missing token
422VALIDATION_ERRORRequest validation failed

Data Flow

  1. Authentication

    • Verify access token
    • Get current user
  2. Validation

    • Validate display_name (if provided)
    • Validate profile_image_url format (URL or data URI)
    • Validate profile JSON structure
  3. Profile Update

    • Update display_name in User table
    • Update profile_image_url
    • Merge profile JSON (deep merge with existing)
  4. Audit Logging

    • Log profile update event
    • Record changes made
  5. Response

    • Return updated profile data
    • Include timestamp

Features

  • Update display_name
  • Update profile_image_url (accepts base64 data URI or URL)
  • Merge additional properties into profile JSON column
  • Only allows updating display_name, profile_image_url, and profile JSON
  • Preserves existing profile data (merge operation)

Example

curl -X PUT https://api.rivergen.com/api/v1/auth/me/profile \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"display_name": "Jane Smith",
"profile_image_url": "https://example.com/avatar.jpg",
"profile": {
"bio": "Software developer"
}
}'