Create Session ID

POST /node/api/users/session

Creates a new session ID.

Request parameters

Body parameters

Parameter
Type
Description
login
String
required
User's login.
password
String
required
User's password.

Response description

The response body contains the only string that corresponds to a session ID.

Examples

Request examples

Here is how you can create a session id:
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
url=https://$saymon_hostname/node/api/users/session
5
6
curl -X POST $url \
7
-H "Content-Type: application/json" \
8
-d @- <<EOF
9
{
10
"login": "$login",
11
"password": "$password"
12
}
13
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let path = "/node/api/users/session";
5
6
let headers = new Headers();
7
headers.append("Content-Type", "application/json");
8
9
let data = JSON.stringify({
10
"login": login,
11
"password": password
12
});
13
14
let requestOptions = {
15
method: "POST",
16
headers: headers,
17
body: data
18
};
19
20
fetch(saymonHostname + path, requestOptions)
21
.then(response => response.text())
22
.then(result => console.log(result))
23
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let path = "/node/api/users/session";
7
8
let options = {
9
"method": "POST",
10
"hostname": saymonHostname,
11
"headers": {
12
"Content-Type": "application/json"
13
},
14
"path": path
15
};
16
17
let req = http.request(options, function (res) {
18
let chunks = [];
19
20
res.on("data", function (chunk) {
21
chunks.push(chunk);
22
});
23
24
res.on("end", function (chunk) {
25
let body = Buffer.concat(chunks);
26
console.log(body.toString());
27
});
28
29
res.on("error", function (error) {
30
console.error(error);
31
});
32
});
33
34
let data = JSON.stringify({
35
login: login,
36
password: password
37
});
38
39
req.write(data);
40
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
url = "https://" + saymon_hostname + "/node/api/users/session"
7
body = {"login": login, "password": password}
8
9
response = requests.request("POST", url, json=body)
10
session_id = response.text
11
print(session_id)
Copied!
After a new session ID is created, you need to provide it in the Cookie header to authenticate in the subsequent requests. The examples below show how this can be done for the Get Current User method:
Bash
JavaScript
NodeJS
Python
1
session_id=<...>
2
saymon_hostname=<...>
3
url=https://$saymon_hostname/node/api/users/current
4
5
curl -X GET $url -H "Cookie: sid=$session_id"
Copied!
1
let sessionId = <...>
2
let saymonHostname = <...>
3
let path = "/node/api/users/current";
4
5
let headers = new Headers();
6
headers.append("Cookie", "sid=" + sessionId);
7
8
let requestOptions = {
9
method: "GET",
10
headers: headers
11
};
12
13
fetch(saymonHostname + path, requestOptions)
14
.then(response => response.text())
15
.then(result => console.log(result))
16
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let sessionId = <...>
4
let saymonHostname = <...>
5
let path = "/node/api/users/current";
6
7
let options = {
8
"method": "GET",
9
"hostname": saymonHostname,
10
"headers": {
11
"Cookie": "sid=" + sessionId
12
},
13
"path": path
14
};
15
16
let req = http.request(options, function (res) {
17
let chunks = [];
18
19
res.on("data", function (chunk) {
20
chunks.push(chunk);
21
});
22
23
res.on("end", function (chunk) {
24
let body = Buffer.concat(chunks);
25
console.log(body.toString());
26
});
27
28
res.on("error", function (error) {
29
console.error(error);
30
});
31
});
32
33
req.end();
Copied!
1
import requests
2
3
session_id = <...>
4
saymon_hostname = <...>
5
url = "https://" + saymon_hostname + "/node/api/users/current"
6
headers = {"Cookie": "sid=" + session_id}
7
8
response = requests.request("GET", url, headers=headers)
9
print(response.text)
Copied!

Response example

1
"a5f946dc-4c21-4ccd-b78b-f0a5fce94f4d"
Copied!
Last modified 1yr ago