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

# Update User Profile Picture

> Set or clear a user's custom profile photo.

Path param `user_id` selects whose photo is being changed; the
`load_user_for_crew_edit` dep enforces self-or-admin/office-admin
scoping (404s on cross-org or unauthorized access).

Body: `{"uploadId": "<uuid>" | null}`. A UUID sets/replaces the
photo; `null` clears it (avatar reverts to the WorkOS-provided URL).

Validations when `uploadId` is non-null:
  - Upload exists in the caller's org (IDOR-safe via get_by_id_and_org).
  - Upload was uploaded by the **caller** (`actor`), not the target.
    An admin uploading a photo for a crew member is the expected
    flow — the upload row's `uploaded_by_user_id` belongs to the
    admin, while the photo is applied to the target user.
  - Upload kind is `image` (rejects PDFs etc.).
  - Upload status is `ready` (rejects pending/scanning/infected/failed).

Returns the target's freshly-resolved profile DTO, identical shape
to the `/me` user payload so the frontend can update either cache
(the /me cache or the /users/{id}/profile cache) from this response.



## OpenAPI

````yaml /openapi.json patch /api/v1/shared/users/{user_id}/profile-picture
openapi: 3.1.0
info:
  title: Seamind Backend
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/shared/users/{user_id}/profile-picture:
    patch:
      tags:
        - shared-users
      summary: Update User Profile Picture
      description: |-
        Set or clear a user's custom profile photo.

        Path param `user_id` selects whose photo is being changed; the
        `load_user_for_crew_edit` dep enforces self-or-admin/office-admin
        scoping (404s on cross-org or unauthorized access).

        Body: `{"uploadId": "<uuid>" | null}`. A UUID sets/replaces the
        photo; `null` clears it (avatar reverts to the WorkOS-provided URL).

        Validations when `uploadId` is non-null:
          - Upload exists in the caller's org (IDOR-safe via get_by_id_and_org).
          - Upload was uploaded by the **caller** (`actor`), not the target.
            An admin uploading a photo for a crew member is the expected
            flow — the upload row's `uploaded_by_user_id` belongs to the
            admin, while the photo is applied to the target user.
          - Upload kind is `image` (rejects PDFs etc.).
          - Upload status is `ready` (rejects pending/scanning/infected/failed).

        Returns the target's freshly-resolved profile DTO, identical shape
        to the `/me` user payload so the frontend can update either cache
        (the /me cache or the /users/{id}/profile cache) from this response.
      operationId: >-
        update_user_profile_picture_api_v1_shared_users__user_id__profile_picture_patch
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: User Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserProfilePictureUpdateDTO'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserProfileDTO'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UserProfilePictureUpdateDTO:
      properties:
        uploadId:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Uploadid
      type: object
      required:
        - uploadId
      title: UserProfilePictureUpdateDTO
      description: |-
        Request body for PATCH /api/v1/users/me/profile-picture.

        `upload_id` is REQUIRED in the body. `null` = remove the custom
        photo (revert to the WorkOS-provided URL). A UUID = set or replace
        the custom photo with the given upload. The endpoint validates
        ownership, scope, kind, and ready-state before writing.
    UserProfileDTO:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        email:
          type: string
          title: Email
        emailVerified:
          type: boolean
          title: Emailverified
        firstName:
          type: string
          title: Firstname
        lastName:
          type: string
          title: Lastname
        profilePictureUrl:
          anyOf:
            - type: string
            - type: 'null'
          title: Profilepictureurl
        hasCustomProfilePicture:
          type: boolean
          title: Hascustomprofilepicture
          default: false
        role:
          type: string
          title: Role
        state:
          type: string
          title: State
        lastLogin:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Lastlogin
        createdAt:
          type: string
          format: date-time
          title: Createdat
      type: object
      required:
        - id
        - email
        - emailVerified
        - firstName
        - lastName
        - profilePictureUrl
        - role
        - state
        - lastLogin
        - createdAt
      title: UserProfileDTO
      description: |-
        User profile for /users/me endpoint.

        `profile_picture_url`: server-resolved. If the user has uploaded a
        custom photo this is a presigned URL for that upload's `thumb`
        derivative (256 px); otherwise it's the WorkOS-provided URL.

        `has_custom_profile_picture`: lets the FE show a "Remove photo"
        affordance only when there's a custom photo to remove.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````