Purge API

The purge API invalidates cached objects across every PoP. Typical propagation is under two seconds worldwide. All requests are authenticated with an API token and must be signed. Purge API инвалидирует объекты в кеше на всех PoP. Типичное распространение — до двух секунд по миру. Все запросы требуют API-токен и подпись.

AuthenticationАвторизация

Issue an API token in Console → API → Tokens. Tokens are scoped per site; revoke them from the same page at any time. Создайте токен в Console → API → Tokens. Токены скоупятся на сайт и отзываются там же.

Authorization: Bearer bto_live_3kH…P1c
X-Batoff-Timestamp: 1745145600
X-Batoff-Signature: sha256=3e91…e4

Purge by URLPurge по URL

POST https://api.batoff.ru/v1/sites/{site_id}/purge
Content-Type: application/json

{
  "urls": [
    "https://www.example.com/index.html",
    "https://www.example.com/assets/app.css"
  ]
}

Up to 200 URLs per request. Response returns 202 Accepted and a task_id for status polling. До 200 URL за запрос. Ответ — 202 Accepted и task_id для проверки статуса.

Purge by prefixPurge по префиксу

POST https://api.batoff.ru/v1/sites/{site_id}/purge
{
  "prefixes": ["https://www.example.com/img/"]
}

Matches any URL beginning with the prefix. Rate-limited to 60 prefix purges per site per minute. Совпадает с любым URL, начинающимся с префикса. Лимит — 60 purge-по-префиксу на сайт в минуту.

Purge by tagPurge по тегу

Attach tags on the origin response with the Cache-Tag header (comma-separated, max 16 per response). Then purge every object with a given tag: На origin добавьте Cache-Tag (через запятую, до 16 на ответ). Затем инвалидируйте всё с этим тегом:

POST https://api.batoff.ru/v1/sites/{site_id}/purge
{
  "tags": ["product:42", "category:shoes"]
}

Task statusСтатус задачи

GET https://api.batoff.ru/v1/sites/{site_id}/purge/{task_id}

200 OK
{
  "task_id": "01JF7M2KZ7YH9Q4K0P2BDH9W3Y",
  "state": "completed",
  "items_total": 2,
  "items_done": 2,
  "started_at": "2026-04-20T08:12:31Z",
  "completed_at": "2026-04-20T08:12:32Z"
}

ErrorsОшибки

HTTPcodeMeaningСмысл
400invalid_urlURL does not belong to the siteURL не относится к сайту
401bad_signatureSignature or timestamp rejectedПодпись или timestamp отвергнуты
403scope_deniedToken missing purge scopeУ токена нет скоупа purge
429rate_limitedPer-site quota exceededПревышена квота сайта

Next:Дальше: SLA →