LendMCP workflow ground rules
These are the constraints LendAPI enforces when you author a decision workflow. An assistant
working through LendMCP has to satisfy all of them before a workflow can be published or run.
Read this before your first authoring session — most authoring failures are one of the rules
below.
Sections 1-9 cover decision trees (Rules Studio). Sections 10-18 cover flows (Flow
Builder), the orchestration layer that composes those trees with pricing engines, integrations
and communications. Sections 19-26 cover products (Product Studio): the pages an applicant
fills in, their routing, and how a version goes live.
Workflow authoring (variables, outcomes, decision trees) works in Live and Sandbox; derived variables
are created in Live only. Product Studio works on both.
1. Dependency order
Build in this order. Each step depends on the one above it.
1. Variables and outcomes must exist
|
2. Create the decision tree
|
3. Add nodes, then connect them
|
4. Configure every rule node and every action node
|
5. Save workflow metadata
|
6. Submit a version
|
7. Promote that version to default
|
8. Discover required parameters, then run
- Variables are the inputs a rule can test. A rule that names a variable which does not
exist will fail. - Outcomes are the labels an action node applies. An action node cannot reference an outcome
that does not exist yet.
Provider-backed variables
Variables that come from an integration partner — credit bureau fields, identity signals, bank
data — only exist once that partner is enabled for your tenant. Enabling a partner creates the
variables automatically.
LendMCP cannot enable an integration partner. If a variable such as equifax_score is missing,
the partner has to be enabled in the portal first; then the variable appears in your variable
list.
2. Variable naming
Every variable has a display name and an engine_name. The engine_name is the identifier
used inside rule expressions, and it is strict.
| Rule | Detail |
|---|---|
| Lowercase only | Uppercase letters are rejected |
| No leading digit | Must start with a letter or underscore |
| Allowed characters | Letters, numbers, underscore |
| Pattern | ^[a-z_][a-z0-9_]*$ |
| Max length | 60 characters |
| Not a reserved word | Expression keywords and math function names are blocked |
| Unique per tenant | Duplicates are rejected |
Reserved words are the names the decision engine uses for its own expression syntax. They
include and, or, not, if, else, for, while, class, def, return, import,
from, True, False, None, in, is, try, except, lambda, and math or conversion
function names such as sin, cos, sqrt, pi, abs, len, int, str, dict, list,
min, max, float, bool, type, range, sum, round, pow, log, exp, ceil,
floor.
Good: annual_income, fico_score, months_at_address, _internal_flag
Rejected: AnnualIncome (uppercase), 2nd_income (leading digit), annual-income (hyphen),
max (reserved), applicant income (space)
3. Variable types
| Type | Name | Notes |
|---|---|---|
1 | Numeric | The only type allowed on both sides of a variable-to-variable comparison |
2 | String | |
3 | Boolean | |
6 | List | Requires list_values: an array of {"value": ..., "displayValue": ...} objects |
Notes:
- Simple variables are created with
variables_create_simple; derived (computed)
variables withvariables_create_derived. Composite variables are not supported yet. - A derived value whose inputs are missing or whose result is not finite (division by zero)
silently evaluates to0in decision trees. Guard divisions:
round(monthly_debt_payments * 1200 / annual_income, 2) if annual_income > 0 else 999. - Type
5(date) exists on the platform but cannot be created through LendMCP. - For a list variable,
list_valuesmust be an array (not an object), every entry must have both
valueanddisplayValue, and both are stored as strings.
4. Rule nodes
A rule node holds a condition expression:
{
"combinator": "and",
"rules": [
{"field": "annual_income", "operator": ">", "value": 50000},
{"field": "fico_score", "operator": ">=", "value": 640}
]
}Rules:
- The expression must contain at least one rule. An empty rule node is rejected.
- Every variable named in
fieldmust already exist. - Variable-to-variable comparisons are numeric-only. When a rule compares one variable
against another (rather than against a constant), both variables must be type1. Anything
else is rejected with "Variable-to-variable comparison is only allowed for numeric variables."
5. Action nodes: the two-field rule
This is the rule that trips up most first workflows. Every action node needs two things, and
they are different concepts:
| Field | What it is | Example |
|---|---|---|
Status change (action_id) | The application status transition this node triggers | 1 (Approve) |
Outcome (assignment_id) | The specific outcome record that labels this decision | 7 (an outcome ID) |
outcomes_create(name, outcome_type) -> returns an outcome id
|
v
decision_trees_update_action_node(
action_id = <status change>, <- required
assignment_id = <outcome id> <- required
)
- The outcome must exist before the action node can reference it.
- Each outcome is itself created with an action type — usually the same value you pass as
action_idon the node. - If either field is missing, the workflow will not pass the publishability check and submitting
a version fails. - The one exception: an action node that chains to another published decision tree supplies
chain_decision_idinstead ofassignment_id. The chained tree must already be published and
active.
Valid action types
| ID | Name | Use |
|---|---|---|
1 | Approve | Standard approval |
2 | Decline | Standard decline |
3 | Review | Manual review / referral |
5 | Request Docs | Document collection |
Never use types 6, 7, or 8. They exist internally but are not exposed in Rules Studio, and
using them leaves the action and outcome dropdowns broken there. LendMCP rejects them before
the call is made.
Outcome names
Letters, numbers, spaces, hyphens, and underscores only. Names are de-duplicated per tenant,
case-insensitively and with surrounding whitespace ignored — so "Quick Approval" and
"quick approval " collide.
6. Tree structure
| Node type | Code | Purpose |
|---|---|---|
| Rule | 1 | Decision point with a boolean condition; branches yes/no |
| Action | 2 | Terminal node that assigns an outcome |
| Edge direction | Meaning |
|---|---|
"1" | Left / No — the parent's condition evaluated false |
"2" | Right / Yes — the parent's condition evaluated true |
Structural rules:
- The tree is binary: a rule node has at most two children.
- A child node has exactly one parent.
- The Start node cannot be used as a connection target.
7. Publishability
A workflow can only be submitted when all of these hold:
- There is at least one rule node.
- Every rule node has a condition expression with at least one rule.
- Every action node has both a status change (
action_id) and an outcome
(assignment_id) — or a chained decision tree instead of the outcome. - Every leaf node is an action node. A rule node cannot be a leaf.
- Every rule node has exactly two children — a YES branch and a NO branch.
If any of these fail, submitting returns "Workflow is not publishable yet."
8. Publish and run sequence
| Step | Tool | Result |
|---|---|---|
| 1 | decision_trees_create | Session UUID + one initial rule node |
| 2 | decision_trees_add_node | A node ID; repeat per node |
| 3 | decision_trees_connect_nodes | Edges, with yes/no direction |
| 4 | decision_trees_update_rule_node / decision_trees_update_action_node | Each node configured |
| 5 | decision_trees_save_metadata | Title, product, pricing, run-all-nodes saved |
| 6 | decision_trees_submit_version | A version, status Pending Approval |
| 7 | decision_trees_set_default_version | That version becomes the one that runs |
| 8 | decision_trees_get_required_params | The inputs a run needs |
| 9 | decision_trees_run | The decision result |
Two behaviors to expect at step 6:
- Nothing changed since the last version? Submitting reports "No New changes Detected" and
does not create a version. That is not an error — the current version already matches your
draft. - A version is a snapshot. Later edits to the draft do not affect a submitted version until
you submit again and promote the new version.
Version statuses
| Status | Meaning |
|---|---|
0 | Draft |
1 | Pending Approval |
2 | Approved |
3 | Declined |
Running
paramsis a map ofengine_nameto value, and it must cover every required variable. Get the
list fromdecision_trees_get_required_params.- Omit
versionto run the default version. - When
run_all_nodesis enabled on the version, the run result also includes
failed_outcomes— the outcomes on paths that did not match.
9. Common failure modes
| Failure | Cause | What to do |
|---|---|---|
engine_name rejected | Uppercase, leading digit, reserved word, or duplicate | Rename and retry |
list_values is required for type 6 | List variable created without values | Supply the array, with value and displayValue on each entry |
| Variable not found in a rule | The variable does not exist, is inactive, or its integration partner is not enabled | Check your variable list; enable the partner in the portal if needed |
| "Variable-to-variable comparison is only allowed for numeric variables" | A non-numeric variable on one side of a variable-to-variable comparison | Compare against a constant, or make both variables numeric |
Rule node options must include at least one rule | Empty rule expression | Add at least one condition |
| "Assignment not found" | The outcome ID does not exist for this tenant | Create the outcome first, or list outcomes to get a valid ID |
Either assignment_id or chain_decision_id is required | Action node has no destination | Supply an outcome, or a chained tree |
| "Chain decision tree not found or not published" | Chained tree is unpublished or inactive | Publish and activate the chained tree first |
| "Workflow is not publishable yet" | A rule node without options, an action node missing its status change or outcome, or a rule node that has no children | Walk the tree against section 7 |
| "Tree is invalid" | No rule node, or a broken structure | Confirm the tree has a rule root and all nodes are connected |
| "No New changes Detected" | The draft is identical to the current version | No action needed |
| Run fails, missing params | Not every required variable was supplied | Call decision_trees_get_required_params and fill them all in |
| Run fails, no default version | The workflow was never published | Submit a version, then set it as default |
variables_create_derived fails on a sandbox connection | Derived variables are Live-only (every other authoring tool works in both environments) | Pass environment: "live" on a sign-in connection, or use a live_ token |
Flow Builder (Workflow Builder)
Everything above is about a decision tree — one tree, one outcome. A flow is the layer
above: an orchestration graph that runs decision trees, prices offers, calls integrations, sends
email and SMS, waits, branches and fans out. Flows are where Rules Studio work gets composed into
something an application actually goes through.
Flows have their own rules. They are looser than the decision-tree rules — LendAPI validates less
at publish time and more at run time — so the burden of getting a graph right sits with whoever
builds it.
10. The graph
A flow version stores one graph:
{
"start_node_id": "trigger-1",
"nodes": [
{"id": "trigger-1", "type": "trigger", "data": {"label": "Start"}},
{"id": "rule-1", "type": "rule", "data": {"selectedRuleId": 42}},
{"id": "end-1", "type": "end", "data": {"label": "Approved"}}
],
"edges": [
{"source": "trigger-1", "target": "rule-1"},
{"source": "rule-1", "target": "end-1"}
]
}- Node ids are yours to choose and must be unique within the graph.
- A node's kind may sit at
typeor atdata.type; both are read,typefirst. - A node's configuration is
data(withconfigmerged over it, if present). - Edges are directed:
source->target. start_node_idis where a run begins. It should be thetriggernode.- Every branch must finish on an
endnode. This is the one structural rule LendAPI enforces
at publish time, and the most common reason a publish is refused.
flows_save_draft checks the graph locally before sending it: unknown node types, edges pointing
at nodes that do not exist, a missing end node, and branches that cannot reach one are all
rejected without a call. Softer findings — a node nothing points at, a rule node with no rule
selected — come back as graph_warnings and do not block the save.
11. Node types and what each one needs
| Type | Aliases | What it does | Required configuration |
|---|---|---|---|
trigger | start, application-trigger | Entry point, one per flow | — |
rule | Runs a Rules Studio decision tree | selectedRuleId — the tree's numeric workflow id | |
pricing_engine | pricing-engine, pricing | Runs an offer table | selectedPricingEngineId — the offer table id |
integration | Calls an integration endpoint | selectedIntegrationId — a provider_type_id | |
email | Sends an email template | selectedActionId — the template id | |
sms | Sends an SMS template | selectedActionId — the template id | |
decision | Branches on a value already in the run context. The canvas saves each rule outcome as a node typed by the outcome's action (Approve, Decline, ...) with data.outcomeId; it counts as a decision node | Its condition | |
condition | Evaluates a rule-builder query and routes by the condition-approve / condition-decline handles | condition | |
delay | Suspends the run and resumes on a timer | waitFor {unit, value} | |
parallel | Runs every outgoing branch concurrently | — | |
loop | Repeats a branch until its condition holds or it times out | Its condition and limit | |
send_webhook | send-webhook | Sends an HTTP request to a configured webhook | Its webhook settings |
wait_webhook | wait-webhook | Suspends the run until an inbound webhook arrives or it times out | Its webhook settings |
action | Canvas module node: runs as its data.moduleId (email, sms, integration, delay, send/wait webhook); any other module passes straight through | moduleId | |
end | Terminal node | outputVariables selects what the run returns |
Confirm every id before you put it in a graph. flows_get_node_variables resolves all three
reference kinds (rule, pricing_engine, integration) and returns both the variables that
reference exposes and the config_key the id belongs in. A 404 there means the object does not
exist for your tenant — and a graph that passes local preflight with a bad id will still fail at
run time.
12. Flow Builder composes Rules Studio
A flow does not re-implement decisioning; it calls it.
- A
rulenode runs a published decision tree by itsworkflow_id— the same tree you built
with thedecision_trees_*tools. The tree must be published and have a default version. - A
pricing_enginenode runs an offer table. It must be published and active, with a default
version. - Outcomes route the graph. A
rulenode's outgoing edges are not ordered or labelled on the
edge itself: the run picks the edge whose target node carries the matching
data.outcomeId. So to branch on approve versus decline, give the approve branch's first node
outcomeIdof the approve outcome and the decline branch's first node the decline outcome.
The practical consequence: build and publish the decision tree first, then wire it into a flow.
flows_get_node_variables with kind="rule" shows what the tree consumes, which is what the
flow has to put in the run context before that node.
13. Versions, drafts and publishing
- A flow has one draft at a time.
flows_save_draftupdates the existing draft in place;
it creates one at the next version number only when the flow has no draft. Published versions
are never modified. - Publishing validates first.
flows_publishruns the same checks asflows_validateand
refuses the version if any fails — nothing is published, and the response carries the errors.
Validate first so a refused publish becomes a fixable list rather than a surprise. flows_runexecutesdefault_version. Publishing a version does not make it the one that
runs: passset_as_default=true. Without it the flow keeps its current default, unless it has
none or the one it has is no longer published.set_as_default=truere-points live traffic at
whatever version the call publishes, an older one included, so confirm the version number with
the user first. The publish response answers it directly:published_version,
default_version,is_default.- A flow must also be active.
flows_toggle_activetakes an explicit boolean, so a repeated
call is a no-op rather than a flip back.
| Flow / version status | Meaning |
|---|---|
0 Draft | Never published |
1 Tested | A test run has passed |
2 Published | Published; the flow has at least one published version |
14. Triggers, and what a run creates
trigger_type | Started by | Application |
|---|---|---|
1 API | A direct call to the flow's run endpoint | The run creates a new application |
2 Application | A call naming an existing application | The run advances that application |
An application-trigger flow needs app_session (or app_id) on every run. An API-trigger flow
takes none — it creates its own application, with product_type=1.
A flow is not tied to a product. Unlike a decision tree, which is attached to a product's
application steps, a flow has no product link: what it does is decided entirely by its graph.
15. Running versus testing
flows_run | flows_test_run | |
|---|---|---|
| Version | Always default_version | Any version, including the draft |
| Application | Real: created, or the one you name | A throwaway test application |
| Trace | No | Yes — per node, with timings |
| Integrations, email, SMS | Really run | Really run |
flows_test_run is safe for the application, not for the outside world: a test run still calls
integrations and still sends email and SMS. If that matters, take those nodes out of the draft
first.
16. Operating a running flow
A run is not always instantaneous. A delay node suspends it and schedules a resume;
flows_get_execution_path reports is_processing while a run is in flight and shows the delay
step it is parked on.
flows_skip_delayends the wait and runs the rest of the flow now — every node downstream
of the delay, at once.flows_suspendstops the run. It does not resume on its own afterwards; a human, or
flows_rerun, has to restart it.flows_rerunruns a version against an application again, reading its inputs from the
application's current data rather than the original trigger payload, and replaces the previous
result. It refuses while another run is in flight.
17. Flow failure modes
| Failure | Cause | Fix |
|---|---|---|
Flow is not active. | The flow is switched off | flows_toggle_active with active=true |
No versions configured for this flow. | Nothing published | flows_save_draft, flows_validate, flows_publish |
app_id or app_session is required for application trigger flows | An application-trigger flow was run with no application | Pass app_session |
Validation failed; the version was not published. | The graph failed validation | Read validation.errors, fix the graph, publish again |
Branch ending at "…" must finish on an end node. | A branch stops short | Add an end node, or an edge to one |
Flow is already processing. | A run or a delayed resume is still in flight | Wait, then check flows_get_execution_path |
Invalid workflow ID / Invalid offer table ID | A node references something that does not exist for your tenant | Confirm with flows_get_node_variables before saving the graph |
Integration not found or not active for this tenant. | The integration is not enabled | Enable it in the portal, then flows_list_active_integrations |
No flow has run on this application; pass flow_id… | Re-run with nothing recorded on the application | Pass flow_id |
| A node runs but does nothing | Its reference id is missing from data | Check graph_warnings from the last flows_save_draft |
18. Out of scope for LendMCP
Canvas layout (node positions, colors), integration credentials, and model-service configuration
are not exposed through these tools. Use the LendAPI portal for those.
Product Studio
A product is what an applicant applies to: an ordered set of pages, the routing between them,
settings, a theme and custom scripts. The Product Studio tools build one from scratch and publish
it. They work on Live and Sandbox connections alike, and every write tells you which one it wrote
to.
19. What takes effect when
| You change | It reaches applicants | Result says |
|---|---|---|
| Pages, routing, page order, removed pages | When a version is published and made live | takes_effect: on_publish |
A publish without is_default | When you set that version live | on_set_live |
| Settings, the product name, opening or closing it, the live version, theme assignment and theme edits | Immediately | immediately |
| A custom script | When it is enabled | when_enabled |
Applicants always run the live version: the published version you chose with
products_set_live_version (or is_default=true on publish), with the product's current settings
and theme. is_live: true in a result means the product is open and has a live version, so an
immediately change is visible to applicants now.
Publishing alone is not live. That is deliberate: you can publish a version, read it back with
products_pages_get and version, and decide when it goes live.
20. Build order
Build bottom-up, so nothing a page or route names is missing when you write it:
1. Variables and outcomes
|
2. Decision tree (nodes, rules, actions)
|
3. The product products_create
|
4. Attach the tree, publish it decision_trees_save_metadata(assigned_product_id), submit, set default
|
5. Pages and routing products_pages_apply (or one page at a time)
|
6. Check products_pages_get, products_validate
|
7. Theme, settings, scripts themes_create / themes_assign, products_update_settings, products_scripts_upsert
|
8. Publish, set live, open products_publish, products_set_live_version, products_set_active
|
9. Wire each outcome pricing engine, contract, email triggers
- Pricing, contracts and email triggers are not set on pages. They attach to the product and
an outcome in their own tools (pricing_engines_save_metadata,contracts_update,
comms_update_template);products_get_overviewshows them under each outcome. - A decision tree and a pricing engine attach only to an active product.
- An email trigger names pages by their
label(the title without spaces, from
products_pages_get), so wire page triggers after the pages exist. - On a product that already takes applications, wire step 9 before step 8 so a new outcome is
never live without its offer or contract.
21. Pages
A page is a list of rows; each row holds one to three elements. An element is a field (a
variable the applicant fills in), a control (banner, checkbox, label, document display or
upload, rich text, divider, scroll-to-bottom) or a widget (an integration such as email OTP,
address lookup or an offer). Rules LendAPI enforces, and LendMCP checks before sending:
| Rule | Detail |
|---|---|
| A row holds 1–3 elements | Two fields side by side are one row with two elements |
| A control or a widget takes a whole row | Put it in a row of its own |
| One widget per page | google_place_widget may repeat, but then no other widget |
| A variable appears once per page | Fields and checkbox controls both count |
| No document upload on the first step | Ask for documents on a later page |
| Variables exist and fit | A slider needs a numeric variable, a dropdown or bubble list a list variable, a checkbox control a boolean, date rules a date variable, length rules a string; a pattern (regex) fits any type |
| References stay on the page | show_when, must_match, a variable min / max and relative_to name a field on the same page; a field from an earlier page is accepted with a warning |
| Titles are unique per product | Case-insensitive |
| Widgets are available | products_get_catalog(include=["widgets"]) shows available and reason |
Updating a page replaces its whole content: read it with products_pages_get, change what you
need, and send it back whole. Elements that still exist keep their ids.
22. Routing
Each page has a step configuration: where the applicant goes next, which decision tree and
integrations run when they continue, and the stage the application moves to.
next_step | Meaning |
|---|---|
{"type": "tab", "tab_id": 502} | Go to that page |
{"type": "complete"} | The application is complete |
{"type": "unmapped"} | No next step |
{"type": "by_outcome", "map": {"41": 503, "42": 0}} | Route on the decision tree's outcome; a value is a page, 0 (complete), -1 (unmapped) or -99 (trigger product) |
- A page with a
decision_tree_idroutes by outcome, keyed by that tree's outcome ids
(products_get_catalog(include=["decision_trees"])). An outcome left out of the map stops the
applicant there, and the result warns about it. - A review page has no tree, integrations or next step, and is never the first step.
- The first step cannot also complete the application.
- Pages are named by
tab_id. Anywhere a tab id is taken you may write"page:<title>"; inside
products_pages_applya page being created in the same call is reached with"tab_key". products_pages_set_routingis a patch: only the keys you send change, andnullclears one.
23. Confirmation
Some writes bypass publish or reach beyond the product you are editing. Without confirm=true,
LendAPI changes nothing and LendMCP returns:
{
"object": "confirmation_required",
"requires_confirmation": true,
"message": "2 applications are in flight on the live version.",
"impact": {"in_flight_applications": 2, "draft_has_changes": false},
"next_steps": ["Show the user the impact and re-run with confirm=true only after they agree."]
}Stop, show the impact to whoever owns the product, and re-run with confirm=true only after they
agree.
| Write | Asks for confirmation when | impact |
|---|---|---|
products_publish with is_default=true | Applications are in flight | in_flight_applications, version_live_before, version_live_after |
products_set_live_version | Applications are in flight, or the draft has unpublished changes (they are kept as a stale version) | in_flight_applications, draft_has_changes |
products_scripts_enable | Always: the script runs on the live page at once | placement, code_sha256 |
themes_update | Other products use the theme, or it is the tenant's Default | products_using |
products_pages_remove | Other pages route to it and you gave no reroute_to | routed_from |
products_restore_draft | The draft has unpublished changes | draft_has_changes |
products_set_active with active=false | Applications are in flight | in_flight_applications |
24. Environment
Build a new product on a Sandbox connection first, and read environment in every result.
One limit applies today: variables, outcomes and decision trees can only be authored on Live, so
a build that also creates its decision tree runs on Live. Pages and routing still
wait for publish, so nothing reaches applicants until you publish, set a version live and open the
product.
25. What LendMCP never does to a product
- Hard-delete a page.
products_pages_removedeactivates it. - Remove pages as part of a publish. Publish takes the draft as it is.
- Unmask a variable. A page save may mask one, never unmask it; the result lists any change.
- Rewrite a list variable's options.
- Delete a theme or a product. Close a product with
products_set_active(active=false). - Write another product's pages.
multi_applicant_productonly sets the link. - Enable a custom script without your confirmation.
26. Product Studio failure modes
| Failure | Cause | Fix |
|---|---|---|
Unknown variables: ... | A field or reference names a variable the tenant does not have | variables_create_simple, or fix the engine name |
... needs a numeric variable; 'x' is string | The input style or rule does not fit the variable's type | Change the style or rule, or use a variable of the right type |
a control takes a whole row / a widget takes a whole row | A control or widget shares a row | Give it its own row |
A page holds one widget | Two widgets on one page | Split the page |
A page titled ... already exists | Titles are unique per product | Update that page, or pick another title |
next_step.map has outcomes that are not this tree's | The map keys come from another tree | Read the tree's outcomes from products_get_catalog |
A page with decision_tree_id routes by outcome | A tree is set but next_step is a single page | Use a by_outcome map |
Unknown page '...' | A "page:<title>" that matches no page | Check the titles with products_pages_list |
Publish refused: the draft has N error(s) | products_validate found errors | Fix each on its page (tab_id), validate, publish again |
stale_version | That version was archived | Pick a current version from products_list_versions |
Disable the script before changing its code | Live code changes only through the enable step | Disable, change, enable again |
Assigned product not found from decision_trees_save_metadata | The product is not active | products_set_active(active=true), then retry |
See also
Updated about 14 hours ago

