Skip to main content

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โ€‹

KeyTypeRequiredDescription
codecode valueyesThe code the action runs โ€” JavaScript executed in the automation sandbox. A code value of string literals and variable references only.
custom_variable_defsarray of variable declarationsnoCustom 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โ€‹

  • code is the only required member; it runs in the automation sandbox and carries the action's code envelope.
  • code is a code value โ€” string literals interleaved with variable references only; it does not resolve template values.
  • custom_variable_defs defaults to [] when omitted, so an omitting caller still yields a complete internal action.
  • A custom variable reference (from this action's code or a later action) resolves only when its custom_type + label match a declaration in custom_variable_defs; otherwise the definition validates as WORKFLOW_ACTION_VARIABLE_DEF_MISSING.

See alsoโ€‹