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

# Update User

> Update a user by ID.
## Returns

A successful response returns a `User` object in `user` owith linked emails and phone numbers in `emails` and `phone_numbers` properties.



## OpenAPI

````yaml put /v1/auth/users/{user_id}/update
openapi: 3.1.0
info:
  title: MoonKey Auth API
  description: >-
    Explore all the details of MoonKey Auth API. All of our APIs are RESTful and
    accept and return JSON.
  version: v1
servers:
  - url: https://api.moonkey.fun
    description: Production
    variables: {}
security:
  - Authorization: []
tags:
  - name: Users
    description: User management API
  - name: Magic Links
    description: ''
  - name: OTPs
    description: >-
      Send OTP (One-time passcodes) by all the supported delivery methods such
      as SMS, email.
  - name: OAuth
    description: ''
  - name: Wallets Login
    description: ''
  - name: Managed Wallets
    description: ''
  - name: Wallet Import
    description: >-
      Import existing wallets into the platform using secure HPKE encryption.
      This flow ensures raw entropy (seed phrases or private keys) never touches
      the server in plaintext.
externalDocs:
  url: ''
  description: ''
paths:
  /v1/auth/users/{user_id}/update:
    parameters:
      - schema:
          type: string
        name: user_id
        in: path
        required: true
        description: 'Unique User ID of the user to update. '
    put:
      tags:
        - Users
      summary: Update User
      description: >-
        Update a user by ID.

        ## Returns


        A successful response returns a `User` object in `user` owith linked
        emails and phone numbers in `emails` and `phone_numbers` properties.
      operationId: UpdateUser
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserRequest'
            examples:
              UpdateUserReq:
                value:
                  first_name: John
                  middle_name: ''
                  last_name: Smith
                  emails:
                    - email: sandbox@moonkey.fun
                  phone_numbers:
                    - phone_number: '+14152222222'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  user_id:
                    type: string
                    minLength: 1
                  phone_numbers:
                    type: array
                    uniqueItems: true
                    minItems: 1
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          minLength: 1
                        verified:
                          type: boolean
                        phone_number:
                          type: string
                          minLength: 1
                        updated_at:
                          type: number
                        created_at:
                          type: number
                      required:
                        - id
                        - verified
                        - phone_number
                        - updated_at
                        - created_at
                  emails:
                    type: array
                    uniqueItems: true
                    minItems: 1
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          minLength: 1
                        verified:
                          type: boolean
                        email:
                          type: string
                          minLength: 1
                        updated_at:
                          type: number
                        created_at:
                          type: number
                      required:
                        - id
                        - verified
                        - email
                        - updated_at
                        - created_at
                  user:
                    $ref: '#/components/schemas/User'
                required:
                  - user_id
                  - phone_numbers
                  - emails
              examples:
                UpdateUserResp:
                  value:
                    user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
                    phone_numbers:
                      - id: pn_24oXBLRv6BoHXbNZoTAZkAFlRsy
                        verified: false
                        phone_number: '+14152222222'
                        updated_at: 1642703333
                        created_at: 1642703333
                    emails:
                      - id: email_24oXBL3PufzHkH1Jzyjc2EXYeo7
                        verified: false
                        email: sandbox@moonkey.fun
                        updated_at: 1642703333
                        created_at: 1642703333
                    user:
                      user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
                      first_name: ''
                      middle_name: ''
                      last_name: ''
                      status: active
                      active: true
                      updated_at: 1646873318
                      created_at: 1646873318
                      emails:
                        - id: email_26AjWpEcss2YyqFh1san6Wjjs7o
                          verified: true
                          email: hello@moonkey.fun
                          updated_at: 1646957196
                          created_at: 1646873318
                        - id: email_24oXBL3PufzHkH1Jzyjc2EXYeo7
                          verified: false
                          email: sandbox@moonkey.fun
                          updated_at: 1642703333
                          created_at: 1642703333
                      phone_numbers:
                        - id: pn_24oXBLRv6BoHXbNZoTAZkAFlRsy
                          verified: false
                          phone_number: '+14152222222'
                          updated_at: 1642703333
                          created_at: 1642703333
                      idp_providers:
                        - id: idpuser_28SRho5nbD045LGq2btZWXhkdjN
                          provider: google
                          provider_subject: '100157402424066154830'
                          idp_type: oauth
                          method_id: email_26AjWpEcss2YyqFh1san6Wjjs7o
                          method_type: email
                          updated_at: 1651208121
                          created_at: 1651208121
                      wallets:
                        - id: wallet_26AjWu075gRWMnjfPglcdoD2PAQ
                          public_address: '0x863c381a56a58370f435b0100faba94e6462b6d1'
                          wallet_type: ethereum
                          verified: true
                          is_default: true
                          is_read_only: false
                          is_imported: false
                          updated_at: 1646873319
                          created_at: 1646873319
                      totps: []
                      webauthn_credentials: []
components:
  schemas:
    UpdateUserRequest:
      description: ''
      type: object
      properties:
        first_name:
          type: string
          minLength: 1
          description: First name of the user.
        middle_name:
          type: string
          minLength: 1
          description: Middle name of the user.
        last_name:
          type: string
          minLength: 1
          description: Last name of the user.
        emails:
          type: array
          uniqueItems: true
          minItems: 1
          description: List of Emails to attach to the user.
          items:
            type: object
            properties:
              email:
                type: string
                minLength: 1
                description: Email that uniquely identifies the user.
            required:
              - email
        phone_numbers:
          type: array
          uniqueItems: true
          minItems: 1
          description: List of E.164 formatted mobile phone numbers to attach to the user.
          items:
            type: object
            properties:
              phone_number:
                type: string
                minLength: 1
                description: >-
                  E.164 formatted mobile phone number that uniquely identifies
                  the user.
            required:
              - phone_number
        metadata:
          $ref: '#/components/schemas/Metadata'
        replace_metadata:
          type: boolean
          default: false
          description: >
            Controls how metadata is updated:

            - If `false` (default): Merges provided metadata with existing
            metadata at the top level only

            - If `true`: Completely replaces all existing metadata (fields not
            in the request are removed)
          examples:
            - false
    User:
      description: ''
      type: object
      x-examples:
        User:
          user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
          first_name: John
          middle_name: ''
          last_name: Smith
          active: true
          updated_at: 1639873806
          created_at: 1639873806
          emails:
            - id: email_24oXBL3PufzHkH1Jzyjc2EXYeo7
              verified: false
              email: sandbox@moonkey.fun
              updated_at: 1639873806
              created_at: 1639873806
          phone_numbers:
            - id: pn_24oXBLRv6BoHXbNZoTAZkAFlRsy
              verified: true
              phone_number: '+14152222222'
              updated_at: 1643004687
              created_at: 1639873806
          wallets:
            - id: wallet_24tdfcVDSJQpK5huDnZaqPP2aiI
              public_address: '0xd3EfC42956c546Cf27B5f18062c63B4BF6d72D7c'
              wallet_type: ethereum
              is_default: true
              updated_at: 1640133104
              created_at: 1640133104
          idp_providers:
            - id: idpuser_28SRho5nbD045LGq2btZWXhkdjN
              provider: google
              provider_subject: '100157402424066154830'
              idp_type: oauth
              method_id: email_26AjWpEcss2YyqFh1san6Wjjs7o
              method_type: email
              updated_at: 1651208121
              created_at: 1651208121
          totps:
            - id: totp_284EPXPYI5zZoh4pp2mpAQ2PnuY
              verified: false
              updated_at: 1650467433
              created_at: 1650467433
          webauthn_credentials: []
          metadata:
            custom_field: custom_value
            user_tier: premium
      title: User
      properties:
        user_id:
          type: string
          minLength: 1
        first_name:
          type: string
          minLength: 0
        middle_name:
          type: string
        last_name:
          type: string
          minLength: 0
        active:
          type: boolean
        updated_at:
          type: number
        created_at:
          type: number
        emails:
          type: array
          uniqueItems: true
          minItems: 0
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              verified:
                type: boolean
              email:
                type: string
                minLength: 1
              updated_at:
                type: number
              created_at:
                type: number
            required:
              - id
              - verified
              - email
              - updated_at
              - created_at
        phone_numbers:
          type: array
          uniqueItems: true
          minItems: 10
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              verified:
                type: boolean
              phone_number:
                type: string
                minLength: 1
              updated_at:
                type: number
              created_at:
                type: number
            required:
              - id
              - verified
              - phone_number
              - updated_at
              - created_at
        wallets:
          type: array
          uniqueItems: true
          minItems: 0
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              app_id:
                type: string
                minLength: 1
              user_id:
                type: string
                minLength: 1
              public_address:
                type: string
                minLength: 1
              wallet_type:
                type: string
                minLength: 1
              is_default:
                type: boolean
              updated_at:
                type: number
              created_at:
                type: number
            required:
              - id
              - app_id
              - user_id
              - public_address
              - wallet_type
              - is_default
              - updated_at
              - created_at
        idp_providers:
          type: array
          uniqueItems: true
          minItems: 10
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              provider:
                type: string
                minLength: 1
              provider_subject:
                type: string
                minLength: 1
              idp_type:
                type: string
                minLength: 1
              method_id:
                type: string
                minLength: 1
              method_type:
                type: string
                minLength: 1
              updated_at:
                type: number
              created_at:
                type: number
            required:
              - id
              - provider
              - provider_subject
              - idp_type
              - method_id
              - method_type
              - updated_at
              - created_at
        totps:
          type: array
          uniqueItems: true
          minItems: 0
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              verified:
                type: boolean
              updated_at:
                type: number
              created_at:
                type: number
            required:
              - id
              - verified
              - updated_at
              - created_at
        metadata:
          $ref: '#/components/schemas/Metadata'
      required:
        - user_id
        - first_name
        - middle_name
        - last_name
        - active
        - updated_at
        - created_at
        - emails
        - phone_numbers
        - wallets
    Metadata:
      type: object
      additionalProperties: true
      description: >
        A flexible JSON object for storing custom data about a user. 

        You can store any arbitrary data as key-value pairs.


        **Update Behavior:**

        - By default, metadata updates are merged at the top level only

        - Send `null` values for specific fields to delete those fields (merge
        mode only)

        - Send `{}` (empty object) to clear all metadata

        - Send `null` for the metadata field itself will be ignored (as if
        metadata was not sent)

        - Deeply nested objects and arrays are NOT merged - they replace the
        entire top-level key

        - Set `replace_metadata: true` to replace all metadata without merging
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: >-
        Auth Platform API includes all the Auth related features. All Users,
        Phone Numbers, Emails, and OTPs are associated with an `App` as the
        container.


        Endpoints only accept App's `Secret API keys` other than certain
        endpoints that are used client side or via SDK that accept the
        `public_token`.


        ## Authentication using App Api Key


        ## Header:


        ```

        Authorization: Bearer {api_key}

        ```


        ## Authenticated Request


        ```curl

        curl \
          -X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \
          -H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
        ```

````