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

# Update UserRole

> Update an existing UserRole record.

Updates an existing UserRole record. You must include the `Id` of the record to update along with all required fields.

## Authentication

> [!NOTE]
>
> This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
> The authenticated user must be a full unrestricted administrator or have the **`UserRole-Edit`** role.

## Request Body

### Required Fields

**Id** `integer` *required*

The Id of the UserRole record to update.

**BusinessId** `integer` *required*

ID of the organisational location associated with this User Role; keep it at the top-most root location where possible, as it does not limit the permissions granted..

**Name** `string` *required*

Required name of this permission group, unique within its organisational location..

### Optional Fields

**Roles** `integer[]`

List of global Role IDs that define this permission group's permissions; an empty list grants no Role permissions..

**AddedRoles** `integer[]`

IDs added to the Roles relationship..

**RemovedRoles** `integer[]`

IDs removed from the Roles relationship..

**Users** `integer[]`

List of User IDs assigned to this permission group; an empty list assigns the group to no users, and an update replaces the complete assignment list..

**AddedUsers** `integer[]`

IDs added to the Users relationship..

**RemovedUsers** `integer[]`

IDs removed from the Users relationship..

## Code Examples

```bash cURL theme={null}
curl -X PUT \
  "https://spaces.nexudus.com/api/security/userroles" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "BusinessId": 0,
    "Name": "",
    "Id": 87654321
}'
```

```javascript JavaScript theme={null}
const response = await fetch(
  'https://spaces.nexudus.com/api/security/userroles',
  {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      BusinessId: 0,
      Name: '',
      Id: 87654321
    })
  }
);

const data = await response.json();
```

```python Python theme={null}
import requests

response = requests.put(
    'https://spaces.nexudus.com/api/security/userroles',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
    },
    json={
        'BusinessId': 0,
        'Name': '',
        'Id': 87654321
    }
)

data = response.json()
```

## Response

### 200

**Status** `integer`

HTTP status code. `200` on success.

**Message** `string`

A human-readable message confirming the update.

**Value** `object`

Contains the `Id` of the updated record.

**WasSuccessful** `boolean`

`true` if the userrole was updated successfully.

**Errors** `array`

`null` on success.

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "UserRole was successfully updated.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

**Message** `string`

A summary of the validation error(s), in the format `PropertyName: error message`.

**Value** `any`

`null` on validation failure.

**Errors** `object[]`

Array of validation errors.

**AttemptedValue** `any`

The value that was submitted for the field, or `null` if missing.

**Message** `string`

The validation error message.

**PropertyName** `string`

The name of the property that failed validation.

**WasSuccessful** `boolean`

`false` when the request fails validation.

```json Example Response theme={null}
{
  "Message": "Name: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Name"
    }
  ],
  "WasSuccessful": false
}
```


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