Manage user preferences
Preferences belong to the signed-in user. You can read and update only your own preferences, not another user's. Configure an authenticated client using the JavaScript setup or Python setup. Preferences are separate from user attributes and don't affect access.
Preference fields
The first GET auto-creates a preference record with these defaults when none
exists.
| Field | Default | Accepted value |
|---|---|---|
date_format | YYYY-MM-DD | YYYY-MM-DD, DD/MM/YYYY, MM/DD/YYYY, DD-MMM-YYYY |
time_format | 24h | 24h, 12h |
timezone | UTC | Valid IANA timezone name, such as Asia/Kolkata |
theme | light | light, dark |
widget_config | {} | Application-defined settings in any JSON object |
Preferences can't be managed in Console.
Read and update preferences
An update changes only the fields you send and creates the preference record if it doesn't exist yet.
- JavaScript SDK
- Python SDK
- REST API
import {User} from '@taruvi/sdk';
const users = new User(taruvi);
const current = await users.getPreferences();
await users.updatePreferences({theme: "dark", timezone: "Asia/Kolkata"});
const verified = await users.getPreferences();
current = client.users.get_preferences()
client.users.update_preferences({"theme": "dark", "timezone": "Asia/Kolkata"})
verified = client.users.get_preferences()
/api/users/me/preferences/curl "$TARUVI_SITE_URL/api/users/me/preferences/" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200
/api/users/me/preferences/curl -X PUT "$TARUVI_SITE_URL/api/users/me/preferences/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"theme": "dark"
}
JSON
200
Verify and recover
Re-read after an update and compare the returned values with the intended
change. If the API rejects an invalid date format, time format, timezone, or
theme, correct the rejected value, retry the update, then re-read the
preferences. A 401 means the user's credential is missing or expired.
For other problems, see troubleshooting.