База знаний

Connect a site through the public API

Эта статья есть на вашем языке: Как подключить сайт через публичное API

The public API creates protection services as the token’s owner. A paid creation immediately charges that account’s balance. Prepare the origin IPv4, port, domain, and a tested token before sending POST.

Select a plan

On Windows, run the following; on Linux, replace curl.exe with curl:

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

Replace the token. Inspect id, min_days, prices, and domain limits in data.tariffs. Do not copy a tariff ID from somebody else’s example. price_month_with_vat covers 30 days; other periods follow the applicable payment conditions.

Create the service once

Save this JSON as create-site.json, replacing the domain, origin address, and tariff ID. Port 80 is appropriate only if your origin actually serves the website there.

{"domain":"example.com","remote_ip":"203.0.113.10","remote_port":80,"tariff":3,"days":30}

Confirm the period: creation charges for at least min_days. Send one request:

curl.exe -i -X POST https://webshield.ru/api/v1/sites -H "X-API-TOKEN: wsk_REPLACE_ME" -H "Content-Type: application/json" --data-binary "@create-site.json"

Success returns HTTP 201, ok: true, and data.site. Save its id. Status 0 means creation is pending; it is not a reason to repeat POST.

Wait and configure DNS

Poll the site periodically, replacing 42 with its returned ID:

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

Wait for status: 1, then point the connected hostnames’ A records to the returned cluster_ips. Working describes cluster state, not successful DNS switching. Check DNS and availability.

For validation_failed, inspect error.fields; for insufficient_funds, inspect balance and cost. After a timeout, first GET /api/v1/sites and check the domain, paid-through date, and balance debit. Paid POSTs are not idempotent; automatic retries and Idempotency-Key are unsupported. Public operations for changing the origin, deleting sites, or configuring every protection setting are unavailable.

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