Skip to main content

Cache Settings API

This page documents the 4 gateway endpoints tagged Cache Settings in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/cache/settingsRead the response cache settings
POST/cache/settingsSave the response cache settings
DELETE/cache/settingsTurn the saved response cache off
POST/cache/settings/testTest a response cache connection

Endpoints​

GET /cache/settings​

Read the response cache settings

Return every response cache setting the Admin UI can edit, with its type, description and default, plus the values saved in the database overlaid on the REDIS_* environment. Passwords and URLs that carry a password come back as REDACTED. Proxy admins and admin viewers may read it.

Example request:

curl -X GET "http://localhost:4000/cache/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The editable fields and the saved values, credentials redacted.application/json CacheSettingsResponse
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
500The settings row could not be read or decryptedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
fieldsarray of CacheSettingsFieldYesList of all configurable cache settings with metadata
current_valuesobjectYesCurrent values of cache settings
redis_type_descriptionsobjectYesDescriptions for each Redis type option

POST /cache/settings​

Save the response cache settings

Encrypt and save the response cache settings in the database, then reinitialise the cache with them and turn response caching on, so the change takes effect without a restart. A credential sent as REDACTED or left out keeps its saved value. Needs a connected database and STORE_MODEL_IN_DB=True. Every save writes an audit log row with the changed settings, credentials redacted.

Parameters:

NameInTypeRequiredDescription
spanway-changed-byheaderstring or nullNoThe spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability

Request body (application/json, schema CacheSettingsUpdateRequest):

FieldTypeRequiredDescription
cache_settingsobjectYesCache settings to save

Example request:

curl -X POST "http://localhost:4000/cache/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cache_settings": {
"type": "redis",
"host": "redis.internal",
"port": "6379",
"password": "s3cret",
"namespace": "prod",
"ttl": 600
}
}'

Responses:

StatusDescriptionBody
200The settings were saved and the cache now runs on them.application/json CacheSettingsUpdateResponse
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500Database not connected. Please connect a database. or Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesConfirmation that the settings were saved and the cache reinitialised
statusstringYessuccess
settingsobjectYesThe saved settings with every credential redacted

DELETE /cache/settings​

Turn the saved response cache off

Remove the response cache settings saved from the Admin UI or POST /cache/settings and turn response caching off on every gateway instance, so requests go to the model again instead of being answered from the cache. Responses already stored in Redis stay there until they expire, and the usage and coordination Redis is not touched. A cache configured in the config file comes back on the next restart. Proxy admins only. Writes a deleted audit row with the removed settings, credentials redacted.

Parameters:

NameInTypeRequiredDescription
spanway-changed-byheaderstring or nullNoThe spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability

Example request:

curl -X DELETE "http://localhost:4000/cache/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The saved settings were removed and the response cache is off.application/json CacheSettingsDeleteResponse
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
404No cache settings are saved, so there is nothing to turn off.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Database not connected. Please connect a database. or Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesConfirmation that the saved settings were removed and the cache is off
statusstringYessuccess

POST /cache/settings/test​

Test a response cache connection

Connect to Redis with the settings in the body, without saving them and without touching the cache the gateway is using. A credential sent as REDACTED falls back to the saved value, so a form that left the password untouched still tests with the real one. A failed connection is a 200 with status failed, not an error status, so the message can be shown as the result. Only type redis can be tested.

Request body (application/json, schema CacheTestRequest):

FieldTypeRequiredDescription
cache_settingsobjectYesCache settings to test connection with

Example request:

curl -X POST "http://localhost:4000/cache/settings/test" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cache_settings": {
"type": "redis",
"host": "redis.internal",
"port": "6379",
"password": "***REDACTED***"
}
}'

Responses:

StatusDescriptionBody
200The verdict of the connection attempt, success or failed with the reason.application/json CacheTestResponse
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
statusstringYesConnection status: 'success' or 'failed'
messagestringYesConnection result message
errorstring or nullNoError message if connection failed