Constants ​
This section provides step-by-step instructions for creating and managing constants in Rulecube.
Constants are placeholders with a fixed value that you can use throughout a ruleset. They are comparable to const elements in JavaScript.
You can create a constant table in two ways:
- Create a constant table manually in Rulecube.
- Create a constant table by importing data from a CSV file.
Constant types ​
Rulecube supports these constant types:
Simple
This type lets you create simple number or string constants for, for example, a fixed discount percentage like22or an information message likeYou are too young to apply for this insurance.JSON
This type lets you create a JSON object, such as a table with discount ratings:json{ "percentage_1": 10, "percentage_2": 15, "percentage_3": 20 }Table
This type lets you create a table with rows and columns:Key value percentage_1 10 percentage_2 15 percentage_3 20 External
This type lets you fetch a value from any website or API in the world.
Create a Constant ​
For step-by-step instructions per constant type, see:
Encryption ​
Data defined in a constant could sometimes be considered "sensitive". For example, you may want to store a username and password, API-key or secret URL in a constant, but you don't want anyone that opens the ruleset to be able to see its value.
For those cases, a constant can be Encrypted. The constant can still be used as you normally would, but it is not visible to anyone that opens the ruleset in Rulecube itself or fetches it via the API.
We must first enable this in the Ruleset itself:
- Go to the Version settings of a Ruleset
- Check the "Contains sensitive data" checkbox
Now we can encrypt any constant we want:
- Open an existing Constant or create a new one
- Click on the "Encrypt" button:

NOTE: Once you save the Ruleset, the encrypted constant can no longer be read. You can only revert this by rolling back to a previous revision from History.
Convert to Environment Variable ​
Any simple constant can be converted to an Environment Variable with the following button, found in the top-right of a constant:

This simplifies the process of manually creating an Environment Variable. After clicking the button above, the constant will be useable in other Rulesets as an Environment Variable.