База знаний

Create, test, and revoke an API token

Эта статья есть на вашем языке: Как создать, проверить и отозвать API-токен

An API token gives an integration access as your account, including viewing sites, creating protection services, and renewing them from your balance. The current interface does not offer read-only or per-site permissions.

Create a token

  1. Open your account profile → API tokens.
  2. Enter a recognizable purpose in Token name, such as “Hosting integration”.
  3. Click Create token. An account can have up to ten active tokens.
  4. Immediately use Copy and store the full secret in your integration’s secret storage. It is shown only on that visit; the table retains a short hint.

A lost secret cannot be recovered. Create a replacement and revoke the old token. Keep live keys out of public repositories, website JavaScript, URLs, and support screenshots.

Test without payment

Use curl.exe on Windows or curl on Linux. Replace wsk_REPLACE_ME with your key:

curl.exe -i -H "X-API-TOKEN: wsk_REPLACE_ME" https://webshield.ru/api/v1/me

A successful response contains ok: true, account ID, email, and balance. Verify the intended account. GET /me neither creates a service nor charges for one. Successful use also updates the token’s last-used value, though not necessarily for every request.

For HTTP 401 with error.code: unauthorized, check the header, full token string, and token state. Expired tokens and keys belonging to unavailable accounts are also rejected. Do not use a paid POST request to test authentication.

Revoke or rotate

Click Revoke beside the intended token. Reload and confirm Revoked. Repeating GET /me with that key should now return 401.

For planned rotation, create and test a new key, update the integration, then revoke the old one. Revoke a compromised key immediately. Closing browser sessions does not replace revoking an API token.

Статья была полезна?