> ## Documentation Index
> Fetch the complete documentation index at: https://docs.handauncle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Profile

> Updates the authenticated user's profile. Supports both JSON and multipart/form-data. Use multipart/form-data to upload an avatar image along with profile updates. Images larger than 1MB are automatically compressed. Use _clearAvatar: true to remove the avatar.

Updates the authenticated user's profile including avatar upload. Requires a valid Auth0 access token in the `Authorization` header.

This endpoint supports both JSON and multipart/form-data content types:

* **JSON**: For updating profile fields only
* **multipart/form-data**: For uploading an avatar image along with profile updates

## Request Body (JSON)

All fields are optional. Only include the fields you want to update.

| Field                       | Type    | Description                                |
| --------------------------- | ------- | ------------------------------------------ |
| `fullName`                  | string  | User's display name (1-120 chars, trimmed) |
| `preferences`               | object  | UI preferences (merged with existing)      |
| `preferences.language`      | string  | Language code (e.g., "en", "hi")           |
| `preferences.theme`         | string  | Theme name (e.g., "dark", "light")         |
| `preferences.notifications` | boolean | Enable/disable notifications               |
| `_clearAvatar`              | boolean | Set to `true` to remove the current avatar |

## Request Body (multipart/form-data)

For uploading an avatar image:

| Field    | Type   | Description                                                            |
| -------- | ------ | ---------------------------------------------------------------------- |
| `avatar` | file   | Avatar image file (JPEG, PNG, GIF, WebP). Auto-compressed if >1MB.     |
| `data`   | string | JSON string with profile fields (fullName, preferences, \_clearAvatar) |

## Example: JSON Request

```bash theme={null}
curl -X PATCH https://api.handauncle.com/api/v1/auth/me \
  -H "Authorization: Bearer <access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "fullName": "Puneet Sharma",
    "preferences": {
      "theme": "dark",
      "notifications": true
    }
  }'
```

## Example: Upload Avatar

```bash theme={null}
curl -X PATCH https://api.handauncle.com/api/v1/auth/me \
  -H "Authorization: Bearer <access-token>" \
  -F "avatar=@/path/to/photo.jpg" \
  -F 'data={"fullName": "Puneet Sharma"}'
```

## Example: Clear Avatar

```bash theme={null}
curl -X PATCH https://api.handauncle.com/api/v1/auth/me \
  -H "Authorization: Bearer <access-token>" \
  -H "Content-Type: application/json" \
  -d '{"_clearAvatar": true}'
```

## Response

Returns the updated profile overview (same format as `GET /api/v1/auth/me`):

```json theme={null}
{
  "success": true,
  "data": {
    "user": {
      "id": "683b7e9f465b1b4e6753627a4f",
      "email": "investor@example.com",
      "fullName": "Puneet Sharma",
      "avatarUrl": "https://storage.googleapis.com/...",
      "preferences": {
        "language": "en",
        "theme": "dark",
        "notifications": true
      }
    },
    "usage": { ... },
    "profileContext": { ... }
  }
}
```

## Avatar Upload Details

* **Supported formats**: JPEG, PNG, GIF, WebP
* **Auto-compression**: Images larger than 1MB are automatically resized (max 800px) and compressed
* **No size limit error**: Even large files are accepted and compressed server-side
* **Auto-deletion**: Previous avatar is automatically deleted when uploading a new one

## Notes

* **Field merging**: Preferences are merged with existing values, not replaced entirely
* **Whitespace trimming**: `fullName` is automatically trimmed
* **Cache invalidation**: The profile context cache is invalidated when changes are saved


## OpenAPI

````yaml PATCH /api/v1/auth/me
openapi: 3.1.0
info:
  title: Handa Uncle API
  version: 1.0.0
  description: Public specification for the Handa Uncle web and mobile APIs.
  contact:
    name: Handa Uncle Engineering
    email: hello@handauncle.com
servers:
  - url: https://handauncle-backend-prod-205012263523.asia-south1.run.app
    description: Prod API base (Cloud Run)
  - url: https://api.handauncle.com
    description: Production
  - url: https://staging-api.handauncle.com
    description: Staging
  - url: http://localhost:8080
    description: Local development
security: []
tags:
  - name: Mobile App
    description: Endpoints used by the native Handa Uncle app.
  - name: Platform
    description: Cross-service operational endpoints.
  - name: Auth
    description: Authentication endpoints handled by the backend adapter.
  - name: AI
    description: LLM chat endpoints supporting streaming and device-auth guests.
  - name: OTP
    description: Phone OTP lifecycle powered by Exotel.
  - name: Webhooks
    description: Server-to-server hooks invoked by Auth0.
  - name: Conversations
    description: Authenticated user conversation management.
  - name: Chat Share
    description: Create, manage, and consume shared conversations.
  - name: Files
    description: Upload, list, and delete user files.
  - name: Prompt management
    description: Admin and public APIs for managing masked pre-prompts.
  - name: User Profile
    description: Profile card collection and user data for personalized AI responses.
  - name: Visual Embeds
    description: Manage visual embed images that attach to AI chat responses.
  - name: Second Opinion
    description: Admin and public APIs for Second Opinion suggestion cards.
  - name: Profile Cards
    description: >-
      APIs for managing profile card questions used in onboarding and
      personalization.
paths:
  /api/v1/auth/me:
    patch:
      tags:
        - Auth
      summary: Update current user profile
      description: >-
        Updates the authenticated user's profile. Supports both JSON and
        multipart/form-data. Use multipart/form-data to upload an avatar image
        along with profile updates. Images larger than 1MB are automatically
        compressed. Use _clearAvatar: true to remove the avatar.
      operationId: updateAuthMe
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProfileUpdateRequest'
          multipart/form-data:
            schema:
              type: object
              properties:
                avatar:
                  type: string
                  format: binary
                  description: >-
                    Avatar image file (JPEG, PNG, GIF, WebP). Auto-compressed if
                    >1MB.
                data:
                  type: string
                  description: >-
                    JSON string with profile fields: { full_name?, preferences?,
                    _clearAvatar? }
      responses:
        '200':
          description: Updated profile overview returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProfileOverviewResponseEnvelope'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  schemas:
    ProfileUpdateRequest:
      type: object
      description: >-
        Profile update fields. Use _clearAvatar: true to remove avatar, or
        upload avatar file via multipart/form-data.
      properties:
        fullName:
          type: string
          maxLength: 120
          description: User's display name
        preferences:
          type: object
          description: User preferences
          properties:
            language:
              type: string
              maxLength: 20
            theme:
              type: string
              maxLength: 20
            notifications:
              type: boolean
        _clearAvatar:
          type: boolean
          description: Set to true to remove the user's avatar
      additionalProperties: false
    ProfileOverviewResponseEnvelope:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/ProfileOverviewData'
        meta:
          $ref: '#/components/schemas/ResponseMeta'
      required:
        - success
        - data
        - meta
    ProfileOverviewData:
      type: object
      properties:
        user:
          $ref: '#/components/schemas/ProfileUser'
        usage:
          type: object
          properties:
            conversations:
              $ref: '#/components/schemas/ProfileUsageConversations'
            shares:
              $ref: '#/components/schemas/ProfileUsageShares'
          required:
            - conversations
            - shares
        profileContext:
          $ref: '#/components/schemas/ProfileContext'
      required:
        - user
        - usage
        - profileContext
    ResponseMeta:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        requestId:
          type: string
          description: Server generated correlation identifier.
      required:
        - timestamp
        - requestId
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          $ref: '#/components/schemas/ErrorObject'
        meta:
          $ref: '#/components/schemas/ResponseMeta'
      required:
        - success
        - error
        - meta
    ProfileUser:
      type: object
      properties:
        id:
          type: string
        fullName:
          type: string
        email:
          type: string
          format: email
          nullable: true
        phoneNumber:
          type: string
          nullable: true
        avatarUrl:
          type: string
          format: uri
          nullable: true
        accountStatus:
          type: string
          enum:
            - active
            - suspended
            - deleted
        authProvider:
          type: string
          nullable: true
        preferences:
          type: object
          properties:
            language:
              type: string
            theme:
              type: string
            notifications:
              type: boolean
        deviceId:
          type: string
          nullable: true
        platform:
          type: string
          enum:
            - android
            - ios
            - web
          nullable: true
        phoneVerified:
          type: boolean
          nullable: true
        emailVerified:
          type: boolean
          nullable: true
        createdAt:
          type: string
          format: date-time
        last_login_at:
          type: string
          format: date-time
          nullable: true
      required:
        - id
        - fullName
        - accountStatus
        - createdAt
    ProfileUsageConversations:
      type: object
      properties:
        total:
          type: integer
        active:
          type: integer
        archived:
          type: integer
        deleted:
          type: integer
        lastActiveAt:
          type: string
          format: date-time
          nullable: true
      required:
        - total
        - active
        - archived
        - deleted
    ProfileUsageShares:
      type: object
      properties:
        total:
          type: integer
        active:
          type: integer
        expired:
          type: integer
        revoked:
          type: integer
        totalViews:
          type: integer
        lastSharedAt:
          type: string
          format: date-time
          nullable: true
      required:
        - total
        - active
        - expired
        - revoked
        - totalViews
    ProfileContext:
      type: object
      properties:
        static:
          type: array
          items:
            type: string
        recent:
          type: array
          items:
            type: string
        frequent:
          type: array
          items:
            type: string
      required:
        - static
        - recent
        - frequent
    ErrorObject:
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message describing the issue.
          example: Please enter a valid 10-digit phone number (e.g., 9876543210)
        code:
          type: string
          description: Error code for programmatic handling.
          example: VALIDATION_ERROR
        details:
          type: array
          description: >-
            Array of field-specific validation errors (for VALIDATION_ERROR
            responses).
          items:
            type: object
            properties:
              field:
                type: string
                description: Field name that failed validation.
                example: phone
              message:
                type: string
                description: Specific validation error message for this field.
                example: Please enter a valid 10-digit phone number (e.g., 9876543210)
            required:
              - field
              - message
      required:
        - message
  responses:
    ValidationError:
      description: The request payload or headers were invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnauthorizedError:
      description: Authentication failed or is missing.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Auth0 access token for registered users.

````