PATCH /api/settings
Updates one or more numeric settings. Changes take effect immediately — they mirror to the GUI and are picked up by the pipeline within roughly 50ms.
Request
PATCH /api/settings HTTP/1.1
Host: localhost:4242
Content-Type: application/json
{
"sensitivity": 0.15
}
The body is a JSON object. Keys are setting names (matching var= declarations in your script); values must be numeric.
You can patch a single setting or multiple at once:
{
"sensitivity": 0.15,
"fov": 480.0,
"delay": 20.0
}
Response
200 OK — returns the full updated settings map (not just the keys you changed):
{
"sensitivity": 0.15,
"fov": 480.0,
"delay": 20.0
}
This lets you immediately confirm the new state without a follow-up GET.
Validation & errors
400 Bad Request — returned when the input fails validation. The response body is:
{ "error": "<description>" }
| Condition | Error message |
|---|---|
| Empty body | Empty body |
| Malformed JSON | Invalid JSON |
| Unknown setting key | Unknown setting key: 'foo' |
| Non-numeric value | Value for 'sensitivity' must be a number |
Validation rules:
- Only numeric values accepted. Strings, booleans, nulls, objects, and arrays are rejected.
-
Unknown keys are rejected — the key must match a
var=from a loaded script. - Empty bodies are rejected — send at least one key/value.
Examples
curl
curl -X PATCH http://localhost:4242/api/settings \
-H "Content-Type: application/json" \
-d '{"sensitivity": 0.15}'
Multi-key:
curl -X PATCH http://localhost:4242/api/settings \
-H "Content-Type: application/json" \
-d '{"sensitivity": 0.15, "fov": 480, "delay": 20}'
JavaScript
await fetch('http://localhost:4242/api/settings', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sensitivity: 0.15 }),
});
PowerShell
$body = @{ sensitivity = 0.15 } | ConvertTo-Json
Invoke-RestMethod `
-Uri http://localhost:4242/api/settings `
-Method Patch `
-ContentType 'application/json' `
-Body $body
Notes
- Atomic per request, not transactional across keys. All keys in a single request are validated up-front; if any fail validation, none are applied. If all pass, all are applied together.
-
GUI updates are visual only — your script reads from
settings.*on its next frame, so PATCH'd values are live as fast as the pipeline runs (typically <50ms). - For non-numeric settings (colour pickers, text inputs, dropdowns by label name), use the in-app GUI — the API is numeric-only by design.
See also
- GET /api/settings — read current values
- GUI directives — how to declare settings in your scripts