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

DataWhere it lives
Email, username, profileThe user's onefold account. You read it through claims.
A few values your application wants beside the identityUser metadata
Everything else your product knows about the userYour 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.

MethodEffect
PUTReplaces the whole document with the body
PATCHMerges 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

RuleLimit
Keys in one document50
Key length64 characters
Key formatStarts with a letter; then letters, digits, _, . and -
Document size8,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 codeMeaning
invalid_metadataToo many keys, or a key that breaks the length or format rule
metadata_too_largeThe 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.

On this page