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

# Update user

> Updates an existing User object.



## OpenAPI

````yaml PATCH /users/{id}
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /users/{id}:
    patch:
      tags:
        - Users
      summary: Update a user
      description: Updates an existing User object.
      operationId: UpdateUser
      parameters:
        - in: path
          name: id
          required: true
          schema:
            description: The ID of the user to update.
            example: usr_01j9dwavghe1ttppewekjjkfrx
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
          description: Updated user
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


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


            const user = await
            client.users.update('usr_01j9dwavghe1ttppewekjjkfrx', { first_name:
            'Brian' });


            console.log(user.id);
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            user = client.users.update(
                id="usr_01j9dwavghe1ttppewekjjkfrx",
                first_name="Brian",
            )
            print(user.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tuser, err := client.Users.Update(\n\t\tcontext.TODO(),\n\t\t\"usr_01j9dwavghe1ttppewekjjkfrx\",\n\t\tsurge.UserUpdateParams{\n\t\t\tFirstName: \"Brian\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", user.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "surge_api"


            surge = SurgeAPI::Client.new(api_key: "My API Key")


            user = surge.users.update("usr_01j9dwavghe1ttppewekjjkfrx",
            first_name: "Brian")


            puts(user)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API
            Key');


            try {
              $user = $client->users->update(
                'usr_01j9dwavghe1ttppewekjjkfrx',
                firstName: 'Brian',
                lastName: 'O\'Conner',
                metadata: ['email' => 'boconner@toretti.family', 'user_id' => '1234'],
                photoURL: 'https://toretti.family/people/brian.jpg',
              );

              var_dump($user);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    UserParams:
      description: POST body for creating a user
      example:
        first_name: Brian
        last_name: O'Conner
        metadata:
          email: boconner@toretti.family
          user_id: '1234'
        photo_url: https://toretti.family/people/brian.jpg
      properties:
        first_name:
          description: The user's first name.
          type: string
        last_name:
          description: The user's last name.
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        photo_url:
          description: URL of a photo to be used as the user's avatar.
          format: uri
          type: string
      required:
        - first_name
      title: UserParams
      type: object
    User:
      description: A user of the app
      example:
        first_name: Brian
        id: usr_01j9dwavghe1ttppewekjjkfrx
        last_name: O'Conner
        metadata:
          email: boconner@toretti.family
          user_id: '1234'
        photo_url: https://toretti.family/people/brian.jpg
      properties:
        first_name:
          description: The user's first name.
          type: string
        id:
          description: Unique identifier for the object.
          type: string
        last_name:
          description: The user's last name.
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        photo_url:
          description: URL of a photo to be used as the user's avatar.
          format: uri
          type: string
      required:
        - first_name
      title: User
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    Metadata:
      additionalProperties:
        maxLength: 500
        type: string
      description: Set of key-value pairs that will be stored with the object.
      maxProperties: 50
      properties: {}
      title: Metadata
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````