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

# Update User Profile

> Update specific fields of an existing user profile without changing everything.

The `userId` in the URL path should be your `externalUserId`. Only the fields you include in your request will be updated—everything else stays the same. Perfect for targeted updates like changing an email address or adding new properties.

Prefer a simpler approach? Use `POST /users` instead—it automatically creates or updates the user, so you don't need to know if they exist yet.

Optionally associate the user with an organization by providing an `externalOrganizationId`. If the organization doesn't exist yet, we'll create it automatically.



## OpenAPI

````yaml https://www.greenflash.ai/api/openapi put /users/{userId}
openapi: 3.1.0
info:
  title: Greenflash API Reference
  version: 1.0.0
  description: >-
    Greenflash endpoints for capturing interactions, managing prompts, and
    identifying users.
servers:
  - url: https://www.greenflash.ai/api/v1
    description: Greenflash API v1
security: []
tags:
  - name: Interactions
    description: Capture interactions between users and AI
  - name: Business Events
    description: Capture business events
  - name: Analytics
    description: Understand chat and agentic interactions analyses
  - name: Inbox
    description: Review flagged conversations
  - name: Segments
    description: Manage user segments
  - name: Prompts
    description: Manage prompts
  - name: Chat
    description: Stream chat and agentic conversations
  - name: Models
    description: Manage AI models
  - name: Products
    description: Manage products
  - name: Users
    description: Manage users
  - name: Organizations
    description: Manage organizations
paths:
  /users/{userId}:
    put:
      tags:
        - Users
      summary: Update User Profile
      description: >-
        Update specific fields of an existing user profile without changing
        everything.


        The `userId` in the URL path should be your `externalUserId`. Only the
        fields you include in your request will be updated—everything else stays
        the same. Perfect for targeted updates like changing an email address or
        adding new properties.


        Prefer a simpler approach? Use `POST /users` instead—it automatically
        creates or updates the user, so you don't need to know if they exist
        yet.


        Optionally associate the user with an organization by providing an
        `externalOrganizationId`. If the organization doesn't exist yet, we'll
        create it automatically.
      parameters:
        - schema:
            type: string
            description: >-
              Your external user ID (the externalUserId used when creating the
              user)
          required: true
          description: >-
            Your external user ID (the externalUserId used when creating the
            user)
          name: userId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserRequest'
            example:
              name: Alice Updated
              email: alice.updated@example.com
              properties:
                plan: enterprise
      responses:
        '200':
          description: User profile updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateUserResponse'
              example:
                success: true
                participant:
                  id: part-001
                  externalId: user-123
                  organizationId: org-001
                  externalOrganizationId: org-456
                  name: Alice Updated
                  email: alice.updated@example.com
                  phone: '+15551234567'
                  anonymized: false
                  properties:
                    plan: enterprise
                  createdAt: '2025-07-01T12:00:00Z'
                  updatedAt: '2025-07-09T08:30:00Z'
        '404':
          description: User not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for user update operations.
              example:
                success: false
                error: User not found. Use POST /users to create a new user.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for user update operations.
              example:
                success: false
                error: Internal server error
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Greenflash from 'greenflash';

            const client = new Greenflash({
              apiKey: process.env['GREENFLASH_API_KEY'], // This is the default and can be omitted
            });

            const updateUserResponse = await client.users.update('userId', {
              email: 'alice.updated@example.com',
              name: 'Alice Updated',
              properties: { plan: 'enterprise' },
            });

            console.log(updateUserResponse.participant);
        - lang: Python
          source: |-
            import os
            from greenflash import Greenflash

            client = Greenflash(
                api_key=os.environ.get("GREENFLASH_API_KEY"),  # This is the default and can be omitted
            )
            update_user_response = client.users.update(
                user_id="userId",
                email="alice.updated@example.com",
                name="Alice Updated",
                properties={
                    "plan": "enterprise"
                },
            )
            print(update_user_response.participant)
components:
  schemas:
    UpdateUserRequest:
      type: object
      properties:
        organizationId:
          type: string
          format: uuid
          description: The Greenflash organization ID that the user belongs to.
        externalOrganizationId:
          type: string
          description: >-
            Your unique identifier for the organization this user belongs to. If
            provided, the user will be associated with this organization.
        name:
          type: string
          description: The user's full name.
        email:
          type: string
          format: email
          description: The user's email address.
        phone:
          type: string
          description: The user's phone number.
        anonymized:
          type: boolean
          description: Whether to anonymize the user's personal information.
        properties:
          type: object
          additionalProperties: {}
          description: Additional data about the user (e.g., plan type, preferences).
      description: Request payload for updating an existing user profile.
    UpdateUserResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the API call was successful.
        participant:
          $ref: '#/components/schemas/Participant'
      required:
        - success
        - participant
      description: Success response for user update.
    Participant:
      type: object
      properties:
        id:
          type: string
          description: The Greenflash participant ID.
        externalId:
          type: string
          description: Your external user ID (matches the externalUserId from the request).
        organizationId:
          type:
            - string
            - 'null'
          format: uuid
          description: The internal organization ID that the user belongs to.
        externalOrganizationId:
          type:
            - string
            - 'null'
          description: Your external identifier for the user's organization.
        name:
          type: string
          description: The participant's full name.
        email:
          type: string
          description: The participant's email address.
        phone:
          type: string
          description: The participant's phone number.
        anonymized:
          type: boolean
          description: Whether the participant's personal information is anonymized.
        properties:
          type: object
          additionalProperties: {}
          description: Additional data about the participant.
        createdAt:
          type: string
          format: date-time
          description: When the participant was first created.
        updatedAt:
          type: string
          format: date-time
          description: When the participant was last updated.
      required:
        - id
        - externalId
        - organizationId
        - externalOrganizationId
        - anonymized
        - properties
      description: The user profile.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````