kind determines how Barekey resolves it at evaluation time. The kind is set when the variable is created and cannot be changed without deleting and recreating it.
secret
A secret is a classic single-value variable. Every evaluation returns the same stored value (subject to authorization).
Storage: one encrypted payload stored in the projectVariables table.
Evaluation response:
ab_roll
An ab_roll variable has two values — A and B — and a chance parameter between 0.0 and 1.0. On each evaluation, Barekey selects one of the two values and returns which bucket was chosen in the decision field.
chance is the probability of returning value A. A chance of 0.8 means 80% of evaluations return A and 20% return B.
Storage: two encrypted payloads (encryptedValueA, encryptedValueB) and a chance float.
Random evaluation
Without a seed, Barekey usesMath.random() to select the bucket. Each evaluation is independent.
Evaluation response:
decision is "a" when value A is returned, "b" when value B is returned.
Deterministic evaluation
Pass aseed (a stable identifier like a user ID) and a key (a namespace) to get a deterministic bucket assignment. Barekey computes:
chance. The same seed + key combination always returns the same bucket for the same variable.
This is useful for cohort-consistent rollouts — a user always sees the same variant across sessions and deployments.
API request with seed:
Creating an ab_roll variable
CLI:--chance value is the probability of returning the first (A) value. 0.2 means 20% get A, 80% get B.
API write entry:
Comparing the two kinds
| Property | secret | ab_roll |
|---|---|---|
| Number of values | 1 | 2 (valueA, valueB) |
chance field | Not applicable | Required (0.0–1.0) |
decision in response | Not present | "a" or "b" |
| Deterministic via seed | N/A | Yes — seed + key |
| Storage cost | 1 encrypted payload | 2 encrypted payloads |

