Update the current user's 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":"zh-CN","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": "zh-CN", "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": "zh-CN", "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”PATCH request:
- non-null built-in fields are merged into existing preferences
customentries are upsertedremove_custom_keysentries are deleted
object
object
Normalized BCP 47 locale tag used by product preferences and plugin-facing localization contracts.
The backend validates language tags without fixing the protocol to the frontend’s currently bundled locale set. Product UI choices remain limited by the resources actually shipped by that frontend build.
Example
zh-CNResponses
Section titled “Responses”Preferences updated
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
API-facing user preference payload: built-in preferences plus custom frontend KV entries.
object
object
Normalized BCP 47 locale tag used by product preferences and plugin-facing localization contracts.
The backend validates language tags without fixing the protocol to the frontend’s currently bundled locale set. Product UI choices remain limited by the resources actually shipped by that frontend build.
Example
{ "code": "success", "data": { "browser_open_mode": "single_click", "color_preset": "#2563eb", "language": "zh-CN", "sort_by": "name", "sort_order": "asc", "theme_mode": "system", "view_mode": "list" }}Not authenticated