---
title: "Invalidate SSR ISR cache rows"
method: POST
path: "/cache/v1/invalidate"
tags: ["SSR Cache"]
---

# Invalidate SSR ISR cache rows

`POST /cache/v1/invalidate`

## Request

- Base URL: `https://api.run402.com`
- URL: `https://api.run402.com/cache/v1/invalidate`
- Auth: HTTP bearer

Invalidate cache rows for one or many `{host, path}` keys. Discriminated on `kind`: `"exact"` deletes one canonical key; `"prefix"` deletes every key whose path starts with the prefix; `"all"` deletes every key on the host; `"many"` deletes a list of URLs (host derived from each URL — every host must belong to the caller's project). Each host MUST be owned by the caller's project (subdomain `*.run402.com` matching `internal.subdomains.name` OR custom hostname in `internal.domains`); cross-project returns 403 `R402_CACHE_INVALIDATION_HOST_FORBIDDEN`. The DELETE and the per-(project, host) generation bump happen atomically; the returned `generation` is the post-increment value and gates in-flight MISS writes from overwriting already-invalidated rows. Pairs with `@run402/astro` v1.0+; capability `ssr-isr-cache` (v1.52).

## Request body

- union
  - object
    - `kind` 'exact', required
    - `host` string, required: Lowercased before lookup.
    - `path` string, required: Must start with `/`.
  - object
    - `kind` 'prefix', required
    - `host` string, required
    - `prefix` string, required: Must start with `/`. Deletes every key whose path starts with this prefix.
  - object
    - `kind` 'all', required
    - `host` string, required
  - object
    - `kind` 'many', required
    - `urls` string[], required: Empty array returns `{ deleted: 0, results: [] }` without touching the DB.

## Response `200`

Single-scope variants (`exact`, `prefix`, `all`) return `{ deleted, generation, host, path? }`; `many` returns `{ deleted, generation, host: "", results: [{ host, deleted, generation }] }` where the top-level `generation` is the first host's post-increment (or `"0"` for empty input).

- object
  - `deleted` integer, required: Number of cache rows deleted across all referenced hosts.
  - `generation` string, required: Post-increment generation value as a decimal string (bigint).
  - `host` string, required: Echoed host for single-scope variants; empty string for `kind: many`.
  - `path` string: Echoed path for `kind: exact` only.
  - `results` object[]: Per-host breakdown for `kind: many` only.
    - `host` string, required
    - `deleted` integer, required
    - `generation` string, required

## Other responses

- `400`: VALIDATION_FAILED — missing/unknown `kind`, malformed URL in `urls`, or `path`/`prefix` not starting with `/`.
- `403`: R402_CACHE_INVALIDATION_HOST_FORBIDDEN — a referenced host is not owned by the caller's project.

---

[API](https://skmtc.dev/run402/apis/run402-api.md) · [All operations](https://skmtc.dev/run402/apis/run402-api/llms.txt) · [OpenAPI document](https://skmtc.dev/run402/apis/run402-api/revisions/893607557f50?raw)
