Create a cache rule
import requests
url = "https://app.langwatch.ai/api/gateway/v1/cache-rules"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"cache_rule": {
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"description": "<string>",
"priority": 123,
"enabled": true,
"matchers": {},
"action": {
"ttl": 123,
"salt": "<string>"
},
"archived_at": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}
}Gateway: Cache Rules
Create a cache rule
Matchers are ANDed across non-null fields; at least one matcher is required. Mode is one of respect/force/disable. TTL is clamped to [0, 86400]. Salt is an optional cache-bust tag (max 64 chars). All writes emit a ChangeEvent so the gateway picks up the new rule within 30 s via its /changes long-poll.
POST
/
api
/
gateway
/
v1
/
cache-rules
Create a cache rule
import requests
url = "https://app.langwatch.ai/api/gateway/v1/cache-rules"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"cache_rule": {
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"description": "<string>",
"priority": 123,
"enabled": true,
"matchers": {},
"action": {
"ttl": 123,
"salt": "<string>"
},
"archived_at": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}
}Was this page helpful?
⌘I