Add a Sensor to a Group
Endpoint URL: https://<your server>/rest/sensors/action/addToGroup
Endpoint URI: sensors/action/addToGroup
Action: POST
Adds the selected sensor to a sensor group to help organize sensors in your environment. You must have the Sensor Admin L1 or System Admin role and be assigned to a group to run this request.
Note
If you want to add a sensor to another group, you must first remove the sensor from the group to which it is assigned and then add it to the new group. Moving a sensor directly from one group to another group is not supported.
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
Input: JSON
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.
{
"sensorsIds":["<sensor ID>"],
"argument":"<group ID>"
}
Request Parameters
URL/URI parameters: none
Request Body Parameters: You must add the following REQUIRED parameters.
argument: A string value with the group ID.
Use one of the following parameters to select specific endpoints:
sensorsIds: The string with the sensor IDs of the sensors to add to the group. If you add multiple sensors, make sure to add commas between the sensor ID values.
filters object. If you do not add filters, add the value null for the filters object.
Note
If you add a parameter in the filters object, ensure you use this syntax: {“fieldName”: “<filter parameter>”, “operator”: “<operator>”, “values”: [“<value>”]}
Response Status Codes
This request can return the following status codes:
200: Success OK or an error message saying why
Response Success Schema
The response contains the following fields:
numberOfSensorsMatchedCriteria: An integer value that shows how many sensors matched the specified criteria.
numberOfSensorsAssigned: The number of sensors assigned to the specified group.
Response Failure Schema
A 400 error code with an error message describing the error.
Important Response Fields
Important information is found in these fields:
numberOfSensorsAssigned: The number of sensors successfully assigned to the selected group.
Example: Assign sensors to a group
Request
curl --request POST \
--url https://12.34.56.78/rest/sensors/actions/addToGroup \
--header 'Content-Type:application/json' \
--data '{
"sensorsIds":["5f1d70c2e4b0f2283bfcbe33:europe1"],
"argument":"20000000-0000-0000-0000-000000000000"
}'
Response
{
"numberOfSensorsMatchedCriteria":1,
"numberOfSensorsAssigned":1
}
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.
Use this request body:
{
"sensorsIds":["5f1d70c2e4b0f2283bfcbe33:europe1"],
"argument":"20000000-0000-0000-0000-000000000000"
}
Response
{
"numberOfSensorsMatchedCriteria":1,
"numberOfSensorsAssigned":1
}
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""
endpoint_url = "/rest/sensors/action/addToGroup"
api_url = base_url + endpoint_url
# These are the variables that represent different fields in the request.
sensor_id = "5f1d70c2e4b0f2283bfcbe33:europe1"
argument = "All admin machines that run Linux"
query = json.dumps({"sensorsIds":[sensor_id],"argument":argument})
api_response = session.request("POST", api_url, data=query, headers=headers)
your_response = json.loads(api_response.content)
print(json.dumps(your_response, indent=4, sort_keys=True))
Response
{
"numberOfSensorsMatchedCriteria":1,
"numberOfSensorsAssigned":1
}