custom_code
Internal beta โ config shape is being migrated
The Automation API is an internal beta and is not released yet โ endpoints and payloads may change or be
withdrawn without notice. This action's config is being migrated to a typed schema; the fields below reflect that
in-progress shape. Always read the authoritative, live shape from
GET /v1/automation/meta/action before building against it.
Run code โ runs custom code (JavaScript) in the automation sandbox. group: "action". No specific trigger context is required.
Part of the Code & variables family. This page
documents the typed config; for how an action sits inside an automation definition, see
Actions and Action examples.
Configโ
| Key | Type | Required | Description |
|---|---|---|---|
code | code value | yes | The code the action runs โ JavaScript executed in the automation sandbox. A code value of string literals and variable references only. |
custom_variable_defs | array of variable declarations | no | Custom variables this action declares (e.g. its result variable) for its own code or later actions. Empty when omitted. |
custom_variable_defs[].custom_type tokens (lower-case): any, single_file, multi_file, single_link,
html_table_rows. Each declaration also carries a label; a custom variable reference resolves only when its
custom_type + label match a declaration.
Exampleโ
An action entry inside an automation definition's actions[]:
{
"type": "custom_code",
"config": {
"code": [
"return { greeting: 'Hello ' + ",
{ "kind": "variable", "source": "meta", "meta_type": "app_record_id" },
" };"
],
"custom_variable_defs": [
{ "custom_type": "any", "label": "result" }
]
}
}
Validation & behaviorโ
codeis the only required member; it runs in the automation sandbox and carries the action's code envelope.codeis a code value โ string literals interleaved with variable references only; it does not resolve template values.custom_variable_defsdefaults to[]when omitted, so an omitting caller still yields a complete internal action.- A
customvariable reference (from this action's code or a later action) resolves only when itscustom_type+labelmatch a declaration incustom_variable_defs; otherwise the definition validates asWORKFLOW_ACTION_VARIABLE_DEF_MISSING.
See alsoโ
- Dynamic values โ code values, variable references, and custom-variable declarations
- Action examples ยท Actions catalog