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

# Update Role Assignment for a User

> Update an existing role assignment for a user. This replaces the current role with a new role.

**Restrictions:**
- Organization admins cannot demote themselves (change their own role from account_admin to a non-admin role)
- The last organization admin in an account cannot be demoted




## OpenAPI

````yaml PUT /api/v1/accounts/{accountId}/roles/{roleId}/assignments/{assigneeId}
openapi: 3.1.0
info:
  title: AuthZ Service API
  description: Authorization service for managing roles and user permissions
  version: 1.1.0
servers:
  - url: https://api.aion.xyz
    description: Production server
  - url: https://api.dev.internal.aion.xyz
    description: Staging server
security:
  - BearerAuth: []
tags:
  - name: Authorization
    description: Authorization check operations
  - name: Roles
    description: Operations related to role management
  - name: User Roles
    description: Operations related to user role queries
  - name: Role Assignments
    description: Operations for assigning, updating, and revoking roles
paths:
  /api/v1/accounts/{accountId}/roles/{roleId}/assignments/{assigneeId}:
    put:
      tags:
        - Role Assignments
      summary: Update role assignment for a user
      description: >
        Update an existing role assignment for a user. This replaces the current
        role with a new role.


        **Restrictions:**

        - Organization admins cannot demote themselves (change their own role
        from account_admin to a non-admin role)

        - The last organization admin in an account cannot be demoted
      operationId: updateRoleAssignment
      parameters:
        - name: accountId
          in: path
          required: true
          description: The account identifier (external account ID)
          schema:
            type: string
            example: my-company-account
        - name: roleId
          in: path
          required: true
          description: The new role identifier to assign
          schema:
            type: string
            example: project_admin
        - name: assigneeId
          in: path
          required: true
          description: The assignee identifier (external user ID)
          schema:
            type: string
            example: john.doe
        - name: projectId
          in: query
          required: false
          description: Project identifier for project-scoped role assignments
          schema:
            type: string
            example: project-alpha
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoleUpdateRequest'
      responses:
        '200':
          description: Role assignment successfully updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoleAssignmentResponse'
        '400':
          description: Bad request - validation failed or org admin restriction violated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Validation Error
                  value:
                    error:
                      code: BAD_REQUEST
                      message: Invalid request parameters
                      details:
                        - projectId is required for PROJECT scoped roles
                self_demotion:
                  summary: Self Demotion Blocked
                  value:
                    error:
                      code: BAD_REQUEST
                      message: Cannot demote yourself
                      details:
                        - Organization admins cannot remove their own admin role
                last_admin:
                  summary: Last Admin Protection
                  value:
                    error:
                      code: BAD_REQUEST
                      message: Cannot demote last admin
                      details:
                        - >-
                          Cannot demote the last organization admin in the
                          account
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    RoleUpdateRequest:
      type: object
      properties:
        assigneeType:
          $ref: '#/components/schemas/AssigneeType'
        roleId:
          type: string
          description: The current role identifier being replaced
          example: project_reader
        projectId:
          type: string
          description: Project identifier (for project-scoped roles)
          example: project-beta
        status:
          $ref: '#/components/schemas/AssignmentStatus'
      required:
        - assigneeType
        - roleId
    RoleAssignmentResponse:
      type: object
      properties:
        assigneeId:
          type: string
          description: Assignee identifier (external user/group ID)
          example: jane.smith
        assigneeType:
          $ref: '#/components/schemas/AssigneeType'
        roleId:
          type: string
          description: Role identifier
          example: account_admin
        status:
          $ref: '#/components/schemas/AssignmentStatus'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - assigneeId
        - assigneeType
        - roleId
        - status
        - createdAt
        - updatedAt
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
              example: BAD_REQUEST
            message:
              type: string
              description: Error message
              example: Invalid request parameters
            details:
              type: array
              items:
                type: string
              description: Additional error details
              example:
                - projectId is required for PROJECT scoped roles
          required:
            - code
            - message
      required:
        - error
    AssigneeType:
      type: string
      enum:
        - USER
        - IAMGROUP
      description: The type of assignee
    AssignmentStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
      description: The status of the role assignment
  responses:
    Unauthorized:
      description: Unauthorized - Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHORIZED
              message: Authentication required
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: FORBIDDEN
              message: Insufficient permissions to access this resource
    NotFound:
      description: Not found - Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Resource not found
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT Bearer token authentication

````