Request authentication
Depending on the product or its resource, the following are used to work with Selectel product APIs and authenticate requests instead of a username and password:
-
IAM tokens are issued to service users. The token lifespan is 24 hours. IAM tokens are passed in the
X-Auth-Tokenheader and have different scopes:- Account-scoped IAM tokens (
iam_token_account_scoped) — for managing resources linked to the account; - Project-scoped IAM tokens (
iam_token_project_scoped) — for managing resources linked to the project;
- Account-scoped IAM tokens (
-
Static tokens (
static_token) are issued to users with access to the control panel and are used to manage resources linked to the account. The token lifespan is unlimited. Static tokens are passed in theX-Tokenheader.
The URL for your requests can be found in the list of URLs.
You can restrict access to the API by addresses that include https://api.selectel.ru.
Account-scoped IAM token (X-Auth-Token)
An account-scoped IAM token can only be issued to a service user.
The token is passed in the X-Auth-Token header.
An IAM token for an account (iam_token_account_scoped) provides access to managing most Selectel products and OpenStack API objects on par with a username and password in the my.selectel.ru Control Panel. It allows you to manage account resources.
The token lifespan is 24 hours.
The token allows you to manage:
- users and roles (IAM) and federations;
- balance and consumption statistics;
- dedicated servers;
- OpenStack API objects (cloud servers, network volumes, and others) using the cloud platform projects and resources, project quotas and limits API; learn more in the OpenStack documentation;
- Global Router;
- DNS hosting (legacy);
- Mobile Farm.
Get an account-scoped IAM token
An account-scoped IAM token can be issued to service users who have a permission with the Account scope selected.
If you are using Windows, replace single quotes ('') with double quotes ("") in your requests. We also recommend using PowerShell for requests instead of CMD.
- Send the following request:
curl -i -XPOST \
-H 'Content-Type: application/json' \
-d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"<username>","domain":{"name":"<account_id>"},"password":"<password>"}}},"scope":{"domain":{"name":"<account_id>"}}}}' \
'https://cloud.api.selcloud.ru/identity/v3/auth/tokens'
Specify:
<username>is the service user name. You can view it in the control panel: in the top menu, click IAM → Service Users section (this section is only available to the Account Owner and users with theiam.adminrole);<account_id>is the account number. You can view it in the control panel in the top-right corner;<password>is the service user password; you can view it when creating the user or change it to a new one.
Upon successful authorization, a response with code 201 Created will be returned in the following format:
HTTP/2 201
X-Subject-Token: token
- Check the token in the
X-Subject-Tokenheader.
Project-scoped IAM token (X-Auth-Token)
A project-scoped IAM token can only be issued to a service user.
The token is passed in the X-Auth-Token header.
An IAM token for a project (iam_token_project_scoped) provides access to managing most Selectel products and OpenStack API objects on par with a username and password in the my.selectel.ru Control Panel. It allows you to manage project resources.
The token lifespan is 24 hours.
The token allows you to manage:
- dedicated servers;
- OpenStack API objects (cloud servers, network volumes, and others) using the cloud platform projects and resources, project quotas and limits API; learn more in the OpenStack documentation;
- cloud platform — direct public IP addresses, private DNS, Managed Databases, Managed Kubernetes, Container Registry, secrets manager (secrets, certificates, Let’s Encrypt® certificates);
- S3 (Swift API and Object Storage API);
- DNS hosting;
- Selectel email service;
- Cloud for 1C;
- audit logs.
Get a project-scoped IAM token
A project-scoped IAM token can be issued to service users who have a permission where:
- the Account scope is selected;
- or the Projects scope is selected and the required project is chosen.
If you are using Windows, replace single quotes ('') with double quotes ("") in your requests. We also recommend using PowerShell for requests instead of CMD.
- Send the following request:
curl -i -XPOST \
-H 'Content-Type: application/json' \
-d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"<username>","domain":{"name":"<account_id>"},"password":"<password>"}}},"scope":{"project":{"name":"<project_name>","domain":{"name":"<account_id>"}}}}}' \
'https://cloud.api.selcloud.ru/identity/v3/auth/tokens'
Specify:
<username>is the service user name. You can view it in the control panel: in the top menu, click IAM → Service Users section (this section is available only to the Account Owner and users with theiam.adminrole);<account_id>is the account number. You can view it in the control panel in the top-right corner;<password>is the service user password; you can view it when creating the user or change it to a new one;<project_name>is the project name.
Upon successful authorization, a response with code 201 Created will be returned in the following format:
HTTP/2 201
X-Subject-Token: token
- Check the token in the
X-Subject-Tokenheader.
Static token (X-Token)
An X-Token can only be issued to a user with access to the control panel.
The token is passed in the request in the X-Token header.
A static token (static_token) provides full access to managing some Selectel products on par with a username and password in the my.selectel.ru Control Panel. It does not allow managing OpenStack API objects.
The token lifespan is unlimited.
For APIs that do not support Account-scoped IAM token and Project-scoped IAM token, the static token is the only option for:
Get a static token
- In the control panel, open the menu in the top-right corner (account number) and select Profile.
- Go to Access → API Keys tab.
- Click Add Key.
- Enter the key name.
- Click Add.