Delete a User
Endpoint URL: https://<your server/rest/users/:username
Endpoint URI: users/:username
Action: DELETE
Deletes a user.
Note
Ensure that you have logged into the Cybereason platform. For details, see Log in with the API.
Request Headers
You must add an Content-Type:application/json header with the request.
Note
If you are using cURL, add the authorization cookie details or the path to the file with cookie details with every request.
Request Body
None
Request Parameters
URL/URI parameters: You must provide the username parameter in the URL of the request.
Request Body Parameters: None
Response Status Codes
This request can return the following status codes:
200: Success OK with details on the operation
Response Success Schema
The response one of the following status messages:
success (Success)
Response Failure
The response one of the following status messages:
success (Success)
badUsername (Invalid username)
badBasicPassword (Invalid password when using the basic password complexity)
badStrictPassword (Invalid password when using the strict password complexity)
previousPassword (Password is the same as a previous password)
userExists (User already exists)
userNotChanged (No changes in user data)
userNotFound (Platform did not find the user)
staleUser (User marked as stale)
actionNotAllowed (Update action not allowed)
errorOccured (A general error occurred)
actionFailed (Creation action failed)
badTotpSid (The TFA secret key is not valid)
incorrectPassword (The password is not correct)
illegaleLocale (User locale is not valid)
Important Response Fields
You want to ensure that the request returns the success message.
Example: Delete a user
Request
curl --request DELETE \
--url https://12.34.56.78/rest/users/[email protected] \
--header 'Content-Type:application/json' \
Response
This response has been shortened to show a single example of the fields for a user. A real response would contain many more users than this response.
"success"
Request
Depending on your browser settings, this linked file may open in a separate tab instead of downloading directly to your machine. If this happens, use the Save As option in your browser to save the file locally.
import requests
import json
# Login information
username = "[email protected]"
password = "mypassword"
server = "yourserver.com"
port = "443"
data = {
"username": username,
"password": password
}
headers = {"Content-Type": "application/json"}
base_url = "https://" + server + ":" + port
login_url = base_url + "/login.html"
session = requests.session()
login_response = session.post(login_url, data=data, verify=True)
print (login_response.status_code)
print (session.cookies.items())
# Request URL
username = "[email protected]"
endpoint_url = "/rest/users"
api_url = base_url + endpoint_url + username
api_response = session.request("DELETE", api_url, headers=headers)
your_response = json.loads(api_response.content)
print(json.dumps(your_response, indent=4, sort_keys=True))
Response
"success"