Skip to main content
PUT
/
user
/
remove-permissions
Remove permissions from a user
curl --request PUT \
  --url http://localhost:2000/user/remove-permissions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "payload": {
    "userId": "68bb46bb4db8c853599f1ebb",
    "permissions": [
      "compass.dashboard.*",
      "compass.dashboard.overview"
    ]
  }
}
'
import requests

url = "http://localhost:2000/user/remove-permissions"

payload = { "payload": {
"userId": "68bb46bb4db8c853599f1ebb",
"permissions": ["compass.dashboard.*", "compass.dashboard.overview"]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payload: {
userId: '68bb46bb4db8c853599f1ebb',
permissions: ['compass.dashboard.*', 'compass.dashboard.overview']
}
})
};

fetch('http://localhost:2000/user/remove-permissions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_PORT => "2000",
CURLOPT_URL => "http://localhost:2000/user/remove-permissions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'payload' => [
'userId' => '68bb46bb4db8c853599f1ebb',
'permissions' => [
'compass.dashboard.*',
'compass.dashboard.overview'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "http://localhost:2000/user/remove-permissions"

payload := strings.NewReader("{\n \"payload\": {\n \"userId\": \"68bb46bb4db8c853599f1ebb\",\n \"permissions\": [\n \"compass.dashboard.*\",\n \"compass.dashboard.overview\"\n ]\n }\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(string(body))

}
HttpResponse<String> response = Unirest.put("http://localhost:2000/user/remove-permissions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payload\": {\n \"userId\": \"68bb46bb4db8c853599f1ebb\",\n \"permissions\": [\n \"compass.dashboard.*\",\n \"compass.dashboard.overview\"\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:2000/user/remove-permissions")

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 \"payload\": {\n \"userId\": \"68bb46bb4db8c853599f1ebb\",\n \"permissions\": [\n \"compass.dashboard.*\",\n \"compass.dashboard.overview\"\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Successfully removed permissions for this user.",
  "data": {}
}
{
"errorMessage": "User with this ID does not exist anymore"
}
Removes one or more permissions from a user’s existing permissions list. Only admin-level users can perform this action.

Request

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Request Body

{
  "payload": {
    "userId": "68bb46bb4db8c853599f1ebb",
    "permissions": [
      "compass.dashboard.*",
      "compass.dashboard.overview"
    ]
  }
}

Request Body Schema

FieldTypeRequiredDescription
payloadobjectYesRemove permissions payload
payload.userIdstringYesThe ID of the user to update
payload.permissionsarrayYesList of permissions to remove

Permission Format

Permissions follow the pattern: compass.module.action
  • Use * as wildcard (e.g., compass.dashboard.*)
  • Specific actions (e.g., compass.dashboard.overview)
  • Module-level access (e.g., compass.emailmeter)

Response

200 OK - Successfully removed permissions

{
  "message": "Successfully removed permissions for this user.",
  "data": {}
}

400 Bad Request

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid payload or missing required fields"
  }
}

401 Unauthorized

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Missing or invalid authentication token"
  }
}

403 Forbidden

{
  "error": {
    "code": "FORBIDDEN",
    "message": "Insufficient permissions"
  }
}

404 Not Found

{
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "User with this ID does not exist anymore"
  }
}

500 Internal Server Error

{
  "error": {
    "code": "SERVER_ERROR",
    "message": "Internal server error"
  }
}

Example

curl -X PUT 'http://localhost:2000/user/remove-permissions' \
  -H 'Authorization: Bearer your-jwt-token' \
  -H 'Content-Type: application/json' \
  -d '{
    "payload": {
      "userId": "68bb46bb4db8c853599f1ebb",
      "permissions": [
        "compass.dashboard.*",
        "compass.dashboard.overview",
        "compass.emailmeter.stats"
      ]
    }
  }'

Notes

  • This is an admin-only endpoint - requires administrative privileges
  • Permissions are removed from the user’s existing permissions
  • Non-existent permissions are automatically ignored
  • The user ID must be a valid MongoDB ObjectId
  • Permission strings must match exactly to be removed
  • Changes take effect immediately for the user’s next request
  • Use the /user/add-permissions endpoint to add permissions
  • Permission changes are logged for audit purposes
  • Removing all permissions may restrict user access to the system

Important Considerations

  • Wildcard Permissions: Removing compass.dashboard.* removes all dashboard permissions
  • Specific Permissions: Must match exactly (case-sensitive)
  • Minimum Permissions: Ensure users retain necessary permissions for their role
  • Audit Trail: All permission changes are tracked
  • Immediate Effect: Changes apply on the user’s next authenticated request

Best Practices

  1. Review user’s current permissions before removal
  2. Test permission changes in a non-production environment
  3. Document permission changes for compliance
  4. Consider using role-based permissions instead of individual management
  5. Regularly audit user permissions for security

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
payload
object
required

Response

Successfully removed permissions

message
string
Example:

"Successfully removed permissions for this user."

data
object
Example:
{}