Skip to content

Clear Policy Cache

Invalidate cached policy state held by the engine. The engine caches compiled policy representations for performance. Use this endpoint after a deployment, rollback, or data change that requires the engine to reload the latest policy state immediately rather than waiting for the cache to expire naturally.

Clearing the cache does not delete the policy itself. Subsequent evaluation requests will recompile and re-cache the policy from the current active version.

Endpoint

DELETE /api/v1/policies/cache

Required Role

MEMBER

Headers

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes
X-Tenant-IDTenant identifier stringYes

Request Body

json
{
  "policyModule": "string",
  "policyFunction": "string"
}

Both fields are optional. The combination of provided fields determines the scope of invalidation:

policyModulepolicyFunctionScope
OmittedOmittedClears the entire policy cache for the tenant.
ProvidedOmittedClears all cached functions within the specified module.
ProvidedProvidedClears only the cached entry for the specific module + function pair.
OmittedProvided400 Bad RequestpolicyFunction cannot be specified without policyModule.
FieldTypeRequiredDescription
policyModulestringNoModule name to target for cache invalidation.
policyFunctionstringNoFunction name within the module to target. Requires policyModule to also be specified.

Response Body

json
{
  "cleared": 0,
  "scope": "string"
}
FieldTypeDescription
clearednumberNumber of individual cache entries that were invalidated.
scopestringHuman-readable description of what was cleared (e.g. "all", "module:Loan.Approval", "function:Loan.Approval.isEligible").

HTTP Status Codes

StatusMeaning
200 OKCache cleared. cleared may be 0 if no matching entries were cached at the time of the request.
400 Bad RequestpolicyFunction was specified without policyModule, or the request body is malformed.
401 UnauthorizedMissing or invalid bearer token.
403 ForbiddenToken is valid but the caller lacks the MEMBER role.
500 Internal Server ErrorUnexpected engine failure. Cache state is undefined when this status is returned.

Examples

Clear Entire Tenant Cache

bash
curl -X DELETE https://policy.aster-lang.dev/api/v1/policies/cache \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-ID: acme-corp" \
  -d '{}'
js
const response = await fetch(
  'https://policy.aster-lang.dev/api/v1/policies/cache',
  {
    method: 'DELETE',
    headers: {
      Authorization: 'Bearer <token>',
      'Content-Type': 'application/json',
      'X-Tenant-ID': 'acme-corp',
    },
    body: JSON.stringify({}),
  }
);

const data = await response.json();
console.log(`Cleared ${data.cleared} cache entries (scope: ${data.scope})`);

Clear Cache for a Specific Module

bash
curl -X DELETE https://policy.aster-lang.dev/api/v1/policies/cache \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-ID: acme-corp" \
  -d '{
    "policyModule": "Loan.Approval"
  }'
js
const response = await fetch(
  'https://policy.aster-lang.dev/api/v1/policies/cache',
  {
    method: 'DELETE',
    headers: {
      Authorization: 'Bearer <token>',
      'Content-Type': 'application/json',
      'X-Tenant-ID': 'acme-corp',
    },
    body: JSON.stringify({
      policyModule: 'Loan.Approval',
    }),
  }
);

const data = await response.json();

Clear Cache for a Specific Function

bash
curl -X DELETE https://policy.aster-lang.dev/api/v1/policies/cache \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-ID: acme-corp" \
  -d '{
    "policyModule": "Loan.Approval",
    "policyFunction": "isEligible"
  }'
js
const response = await fetch(
  'https://policy.aster-lang.dev/api/v1/policies/cache',
  {
    method: 'DELETE',
    headers: {
      Authorization: 'Bearer <token>',
      'Content-Type': 'application/json',
      'X-Tenant-ID': 'acme-corp',
    },
    body: JSON.stringify({
      policyModule: 'Loan.Approval',
      policyFunction: 'isEligible',
    }),
  }
);

const data = await response.json();

Example Responses

Entire tenant cache cleared:

json
{
  "cleared": 47,
  "scope": "all"
}

Module-scoped clear:

json
{
  "cleared": 3,
  "scope": "module:Loan.Approval"
}

Function-scoped clear:

json
{
  "cleared": 1,
  "scope": "function:Loan.Approval.isEligible"
}

No entries were cached (still succeeds):

json
{
  "cleared": 0,
  "scope": "function:Loan.Approval.isEligible"
}

Released under the MIT License.