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 |
A user cannot change metadata, so an entitlement may live there. Values are strings, numbers or booleans under keys of up to 64 characters ([A-Za-z0-9_.-]); at most 100 keys and 32 KB, strings at most 2,048 characters.
With the user’s token
python
prefs = decane.get_preferences(token) # {"theme": "dark", …}
decane.update_preferences(token, {"theme": "light", "old": None}) # merge; None removes a key
decane.set_preferences(token, {"theme": "dark"}) # replace
decane.get_metadata(token) # read-only on this sideBy user id, with the project secret
python
decane = DecaneClient(app_id=APP_ID, project_secret=os.environ["DECANE_PROJECT_SECRET"])
decane.update_user_metadata(claims.user_id, {"plan": "pro"})
decane.get_user_metadata(claims.user_id)
decane.set_user_metadata(claims.user_id, {})
decane.get_user_preferences(claims.user_id) # update_user_preferences / set_user_preferences tooA write that breaks the rules raises DecaneApiError with code INVALID_RECORD, and the message names the key. A user of another project is NOT_FOUND.