Update the current user's preferences.
PATCH
/api/v1/auth/preferences
const url = 'https://example.com/api/v1/auth/preferences';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"browser_open_mode":"single_click","color_preset":"#2563eb","custom":{"additionalProperty":"example"},"display_time_zone":"example","language":"en","remove_custom_keys":["example"],"sort_by":"name","sort_order":"asc","storage_event_stream_enabled":true,"theme_mode":"system","view_mode":"list"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use std::str::FromStr;use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/auth/preferences";
let payload = json!({ "browser_open_mode": "single_click", "color_preset": "#2563eb", "custom": json!({"additionalProperty": "example"}), "display_time_zone": "example", "language": "en", "remove_custom_keys": ("example"), "sort_by": "name", "sort_order": "asc", "storage_event_stream_enabled": true, "theme_mode": "system", "view_mode": "list" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.request(reqwest::Method::from_str("PATCH").unwrap(), url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request PATCH \ --url https://example.com/api/v1/auth/preferences \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "browser_open_mode": "single_click", "color_preset": "#2563eb", "custom": { "additionalProperty": "example" }, "display_time_zone": "example", "language": "en", "remove_custom_keys": [ "example" ], "sort_by": "name", "sort_order": "asc", "storage_event_stream_enabled": true, "theme_mode": "system", "view_mode": "list" }'Only non-null fields in the request body are merged into the existing preferences. Returns the full updated preferences object.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
PATCH request:
- non-null built-in fields are merged into existing preferences
customentries are upsertedremove_custom_keysentries are deleted
object
color_preset
custom
object
key
additional properties
display_time_zone
string | null
remove_custom_keys
Array<string>
storage_event_stream_enabled
boolean | null
Responses
Section titled “Responses”Preferences updated
Media typeapplication/json
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
code
required
string
data
API-facing user preference payload: built-in preferences plus custom frontend KV entries.
object
color_preset
custom
object
key
additional properties
display_time_zone
string | null
storage_event_stream_enabled
boolean | null
error
msg
required
string
Example
{ "code": "success", "data": { "browser_open_mode": "single_click", "color_preset": "#2563eb", "language": "en", "sort_by": "name", "sort_order": "asc", "theme_mode": "system", "view_mode": "list" }}Not authenticated