ByteChef LogoByteChef
EmbeddedAutomations

Automation Code Workflows

Author a code workflow once - in ByteChef or as an uploaded file - and serve it to every connected user by reference through the embedded catalog.

An automation code workflow lets you author a code workflow

  • the same project contract a standalone automation project uses, in JavaScript, Python or Java - and make it invocable by your connected users, without hand-authoring it in the visual Automation editor and without giving every connected user their own private copy. A deployed workflow reaches connected users only through an enabled configuration in their environment.

The source itself says nothing about being "embedded". What makes it embedded-servable is that it lives in the embedded catalog as a catalog code project. The sample projects show a complete one in each language.

Creating a catalog code project

There are three ways in, and all of them land in the same catalog project:

  • New Code Project (Embedded → Automations → the arrow next to New Project) creates a JavaScript or Python project from a starter source. The dialog asks for a Language, a Name, and an optional Description, Category, Tags and Permission Expression; the project is created as an unpublished draft and opens in the code editor. See Editing in ByteChef.
  • Import Code Project in the same menu uploads a .js, .py or .jar file and publishes it. It doesn't release the new version to any environment. When a workflow has no trigger that can start it, the dialog stays open and lists the warning.
  • The public deploy endpoint does the same as Import, from your CI pipeline, and can also release the version.

A catalog project's name must be unique: creating a second one with a name already in use is refused, and a name must not start with __EMBEDDED or contain quotes, backslashes or line breaks. Java uploads are subject to the same BYTECHEF_WORKFLOW_CODE_WORKFLOW_JAVA_ENABLED switch as automation projects.

Deploying through the API

POST /api/embedded/v1/automation-project-code-workflows/deploy

A multipart/form-data request:

Parameter
projectFile (file part)Required. The .js, .py or .jar file. The file name's extension picks the language.
releaseOptional, false by default. Send it as a form field beside projectFile or as a query parameter. See Deploy once, reference per user.
X-ENVIRONMENT (header)Optional. DEVELOPMENT, STAGING or PRODUCTION (case-insensitive); PRODUCTION when absent.

Authenticate with an Embedded API key (Embedded → Settings → API Keys) that belongs to an administrator - deploying requires the admin role. Only an Embedded API key is accepted: an automation workspace key or an organization admin key (Settings → Organization → Admin API Keys) is rejected with 401. The key is looked up in the environment named by X-ENVIRONMENT, so send the environment the key was created in; the same header picks the environment release acts on. The request runs as the key's own ByteChef user, not as a connected user.

curl -X POST "$BYTECHEF_URL/api/embedded/v1/automation-project-code-workflows/deploy" \
  -H "Authorization: Bearer $BYTECHEF_EMBEDDED_API_KEY" \
  -H "X-ENVIRONMENT: DEVELOPMENT" \
  -F "projectFile=@src/sample_catalog_code_project.py" \
  -F "release=true"

A successful deploy returns 200 with the import warnings, for example {"warnings": []}. A warning names each workflow that has no trigger able to start it (none, or only a manual one): it still deploys, but no endpoint can reach it. A file that fails to load, an unsupported language or disabled Java uploads return 400; an unknown key, a key that isn't an Embedded API key or an invalid X-ENVIRONMENT return 401; a key whose user isn't an administrator returns 403.

GET /api/embedded/v1/automation-project-code-workflows, with the same key, lists the published catalog projects, each with its name, its kind (REFERENCE for a code project, COPY for a visual one) and the labels of its workflow templates.

Component tasks

A catalog code project follows the automation project contract, so its tasks can also be component tasks: a type of the form <component>/v<version>/<action> with the action's inputs as parameters, run by the engine like the same task in a visual workflow. A component task has no perform and declares no connections. It is stored as an ordinary workflow task, so its connection is wired as the same task's would be in a visual automation workflow.

Sample projects

Each one is a catalog project named "Sample Catalog Code Project JavaScript", "Sample Catalog Code Project Python" or "Sample Catalog Code Project Java", with four workflows:

  • greetOnRequest, started by a request/v1/autoRespondWithHTTP200 trigger, returns a greeting. It can be called through the sync endpoint as soon as a connected user holds a reference to it.
  • summarizeNewEmail, started by the Gmail New Email polling trigger, runs on its own for every new email in the connected user's inbox.
  • fetchRecentEmails, started by a request/v1/awaitWorkflowAndRespond trigger, calls the Gmail Search Email action through a declared gmail connection. The optional request body {"from": "...", "maxResults": 5} narrows the search.
  • notifySlackOnNewEmail, started by the Gmail trigger, posts each new email to Slack through a declared slack connection. Its required channel input takes its options from Slack's own channel input, and provisioning stores it from the request's inputs.

The Gmail and Slack workflows run on the connected user's own connections, which provisioning binds. To check a sample locally and find the file to deploy:

SampleLocal checkFile to deploy
JavaScriptnpm run checksrc/sample_catalog_code_project.js
Pythonpython3 scripts/check.py src/sample_catalog_code_project.pysrc/sample_catalog_code_project.py
Java./gradlew build (JDK 25)build/libs/sample-catalog-code-project-java-1.0.0.jar

The JavaScript and Python checks evaluate the file the way the server does, check its shape and run each task once against a stub context; they need only Node.js or Python 3.9 or later. The JavaScript sample also carries a TypeScript version, src/sample_catalog_code_project.ts, checked with npm run check:ts; that step needs the type package, which is not published yet. Its project is named "Sample Catalog Code Project TypeScript", so it publishes a catalog project of its own.

Editing in ByteChef

Clicking a catalog code project, or any of its workflows, opens the project's code editor instead of the canvas; the row menu has Edit Source too. One source covers all of the project's workflows.

  • Save checks the source before storing it: source that fails to load is rejected with the loader's error and the draft stays as it was. The name declared in the source must stay the project's name - renaming through the source is not supported.
  • Saves change the draft only. Connected users keep running the last published version.
  • Publish (in the editor header, disabled while there are unsaved edits) publishes the draft as a new version. It reaches connected users once an environment's configuration points at it - see Deploy once, reference per user.
  • Uploading (Import Code Project or the deploy endpoint) saves the upload as the draft and publishes it, so an upload replaces any unpublished editor changes. After an upload the editor continues from the uploaded source.
  • Publishing a code project whose draft has no source is refused, so an empty version can never be released.

The workflow-structure actions of the visual catalog don't apply to a code project: its workflows come from the source, so you add, rename or remove a workflow by editing the source, and duplicating a code project is refused.

Deploy once, reference per user

Unlike the visual bridge - where each connected user gets their own copy of a workflow template

  • a code workflow is deployed once into a shared catalog project, and every connected user holds a reference to it. Code is not something a connected user can edit per-user, so a copy would only duplicate the same container for no benefit.

Nothing is exposed to connected users until the environment has an enabled configuration pointing at a published version, or the deploy passes the release flag (below).

Practically:

  • The catalog project is created on the first deploy and reused by later deploys. It is kept out of the regular Automation screens because Embedded owns it.
  • Redeploying the same artifact, or publishing an edit, publishes a new version. It reaches an environment's connected users when that environment's configuration is moved to it, which then upgrades every referencing user's workflow in that environment at once - there is no per-user version pinning and no per-user bespoke deploy. To deploy and release in one call, send release=true in the deploy request (X-ENVIRONMENT picks the environment): the deploy then also points every configuration of the request's environment at the new version, or creates one, enabled and visible in the Automation Hub, if the environment has none. It never turns a disabled configuration back on. Without the flag, nothing is exposed or upgraded until an administrator releases the version. To stage a change, release it to a separate environment first.
  • A workflow keeps the same identity (its ProjectWorkflow uuid) across uploads, editor saves and publishes as long as its name doesn't change, so existing references keep pointing at the right workflow after an upgrade.

The project appears in the same catalog listing as visual workflow templates, distinguished by a kind field:

  • kind: "COPY" - a visual template; provisioning creates a per-user copy.
  • kind: "REFERENCE" - a code workflow; provisioning creates a per-user reference to the shared, deploy-once workflow.

Invocation - the same two endpoints, the same rules

Automation code workflows are invoked through the existing embedded public endpoints - there is no new invocation surface:

  • Sync - POST /api/embedded/v1/workflows/{workflowUuid}, addressed by the workflow's catalog uuid. Requires a Request trigger, the same contract integration workflows follow - see Request Triggers for the trigger operations, the response and the errors.
  • Async - POST /api/embedded/v1/app-events. Requires the App Event trigger. Every enabled, non-dangling reference whose workflow declares that trigger fires when the connected user's app event is posted, alongside their integration workflows.

Deploy-time validation is advisory, not a hard rejection: a workflow with no trigger that can start it (none, or only a manual one) still deploys, but the deploy returns a warning for it, which the Import dialog shows. A workflow with a component trigger, such as Gmail New Email, needs no call: once its reference is enabled, the trigger starts it.

Both endpoints resolve the whole bridge, not just code-workflow references: the async endpoint's fan-out iterates every ConnectedUserProjectWorkflow row for the connected user, firing both reference-mode rows (code workflows) and copy-mode rows (visual bridge copies, addressed by the copy's own workflow uuid, not the template's). The sync endpoint resolves the same shapes against a single workflowUuid: a connected user's own copy uuid dispatches directly; a catalog uuid the user holds a reference to runs that reference; a catalog template uuid the user has already copied runs their copy. Anything else returns 404 - see No provisioning on first call below.

No provisioning on first call

Neither invocation endpoint creates anything. A catalog workflow uuid the connected user has no reference to and no copy of returns 404 from the sync endpoint, and the async endpoint only iterates rows that already exist. Provision the reference (below), or copy the template with POST /automation/workflow-templates/{workflowUuid}/copy, before the first call.

Explicit provisioning

Provision a reference before the connected user's first call:

POST /api/embedded/v1/{externalUserId}/automation/workflow-templates/{workflowUuid}/provision
X-Environment: PRODUCTION

ByteChef wires each of the workflow's connections from the connected user's existing connections, matched by component. To choose connections instead, send them keyed by component name in an optional body: {"connections": {"slack": 42}}. Components you leave out are auto-matched.

The same body can carry the workflow's input values, keyed by input name: {"connections": {"slack": 42}, "inputs": {"channel": "#alerts"}}. They are stored before the reference is enabled, so a workflow with required inputs comes out enabled in one call. When you send inputs, they replace the values already stored for the reference.

  • If every required component resolves to a connection, the reference is created enabled.
  • If a component has no matching connection, the reference is still created - left disabled - and the call returns HTTP 409 with {"missingConnectionComponentName": "slack"}.
  • If a required workflow input has no value yet (neither sent in inputs nor stored), the reference is created disabled and the call returns 204. Store the value, then enable the reference (next section).
  • A requested connection that isn't one of the connected user's connections returns 400. A catalog workflow the connected user can't see returns 404.
  • A connection that the configuration already provides for every connected user can't be overridden: naming it in connections returns 409 with {"providedComponentName": "slack"}. Values sent in inputs for an internal-only input are ignored, because only the configuration sets those.

A complete call from your backend, with an API Key, that picks the Slack connection and sets an input:

curl -X POST "https://your-bytechef-host.example.com/api/embedded/v1/user-123/automation/workflow-templates/$WORKFLOW_UUID/provision" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Environment: PRODUCTION" \
  -d '{"connections": {"slack": 42}, "inputs": {"channel": "#alerts"}}'

A 204 means the reference was created, enabled unless a required input still has no value. If the workflow also uses a component the body does not name, for example Google Mail, and the user has no connection for it, the reference is created disabled and the response is 409:

{"missingConnectionComponentName": "googleMail"}

Calling provision again for an existing reference doesn't re-run auto-wiring. It only catches the reference up to the version its environment's configuration points at and, if the body names connections or inputs, applies them. It keeps the reference's enabled state.

De-provisioning removes the reference (and its per-node connection wiring) outright:

DELETE /api/embedded/v1/{externalUserId}/automation/workflow-templates/{workflowUuid}/provision

Enabling, disabling and inputs

A reference is addressed by its catalog workflow uuid on the same workflow endpoints a copy uses:

  • DELETE /api/embedded/v1/{externalUserId}/automation/workflows/{workflowUuid}/enable disables the reference and keeps it, with its connections and input values.
  • POST /api/embedded/v1/{externalUserId}/automation/workflows/{workflowUuid}/enable enables it. The reference first catches up to the version its environment's configuration points at, then its connections are resolved again against the connected user's current connections - so a connection created after provisioning is picked up here. A missing connection returns 409 {"missingConnectionComponentName": ...}, a required input without a value returns 409 {"missingInputName": ...}, and the reference stays disabled.
  • PUT /api/embedded/v1/{externalUserId}/automation/workflows/{workflowUuid}/inputs stores the connected user's input values, with an inputs object keyed by input name. On an enabled reference, a change that leaves a required input without a value is rejected with 409 {"missingInputName": ...}. Values for an internal-only input are ignored.

Enabling a dangling reference, or storing inputs on one, fails with an error naming the reference as dangling. The frontend routes (without {externalUserId}, with the end user's JWT) behave the same.

Seeing who uses a catalog project

Usage in a catalog project's row menu opens a read-only side sheet listing the connected users who use the project's workflows in the current environment. Switch the environment to see another one. The sheet has two tabs:

  • References lists each reference with its workflow, the connected user's external id and an Enabled or Disabled badge. A dangling reference carries a Dangling badge too.
  • Copies lists the connected users who copied a visual project's workflow templates. A code project can't be copied, so the tab says so.

Dangling references

If the version an environment's configuration points at no longer contains a workflow a connected user is referencing (for example after the configuration is moved to a version that dropped it), or the catalog project is deleted, their reference doesn't silently disappear and doesn't silently keep running against a nonexistent workflow. It flips to a dangling state and is disabled:

  • Invisible to both invocation endpoints - a dangling reference behaves exactly like a disabled one to a caller (same 404, no existence leak).
  • Still listed for the connected user, carrying a reason: "Not in the version released to this environment" when the version drops the workflow, or "The automation project was deleted". A rollback counts too: moving the configuration back to an older version dangles references to templates that version lacks.
  • The connected user's connection configuration is preserved on the row, so nothing is lost even though the row itself stops being usable.

Dangling is permanent for that reference row - nothing currently clears the flag, and enabling it fails. It is different from the recoverable turned off by the administrator state: when an administrator disables the environment's configuration or one of its workflows, or deletes the configuration, the reference is switched off and marked as needing attention with that reason. Its connections and inputs are kept, the user's own enabled choice is untouched, and turning the configuration or workflow back on, or recreating the configuration, restores the reference exactly as the user had it. Disabling a dangling reference removes its deployment entry but keeps the row. A workflow added back under a name that is in the last published version gets that version's uuid back, but once a publish has dropped the name, a same-named workflow restored in a later publish gets a new uuid, not the one the dangling reference still points at. Recovering means de-provisioning the dangling reference and provisioning a fresh one against the workflow's new uuid - the connection auto-wiring runs again from scratch, so nothing carries over automatically.

Dangling only ever compares one catalog project's previous published version against its new one - publishing one catalog project never dangles a reference into a different catalog project.

Limits

  • No per-user version pinning. Releasing a version upgrades every referencing user in that environment at once; there's no way to keep one connected user on an older version of the workflow while others move to a new one.
  • No per-user editing. A reference has no definition of its own - the workflow update/edit APIs reject reference rows outright. If a connected user needs their own customized copy, that's what the visual bridge's copy-mode is for.
  • Edited in the catalog only. A catalog code project is edited in its own code editor under Embedded → Automations. The automation Projects code editor excludes catalog projects and rejects saves on them, because an editor draft there would bypass the catalog's publish path.
  • No Java in the editor. Java catalog projects are uploaded only.
  • Resolution differs by kind. A code-workflow reference always resolves to the workflow in the version its environment's configuration points at. A visual copy resolves to its own, independently deployed workflow - the connected user's copy, not the template it was copied from. Two connected users calling the same catalog uuid on a code workflow in the same environment always run the same logic; two connected users who each copied the same template can be running different versions if one of them edited their copy since.

See also

  • Automations - the visual bridge's copy-mode counterpart.
  • Code Workflows - the underlying ProjectHandler artifact contract, shared with standalone automation projects.
  • App Events - the async invocation endpoint and its trigger contract.
  • Request Triggers - the sync invocation endpoint, its response and its errors.

How is this guide?

Last updated on

On this page