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

# Update User Roles

> Replace a member's role attachments.



## OpenAPI

````yaml PUT /orgs/{org_id}/iam/users/{user_id}/roles
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/iam/users/{user_id}/roles:
    put:
      tags:
        - iam
      description: Replace a member's role attachments.
      operationId: handler
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: user_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplaceRolesReqBody'
        required: true
      responses:
        '204':
          description: Attachments updated
        '403':
          description: Insufficient permissions
        '422':
          description: Invalid attachment
      security:
        - bearer_auth: []
components:
  schemas:
    ReplaceRolesReqBody:
      type: object
      required:
        - attachments
      properties:
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/AttachmentReq'
          description: |-
            Desired attachment set for this member. Attachments present today
            but not in the list are detached; new ones are attached. An empty
            list detaches everything. Duplicate `(role_id, scope)` pairs are
            ignored.
    AttachmentReq:
      type: object
      description: |-
        A single (role, scope) attachment in the desired state.

        `scope` is an optional hierarchical resource path (`projects:42`,
        `projects:42:envs:5`). `null` / omitted = unscoped (the role's grants
        apply as-written). The same role may appear multiple times with
        different scopes — the unique key on `OrgUserRoles` is
        `(org, user, role, scope) NULLS NOT DISTINCT`.
      required:
        - role_id
      properties:
        role_id:
          type: integer
          format: int64
        scope:
          type:
            - string
            - 'null'
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````