> ## 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.

# Create or Update User Profile

> Keep track of who's talking to your AI by creating user profiles with contact information and custom properties.

Provide an `externalUserId` to identify the user—your ID from your own system. Don't worry about whether they already exist; we'll create them if they're new or update their profile if they already exist. This makes syncing user data effortless.

You can then reference this user in other API calls using the same `externalUserId`.

Optionally associate users 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 post /users
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:
    post:
      tags:
        - Users
      summary: Create or Update User Profile
      description: >-
        Keep track of who's talking to your AI by creating user profiles with
        contact information and custom properties.


        Provide an `externalUserId` to identify the user—your ID from your own
        system. Don't worry about whether they already exist; we'll create them
        if they're new or update their profile if they already exist. This makes
        syncing user data effortless.


        You can then reference this user in other API calls using the same
        `externalUserId`.


        Optionally associate users with an organization by providing an
        `externalOrganizationId`. If the organization doesn't exist yet, we'll
        create it automatically.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
            example:
              externalUserId: user-123
              externalOrganizationId: org-456
              name: Alice Example
              email: alice@example.com
              phone: '+15551234567'
              anonymized: false
              properties:
                plan: premium
      responses:
        '200':
          description: User profile created or updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUserResponse'
              example:
                success: true
                participant:
                  id: part-001
                  externalId: user-123
                  organizationId: org-001
                  externalOrganizationId: org-456
                  name: Alice Example
                  email: alice@example.com
                  phone: '+15551234567'
                  anonymized: false
                  properties:
                    plan: premium
                  createdAt: '2025-07-01T12:00:00Z'
                  updatedAt: '2025-07-01T12:00:00Z'
        '400':
          description: Bad request - invalid input data
          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 creation operations.
              example:
                success: false
                error: Invalid request body
        '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 creation 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 createUserResponse = await client.users.create({
              externalUserId: 'user-123',
              email: 'alice@example.com',
              externalOrganizationId: 'org-456',
              name: 'Alice Example',
              phone: '+15551234567',
              properties: { plan: 'premium' },
            });

            console.log(createUserResponse.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
            )
            create_user_response = client.users.create(
                external_user_id="user-123",
                anonymized=False,
                email="alice@example.com",
                external_organization_id="org-456",
                name="Alice Example",
                phone="+15551234567",
                properties={
                    "plan": "premium"
                },
            )
            print(create_user_response.participant)
components:
  schemas:
    CreateUserRequest:
      type: object
      properties:
        externalUserId:
          type: string
          description: >-
            Your unique identifier for the user. Use this same ID in other API
            calls to reference this user.
        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. Defaults to
            false.
        properties:
          type: object
          additionalProperties: {}
          description: Additional data about the user (e.g., plan type, preferences).
      required:
        - externalUserId
      description: Request payload for creating a new user profile.
    CreateUserResponse:
      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 creation.
    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

````