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
| Item | Value |
|---|---|
| Method | PUT |
| Path | /v1/projects/{project_id}/databases/{database_id}/cache-rules/{query_hash} |
| Auth | Authorization: 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.jsonJWT issued by Better Auth. Verified via JWKS.
In: header
Path Parameters
Unique project identifier (prefixed, e.g. prj_xxx).
^[a-zA-Z0-9_.-]+$Unique database identifier (prefixed, e.g. db_xxx).
^[a-zA-Z0-9_.-]+$xxhash64 hex of the normalized SQL.
^[a-f0-9]+$16 <= length <= 16Request 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"
}
}