User metadata
Store a small JSON document about each user of your application in onefold, with PUT and PATCH semantics, limits and key rules, and where your own database fits.
User metadata is a small JSON document your application keeps about one user, stored by onefold next to that user's identity. Use it for a few values you want at hand wherever you read the user, such as a plan name or an internal customer ID.
It is not a database. You cannot query, filter or search it. Keep everything else in your own
database, keyed on the user's sub.
What belongs where
| Data | Where it lives |
|---|---|
| Email, username, profile | The user's onefold account. You read it through claims. |
| A few values your application wants beside the identity | User metadata |
| Everything else your product knows about the user | Your database, keyed on sub |
Properties
- Scoped to your application and one user. Another application cannot read it.
- Yours alone to write. The user does not see or edit it.
- Not in tokens or userinfo. You read it only through the management API.
- Kept when a grant ends. If a user removes your application and later authorizes it again, the metadata is still there.
- Deleted when the user's account is disabled.
You can read or write a user's metadata only while that user holds a grant with your
application. Without one, the endpoints answer 404.
Read
curl "https://onefold.eitozx.com/api/v1/manage/users/USER_ID/metadata/" \
-H "Authorization: Bearer eitozx_YOUR_KEY"Needs the metadata:read scope.
Write: PUT and PATCH
Both need the metadata:write scope and take a JSON object.
| Method | Effect |
|---|---|
PUT | Replaces the whole document with the body |
PATCH | Merges the body into the document. A key set to null is removed. |
# Set or change one key, leaving the others
curl -X PATCH "https://onefold.eitozx.com/api/v1/manage/users/USER_ID/metadata/" \
-H "Authorization: Bearer eitozx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"plan": "pro"}'
# Remove one key
curl -X PATCH "https://onefold.eitozx.com/api/v1/manage/users/USER_ID/metadata/" \
-H "Authorization: Bearer eitozx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"plan": null}'Use PATCH unless you mean to discard every key you do not send.
Limits and key rules
| Rule | Limit |
|---|---|
| Keys in one document | 50 |
| Key length | 64 characters |
| Key format | Starts with a letter; then letters, digits, _, . and - |
| Document size | 8,192 bytes, measured as stored JSON |
The limits apply to the document that would be stored. A PATCH that adds a key to a full
document fails; a PATCH that removes keys from one succeeds.
| Error code | Meaning |
|---|---|
invalid_metadata | Too many keys, or a key that breaks the length or format rule |
metadata_too_large | The document would exceed the size limit |
Do not store secrets
Metadata is readable with any API key that has metadata:read, and in the developer portal by
the developers who manage your application's users. Do not put credentials in it.
See the API reference for the exact request and response shapes.
Management API
Use an API key to read your application's users, metadata, sign-up answers, analytics and activity from your server with the onefold management API.
Organization profiles
The profile your organization keeps of each person, its built-in, shared and private fields, who may read and write each field, and the hosted account page where people manage it.