nsindocs Search the docs⌘K
  1. Docs
  2. API reference
  3. Cache

Purge or refresh selected cached entries

posthttps://api.nsin.ir/domains/{domain}/cache/keys/purge

Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.

Targets specific entries — either by listing them in entries, or by matching a filter. Supply one or the other.

  • mode: "delete" (default) removes the entry and drops it from the listing.
  • mode: "refresh" only evicts the stored copy, so the next visitor re-fills it. The row stays and updates itself.

entries must carry each row's stored identity — copy hostname, store_path, key_hash and node straight from the listing (note the request body uses camelCase for these). Entries belonging to another domain are rejected.

truncated is true when a filter matched more entries than one call may touch — repeat the call until it is false. When a storage node that may hold the entries does not confirm, the answer is 502 with complete: false and unreached — the purge did not fully happen. Requires cache.edit and a plan including cache purge.

Path parameters

  • domainstringrequiredpath

    The domain name (for example example.com) — not a numeric id.

Request body

Content type: application/json · required

  • modestring

    delete removes the entry and drops it from the listing; refresh only evicts the stored copy so the next visitor re-fills it.

    One of: "delete" "refresh"
    Default: "delete"
  • entriesarray of CachePurgeTarget
    Item fields
    • domainIdinteger
    • hostnamestringrequired

      The listing's hostname.

    • storePathstring

      The listing's store_path.

    • keyHashstringrequired

      The listing's key_hash.

    • nodestringrequired

      The listing's node.

    • encstring

      The listing's enc. Optional — when omitted, every stored encoding of the entry is targeted.

  • filterobject

    Purge everything matching this filter.

    Fields
    • hostnamestring
    • nodestring
    • pathstring

      Path wildcard, e.g. /assets/*.

Responses

200Purge result.

Content type: application/json

  • deletedinteger
  • modestring
    One of: "delete" "refresh"
  • truncatedboolean

    The filter matched more entries than one call may touch. Repeat the request until this is false.

  • completeboolean

    Every storage node that could hold the entries confirmed. false only on a 502: the purge did not fully happen.

  • unreachedarray of string

    What could not be reached and why. Present when complete is false.

  • errorstring

    Explanation on a 502.

json
{
  "deleted": 0,
  "mode": "delete",
  "truncated": true,
  "complete": true,
  "unreached": [
    "string"
  ],
  "error": "string"
}
400Malformed body, or neither entries nor filter supplied.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
401Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "invalid API key"
}
402The domain has no active plan.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
403Read-only key, your role on the domain lacks cache.edit, or cache purge is not on the domain's plan.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
404No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
409The domain is disabled or banned.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
429The key exceeded its request budget (300 requests per minute by default).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "rate limit exceeded"
}
502A storage node that may hold the entries did not confirm. unreached says which and why; retry.

Content type: application/json

  • deletedinteger
  • modestring
    One of: "delete" "refresh"
  • truncatedboolean

    The filter matched more entries than one call may touch. Repeat the request until this is false.

  • completeboolean

    Every storage node that could hold the entries confirmed. false only on a 502: the purge did not fully happen.

  • unreachedarray of string

    What could not be reached and why. Present when complete is false.

  • errorstring

    Explanation on a 502.

json
{
  "deleted": 0,
  "mode": "delete",
  "truncated": true,
  "complete": true,
  "unreached": [
    "string"
  ],
  "error": "string"
}
503The cache registry is temporarily unreachable.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}

Example request

bash
curl -X POST "https://api.nsin.ir/domains/example.com/cache/keys/purge" \
  -H "Authorization: Bearer $NSIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "mode": "delete",
  "entries": [
    {
      "domainId": 0,
      "hostname": "string",
      "storePath": "string",
      "keyHash": "string",
      "node": "string",
      "enc": "string"
    }
  ],
  "filter": {
    "hostname": "string",
    "node": "string",
    "path": "string"
  }
}'
esc