Create/Update Tokens
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens
Creates tokens, or changes the value of existing ones, in the current execution. Each row has a Token Name and a Token Value. The value is an expression that can mix text and tokens, and it's evaluated when the action runs. Actions that run afterwards can use the result, for example [FullName].
The value can be evaluated more than once. That's useful when a token contains text with more tokens inside, such as a stored email template.
Typical Use Cases
- Set a token to a fixed value, or to an empty string, before other actions use it
- Combine tokens into a new one, for example
[FirstName] [LastName]into[FullName] - Calculate a value with a token such as
[DoMath:Eval(...)]and keep the result - Replace the tokens inside a template stored in the database or in another token
- Change a value that earlier actions set, for example to clean up or reformat it
- Create numbered tokens in a loop, such as
Customer1,Customer2, with Tokenize Token Names
Don't use it to
- Keep data for a later request, such as the next submit. Tokens only exist for the current execution. Save the data in a database, hidden field or session instead.
- Evaluate text that users typed with Number of Recursions above
1. Tokens can read data users shouldn't see. See Considerations. - Split JSON into separate tokens. Use Parse JSON into Tokens instead.
Related Actions
| Action Name | Description |
|---|---|
| Execute Token (Obsolete) | Older action that evaluates one expression once. Replaced by this action. |
| Inject Data (Obsolete) | Older action that sets tokens without recursion. Replaced by this action. |
| Run SQL Query | Runs SQL and saves the result in tokens. |
| Parse JSON into Tokens | Turns the properties of a JSON object into tokens. |
| Context to JSON Object | Builds a JSON object from tokens. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Tokens | A list of rows, each with a Token Name and a Token Value. The value is the expression to evaluate, for example [FirstName] [LastName]. Rows run top to bottom, and you can reorder them. Rows with an empty name are skipped. | Yes (Token Value) | empty list | Yes (Token Name of each row) |
| Tokenize Token Names | When checked, tokens in the Token Name are also replaced. For example, if [Index] is 1, the name Customer[Index] sets [Customer1]. | No | false | No |
| Number of Recursions | How many times the tokens in each Token Value are replaced. Use 1 for normal values. Use 2 or more when the value contains tokens whose own values contain tokens. 0, an empty value or text that isn't a whole number means the value is saved as typed, with no tokens replaced. | Yes | 1 | Yes |
Output Parameters Reference
| Parameter | Description |
|---|---|
| Tokens (Token Name) | Each row's Token Name becomes a token that holds the evaluated Token Value. Use it as [TokenName] in later actions. |
How recursion works
Each pass replaces the tokens found in the value. With Number of Recursions set to 1, tokens are replaced once. If a token's value contains more tokens, those stay as text.
For example, a token [EmailTemplate] holds the text Hi [User:FirstName], your order is ready.
| Number of Recursions | Token Value | Result |
|---|---|---|
1 | [EmailTemplate] | Hi [User:FirstName], your order is ready. |
2 | [EmailTemplate] | Hi John, your order is ready. |
Use the lowest number that gives you the result you need. Extra passes don't change the result once no tokens are left, but each pass takes time. 2 or 3 is enough for almost every case.
Considerations
- Rows run in order. A row can use a token set by a row above it. If two rows have the same name, the lower row wins.
- Existing tokens are overwritten. If a token with the same name already exists, its value is replaced. Token names aren't case-sensitive, so
totalandTotalare the same token. - Type the name without brackets. Enter
FullName, not[FullName]. The name is used exactly as typed, so avoid spaces too. - The result is text. A calculation or JSON result is saved as a string.
- Tokens only last for the current execution. They're available to the actions that run after this one, but not in the next request.
- Always include
RecursionCountin imported JSON. If it's missing, the value is saved as typed and no tokens are replaced. - Security. Only use Number of Recursions above
1on content your application controls. If a value contains text that users typed, the second pass evaluates any tokens in it. For example, a user could enter[User:Email(UserId=1)]and get another user's email address.
Examples
To understand how to use the below examples, please see Running Examples.
1. Build a full name and calculate a total
This action sets [FullName] from two tokens, then calculates [Total] from [Price] and [Quantity].
{
"Title": "Create/Update Tokens",
"ActionType": "ApplyTokens",
"Description": "Set the full name and the order total",
"Parameters": {
"Tokens": [
{
"name": "FullName",
"value": "[FirstName] [LastName]"
},
{
"name": "Total",
"value": "[DoMath:Eval(expression=[Price]*[Quantity])]"
}
],
"TokenizeTokenNames": false,
"RecursionCount": "1"
}
}
2. Replace the tokens inside a template
The first row copies the template text into [EmailTemplate], as it would come from a database. The second action evaluates it twice, so the [User:FirstName] token inside the template is also replaced. [EmailBody] then contains, for example, Hi John, your order is ready.
{
"Title": "Execute Actions",
"ActionType": "ExecuteActions",
"Description": "Apply the tokens inside a template",
"Parameters": {
"ActionList": [
{
"Title": "Create/Update Tokens",
"ActionType": "ApplyTokens",
"Description": "Load the template",
"Parameters": {
"Tokens": [
{
"name": "EmailTemplate",
"value": "Hi [User:FirstName], your order is ready."
}
],
"RecursionCount": "0"
}
},
{
"Title": "Create/Update Tokens",
"ActionType": "ApplyTokens",
"Description": "Replace the tokens in the template",
"Parameters": {
"Tokens": [
{
"name": "EmailBody",
"value": "[EmailTemplate]"
}
],
"RecursionCount": "2"
}
}
]
}
}
3. Create a numbered token
With Tokenize Token Names checked, the name Customer[Index] becomes Customer1 when [Index] is 1. This is useful inside a loop such as Repeat.
{
"Title": "Create/Update Tokens",
"ActionType": "ApplyTokens",
"Description": "Save the customer name under a numbered token",
"Parameters": {
"Tokens": [
{
"name": "Customer[Index]",
"value": "[CustomerName]"
}
],
"TokenizeTokenNames": true,
"RecursionCount": "1"
}
}
Revised 09/26/2026