Custom attributes

Define additional attributes specific to your business.

In addition to the standard attributes, the user profile supports custom attributes. Use them to track information specific to your business needs, such as preferences, categories, or internal classifications.

Implementation

Here is an example of how to set a custom attribute:

example.js
12345
import croct from '@croct/plug';
await croct.user.edit()  .set('custom.expertise', "Engineering")  .save();

Attributes

custom.*
string|number|boolean|array|object|null

A custom attribute, where * is the name of the attribute, such as custom.pets or custom.loyaltyNumber.

Restrictions

The following restrictions apply to custom attributes:

  • Profiles support up to 10 custom attributes.
  • Attribute names must be strings up to 20 characters, starting with a letter or underscore, followed by letters, digits, or underscores.
  • Attributes can be primitives (strings, numbers, booleans, null) or collections (lists, maps).
  • Strings can be up to 100 characters long.
  • Lists can contain up to 30 elements, including primitives, lists of primitives, or maps of primitives.
  • Maps can contain up to 30 elements, including primitives, lists of primitives, or maps of primitives.
  • Map keys must be strings up to 50 characters long.

Attribute names are case-insensitive, so loyaltyNumber and loyaltynumber are treated as the same attribute and will override each other.