Account
Accounts
Several operations can be performed via API for user account management, including login and the display of account information:
login
Operations on users are processed through our API, so it is necessary to generate a JWT token to allow the user to identify themselves on our services. The following endpoint allows the generation of a login token starting from from the user name and password.
HTTP request
POST /ecs/v2/login
{
"username": "foo",
"password": "foo-s3cr3t-passw0rd"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtc2ciOiJXcm9uZyBQbGFjZSBkdWRlPyJ9.vBb9pIUYaxiGtO-7HY6hzBXH-q7L0GJS8stz2VYqb90",
"expire": 1728560902,
"status": "ok"
}
Info
The generated token can be used as a simple bearer token until it expires.
curl --request GET 'https://api.seeweb.it/ecs/v2/' \
--header 'Authorization: Your-Token-JWT' \'
Account Information.
User information can be collected via the following endpoint:
HTTP request
GET /ecs/v2/account
{
"username": "foo",
"email": "foo@seeweb.it",
"reserved_available": true, # L'utente può utilizzare il piano riservato
"offline_available": false, # L'utente riceve uno sconto offline
"ecs_special_discount": 12, # se > 0 l'utente ha già uno sconto speciale sui piani ecs standard
"ecshm_special_discount": 0, # se == 0 l'utente non ha sconti speciali sui piani high memory
"ecsgpu_special_discount": -1 # se < 0 l'utente ha uno sconto speciale sui piani gpu
}
Change Password.
You can change a user's password directly from the API at the following endpoint:
HTTP request
POST /ecs/v2/account
{
"password": "my-new-supers3cr3t-passw0rd"
}
{
"status": "ok"
}
API-Token
TL;DR:
API-Tokens are used to integrate ECS services with your applications but without, unlike the tokens JWT, no token expiration.
To use it just add it as a header:
curl --location --request GET 'https://api.seeweb.it' \
--header 'X-APITOKEN: *your API token*' \
Continue reading:
JWT tokens are very useful for validating a user's operations for short periods, but what can I do if I need to connect ECS systems with an automated service?
To solve this problem, we introduced API-Tokens, long-lived tokens that allow integration with our systems the need to generate jwt tokens per request.
!!! warning “Warning” ECS services do not force token regeneration, but it is strongly recommended to do so over long periods for security reasons.
Create an API-Token
To create an API-Token you can simply use the following endpoint:
HTTP request
POST /ecs/v2/keys
{
"notes": "foo-rest-api-token-label"
}
{
"status": "ok",
"token": "8yKnCbmPMyAgeaxjhzhdWc7WtsI9Y0XVvuavy0m9E1co6S0epK3e0DPqRjzpBDyGBxFeeFdYKFgpPfWZaTdNu2K1hdhcvviarI4biDNrybmQUY4LLbHtM6C5GsW2EIhc"
}
Info
After creating the token, you can simply add it to the “X-APITOKEN” header as follows:
curl --location --request GET 'https://api.seeweb.it' \
--header 'X-APITOKEN: *il tuo token API*' \
!!! warning “Warning” This token is shown only after creation, in case the token is lost or compromised it is strongly recommended to destroy it and generate a new one.
List API-Token.
Obviously ECS is not allowed to share the contents of the token, it is, however, able to share the labels and code associated with each token so that it can be deleted:
HTTP Request
GET /ecs/v2/keys
[
{
"id": 0,
"notes": "foo-rest-api-token-label-1",
"created_at": "2024-10-10 10:36..."
},
{
"id": 1,
"notes": "foo-rest-api-token-label-2",
"created_at": "2024-10-10 10:37..."
}
]
Rename an API-Token.
To change the label of your API-Token you can simply use the following request:
HTTP request
PUT /ecs/v2/keys/{token-id}
{
"notes": "my-new-label"
}
{
"status": "ok"
}
Delete an API-Token
To delete an API-Token, the following request is available:
HTTP request
DELETE /ecs/v2/keys/{token-id}
{
"status": "ok"
}