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

# Add a member to a chat workspace, or change their role

> Owners only. A member is a Keycloak user or a realm role (everyone holding it), checked against Keycloak first: an unknown name or a role every user holds is a 422, and 503 means Keycloak couldn't be reached — nothing is changed either way. A change that would leave no owner is a 409.



## OpenAPI

````yaml put /api/chat/workspaces/{workspace_id}/members
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/chat/workspaces/{workspace_id}/members:
    put:
      tags:
        - Chat
      summary: Add a member to a chat workspace, or change their role
      description: >-
        Owners only. A member is a Keycloak user or a realm role (everyone
        holding it), checked against Keycloak first: an unknown name or a role
        every user holds is a 422, and 503 means Keycloak couldn't be reached —
        nothing is changed either way. A change that would leave no owner is a
        409.
      operationId: set_member_api_chat_workspaces__workspace_id__members_put
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Workspace Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetChatWorkspaceMemberRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChatWorkspaceMemberResponse'
                title: >-
                  Response Set Member Api Chat Workspaces  Workspace Id  Members
                  Put
        '403':
          description: Owners only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found, or you aren't a member.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: It would leave no owner.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unknown or built-in member.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
        '503':
          description: Keycloak unreachable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    SetChatWorkspaceMemberRequest:
      properties:
        member_type:
          $ref: '#/components/schemas/ChatMemberType'
          description: '`user` for one person, `role` for everyone holding a realm role.'
        member:
          type: string
          maxLength: 255
          minLength: 1
          title: Member
          description: A Keycloak username, or a Keycloak realm role name.
        role:
          $ref: '#/components/schemas/ChatWorkspaceRole'
          description: What the member can do.
      type: object
      required:
        - member_type
        - member
        - role
      title: SetChatWorkspaceMemberRequest
      description: Add a member to a workspace, or change their role.
    ChatWorkspaceMemberResponse:
      properties:
        member_type:
          $ref: '#/components/schemas/ChatMemberType'
          description: '`user` for one person, `role` for everyone holding a realm role.'
        member:
          type: string
          title: Member
          description: The username, or the realm role name.
        role:
          $ref: '#/components/schemas/ChatWorkspaceRole'
          description: What the member can do.
        added_by:
          type: string
          title: Added By
          description: Who last set this membership.
        added_at:
          type: string
          format: date-time
          title: Added At
          description: When it was last set.
      type: object
      required:
        - member_type
        - member
        - role
        - added_by
        - added_at
      title: ChatWorkspaceMemberResponse
      description: One membership in a workspace.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    ChatMemberType:
      type: string
      enum:
        - user
        - role
      title: ChatMemberType
      description: Who a workspace membership is for.
    ChatWorkspaceRole:
      type: string
      enum:
        - owner
        - editor
        - viewer
      title: ChatWorkspaceRole
      description: What a workspace member can do.
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.