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

# Update a User

> Update a user's information by their external ID. Can optionally assign to an organization and set their role using organization_id and role parameters. If the user is already in the organization, their role will be updated. If the user is not in the organization, they will be moved from their current organization(s) to the new one. Note: Cannot demote the last owner of an organization - must promote another user to owner first.




## OpenAPI

````yaml /openapi.yaml patch /users/{external_id}
openapi: 3.0.0
info:
  title: Answering Agent API
  description: API for Answering Agent platform
  version: 1.0.0
servers:
  - url: https://answeringagent.com/api/v1
    description: Production API
  - url: https://playground.answeringagent.com/api/v1
    description: Playground API
security: []
paths:
  /users/{external_id}:
    patch:
      tags:
        - Users
      summary: Update a User
      description: >
        Update a user's information by their external ID. Can optionally assign
        to an organization and set their role using organization_id and role
        parameters. If the user is already in the organization, their role will
        be updated. If the user is not in the organization, they will be moved
        from their current organization(s) to the new one. Note: Cannot demote
        the last owner of an organization - must promote another user to owner
        first.
      operationId: updateUser
      parameters:
        - in: path
          name: external_id
          required: true
          schema:
            type: string
          description: The external ID of the user to update
        - in: query
          name: organization_id
          schema:
            type: integer
          description: Organization to assign the user to (alternative to body parameter)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: User's display name
                email:
                  type: string
                  format: email
                  description: User's email address
                team_name:
                  type: string
                  description: Name of the user's team
                organization_id:
                  type: integer
                  description: >-
                    ID of an existing organization to add the user to
                    (alternative to query parameter). Required if role is
                    provided.
                  nullable: true
                role:
                  type: string
                  description: >-
                    Role to assign to the user in the organization. If provided,
                    organization_id is required.
                  enum:
                    - owner
                    - manager
                    - user
                  nullable: true
      responses:
        '200':
          description: User updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: User or organization not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User not found
                    enum:
                      - User not found
                      - Organization not found
        '422':
          $ref: '#/components/responses/ValidationError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          description: Internal user ID
        external_id:
          type: string
          description: External identifier provided by the reseller
        email:
          type: string
          format: email
          description: User's email address
        name:
          type: string
          description: User's display name
        created_at:
          type: string
          format: date-time
          description: When the user was created
        updated_at:
          type: string
          format: date-time
          description: When the user was last updated
        organizations:
          type: array
          description: Organizations this user belongs to with their role
          items:
            type: object
            properties:
              id:
                type: integer
                description: Organization ID
              name:
                type: string
                description: Organization name
              role:
                type: string
                description: User's role in this organization
                enum:
                  - owner
                  - manager
                  - user
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: API key is required
                enum:
                  - API key is required
                  - Invalid credentials
    ValidationError:
      description: Validation failed.
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              errors:
                type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````