guides

ByteChef Embedded, Part 16: Permission Expressions and Internal-Only Inputs

ByteChef Embedded, Part 16: Permission Expressions and Internal-Only Inputs
21 min read
Ivica Čardić

TL;DR: A permission expression on an integration, automation project or workflow decides which connected users are offered it, based on the metadata you attach to each user, and anything other than a clean true hides the resource. The same expressions, as an assignment rule, pick a new user's configuration, and internal-only inputs keep values you own out of the Connect dialog.

In part fifteen you shared your own accounts with every connected user, which settled which accounts a user can reach. This part goes one level up: which integrations, automations and inputs should a user see at all?

By now your catalog has probably grown. Maybe Salesforce is a premium add-on, HubSpot isn't cleared for EU customers yet, and a beta automation is meant for a handful of accounts. The Integration Marketplace, the Automation Hub and your pages from part one show all of it to everyone, because nothing has told them otherwise.

Workflow inputs have the same problem on a smaller scale. A workflow may need an account ID or region that you set once as the vendor, yet the Connect dialog renders every input as a field the user can edit. A permission expression decides who is offered a resource, and the internal-only flag decides who fills in an input.

Two Questions, Two Switches

Permission expressions also have a sibling that picks configurations, so there are three settings in play:

QuestionSwitchWhere you set itWho reads it
Should this user be offered this integration, automation or workflow?Permission ExpressionThe integration, project and workflow dialogsThe server, every time it builds a user's catalog
Which configuration should a new user get?Assignment ruleThe integration and automation configuration dialogsThe server, once, when the user is first placed
Should the user fill in this input, or should I?Internal onlyThe workflow editor's Workflow InputsThe Connect dialog, which leaves the input out

All three are Enterprise Edition features of ByteChef Embedded. Expressions and assignment rules are evaluated on the server. Internal-only is a flag on the workflow definition: the Connect dialog leaves those inputs out, and the server keeps your value whatever the user sends.

Where an Expression Lives

Each gateable resource has a multi-line Permission Expression text box in its dialog; empty means no restriction. There are four:

ResourceWhere in the admin UIWhat a false result hides
IntegrationEmbedded → Integrations → New Integration, or Edit on an existing one (the Create Integration / Edit Integration dialog)The whole integration, with all its workflows
Integration workflowEmbedded → Integrations, the workflow's row menu → Edit (the Edit Workflow dialog)That one workflow inside the integration
Automation projectEmbedded → Automations → New Project, or edit an existing project (the Create Project / Edit Project dialog)The whole project, with all its workflow templates
Automation workflowThe automation editor's Create Workflow / Edit Workflow dialogThat one workflow template
The Edit Integration dialog for Gmail with metadata['plan'] == 'pro' in the Permission Expression box

The levels nest: a resource is offered only if every level above it passes, so a workflow inside a hidden integration stays hidden whatever its own expression says. The workflow level lets you ship broadly and still hold one piece back, say Salesforce for every paying customer but its "bulk export" workflow only for enterprise accounts. The dialog placeholders show the shape: metadata['plan'] == 'pro' on integrations and projects, metadata['tier'] == 'gold' on workflows, where the field sits in the Edit Workflow dialog.

The Edit Workflow dialog for an integration workflow, with metadata['tier'] == 'gold' in its Permission Expression field

When a change takes effect

Integration-level and project-level expressions belong to the resource itself rather than to a version, and so do automation workflow expressions, which ByteChef keys by the workflow's UUID. Change any of them and the next catalog request uses the new rule, no publish needed. Publishing an automation project doesn't touch them either: a template's expression applies to whichever published version a user runs.

Integration workflow expressions are the exception. They're saved on the workflow in the integration's draft, and publishing copies each one onto the version it publishes. Configurations run a published version, so a change made after publishing reaches users at the next publish, like any other draft edit.

What an Expression Can See

ByteChef evaluates every expression against a small context built from the connected user making the request:

VariableTypeWhat it holds
metadatamap of string to stringThe key/value metadata attached to the user (plan, region, flags, account tier). Every value is a string.
externalIdstringThe user's ID in your system: the sub your backend signs into their JWT.
emailstring or nullThe connected user's email, if you set one.
namestring or nullThe connected user's display name, if you set one.
environmentstringDEVELOPMENT, STAGING or PRODUCTION: the environment the user belongs to.

That's the whole surface: no integration, request, time of day or anything else. This is deliberate. ByteChef doesn't need to know what a "plan" or "region" means; your entitlement model stays where it lives, and you mirror the parts that matter onto each user as metadata.

environment is the one variable you don't set. Integrations and automation projects are shared by all three environments, while users and configurations live in one, so environment != 'PRODUCTION' keeps a half-finished integration visible to test users in development and staging and invisible to real customers.

Writing Expressions

Expressions use ByteChef's expression language, the one behind workflow editor formulas: SpEL with a locked-down evaluation context. Leave off the leading = you'd type in a formula field; ByteChef adds it.

Each of these evaluates to true for a user with plan: pro, region: eu, seats: 5 and the email jane@acme.com:

metadata['plan'] == 'pro'
metadata['plan'] == 'pro' || metadata['plan'] == 'enterprise'
metadata['plan'] matches 'pro|enterprise'
metadata['region'] == 'eu' and !(metadata['plan'] == 'free')
equalsIgnoreCase(metadata['region'], 'EU')
int(metadata['seats']) > 3
contains(email, '@acme.com')
email matches '.+@acme[.]com'
environment != 'PRODUCTION' || metadata['plan'] == 'pro'
name == 'Jane' and externalId == 'user-42'

The operators are plain SpEL: ==, !=, <, >, && / and, || / or, ! / not, parentheses and the matches regex operator all work. You can read a key as metadata.plan or metadata['plan'], and the bracket form also handles keys with dashes or dots.

Beyond operators you have ByteChef's formula functions (contains(...), equalsIgnoreCase(...), int(...), size(...) and the rest), written as standalone calls with the value as the first argument. Method calls are not allowed. Anything shaped like value.method(...) is rejected before it runs, so email.endsWith('@acme.com') and {'pro', 'enterprise'}.contains(metadata['plan']) never match anyone. Type references (T(...)) and new are rejected too. Use matches or a formula function instead.

Metadata values are always strings. Your backend may send "betaIntegrations": true or "seats": 5, but ByteChef stores "true" and "5". So metadata['betaIntegrations'] == 'true' matches while metadata['betaIntegrations'] == true doesn't, and metadata['seats'] > 3 fails with a type error (which hides the resource) until you convert it with int(metadata['seats']) > 3. Comparisons are also case-sensitive: metadata['region'] == 'eu' won't match EU, so normalize values when you write them or use equalsIgnoreCase(...).

Fail Closed, on Purpose

An expression is an access decision, and the evaluator treats it like one:

ExpressionResult
Blank or absentVisible. No restriction. Most resources have no expression at all.
Evaluates to trueVisible.
Evaluates to falseHidden.
Evaluates to anything else, like metadata['plan'] (a string)Hidden. Only a real true counts.
Syntax error, rejected method call, type error, a matches on a null emailHidden.

So a typo hides an integration instead of exposing it. When evaluation fails, the server logs a warning that names the expression and the connected user's external ID and ends with hiding (fail closed). That log line is where you'll look when a customer swears the Salesforce card vanished.

Fail-closed can't save you from a missing value combined with a negative check. metadata['plan'] != 'free' is true for a user with no plan at all, because a missing key reads as null and null isn't 'free'. Prefer positive checks like == 'pro'.

Where ByteChef Applies Them

Expressions are evaluated on the server, per request, for the user the request is about. These are the surfaces that check them:

SurfaceEffect of a hidden resource
GET /api/embedded/v1/integrations (the Integration Marketplace, the sample's Integrations page)Hidden integrations are left out of the list
GET /api/embedded/v1/integrations/{id} (what the Connect dialog loads)A hidden integration answers 404, not 403, so its existence doesn't leak. Hidden workflows are left out of workflows, and out of the MCP workflows list too
GET /api/embedded/v1/automation/projects (the Automation Hub, the sample's template picker)Hidden projects and hidden templates are left out. A template that needs a hidden integration still lists the component, but with no integration to connect
POST /api/embedded/v1/automation/workflow-templates/{workflowUuid}/copy404 for a template the user can't see
POST /api/embedded/v1/automation/workflow-templates/{workflowUuid}/provision404 for a template the user can't see
POST /api/embedded/v1/integrations/{id}/instances (connecting an integration)404 for an integration the user can't see, before any configuration is picked
POST /api/embedded/v1/integration-instances/{id}/workflows/{workflowUuid}/enable404 if the integration or that workflow is hidden for the user. Disabling isn't gated, so a user can still turn off a workflow you've since hidden
Embedded → Connected Users, a user's sheet → Provision IntegrationOnly integrations visible to that user are offered, and provisioning a hidden integration or a hidden workflow is refused
Embedded → Connected Users, a user's sheet → Provision WorkflowOnly projects and templates visible to that user are offered

Every frontend path has a backend twin that takes the user's ID in the path (/api/embedded/v1/{externalUserId}/integrations and so on), and it filters the same way for that user.

Note the last two rows: admin provisioning respects the user's expressions too, which keeps "what this customer can have" in one place. If an admin can't find an integration for a customer, check the customer's metadata first.

Assignment Rules: The Same Expressions, One Level Down

In part twelve and part thirteen you created configurations: an Integration Configuration pins a published integration version with its connection settings and enabled workflows, and an Automation Configuration does the same for an automation project. An environment can hold several of each for the same integration or project.

Both configuration dialogs have an Assignment rule text box (placeholder e.g. metadata['beta'] == 'true'). It takes the same expressions with the same fail-closed evaluation, but answers a different question. In the tooltip's words, it decides which new users self-serve places on this configuration, checked once, when a user is first assigned; users already on it stay until you move them; empty means everyone.

The Edit Configuration dialog with metadata['beta'] == 'true' in the Assignment rule field and its tooltip open

When a user without a configuration needs one (to list an integration, connect it, or open an automation project), ByteChef looks at the enabled configurations whose rule passes for that user and picks one. For integrations, the configuration with the highest integration version wins; for automation projects, the highest project version wins. In both cases a tie goes to the most recently created configuration.

That gives you a clean pattern for staged rollouts. Keep your stable configuration on version 3 with an empty rule, then add a configuration on version 4 with the rule metadata['beta'] == 'true'. Beta users land on version 4 and everyone else on version 3. When version 4 is ready, widen the rule; existing users stay where they are until you move them.

Two consequences follow. If every configuration has a rule and none passes for a user, there's nothing to offer: that user doesn't see the integration or project at all unless they already have an instance on one. An assignment rule doesn't hide anything the way a permission expression does, but an empty match has the same effect for new users. And since rules are checked at placement, not on every request, changing a user's metadata later doesn't move them. Admins can still place a user on any configuration from the admin UI; that path ignores assignment rules (though not permission expressions).

Configurations are also the most robust way to gate workflows by group. Enable the bulk-export workflow only in the enterprise configuration, and let the assignment rule decide who gets that configuration.

Giving Users Metadata

An expression is only as good as the metadata behind it. There are three ways to set it.

In the Admin UI

Open Embedded → Connected Users. New connected user creates a user ahead of time, with an External ID (at most 50 characters), Name, Email and a Metadata list of key/value rows that you extend with Add metadata. To create users in bulk, use Import with a CSV file whose columns are externalId (required), name, email and any metadata columns you like; the dialog reports how many rows it created and lists the duplicates it skipped and the rows it rejected.

To change an existing user, open their sheet and pick Edit from the actions menu. Edit connected user has the same fields, with keys and values capped at 256 characters, and saving replaces the user's metadata with exactly what's in the form.

The Edit connected user dialog with two metadata rows, plan = pro and region = eu, above the Add metadata button

The user's sheet lists every metadata key and value in its profile panel, the first place to look when an expression misbehaves.

With the User's Token

PATCH /api/embedded/v1/me updates the user the JWT belongs to:

PATCH /api/embedded/v1/me
Authorization: Bearer <connected user's JWT>
X-Environment: DEVELOPMENT
Content-Type: application/json

{
    "plan": "pro",
    "region": "eu",
    "email": "jane@acme.com",
    "betaIntegrations": true
}
HTTP/1.1 204 No Content

name and email (in any capitalization) set the user's name and email when their values are strings. Every other key is merged into the metadata, and keys you don't send keep their values. Values are stored as strings (true becomes "true", 5 becomes "5"), and nested objects are stringified too, so keep the body flat. Sending a key as null doesn't delete anything: it's ignored and the old value stays, so to downgrade a user you write a new value such as "plan": "free". The user is whoever the token's sub says, in the environment from X-Environment. That header defaults to PRODUCTION, so send it.

A JWT request also creates the connected user if it doesn't exist yet, so a PATCH right after you mint a user's first token works without waiting for them to open the Connect dialog.

From Your Backend

The natural place for that call is the backend that already signs your users' tokens. In the embedded sample app, that's the Fastify route POST /api/token in back-end/src/index.ts. It signs {sub, name, iat, ...customClaims} with RS256 and your ByteChef key ID. The sample doesn't set metadata, but adding it takes one call after jwt.sign(...):

// back-end/src/index.ts, inside POST /api/token, after the token is signed
// BYTECHEF_APP_BASE_URL and the account lookup are additions; the sample doesn't have them
const account = await lookUpAccount(externalUserId);

await fetch(`${process.env.BYTECHEF_APP_BASE_URL}/api/embedded/v1/me`, {
    method: 'PATCH',
    headers: {
        Authorization: `Bearer ${token}`,
        'Content-Type': 'application/json',
        'X-Environment': 'DEVELOPMENT',
    },
    body: JSON.stringify({
        email: account.email,
        name: account.name,
        plan: account.plan,
        region: account.region,
    }),
});

return {token};

Doing this on every mint means a plan change in your system reaches ByteChef the next time the user's session refreshes. (The sample's front end fetches a new token shortly before the old one expires, in getToken() in front-end/src/lib/api.ts.)

Why not put the plan in the token? The sample's JWT already carries a name claim plus any customClaims you pass, but ByteChef doesn't read them. From the token it uses only sub, the optional environment claim and connectionDialogAllowed (from part fifteen). A plan claim in the JWT does nothing for your expressions; it has to be written as metadata.

Setting Expressions Without the UI

If you manage your catalog from code, script against the admin API the dialogs use. Each field maps to one operation, and they clear differently:

ResourceOperationClearing it
IntegrationpermissionExpression field of the integration, saved with the rest of it (PUT /api/embedded/internal/integrations/{id})The update replaces the whole integration: an update without the field clears the expression
Integration workflowGraphQL updateIntegrationWorkflowPermissionExpression(integrationWorkflowId, permissionExpression)Send an empty value
Automation projectGraphQL createAutomationProject(..., permissionExpression) and updateAutomationProject(..., permissionExpression)null leaves the stored expression alone; an empty string clears it
Automation workflowGraphQL createAutomationProjectWorkflow(projectId, definition, permissionExpression), later updateAutomationProjectWorkflowPermissionExpression(workflowUuid, permissionExpression)Blank clears it
ConfigurationsGraphQL createAutomationProjectConfiguration / updateAutomationProjectConfiguration take permissionExpression, the integration configuration model has the same field; both show up as Assignment rule in the UIBlank clears it

These are admin endpoints, called with an admin's session rather than the connected-user API used elsewhere in this series. Watch the first row: a script that updates an integration's name and forgets the expression opens the integration to everyone, the one failure here that doesn't fail closed.

With audit recording on (bytechef.audit.enabled), expression changes appear in Settings → Audit Events as AUTOMATION_PERMISSION_EXPRESSION_UPDATED and INTEGRATION_WORKFLOW_PERMISSION_EXPRESSION_UPDATED, and the project create and update events carry the expression.

Internal-Only Inputs

Now the second switch. Some inputs aren't questions for your users at all: the account ID in your own system, a fixed API region, a default your support team relies on. Showing them in the Connect dialog only invites someone to change them.

Marking an Input

In an integration's workflow editor:

  1. Click Workflow Inputs in the editor's right sidebar.
  2. Click New Input, or edit an existing one.
  3. In the Create a new Input or Edit Input dialog, set Internal only to True.
  4. Click Save.
The Create a new Input dialog in the workflow editor for an input named accountId, with Internal only set to True

The Workflow Inputs table shows the setting in its Internal only column, and the workflow definition stores it as a flag on the input:

{
    "inputs": [
        {"name": "accountId", "label": "Account ID", "type": "string", "internalOnly": true},
        {"name": "channel", "label": "Channel", "type": "string"}
    ]
}

Inputs without the flag, including every input created before the setting existed, stay user-facing.

Who Fills What

The flag splits inputs between two forms. Yours is the configuration dialog under Embedded → Integration Configurations. Its Workflows step shows each workflow as a card with its Connections and Inputs, and that Inputs list holds only the internal-only inputs. You fill accountId once per configuration, and every user on that configuration runs with it.

Your users' form is the Connect dialog. GET /api/embedded/v1/integrations/{id} still returns every input, each with internalOnly, and the Connect dialog in @bytechef/embedded 0.4.0 drops the flagged ones before it renders the workflow's INPUTS section, so the user sees only channel. Workflows exposed as MCP tools carry the flag too, in the response's mcpWorkflows list, and the dialog's Tools tab leaves those inputs out the same way. The admin Provision Integration dialog in a connected user's sheet follows the same split: it asks only for the user-facing inputs, since the internal ones come from the configuration.

At run time ByteChef merges the two. It starts from the configuration's input values and lays the user's own values on top, except for internal-only inputs, where a value set in the configuration always wins. The same merge feeds the workflow's trigger when the user enables it. The configuration's values never leave the server: the integration response carries the input definitions, not your values.

The server enforces the split too. When a connected user saves a workflow with their JWT (PUT /api/embedded/v1/integration-instances/{id}/workflows/{workflowUuid}, or .../mcp-workflows/{workflowUuid} for an MCP tool), the server drops any internal-only key from inputs and keeps the value already stored for it, so a hand-crafted request can't override yours. It drops the key rather than refusing the request because the Connect dialog sends the instance's stored inputs back on every save. Your backend can still set an internal-only value for one user's instance through the API-key twin of that endpoint (/api/embedded/v1/{externalUserId}/integration-instances/...), and that value applies wherever the configuration leaves the input empty.

Automations Work Differently

The automation editor's Workflow Inputs shows the same Internal only setting, but the automation endpoints don't carry the flag. There, the vendor-owned equivalent is a provided input on an Automation Configuration: in its Workflows step, pick a value instead of Let each user fill it. The dialog's note: connections and inputs set here are used by every connected user and cannot be changed by them. The server enforces it: a request that tries to set a provided input answers 409 with providedInputName in the body. Part twelve covers provided values in the Automation Hub.

Gotchas

  • Metadata is writable from the user's token. PATCH /api/embedded/v1/me accepts any connected user's JWT, and in an embedded product that JWT lives in the browser. A determined user can set their own plan to enterprise and see what you've gated behind it. Expressions decide what each user is offered, so treat them as a catalog filter and enforce anything that must be paid for on your side as well. Rewriting metadata from your backend on every token mint undoes a self-edit at the next session.
  • Expressions gate the catalog, not everything. Listing, detail, connecting, enabling a workflow, template copy and provisioning all check them. The AI builders from parts nine and ten don't: they pick components from every integration enabled in the environment without reading expressions. What keeps one customer away from another's data is tenant isolation, and expressions play no part in it.
  • Method calls fail closed. email.endsWith(...) quietly hides the resource from everyone. Use email matches '.+@acme[.]com' or contains(email, '@acme.com'), and test every new expression with a real user.
  • Workflow-level gates follow publish. An integration workflow's expression reaches users at the next publish. Integration, project and automation workflow expressions apply right away.
  • Negative checks pass on missing keys. metadata['plan'] != 'free' is true for a user you never enriched. Write positive checks.
  • Numbers and booleans are strings. Compare against 'true' rather than true, and wrap numbers in int(...).
  • Assignment rules don't re-run. New metadata changes what a user is offered immediately, not which configuration they're on. Move existing users yourself.
  • Clearing a field from code can open a resource. An integration update without permissionExpression removes the gate.

Before You Go to Production

  • Write down your metadata keys and values (plan, region, beta) with their exact spelling and case.
  • Write metadata from your backend on every token mint or plan change, with the user's JWT and an explicit X-Environment.
  • Backfill existing users with Import in Embedded → Connected Users before the first expression goes live, so nobody loses an integration they already use.
  • Prefer positive expressions, and keep them short enough to read in the dialog.
  • Test every expression in each environment with two test users, one who should see the resource and one who shouldn't. Check the integration list, the Connect dialog, the Automation Hub and the admin Provision Integration dialog.
  • Watch the server log for hiding (fail closed) warnings after each change.
  • Publish after changing a workflow-level gate, and check it as a test user.
  • Use configurations for rollouts: one stable configuration with an empty assignment rule, one beta configuration with a rule.
  • Audit every integration workflow's internal-only inputs and fill them in each environment's configuration. A configuration value always wins over the user's; one you leave empty can only be filled for a user through your backend.
  • Turn on audit recording if you need a history of who changed which rule.

Who Does What

You own the entitlement model (plans, regions, flags), the metadata that mirrors it onto each user, the expressions and rules, the internal-only values, and enforcing anything paid for in your own product. ByteChef evaluates the expressions on the server, fails closed, filters every catalog path, places new users on configurations, and keeps internal-only and provided values out of your users' hands.

In practice your side is a few short strings in the admin UI and one PATCH in the backend that already signs your tokens. In return, every catalog page from parts one through fifteen shows each customer only what their plan, region and flags say they should get.

What's Next

Permission expressions decide what a user is offered, and they aren't a security boundary. So what is? Part seventeen, Embedding Securely, walks the real boundary: which sites may frame your embedded pages, how the embed handshake checks origins, why a token can only act on its own user's path, and who is allowed to run the admin side.

Sixteen Parts In

Here's the series so far:

  1. Connect your users' apps (the JWT and ConnectDialog everything rests on).
  2. Act on those connected apps directly with the ComponentKit.
  3. Chat with an AI assistant that uses the ComponentKit's tools.
  4. Trigger their workflows from your product's events.
  5. Call a workflow like a synchronous API.
  6. Agent over MCP: the same tools, discovered through an open protocol.
  7. Author workflows in a builder you designed yourself.
  8. Start from a template you curated.
  9. Talk a workflow into existence with ByteChef's agent.
  10. Describe it in one sentence and get a finished workflow back.
  11. Build on ByteChef's own canvas, embedded in your page.
  12. Ship a whole automations page with the Automation Hub.
  13. Ship a whole integrations page with the Integration Marketplace.
  14. Map fields between your data model and each user's apps.
  15. Share your own accounts with every connected user, read-only.
  16. Decide who sees what with permission expressions, and keep your own inputs yours (this part).

Nothing in the earlier parts changes. Every list they render now simply asks ByteChef for that user's catalog, filtered by metadata you already have, with the values you own kept out of their forms.

Following along? In Embedded → Connected Users, open your embedded sample app's demo user and add the metadata plan = free. Put metadata['plan'] == 'pro' on one integration and reload the sample's Integrations page: it's gone. Change the plan to pro and it's back. While you're there, mark one workflow input Internal only and watch it move from the Connect dialog to the configuration dialog.

Subscribe to the ByteChef Newsletter

Get the latest guides on complex automation, AI agents, and visual workflow best practices delivered to your inbox.

Related posts