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.
| Method | Path | Summary |
|---|---|---|
| GET | /cache/settings | Read the response cache settings |
| POST | /cache/settings | Save the response cache settings |
| DELETE | /cache/settings | Turn the saved response cache off |
| POST | /cache/settings/test | Test 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:
| Status | Description | Body |
|---|---|---|
| 200 | The editable fields and the saved values, credentials redacted. | application/json CacheSettingsResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 500 | The settings row could not be read or decrypted | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
fields | array of CacheSettingsField | Yes | List of all configurable cache settings with metadata |
current_values | object | Yes | Current values of cache settings |
redis_type_descriptions | object | Yes | Descriptions 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The 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):
| Field | Type | Required | Description |
|---|---|---|---|
cache_settings | object | Yes | Cache 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:
| Status | Description | Body |
|---|---|---|
| 200 | The settings were saved and the cache now runs on them. | application/json CacheSettingsUpdateResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database 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):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Confirmation that the settings were saved and the cache reinitialised |
status | string | Yes | success |
settings | object | Yes | The 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | The saved settings were removed and the response cache is off. | application/json CacheSettingsDeleteResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 404 | No cache settings are saved, so there is nothing to turn off. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database 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):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Confirmation that the saved settings were removed and the cache is off |
status | string | Yes | success |
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):
| Field | Type | Required | Description |
|---|---|---|---|
cache_settings | object | Yes | Cache 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:
| Status | Description | Body |
|---|---|---|
| 200 | The verdict of the connection attempt, success or failed with the reason. | application/json CacheTestResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | Connection status: 'success' or 'failed' |
message | string | Yes | Connection result message |
error | string or null | No | Error message if connection failed |