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)const options = {method: 'POST', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/cache-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/gateway/v1/cache-rules \
--header 'X-Auth-Token: <api-key>'{
"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>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<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)const options = {method: 'POST', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/cache-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/gateway/v1/cache-rules \
--header 'X-Auth-Token: <api-key>'{
"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>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Was this page helpful?
⌘I