Expressions
Explore the expression language used throughout the Basis Theory API.Expressions provide a flexible templating language that can be used to apply custom transformations to token data.
Expressions can be used within many API endpoints, including:
- Reactor args, to detokenize and transform tokens
- Proxy requests, to detokenize and transform tokens
- Aliasing when creating a token or tokenizing, to specify the id of the created token
- fingerprint_expression when creating a token or tokenizing, to define a value used to generate a token fingerprint
- mask when creating a token or tokenizing, to define the mask applied to the token's data when the actor has restricted permissions
- search_indexes when creating a token or tokenizing, to define indexes to enable searching tokens
Language
The expression language used within the Basis Theory API is based on the Liquid template language. While all valid Liquid syntax is supported, Basis Theory expressions are typically formed from a combination of objects and filters.
Objects
Objects contain content that will be
rendered when the expression is evaluated, and they are formed by wrapping a statement within double curly braces. For example,
{{ data.card_number }}
would be evaluated by rendering the card_number
property within the data
object.
The variables that are available for reference within an object expression depends on the context in which the expression is used.
When including expressions during token creation (e.g., within search_indexes
, fingerprint_expression
or mask
),
the data
variable is automatically bound to the token's data
value. metadata
is also available for expressions within
fingerprint_expression
.
When including expressions within Reactor or Proxy requests, token ids may be specified within object expressions, and each token id will be bound to the corresponding token's data value. See detokenization for further details about this process.