-
Notifications
You must be signed in to change notification settings - Fork 10
API
adamkobor edited this page Oct 1, 2020
·
6 revisions
Kuvasz provides a REST API that you can use to manage your monitors. You can find the latest documentation in OpenAPI 3.0 format here: API docs. Note that a running service also exposes this documentation at the /swagger-ui
route, i.e. https://your.host:8080/swagger-ui.
The API endpoints are sitting behind a JWT based authentication/authorization (except /health
and /info
). To use them, you have to call /login
first:
curl --location --request POST 'https://your.host:8080/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "YourAdminUserName",
"password": "YourAdminPassword"
}'
The token in the response will be valid for 1 hour:
{
"username": "YourAdminUserName",
"roles": [
"ROLE_ADMIN"
],
"access_token": "eyJhbGciHJFKIjfjzI1NiJ9.eyJzdWIiOiJEYXZleU1vb3JlIiwibmJmIjdf657adf8da65NTkyLCJyb2xlcyI6WyJST0xFX0FETUlOIl0sImlzcyI6Imt1dmFzeiIsImV4cCI6MTU5NzYwNTE5MiwiaWF0IjoxNTk3NjAxNTkyfQ.EDAeFfsdfsfdsoJmUtP11XLGksmiVDttU_N4dsfsdXJLP4",
"token_type": "Bearer",
"expires_in": 3600
}
Now, you can send your authenticated requests with your fresh new token in the header:
curl --location --request GET 'https://your.host:8080/monitors' \
--header 'Authorization: Bearer eyJhbGciHJFKIjfjzI1NiJ9.eyJzdWIiOiJEYXZleU1vb3JlIiwibmJmIjdf657adf8da65NTkyLCJyb2xlcyI6WyJST0xFX0FETUlOIl0sImlzcyI6Imt1dmFzeiIsImV4cCI6MTU5NzYwNTE5MiwiaWF0IjoxNTk3NjAxNTkyfQ.EDAeFfsdfsfdsoJmUtP11XLGksmiVDttU_N4dsfsdXJLP4' \
--header 'Content-Type: application/json'