Variables
This functionality is only available on paid plans. Check our plans here.
Variables allow you specify values to reuse across all your rules, without having to repeat that value multiple times, making your rules cleaner and quicker to modify. You can access the variables panel from the tweak toolbar.

Each row carries a name, its value, and an optional description. The right edge of the description shows how long ago that variable was last changed ("12m", "5h", "3d"), which is usually enough to tell a token you rotated this morning from one that went stale weeks ago.
Rows can be reordered: drag the handle that appears at the left of a row when you hover it, walk a row with the arrow keys while the handle has focus, or click the Name heading to sort the whole table alphabetically. The order is yours to arrange, nothing downstream reads it.
To reference a variable use the following syntax:
{{<VARIABLE_NAME>}}
Let's for example use the above specified variable to interpolate it with some JSON:
{
"token": "{{custom_token}}"
}
Variables used to be written $tweak.var.<name>. They are {{<name>}} now, and tweak rewrites
your existing rules for you the first time it runs after the update — there is nothing to do by
hand. Generators are unchanged and keep their $tweak. spelling.
The one place nothing is rewritten is the JavaScript of a
hook, because rewriting your own code is riskier than leaving it
alone. $tweak.var.x never resolved inside a hook anyway — use vars.x there, or {{x}}, which
a hook's source now does resolve.
Variables can be accessed from the top toolbar, and they offer you a simple table where you can specify a variable name and its value. Variables can be referenced across all editors:
In header cells and in urls​
Variables are not only for the editors. They also work in:
- Every header cell, name and value alike, on both tables and on every rule type, including headers only rules. See headers.
- The url expression of every rule, and the replacement url of a redirect rule.
In a url, tweak paints each token as a chip over the field, so a long value does not turn the expression into something you cannot read. Click into the field and the raw token is there, exactly as you typed it. Pressing backspace on a chip removes the whole token rather than one character of it.

A generator produces a fresh value every time it runs, and a url is a matcher: a generated one would
match nothing twice. So urls accept {{variables}} only, while header cells accept both.
Typing {{ in any of these fields opens a suggestions list with your variables in it, so you do
not have to remember the exact name. (Typing $ opens the generators, in the fields that take them.)
It's also possible to access a plain JavaScript object that holds all the defined variables when writing a response hook script. To be able to access variables programmatically in the script you'll be provided variables through context.
Only alphanumerical and _ (underscore) are considered valid characters for the variable name.
Types​
It's possible to have numerical or boolean values in a given JSON payload. Let's say you want to have a numerical variable timestamp, and its value is 123. When interpolating the variable simply remove the double quotes around the expression:
{
"name" "John Doe",
"timestamp": {{timestamp}}
}
The JSON editor will throw syntax errors, but that's ok, you can still proceed and tweak will render the JSON with the numerical value.
Need something else? Request a feature