Convert a Code step to 2.0.0
POST/
Converts one Code 1.0.0 step’s code and Inputs for Code 2.0.0, and answers the result. It reads and writes nothing.
Needs an API token with the Read permission for workflows (workflow:read).
Parameters
Body
codeRequired · stringThe step’s
config.code, as stored. Up to 256 KB.inputsOptional · object or string or nullThe step’s
config.inputs: an object, a string holding a JSON object, ornull. One expression is refused: switch Inputs to rows first.
Apply the answer
Nothing is saved. Set the step’s pieceVersion to 2.0.0, and its config.code and config.inputs to the answer’s, with Update a workflow’s draft. Then test the step.
A note with level review means the converter left that line for you to rewrite. A step’s output stays {result, logs}, so later steps need no change.
Responses
- 200OK
The converted step.
unchanged: true: nothing to convert, so upgrading only changes the pin. Unreadable JSON, no
code, or Inputs that can’t be converted.details.fieldnames which.- 403
FORBIDDENThe token lacks the Read permission for workflows.
The body is over 600 KB, or
codeis over 256 KB (details.field:code).
Any call can also answer: 401 UNAUTHORIZED · 401 TOKEN_ENDED · 403 TOKEN_SURFACE_OFF · 403 FEATURE_OFF · 403 EMBED_NOT_ALLOWED · 403 EMBED_NOT_AVAILABLE · 403 ACCOUNT_SUSPENDED · 415 INVALID_CONTENT_TYPE · 429 RATE_LIMITED · 503 BUSY · 503 PAUSED · 503 SERVICE_UNAVAILABLE. See Errors.
Request
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…" # needs Read for workflows
curl -X POST "$GORUNNER/api/code-steps/upgrade" \
-H "Authorization: Bearer $GORUNNER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"code": "const email = \"{{trigger.body.email}}\";\nreturn { domain: email.split(\"@\")[1] };",
"inputs": {}
}'const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;
const res = await fetch(
`${GORUNNER}/api/code-steps/upgrade`,
{
method: "POST",
headers: {
Authorization: `Bearer ${TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
code: "const email = \"{{trigger.body.email}}\";\nreturn { domain: email.split(\"@\")[1] };",
inputs: {},
}),
},
);
const { data } = await res.json();import os, requests
GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]
res = requests.post(
f"{GORUNNER}/api/code-steps/upgrade",
headers={"Authorization": f"Bearer {TOKEN}"},
json={
"code": "const email = \"{{trigger.body.email}}\";\nreturn { domain: email.split(\"@\")[1] };",
"inputs": {},
},
)
data = res.json()["data"]Response · 200 OK, shortened
{
"data": {
"code": "const email = inputs.email;\nreturn { domain: email.split(\"@\")[1] };",
"inputs": {
"email": "{{trigger.body.email}}"
},
"pieceVersion": "2.0.0",
"unchanged": false,
"changes": [
{
"line": 1,
"before": "\"{{trigger.body.email}}\"",
"after": "inputs.email",
"input": "email"
}
],
"moreChanges": 0,
"notes": [
{
"level": "info",
"text": "Test the step: its result should match its last run."
}
],
"moreNotes": 0
}
}Every field
Body
codeRequired · stringThe step’s
config.code, as stored. Required; an empty string is accepted and answersunchanged: true.inputsOptional · object or string or nullThe step’s
config.inputs: an object (the usual shape), a string holding a JSON object, or null.
Response · 200 OK
dataobjectA Code step converted for Code 2.0.0 by
POST /api/code-steps/upgrade.codestringThe new
config.code.inputsobjectThe new
config.inputs: the step’s own rows in their order, then one row per new input, whose value is the original{{ }}text.pieceVersionstringThe version to pin the step to.
unchangedbooleanTrue when the code needed no rewrite and holds nothing to review (no
reviewnote): upgrading only changes the pin.changesarray of objectsThe rewrites, in code order, at most 500.
lineinteger1-based line of the code.
beforestringThe text replaced (cut at 400 characters).
afterstringWhat replaced it (cut at 400 characters).
inputstringThe Inputs row it reads, when it reads one (several, comma-separated, for a string that held more than one
{{ }}).moreChangesintegerHow many rewrites were made beyond the 500 listed.
notesarray of objectsWhat the author should know.
reviewmeans look at that line yourself: the converter left something it could not convert safely. At most 500 notes about the code are listed (moreNotescounts the rest); after them always come the runtime differences no rewrite can see (NaN, BigInt, Map/Set, UTC, console, logs on failure) and "Test the step".lineinteger1-based line, when the note is about one.
levelstringOne of
info,review.textstringmoreNotesintegerHow many notes about the code there were beyond the 500 listed.