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

# Update a role

> Perform a full replacement update of the mutable fields of the role in a single request, including the complete set of permissions.



## OpenAPI

````yaml /en/api-reference/openapi.en-v1.json put /v1/organizations/{organization_id}/roles/{role_id}
openapi: 3.0.3
info:
  title: API Publica Portal
  version: 1.0.0
  description: Public REST API for portal
servers:
  - url: https://api.flexxible.net/
    description: Portal API
security:
  - bearerAuth: []
tags: []
paths:
  /v1/organizations/{organization_id}/roles/{role_id}:
    put:
      tags:
        - Roles
      summary: Update a role
      description: >-
        Perform a full replacement update of the mutable fields of the role in a
        single request, including the complete set of permissions.
      operationId: update_role_by_id
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[0-9a-f]{24}$
            minLength: 24
            maxLength: 24
          description: Organization identifier.
          example: 507f1f77bcf86cd799439011
        - name: role_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[0-9a-f]{24}$
            minLength: 24
            maxLength: 24
          description: Role identifier.
          example: 64f0c2a1b2d3e4f5060708aa
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateRoleRequestV1'
            examples:
              full_update_organization_scoped:
                summary: Update role with organization scoped permissions
                value:
                  name: Operador de organizacion
                  permissions:
                    - target_organization: 507f1f77bcf86cd799439011
                      portal_permission: organization_admin
                      workspaces_permission: admin_read_only
                      analyzer_permission: access
                      target_reporting_groups:
                        - 64f0c2a1b2d3e4f5060708c1
                        - 64f0c2a1b2d3e4f5060708c2
              full_update_mixed_scopes:
                summary: Update role with mixed scope permissions
                value:
                  name: Soporte de plataforma
                  permissions:
                    - target_organization: all
                      portal_permission: platform
                      workspaces_permission: admin
                      analyzer_permission: admin
                      target_reporting_groups: all
                    - target_organization: 507f1f77bcf86cd799439011
                      portal_permission: l2_support_team
                      workspaces_permission: l2_support_team
                      analyzer_permission: access
                      target_reporting_groups:
                        - 64f0c2a1b2d3e4f5060708d1
      responses:
        '200':
          description: Role updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoleV1'
        '400':
          description: Invalid path parameter or invalid request body contract.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request_body:
                  summary: Malformed update payload
                  value:
                    error:
                      message: Cuerpo de solicitud invalido
                      code: bad_request
                      details: >-
                        permissions[0].target_organization debe ser una cadena
                        hexadecimal en minusculas de 24 caracteres o el valor
                        all
        '401':
          description: Not authorized or organization not accessible.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                organization_not_authorized:
                  summary: Organization access failure
                  value:
                    error:
                      message: No autorizado
                      code: unauthorized
        '404':
          description: Role not found within the authorized scope of the organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                role_not_found:
                  summary: Requested role not found
                  value:
                    error:
                      message: Rol no encontrado
                      code: not_found
        '409':
          description: The request conflicts with the existing role state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                role_name_conflict:
                  summary: Role name already exists
                  value:
                    error:
                      message: El nombre del rol ya existe
                      code: conflict
                      details: name ya esta en uso dentro de esta organizacion
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unexpected_error:
                  summary: Unhandled failure
                  value:
                    error:
                      message: Error interno del servidor
                      code: internal_error
components:
  schemas:
    UpdateRoleRequestV1:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
          description: User role name.
        permissions:
          type: array
          minItems: 1
          description: Complete permission entries defining the final state of the role.
          items:
            $ref: '#/components/schemas/UpdateRolePermissionItemV1'
      required:
        - name
        - permissions
    RoleV1:
      type: object
      properties:
        id:
          type: string
          pattern: ^[0-9a-f]{24}$
          minLength: 24
          maxLength: 24
          description: Role identifier.
        name:
          type: string
          description: Role name.
        organization_id:
          type: string
          pattern: ^[0-9a-f]{24}$
          minLength: 24
          maxLength: 24
          description: Organization identifier associated with this role.
        created_at:
          type: string
          format: date-time
          description: Role creation timestamp in ISO 8601 format.
        created_by:
          type: string
          nullable: true
          pattern: ^[0-9a-f]{24}$
          minLength: 24
          maxLength: 24
          description: Identifier of the user who created the role.
        permissions:
          type: array
          nullable: true
          description: Permission entries configured for this role.
          items:
            $ref: '#/components/schemas/GetRolePermissionItemV1'
      required:
        - id
        - name
        - organization_id
        - created_at
        - created_by
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
            details:
              type: string
          required:
            - message
            - code
      required:
        - error
    UpdateRolePermissionItemV1:
      type: object
      properties:
        target_organization:
          oneOf:
            - type: string
              enum:
                - all
            - type: string
              pattern: ^[0-9a-f]{24}$
              minLength: 24
              maxLength: 24
          description: >-
            Permission organization scope. Use all for all organizations or a
            specific organization_id.
        portal_permission:
          type: string
          enum:
            - admin
            - organization_admin
            - organization_admin_read_only
            - user
            - platform
            - l1_support_team
            - l1_support_team_read_only
            - l2_support_team
            - l2_support_team_read_only
            - l3_engineering_team
            - l3_engineering_team_read_only
            - billing
          description: Portal permission level.
        workspaces_permission:
          type: string
          enum:
            - no_access
            - l1_support_team_read_only
            - l1_support_team
            - l2_support_team_read_only
            - l2_support_team
            - l3_engineering_team_read_only
            - l3_engineering_team
            - admin_read_only
            - admin
          description: Workspace permission level.
        analyzer_permission:
          type: string
          enum:
            - no_access
            - access
            - admin
          description: Analyzer permission level.
        target_reporting_groups:
          oneOf:
            - type: string
              enum:
                - all
            - type: array
              minItems: 1
              items:
                type: string
                pattern: ^[0-9a-f]{24}$
                minLength: 24
                maxLength: 24
          description: >-
            Permission reporting groups scope. Use all for all groups or a list
            of reporting_group_id.
      required:
        - target_organization
        - portal_permission
        - workspaces_permission
        - analyzer_permission
        - target_reporting_groups
    GetRolePermissionItemV1:
      type: object
      properties:
        portal_permission:
          type: string
          nullable: true
          enum:
            - admin
            - organization_admin
            - organization_admin_read_only
            - user
            - platform
            - l1_support_team
            - l1_support_team_read_only
            - l2_support_team
            - l2_support_team_read_only
            - l3_engineering_team
            - l3_engineering_team_read_only
            - billing
          description: Portal permission level.
        workspaces_permission:
          type: string
          nullable: true
          enum:
            - no_access
            - l1_support_team_read_only
            - l1_support_team
            - l2_support_team_read_only
            - l2_support_team
            - l3_engineering_team_read_only
            - l3_engineering_team
            - admin_read_only
            - admin
          description: Workspace permission level.
        analyzer_permission:
          type: string
          nullable: true
          enum:
            - no_access
            - access
            - admin
          description: Analyzer permission level.
        target_organization:
          oneOf:
            - type: string
              enum:
                - all
            - type: string
              pattern: ^[0-9a-f]{24}$
              minLength: 24
              maxLength: 24
          description: >-
            Organization scope of permission: `all` for all organizations or a
            specific `organization_id`.
        target_reporting_groups:
          oneOf:
            - type: string
              enum:
                - all
            - type: array
              minItems: 1
              items:
                type: string
                pattern: ^[0-9a-f]{24}$
                minLength: 24
                maxLength: 24
          description: >-
            Reporting groups scope of permission: `all` for all groups or list
            of specific `reporting_group_id`.
      required:
        - target_organization
        - target_reporting_groups
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````