Data
Per-user records
Two small, flat JSON records live on every Decane user, split by who may write them. They replace Privy’s custom metadata.
| Record | Written with | For |
|---|---|---|
preferences | the user’s token, or the project secret | the user’s own choices |
metadata | the project secret only | your facts about the user: plan, flags, your own ids |
Record is a BTreeMap<String, RecordValue>; RecordValue is Bool, Int, Float or String, with From impls for the matching Rust types. RecordPatch is the same map with Option values, where None removes the key. At most 100 keys and 32 KB.
With the user’s token
rust
use decane::{Record, RecordPatch};
let prefs: Record = decane.get_preferences(token).await?;
let mut patch = RecordPatch::new();
patch.insert("theme".into(), Some("light".into()));
patch.insert("old".into(), None); // None removes the key
decane.update_preferences(token, &patch).await?; // merge
decane.set_preferences(token, &Record::new()).await?; // replace
decane.get_metadata(token).await?; // read-only on this sideBy user id, with the project secret
rust
let decane = DecaneClient::builder()
.app_id(app_id)
.project_secret(std::env::var("DECANE_PROJECT_SECRET")?)
.build()?;
let mut patch = RecordPatch::new();
patch.insert("plan".into(), Some("pro".into()));
decane.update_user_metadata(&claims.user_id, &patch).await?;
decane.get_user_metadata(&claims.user_id).await?;
decane.get_user_preferences(&claims.user_id).await?; // update / set variants tooA write that breaks the rules fails with ApiErrorCode::InvalidRecord, and the message names the key. A user of another project is NotFound.