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

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

*Remove User from Workspace*

Remove a user from a workspace. The authenticated user must have ADMIN access to the workspace to perform this operation.

#### TypeScript Client Library

```typescript
public removeUserFromWorkspace = async (workspaceId: string, userId: string): Promise<WorkspaceTypes.RemoveUserFromWorkspaceResponse> => {
  return this.makeRequest<WorkspaceTypes.RemoveUserFromWorkspaceResponse>(`workspace/${workspaceId}/users/${userId}`, 'DELETE', null);
};
```

#### Code Samples

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

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

{% endtab %}

{% tab title="HTTP" %}

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

{% endtab %}

{% tab title="JavaScript" %}

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

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

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'

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

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

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

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

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

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(
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

try {
    $response = $client->request('DELETE',"https://backend.flashback.tech/workspace/{$workspace_id}/users/{$user_id}", array(
        'headers' => $headers,
       )
    );
    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("DELETE");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Bearer {access-token}");

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 (
       "net/http"
       "fmt"
)

func main() {
    workspaceId := "123e4567-e89b-12d3-a456-426614174000"
    userId := "user-456"
    headers := map[string][]string{
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

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

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

{% endtab %}
{% endtabs %}

#### Parameters <a href="#delete__workspace_wksid_users_userid-parameters" id="delete__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 to remove |

#### Path Parameters <a href="#delete__workspace_wksid_users_userid-path-parameters" id="delete__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 to remove |

> 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 remove user from workspace"
}
```

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

| Status | Meaning                                                                    | Description                              | Schema |
| ------ | -------------------------------------------------------------------------- | ---------------------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | User removed from workspace 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="#delete__workspace_wksid_users_userid-responseschema" id="delete__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 remove users
* **Account Validation**: User account must be validated to perform this operation
* **User Existence**: The target user must exist in the workspace to be removed
* **Immediate Effect**: User removal takes effect immediately
* **Access Revocation**: Removed users lose all access to the workspace
* **Organization Scoped**: Users can only be removed from workspaces within their organization
* **No Recovery**: Once removed, users must be re-added to regain access
* **Self-Removal**: Users cannot remove themselves from a workspace (this prevents accidental lockout)
