# Update User Profile Modify authenticated user's profile information. Supports partial updates - only include fields to change. ## Request Body **`username`** string optional Username (3-100 characters, lowercase letters/numbers/dots/underscores/hyphens only). **`first_name`** string optional User's first name. **`last_name`** string optional User's last name. **`full_name`** string optional User's full display name. **`birthday`** date optional Date of birth in YYYY-MM-DD format. **`gender`** string optional Gender identity. **`profile_image`** string optional URL to profile image. **`timezone`** string optional User's timezone (e.g., "America/New_York"). **`country_id`** string optional Country ID with `country_` prefix (must be valid). **`post_code`** string optional Postal/ZIP code. ## Returns Updated User object with complete profile information. ## Validation Rules ### Username - 3-100 characters - Lowercase letters, numbers, dots (`.`), underscores (`_`), hyphens (`-`) - Must be unique ### Birthday - Valid past date - Cannot be future ### Country ID - Format: `country_` + UUID hex - Must exist in system ### Other Fields - `first_name`, `last_name`, `full_name`: Max 255 characters - `gender`: Max 50 characters - `timezone`: Max 100 characters - `post_code`: Max 20 characters ## Notes - Email cannot be updated via this endpoint - Only provided fields updated - Atomic updates (all or nothing) - Response includes complete profile Update Single Field ```bash curl -X PATCH \ "https://api.aitronos.com/v1/user/profile" \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "first_name": "John" }' ``` ```python import requests response = requests.patch( "https://api.aitronos.com/v1/user/profile", headers={"Authorization": f"Bearer {FREDDY_API_KEY}"}, json={"first_name": "John"} ) ``` ```javascript const response = await fetch('https://api.aitronos.com/v1/user/profile', { method: 'PATCH', headers: { 'Authorization': `Bearer ${FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ first_name: 'John' }) }); ``` Update Multiple Fields ```bash curl -X PATCH \ "https://api.aitronos.com/v1/user/profile" \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "username": "john_doe", "timezone": "America/New_York", "profile_image": "https://example.com/avatars/john.jpg" }' ``` ```python import requests response = requests.patch( "https://api.aitronos.com/v1/user/profile", headers={"Authorization": f"Bearer {FREDDY_API_KEY}"}, json={ "username": "john_doe", "timezone": "America/New_York", "profile_image": "https://example.com/avatars/john.jpg" } ) ``` ```javascript const response = await fetch('https://api.aitronos.com/v1/user/profile', { method: 'PATCH', headers: { 'Authorization': `Bearer ${FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'john_doe', timezone: 'America/New_York', profile_image: 'https://example.com/avatars/john.jpg' }) }); ``` With Country & Birthday ```bash curl -X PATCH \ "https://api.aitronos.com/v1/user/profile" \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "country_id": "country_840", "post_code": "10001", "birthday": "1990-05-15" }' ``` ```python import requests response = requests.patch( "https://api.aitronos.com/v1/user/profile", headers={"Authorization": f"Bearer {FREDDY_API_KEY}"}, json={ "country_id": "country_840", "post_code": "10001", "birthday": "1990-05-15" } ) ``` ```javascript const response = await fetch('https://api.aitronos.com/v1/user/profile', { method: 'PATCH', headers: { 'Authorization': `Bearer ${FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ country_id: 'country_840', post_code: '10001', birthday: '1990-05-15' }) }); ``` **Response:** 200 OK ```json { "success": true, "message": "Profile updated successfully", "profile": { "id": "usr_123e4567e89b12d3a456426614174000", "email": "user@example.com", "username": "myusername", "full_name": "John Doe", "first_name": "John", "last_name": "Doe", "profile_image": "https://example.com/avatar.jpg", "timezone": "America/New_York", "is_active": true, "last_verified": "2025-11-13T10:30:00Z", "last_login": "2025-11-13T09:15:00Z", "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-11-13T10:30:00Z" } } ``` 401 Unauthorized ```json { "success": false, "error": { "code": "AUTHENTICATION_REQUIRED", "message": "Authentication required to access this resource", "system_message": "Authentication required", "type": "client_error", "status": 401, "trace_id": "trace_abc123", "timestamp": "2025-11-13T10:30:00Z" } } ``` 409 Conflict ```json { "success": false, "error": { "code": "USERNAME_TAKEN", "message": "Username is already taken", "system_message": "Username is already taken", "type": "client_error", "status": 409, "trace_id": "trace_abc123", "timestamp": "2025-11-13T10:30:00Z", "details": { "username": "takenusername" } } } ``` 422 Validation Error ```json { "success": false, "error": { "code": "INVALID_USERNAME_FORMAT", "message": "Username must contain only lowercase letters, numbers, dots, underscores, and hyphens", "system_message": "Username format is invalid", "type": "client_error", "status": 422, "trace_id": "trace_abc123", "timestamp": "2025-11-13T10:30:00Z", "details": { "username": "Invalid Username!" } } } ```