Building blocks
Attributes
Attributes are the building blocks of creating conditions, which can later be used in reusable segments.
Create an attribute#
Let's create an attribute called country:
description: Countrytype: stringdescription is required.
At the top level, an attribute must define either:
typeoneOf
You cannot use both together at the top level.
Types#
These types are supported for attribute values:
booleanstringintegerdoubledatearray(of strings)object(flat object)
boolean#
When an attribute is of type boolean, it can have two possible values: true or false.
For example, if you want to create an attribute for isPremiumUser, you can do it like this:
description: Is Premium Usertype: booleanstring#
When an attribute is of type string, it can have any string value.
For example, if you want to create an attribute for country, you can do it like this:
description: Countrytype: stringinteger#
When an attribute is of type integer, it can have any integer value.
For example, if you want to create an attribute for age, you can do it like this:
description: Agetype: integerdouble#
When an attribute is of type double, it can have any floating point number value.
For example, if you want to create an attribute for rating, you can do it like this:
description: Ratingtype: doubledate#
When an attribute is of type date, it can have any date value in ISO 8601 format.
For example, if you want to create an attribute for signupDate, you can do it like this:
description: Signup Datetype: datearray#
When an attribute is of type array, it can have an array of string values.
If you want to keep it simple, you can define it like this:
description: Permissionstype: arrayIf you want stricter validation, you can define items and other schema properties:
description: User permissionstype: arrayitems: type: string enum: - read - write - adminArray attributes only support arrays of strings.
object#
When an attribute is of type object, it is treated as a flat object.
If you want to keep it simple, you can define it like this:
description: User preferences as a flat objecttype: objectIf you want stricter validation, you can define properties, required, and other schema properties:
description: Account detailstype: objectproperties: plan: type: string enum: - free - pro locale: type: stringrequired: - planObject attributes must stay flat. In other words, if type: object is used, none of its properties can be another object type.
When writing conditions for segments, you can use dot notation for object properties, such as account.plan or account.locale.
oneOf#
At the top level, you can use oneOf instead of type when an attribute can match exactly one of multiple schemas.
For example:
description: Version number of the apponeOf: - type: string - type: doubleSchema properties#
Attributes support schema-style properties for authoring and linting, including:
enumconstoneOfpropertiesrequiredadditionalPropertiesitemsminimummaximumminLengthmaxLengthpatternminItemsmaxItemsuniqueItems
These schema properties help with linting and code generation.
Attributes are not included in generated datafiles, so they are here to help improve the authoring workflow without affecting datafile size.
You can learn more in Schemas page.
Archiving#
You can archive an attribute by setting archived: true:
archived: truetype: stringdescription: CountryRelationship with context#
SDKs evaluate values against the context available at runtime. The context is an object where the keys are attribute names and the values are the attribute values.
For example, if you have an attribute called country, the context will look like this:
{ "country": "nl" // The Netherlands}If we combine all the above examples, the full context may look like this:
{ "country": "nl", "isPremiumUser": true, "age": 30, "rating": 4.5, "signupDate": "2025-01-01T00:00:00Z", "permissions": ["read", "write"], "preferences": { "theme": "dark", "language": "nl" }, "account": { "plan": "pro", "locale": "nl-NL" }, "version": "5.5.0"}
