Set Object's Manual State

PUT /node/api/objects/:id/manual-state

Sets an object's manual state. Returns a JSON representation of the updated object.
Permissions: objectPermissions & (modify-objects | manage-objects).

Request parameters

Path parameters

Parameter
Type
Description
id
string required
The ID or discovery ID of the object whose manual state must be set.

Body parameters

Parameter
Type
Description
by
integer
optional
A timestamp when the state should be unset.
clear
boolean optional
Whether to clear a previously set state. If set to true, the stateId parameter is not required.
clearedByState
array
optional
A list of states that trigger a cleaning of the current state.
reason
string
optional
The reason why the state was set.
since
integer optional
A timestamp when the state was set.
stateId
string required
The ID of a state to be set.

Response description

...

Examples

Request examples

Here is how you can set a new state:
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
object_id=<...>
5
url=https://$saymon_hostname/node/api/objects/$object_id/manual-state
6
7
curl -X PUT $url -u $login:$password \
8
-H "Content-Type: application/json" \
9
-d @- <<EOF
10
{
11
"stateId": 3,
12
"clear": false,
13
"reason": "Testing"
14
}
15
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let objectId = <...>
5
let path = "/node/api/objects/" + objectId + "/manual-state";
6
let auth = "Basic " + btoa(login + ":" + password);
7
8
let headers = new Headers();
9
headers.append("Authorization", auth);
10
headers.append("Content-Type", "application/json");
11
12
let data = JSON.stringify({
13
"stateId": 3,
14
"clear": false,
15
"reason": "Testing"
16
});
17
18
let requestOptions = {
19
method: "PUT",
20
headers: headers,
21
body: data
22
};
23
24
fetch(saymonHostname + path, requestOptions)
25
.then(response => response.text())
26
.then(result => console.log(result))
27
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let objectId = <...>
7
let path = "/node/api/objects/" + objectId + "/manual-state";
8
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
9
10
let options = {
11
"method": "PUT",
12
"hostname": saymonHostname,
13
"headers": {
14
"Authorization": auth,
15
"Content-Type": "application/json"
16
},
17
"path": path
18
};
19
20
let req = http.request(options, function (res) {
21
let chunks = [];
22
23
res.on("data", function (chunk) {
24
chunks.push(chunk);
25
});
26
27
res.on("end", function (chunk) {
28
let body = Buffer.concat(chunks);
29
console.log(body.toString());
30
});
31
32
res.on("error", function (error) {
33
console.error(error);
34
});
35
});
36
37
let data = JSON.stringify({
38
"stateId": 3,
39
"clear": false,
40
"reason": "Testing"
41
});
42
43
req.write(data);
44
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
object_id = <...>
7
url = "https://" + saymon_hostname + "/node/api/objects/" + \
8
object_id + "/manual-state";
9
10
body = {
11
"stateId": 3,
12
"clear": false,
13
"reason": "Testing"
14
}
15
16
response = requests.request("PUT", url, json=body, auth=(login, password))
17
print(response.text)
Copied!
Here is how you can unset the state:
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
object_id=<...>
5
url=https://$saymon_hostname/node/api/objects/$object_id/manual-state
6
7
curl -X PUT $url -u $login:$password \
8
-H "Content-Type: application/json" \
9
-d @- <<EOF
10
{
11
"clear": true
12
}
13
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let objectId = <...>
5
let path = "/node/api/objects/" + objectId + "/manual-state";
6
let auth = "Basic " + btoa(login + ":" + password);
7
8
let headers = new Headers();
9
headers.append("Authorization", auth);
10
headers.append("Content-Type", "application/json");
11
12
let data = JSON.stringify({
13
"clear": true
14
});
15
16
let requestOptions = {
17
method: "PUT",
18
headers: headers,
19
body: data
20
};
21
22
fetch(saymonHostname + path, requestOptions)
23
.then(response => response.text())
24
.then(result => console.log(result))
25
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let objectId = <...>
7
let path = "/node/api/objects/" + objectId + "/manual-state";
8
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
9
10
let options = {
11
"method": "PUT",
12
"hostname": saymonHostname,
13
"headers": {
14
"Authorization": auth,
15
"Content-Type": "application/json"
16
},
17
"path": path
18
};
19
20
let req = http.request(options, function (res) {
21
let chunks = [];
22
23
res.on("data", function (chunk) {
24
chunks.push(chunk);
25
});
26
27
res.on("end", function (chunk) {
28
let body = Buffer.concat(chunks);
29
console.log(body.toString());
30
});
31
32
res.on("error", function (error) {
33
console.error(error);
34
});
35
});
36
37
let data = JSON.stringify({
38
"clear": true
39
});
40
41
req.write(data);
42
req.end();
Copied!
1
import requests
2
import json
3
4
login = <...>
5
password = <...>
6
saymon_hostname = <...>
7
object_id = <...>
8
url = "https://" + saymon_hostname + "/node/api/objects/" + \
9
object_id + "/manual-state";
10
11
body = {
12
"clear": True
13
}
14
15
response = requests.request("PUT", url, json=body, auth=(login, password))
16
print(response.text)
Copied!

Response example

1
{
2
"id": "5e21b85b308c3c66d64e07d2",
3
"name": "CPU",
4
"discovery_id": "192.168.1.82-CPU",
5
"object_groups": [],
6
"geoposition": [],
7
"child_ref_ids": [],
8
"child_link_ids": [],
9
"child_ids": [],
10
"parent_id": "5e21b85b308c3c66d64e07bc",
11
"weight": 1,
12
"tags": [],
13
"last_state_update": 1585047151777,
14
"updated": 1585047151770,
15
"created": 1579268187099,
16
"state_id": 7,
17
"class_id": 4,
18
"_stateConditionRefs": [],
19
"operations": [],
20
"properties": [],
21
"client_data": "{...}",
22
"manual_state": null,
23
"owner_id": "5e21b752308c3c66d64e072c"
24
}
Copied!