PgBeam Docs
Projects

Update cache rule

Enable or disable caching for a specific query shape, with optional TTL and SWR overrides. Requires the query to exist in the cache rules.

At a glance

ItemValue
MethodPUT
Path/v1/projects/{project_id}/databases/{database_id}/cache-rules/{query_hash}
AuthAuthorization: Bearer <token-or-api-key>

Quick request

Use this as a starting point. Replace the placeholder IDs, set PGBEAM_TOKEN, and create body.json from the schema below.

curl -X PUT \
  "$PGBEAM_API_URL/v1/projects/<project_id>/databases/<database_id>/cache-rules/<query_hash>" \
  -H "Authorization: Bearer $PGBEAM_TOKEN" \
  -H "Content-Type: application/json" \
  --data @body.json
PUT
/v1/projects/{project_id}/databases/{database_id}/cache-rules/{query_hash}
AuthorizationBearer <token>

JWT issued by Better Auth. Verified via JWKS.

In: header

Path Parameters

project_id*string

Unique project identifier (prefixed, e.g. prj_xxx).

Match^[a-zA-Z0-9_.-]+$
database_id*string

Unique database identifier (prefixed, e.g. db_xxx).

Match^[a-zA-Z0-9_.-]+$
query_hash*string

xxhash64 hex of the normalized SQL.

Match^[a-f0-9]+$
Length16 <= length <= 16

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X PUT "https://api.pgbeam.com/v1/projects/string/databases/string/cache-rules/stringstringstri" \  -H "Content-Type: application/json" \  -d '{    "cache_enabled": true  }'
{
  "entry": {
    "query_hash": "a1b2c3d4e5f60718",
    "normalized_sql": "SELECT * FROM users WHERE id = $1",
    "query_type": "read",
    "cache_enabled": true,
    "cache_ttl_seconds": 0,
    "cache_swr_seconds": 0,
    "call_count": 0,
    "avg_latency_ms": 0.1,
    "p95_latency_ms": 0.1,
    "avg_response_bytes": 0,
    "stability_rate": 0.1,
    "recommendation": "great",
    "first_seen_at": "2019-08-24T14:15:22Z",
    "last_seen_at": "2019-08-24T14:15:22Z"
  }
}
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "message": "string"
  }
}