# put\_\_workspace\_{wksId}\_users\_{userId}

`PUT /workspace/{id}/users/{userId}`

*Update User Role in Workspace*

Update a user's role in a workspace. The authenticated user must have ADMIN access to the workspace to perform this operation.

#### TypeScript Client Library

```typescript
public updateWorkspaceUserRole = async (workspaceId: string, userId: string, request: WorkspaceTypes.UpdateUserRoleRequest): Promise<WorkspaceTypes.UpdateUserRoleResponse> => {
  return this.makeRequest<WorkspaceTypes.UpdateUserRoleResponse>(`workspace/${workspaceId}/users/${userId}`, 'PUT', request);
};
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# You can also use wget
curl -X PUT https://backend.flashback.tech/workspace/123e4567-e89b-12d3-a456-426614174000/users/user-456 \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}' \
  -d '{
    "role": "ADMIN"
  }'
```

{% endtab %}

{% tab title="HTTP" %}

```http
PUT https://backend.flashback.tech/workspace/123e4567-e89b-12d3-a456-426614174000/users/user-456 HTTP/1.1
Host: backend.flashback.tech
Content-Type: application/json
Accept: application/json
Authorization: Bearer {access-token}

{
  "role": "ADMIN"
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const workspaceId = '123e4567-e89b-12d3-a456-426614174000';
const userId = 'user-456';
const inputBody = '{
  "role": "ADMIN"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

fetch(`https://backend.flashback.tech/workspace/${workspaceId}/users/${userId}`,
{
  method: 'PUT',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

workspace_id = '123e4567-e89b-12d3-a456-426614174000'
user_id = 'user-456'
headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

data = {
  'role' => 'ADMIN'
}

result = RestClient.put "https://backend.flashback.tech/workspace/#{workspace_id}/users/#{user_id}",
  data.to_json, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

workspace_id = '123e4567-e89b-12d3-a456-426614174000'
user_id = 'user-456'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

data = {
  'role': 'ADMIN'
}

r = requests.put(f'https://backend.flashback.tech/workspace/{workspace_id}/users/{user_id}', 
                 headers=headers, 
                 json=data)

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$workspace_id = '123e4567-e89b-12d3-a456-426614174000';
$user_id = 'user-456';
$headers = array(
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array(
    'role' => 'ADMIN'
);

try {
    $response = $client->request('PUT',"https://backend.flashback.tech/workspace/{$workspace_id}/users/{$user_id}", array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }
```

{% endtab %}

{% tab title="Java" %}

```java
String workspaceId = "123e4567-e89b-12d3-a456-426614174000";
String userId = "user-456";
URL obj = new URL("https://backend.flashback.tech/workspace/" + workspaceId + "/users/" + userId);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Bearer {access-token}");

String jsonInputString = "{\"role\": \"ADMIN\"}";
con.setDoOutput(true);
try(OutputStream os = con.getOutputStream()) {
    byte[] input = jsonInputString.getBytes("utf-8");
    os.write(input, 0, input.length);           
}

int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
       "encoding/json"
       "fmt"
)

func main() {
    workspaceId := "123e4567-e89b-12d3-a456-426614174000"
    userId := "user-456"
    data := map[string]string{
        "role": "ADMIN",
    }
    
    jsonData, _ := json.Marshal(data)
    
    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    req, err := http.NewRequest("PUT", fmt.Sprintf("https://backend.flashback.tech/workspace/%s/users/%s", workspaceId, userId), bytes.NewBuffer(jsonData))
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Body parameter

```json
{
  "role": "ADMIN"
}
```

#### Parameters <a href="#put__workspace_wksid_users_userid-parameters" id="put__workspace_wksid_users_userid-parameters"></a>

| Name   | In   | Type   | Required | Description                            |
| ------ | ---- | ------ | -------- | -------------------------------------- |
| id     | path | string | true     | The unique identifier of the workspace |
| userId | path | string | true     | The unique identifier of the user      |
| body   | body | object | true     | Role update data                       |

#### Path Parameters <a href="#put__workspace_wksid_users_userid-path-parameters" id="put__workspace_wksid_users_userid-path-parameters"></a>

| Name   | Type   | Required | Restrictions | Description                            |
| ------ | ------ | -------- | ------------ | -------------------------------------- |
| id     | string | true     | none         | The unique identifier of the workspace |
| userId | string | true     | none         | The unique identifier of the user      |

#### Request Body Schema <a href="#put__workspace_wksid_users_userid-request-body-schema" id="put__workspace_wksid_users_userid-request-body-schema"></a>

| Name   | Type   | Required | Restrictions | Description                                             |
| ------ | ------ | -------- | ------------ | ------------------------------------------------------- |
| » role | string | true     | none         | The new role to assign to the user (READ, WRITE, ADMIN) |

**Enumerated Values**

| Parameter | Value |
| --------- | ----- |
| » role    | READ  |
| » role    | WRITE |
| » role    | ADMIN |

> Example responses

> 200 Response

```json
{
  "success": true
}
```

> 400 Response

```json
{
  "success": false,
  "message": "User not found or account is not validated"
}
```

> 403 Response

```json
{
  "success": false,
  "message": "Insufficient permissions to manage workspace users"
}
```

> 404 Response

```json
{
  "success": false,
  "message": "User not found in workspace"
}
```

> 500 Response

```json
{
  "success": false,
  "message": "Failed to update user role"
}
```

#### Responses <a href="#put__workspace_wksid_users_userid-responses" id="put__workspace_wksid_users_userid-responses"></a>

| Status | Meaning                                                                    | Description                     | Schema |
| ------ | -------------------------------------------------------------------------- | ------------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | User role updated successfully  | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)           | User not found or not validated | Inline |
| 403    | [Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)             | Insufficient permissions        | Inline |
| 404    | [Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)             | User not found in workspace     | Inline |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Server error                    | Inline |

#### Response Schema <a href="#put__workspace_wksid_users_userid-responseschema" id="put__workspace_wksid_users_userid-responseschema"></a>

Status Code **200**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | true     | none         | Operation success status |

Status Code **400**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | true     | none         | Operation success status |
| » message | string  | true     | none         | Error message            |

Status Code **403**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | true     | none         | Operation success status |
| » message | string  | true     | none         | Error message            |

Status Code **404**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | true     | none         | Operation success status |
| » message | string  | true     | none         | Error message            |

Status Code **500**

| Name      | Type    | Required | Restrictions | Description              |
| --------- | ------- | -------- | ------------ | ------------------------ |
| » success | boolean | true     | none         | Operation success status |
| » message | string  | true     | none         | Error message            |

## Notes

* **Authentication Required**: User must be authenticated with a valid Bearer token
* **Permissions**: User must have ADMIN access to the workspace to update user roles
* **Account Validation**: User account must be validated to perform this operation
* **User Existence**: The target user must already exist in the workspace
* **Role Assignment**: Users can be assigned READ, WRITE, or ADMIN roles
* **Role Hierarchy**: All roles (READ, WRITE, ADMIN) can be assigned to any user
* **Organization Scoped**: Users can only be managed within workspaces of their organization
* **Immediate Effect**: Role changes take effect immediately


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flashback.tech/support-reference/platform-api-reference/workspace/put__workspace_-wksid-_users_-userid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
