> This page is for Self-Hosted, version v3.0 (default).
> For other versions, use one of these documentation indexes:
> - v3.0 (default): https://docs.nvidia.com/run-ai/self-hosted/v3.0/llms.txt
> - v2.26: https://docs.nvidia.com/run-ai/self-hosted/v2.26/llms.txt
> - v2.25: https://docs.nvidia.com/run-ai/self-hosted/v2.25/llms.txt
> - v2.24: https://docs.nvidia.com/run-ai/self-hosted/v2.24/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/run-ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/run-ai/_mcp/server.

# Update a role by id.

PUT http://localhost:8080/api/v2/authorization/roles/{roleIdPath}
Content-Type: application/json

Updates a custom role, including its name, description, or associated permission sets. NVIDIA Run:ai predefined roles cannot be updated.

Reference: https://docs.nvidia.com/run-ai/self-hosted/reference/rest-api/endpoints/authentication-and-authorization/roles/update-role

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication

## Request

### Path parameters

- `roleIdPath` (integer, required) — The ID of the role

### Body (application/json)

This endpoint expects a RoleCreationFieldsInternal.

- `name` (string, required) — The name of the role to create. Must be unique within the given scope.
- `description` (string, required) — A description of the role.
- `enabled` (boolean, optional, nullable, default: true) — Specifies whether the role is active. Default: true
- `permissionSets` (list of RolePermissionSet, optional) — The permission sets assigned to this role. Each item includes the UUID and name of the permission set.
- `kubernetesPermissions` (KubernetesPermissions, optional) — Defines the Kubernetes cluster permissions associated with this role.

## Response

### 200

Executed successfully.

- `name` (string, required) — The name of the role to create. Must be unique within the given scope.
- `description` (string, required) — A description of the role.
- `id` (integer, required) — The ID of the role.
- `createdAt` (datetime, required) — The timestamp for when the role was created.
- `updatedAt` (datetime, required) — The timestamp for the last time the role was updated.
- `createdBy` (string, required) — Identifier of the user who created the role.
- `effectiveEnabled` (boolean, required, default: true) — Indicates whether the role is effectively enabled in the tenant. This reflects the role’s operational state after considering tenant-level configuration or restrictions. Default: true
- `permissions` (list of RolePermission, required)
- `enabled` (boolean, optional, nullable, default: true) — Specifies whether the role is active. Default: true
- `permissionSets` (list of RolePermissionSet, optional) — The permission sets assigned to this role. Each item includes the UUID and name of the permission set.
- `kubernetesPermissions` (KubernetesPermissions, optional) — Defines the Kubernetes cluster permissions associated with this role.
- `deprecated` (boolean, optional) — Indicates whether the role is deprecated. When set to true, the role is considered deprecated and should not be used for new assignments.

## Errors

### 400 Bad Request Error

Bad request.

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 401 Unauthorized Error

Unauthorized

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 403 Forbidden Error

Forbidden

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 404 Not Found Error

The specified resource was not found

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 500 Internal Server Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 503 Service Unavailable Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

## Types

### RolePermissionSet

- `id` (string, required) — The universally unique ID (UUID) of the permission set.
- `name` (string, optional) — The name of the permission set.

### KubernetesPermissions

- `predefinedRole` (string, optional, nullable) — The ID of an NVIDIA Run:ai predefined role. The custom role will include the mapped Kubernetes ClusterRole and its permissions.

### RolePermission

- `resourceType` (enum, required) — The type of resource the permission applies to.
  - Allowed values: `department`, `tenant`, `project`, `cluster`, `cluster-config`, `nodepools`, `nodes`, `settings`, `security-settings`, `notification-settings`, `branding-settings`, `users`, `apps`, `service-account`, `roles`, `access_rules`, `workloads`, `applications`, `workspaces`, `trainings`, `inferences`, `environments`, `pvc-assets`, `git-assets`, `host-path-assets`, `nfs-assets`, `s3-assets`, `compute-resources`, `resource-claim-templates`, `templates`, `credentials`, `events-history`, `policies`, `cm-volume-assets`, `datavolumes`, `secret-volume-assets`, `storage-class-configuration`, `device-classes`, `access-keys`, `workload-properties`, `network-topologies`, `registries`, `workload-integration-metrics`, `nodepools-minimal`, `clusters-minimal`, `users-minimal`
- `actions` (list of enum, required) — The list of allowed actions for this resource - create - read - update - delete
  - Allowed values: `create`, `read`, `update`, `delete`

## Examples

**Request**

```json
{
  "name": "admin",
  "description": "can manage all resources"
}
```

**Response**

```json
{
  "name": "admin",
  "description": "can manage all resources",
  "id": 32,
  "createdAt": "2024-01-15T09:30:00Z",
  "updatedAt": "2024-01-15T09:30:00Z",
  "createdBy": "user@run.ai",
  "effectiveEnabled": true,
  "permissions": [
    {
      "resourceType": "department",
      "actions": [
        "create"
      ]
    }
  ],
  "enabled": true,
  "permissionSets": [
    {
      "id": "string",
      "name": "test"
    }
  ],
  "kubernetesPermissions": {
    "predefinedRole": "12"
  },
  "deprecated": true
}
```

**SDK Code**

```python
import requests

url = "http://localhost:8080/api/v2/authorization/roles/32"

payload = {
    "name": "admin",
    "description": "can manage all resources"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'http://localhost:8080/api/v2/authorization/roles/32';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"admin","description":"can manage all resources"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8080/api/v2/authorization/roles/32"

	payload := strings.NewReader("{\n  \"name\": \"admin\",\n  \"description\": \"can manage all resources\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/v2/authorization/roles/32")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"admin\",\n  \"description\": \"can manage all resources\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("http://localhost:8080/api/v2/authorization/roles/32")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"admin\",\n  \"description\": \"can manage all resources\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'http://localhost:8080/api/v2/authorization/roles/32', [
  'body' => '{
  "name": "admin",
  "description": "can manage all resources"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v2/authorization/roles/32");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"admin\",\n  \"description\": \"can manage all resources\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "admin",
  "description": "can manage all resources"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v2/authorization/roles/32")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```