Code Actions
The code family runs custom TypeScript as an automation step for logic that the declarative actions don't cover. One operator, runTypescript. The source is a named execute(context) function whose body is type-checked at server startup.
| Prop | Description |
|---|---|
code |
TypeScript source for a named execute(context) function. In TS configs, wrap with String(function execute(context: CodeContext) { … }) for IDE autocompletion. Required. |
inputData |
Template-resolved key-value pairs passed as context.inputData. |
timeout |
Execution timeout in ms (1000–300000, default 30000). |
Code Context
The execute function receives a context object with exactly five members:
| Member | Description |
|---|---|
context.inputData |
Template-resolved inputs from the inputData prop. |
context.actions |
Invoke native actions or reusable templates from within the code. |
context.env |
Environment variables (sensitive values redacted in logs). |
context.log |
Structured logging: info, warn, error. |
context.run |
Metadata for the current call. context.run.attempt is the 1-indexed retry attempt number. |
There is no context.trigger and no context.steps. The trigger payload and the outputs of prior steps reach the code only as {{…}} template references declared in inputData — which keeps a code action a pure function of its declared inputs.
- name: enrich-lead
type: code
operator: runTypescript
props:
inputData: { url: '{{trigger.data.profile_url}}' }
code: |
async function execute(context) {
const res = await context.actions.http.get({ url: context.inputData.url })
context.log.info('fetched', res.status)
return { score: res.body.score, fetchedAt: new Date().toISOString() }
}Type-checked at startup, sandboxed at runtime. The execute body is validated when the app boots, so a malformed function fails fast rather than mid-run.
Related Pages
- Actions Overview — invoking native actions (also available as
context.actions) and reusablereftemplates. - Environment Variables —
context.envand secret redaction. - HTTP & Webhooks — the HTTP actions reachable from code.
Last updated August 11, 2026
This documentation was written with AI, so errors or outdated content are possible. Sovrium is in beta. Contributions and corrections are welcome.