Automation API
conditional
Use this action to run nested actions only when a condition holds, with an optional else branch.
Tip
Read the live config shape of each action type from GET /v1/automation/meta/action before you build on it.
In the automation editor, this action is Conditional actions in the Flow control family. Its group is control_flow, and it works with every trigger.
Send it in the actions array of Create an automation or Update an automation. An update replaces the whole array, so include the other actions.
Example
When a deal is worth more than 50,000, this action asks the sales director for approval. Otherwise, it tells the account owner that the deal is ready to close:
{
"type": "conditional",
"config": {
"condition": {
"operator": "and",
"rows": [
{
"subject": { "kind": "variable", "source": "field", "field_id": 601, "field_type": "number", "previous": false, "collection": false, "triggering": false },
"operator": "greater_than",
"value": { "type": "number", "number": ["50000"] }
}
]
},
"action_rows": [
{
"type": "send_email",
"config": {
"to_address": ["romeo@acme.com"],
"subject": ["Approval needed: deal over 50,000"]
}
}
],
"else_action_rows": [
{
"type": "send_email",
"config": {
"to_address": ["juliet@acme.com"],
"subject": ["Deal ready to close"]
}
}
]
}
}
Config
| Property | Type | Description | Example value |
|---|---|---|---|
condition | filter group | null | The if condition. null or left out counts as true. | { "operator": "and", "rows": [ … ] } |
action_rows | array of nested actions | The then branch. Runs when the condition holds. Empty when left out. | [{ "type": "send_email", "config": { … } }] |
else_action_rows | array of nested actions | The else branch. Runs when the condition fails. Leave it out to switch the else branch off. | [{ "type": "exit", "config": { "exit_type": "success" } }] |
To find the field IDs, see App and field IDs.
General behavior
- No key is required.
- The condition and both branches live in
config, like every other action. Each branch is a nested list of actions. - A missing,
nullor emptyconditioncounts as true. The then branch runs on every run. It reads back ascondition: null. - Leave
else_action_rowsout to switch the else branch off. Send it, even as[], to switch it on. There are no*_enabledflags. action_rowsandelse_action_rowshold full action objects.GET /v1/automation/meta/actionlists the types you can nest.- When the API rejects the input of a nested action, the error names its path, for example
config/else_action_rows/0. conditionuses the same filter tree as the collect actions.GET /v1/automation/meta/filterlists the operators for each field type.
Requirements
- To add or change this action through the API, your token needs the
automations:editcapability. See Capabilities. - You must administer the workspace that the automation's database app belongs to.