PATCH /api/v1/settings/notifications • HTTP 200 OK
PATCH Request (Partial Field Update) — Request & Response Example
Demonstrates a partial update where a client flips a single toggle without re-sending all account settings.
1. HTTP Client Request (PATCH)
PATCH /api/v1/settings/notifications HTTP/1.1
{
"Content-Type": "application/json"
}
{
"email_digest": "weekly"
}
2. Server JSON Response (HTTP 200 OK)
{
"user_id": "usr_882",
"push_alerts": true,
"sms_alerts": false,
"email_digest": "weekly",
"updated_at": "2026-10-06T12:52:00Z"
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl -X PATCH "https://cometflow.space/api/v1/settings/notifications" \
-H "Content-Type: application/json" \
-d '{"email_digest": "weekly"}'
fetch('https://cometflow.space/api/v1/settings/notifications', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email_digest: 'weekly' })
}).then(res => res.json()).then(console.log);
import requests
res = requests.patch('https://cometflow.space/api/v1/settings/notifications', json={"email_digest": "weekly"})
print(res.json())
How This API Call Works Step-by-Step
- 1. Client identifies the setting path.
- 2. Client sends only the modified key (email_digest: weekly).
- 3. Server leaves push_alerts and sms_alerts untouched.
- 4. Server responds with the resulting merged state.
Backend API Functions: The API function patchSettings(req, res) constructs a dynamic UPDATE query touching only the fields passed in Object.keys(req.body).
Frequently Asked Questions
Why prefer PATCH over PUT in modern frontend development?
PATCH reduces payload size and eliminates race conditions where two simultaneous updates overwrite each other’s unrelated fields.