SAYMON REST API
Search…
SAYMON REST API
General
Methods
Agents [WIP]
Authentication
Authentication Token
Create Authentication Token
Delete Authentication Token
Session ID
Bulks [?]
Classes
Configuration
Dictionaries [?]
Event Log
Flows
History Annotations
Incidents
Incident Levels
Jobs
Limits
Links
Metric Tokens [?]
MQTT
Notification Templates [?]
Objects
Operations
Presets
Properties
References
Reports [?]
Scripts
Service
Stat
Stat Rules
State History
States
Tags
Users
User Groups
Models
Misc
Powered By
GitBook
Create Authentication Token
POST /node/api/users/:id/auth-token
Creates a new authentication token.
Permissions
: manage-users.
Request parameters
Path parameters
Parameter
Type
Description
id
String
required
The ID of a user for which an authentication token should be created.
Response description
The response body contains the only string that corresponds to an authentication token.
Examples
Request examples
Here is how you can create a new authentication token for a user with ID
user_id
:
Bash
JavaScript
NodeJS
Python
1
login
=<
..
.
>
2
password
=<
..
.
>
3
user_id
=<
..
.
>
4
saymon_hostname
=<
..
.
>
5
url
=
https://
$saymon_hostname
/node/api/users/
$user_id
/auth-token
6
​
7
curl
-X POST
$url
-u
$login
:
$password
Copied!
1
let
login
=
<...>
2
let
password
=
<...>
3
let
userId
=
<...>
4
let
saymonHostname
=
<...>
5
let
path
=
"/node/api/users/"
+
userId
+
"/auth-token"
;
6
let
auth
=
"Basic "
+
btoa
(
login
+
":"
+
password
);
7
​
8
let
headers
=
new
Headers
();
9
headers
.
append
(
"Authorization"
,
auth
);
10
​
11
let
requestOptions
=
{
12
method
:
"POST"
,
13
headers
:
headers
14
};
15
​
16
fetch
(
saymonHostname
+
path
,
requestOptions
)
17
.
then
(
response
=>
response
.
text
())
18
.
then
(
result
=>
console
.
log
(
result
))
19
.
catch
(
error
=>
console
.
log
(
"error"
,
error
));
Copied!
1
const
http
=
require
(
"http"
);
2
​
3
let
login
=
<...>
4
let
password
=
<...>
5
let
userId
=
<...>
6
let
saymonHostname
=
<...>
7
let
path
=
"/node/api/users/"
+
userId
+
"/auth-token"
;
8
let
auth
=
"Basic "
+
Buffer
.
from
(
login
+
":"
+
password
).
toString
(
"base64"
);
9
​
10
let
options
=
{
11
"method"
:
"POST"
,
12
"hostname"
:
saymonHostname
,
13
"headers"
:
{
14
Authorization
:
auth
15
},
16
"path"
:
path
17
};
18
​
19
let
req
=
http
.
request
(
options
,
function
(
res
)
{
20
let
chunks
=
[];
21
​
22
res
.
on
(
"data"
,
function
(
chunk
)
{
23
chunks
.
push
(
chunk
);
24
});
25
​
26
res
.
on
(
"end"
,
function
(
chunk
)
{
27
let
body
=
Buffer
.
concat
(
chunks
);
28
console
.
log
(
body
.
toString
());
29
});
30
​
31
res
.
on
(
"error"
,
function
(
error
)
{
32
console
.
error
(
error
);
33
});
34
});
35
​
36
req
.
end
();
Copied!
1
import
requests
2
​
3
login
=
<
...
>
4
password
=
<
...
>
5
user_id
=
<
...
>
6
saymon_hostname
=
<
...
>
7
url
=
"https://"
+
saymon_hostname
+
"/node/api/users/"
+
\
8
user_id
+
"/auth-token"
9
​
10
response
=
requests
.
request
(
"POST"
,
url
,
auth
=
(
login
,
password
))
11
print
(
response
.
text
)
Copied!
After the token is created, the user needs to provide it as a query parameter to authenticate in the subsequent requests. The examples below show how to do it for the
Get Current User
method:
Bash
JavaScript
NodeJS
Python
1
saymon_hostname
=<
..
.
>
2
api_token
=<
..
.
>
3
url
=
https://
$saymon_hostname
/node/api/users/current
4
​
5
curl
-X GET
$url
?api-token
=
$api_token
Copied!
1
let
authToken
=
<...>
2
let
saymonHostname
=
<...>
3
let
path
=
"/node/api/users/current?api-token="
+
authToken
;
4
​
5
let
requestOptions
=
{
6
method
:
"GET"
7
};
8
​
9
fetch
(
saymonHostname
+
path
,
requestOptions
)
10
.
then
(
response
=>
response
.
text
())
11
.
then
(
result
=>
console
.
log
(
result
))
12
.
catch
(
error
=>
console
.
log
(
"error"
,
error
));
Copied!
1
const
http
=
require
(
"http"
);
2
​
3
let
authToken
=
<...>
4
let
saymonHostname
=
<...>
5
let
path
=
"/node/api/users/current?api-token="
+
authToken
;
6
​
7
let
options
=
{
8
"method"
:
"GET"
,
9
"hostname"
:
saymonHostname
,
10
"path"
:
path
11
};
12
​
13
let
req
=
http
.
request
(
options
,
function
(
res
)
{
14
let
chunks
=
[];
15
​
16
res
.
on
(
"data"
,
function
(
chunk
)
{
17
chunks
.
push
(
chunk
);
18
});
19
​
20
res
.
on
(
"end"
,
function
(
chunk
)
{
21
let
body
=
Buffer
.
concat
(
chunks
);
22
console
.
log
(
body
.
toString
());
23
});
24
​
25
res
.
on
(
"error"
,
function
(
error
)
{
26
console
.
error
(
error
);
27
});
28
});
29
​
30
req
.
end
();
Copied!
1
import
requests
2
​
3
api_token
=
<
...
>
4
saymon_hostname
=
<
...
>
5
url
=
"https://"
+
saymon_hostname
+
"/node/api/users/current"
6
params
=
{
"api-token"
:
api_token
}
7
​
8
response
=
requests
.
request
(
"GET"
,
url
,
params
=
params
)
9
print
(
response
.
text
)
Copied!
Response example
1
"6c41afda-0f18-4613-983f-3e01d83c6aaa"
Copied!
Previous
Authentication Token
Next
Delete Authentication Token
Last modified
1yr ago
Copy link
Contents
POST /node/api/users/:id/auth-token
Request parameters
Path parameters
Response description
Examples
Request examples
Response example