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.

RuleDetail
Lowercase onlyUppercase letters are rejected
No leading digitMust start with a letter or underscore
Allowed charactersLetters, numbers, underscore
Pattern^[a-z_][a-z0-9_]*$
Max length60 characters
Not a reserved wordExpression keywords and math function names are blocked
Unique per tenantDuplicates 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

TypeNameNotes
1NumericThe only type allowed on both sides of a variable-to-variable comparison
2String
3Boolean
6ListRequires list_values: an array of {"value": ..., "displayValue": ...} objects

Notes:

  • Simple variables are created with variables_create_simple; derived (computed)
    variables with variables_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 to 0 in 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_values must be an array (not an object), every entry must have both
    value and displayValue, 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 field must 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 type 1. 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:

FieldWhat it isExample
Status change (action_id)The application status transition this node triggers1 (Approve)
Outcome (assignment_id)The specific outcome record that labels this decision7 (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_id on 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_id instead of assignment_id. The chained tree must already be published and
    active.

Valid action types

IDNameUse
1ApproveStandard approval
2DeclineStandard decline
3ReviewManual review / referral
5Request DocsDocument 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 typeCodePurpose
Rule1Decision point with a boolean condition; branches yes/no
Action2Terminal node that assigns an outcome
Edge directionMeaning
"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:

  1. There is at least one rule node.
  2. Every rule node has a condition expression with at least one rule.
  3. Every action node has both a status change (action_id) and an outcome
    (assignment_id) — or a chained decision tree instead of the outcome.
  4. Every leaf node is an action node. A rule node cannot be a leaf.
  5. 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

StepToolResult
1decision_trees_createSession UUID + one initial rule node
2decision_trees_add_nodeA node ID; repeat per node
3decision_trees_connect_nodesEdges, with yes/no direction
4decision_trees_update_rule_node / decision_trees_update_action_nodeEach node configured
5decision_trees_save_metadataTitle, product, pricing, run-all-nodes saved
6decision_trees_submit_versionA version, status Pending Approval
7decision_trees_set_default_versionThat version becomes the one that runs
8decision_trees_get_required_paramsThe inputs a run needs
9decision_trees_runThe 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

StatusMeaning
0Draft
1Pending Approval
2Approved
3Declined

Running

  • params is a map of engine_name to value, and it must cover every required variable. Get the
    list from decision_trees_get_required_params.
  • Omit version to run the default version.
  • When run_all_nodes is enabled on the version, the run result also includes
    failed_outcomes — the outcomes on paths that did not match.

9. Common failure modes

FailureCauseWhat to do
engine_name rejectedUppercase, leading digit, reserved word, or duplicateRename and retry
list_values is required for type 6List variable created without valuesSupply the array, with value and displayValue on each entry
Variable not found in a ruleThe variable does not exist, is inactive, or its integration partner is not enabledCheck 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 comparisonCompare against a constant, or make both variables numeric
Rule node options must include at least one ruleEmpty rule expressionAdd at least one condition
"Assignment not found"The outcome ID does not exist for this tenantCreate the outcome first, or list outcomes to get a valid ID
Either assignment_id or chain_decision_id is requiredAction node has no destinationSupply an outcome, or a chained tree
"Chain decision tree not found or not published"Chained tree is unpublished or inactivePublish 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 childrenWalk the tree against section 7
"Tree is invalid"No rule node, or a broken structureConfirm the tree has a rule root and all nodes are connected
"No New changes Detected"The draft is identical to the current versionNo action needed
Run fails, missing paramsNot every required variable was suppliedCall decision_trees_get_required_params and fill them all in
Run fails, no default versionThe workflow was never publishedSubmit a version, then set it as default
variables_create_derived fails on a sandbox connectionDerived 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 type or at data.type; both are read, type first.
  • A node's configuration is data (with config merged over it, if present).
  • Edges are directed: source -> target.
  • start_node_id is where a run begins. It should be the trigger node.
  • Every branch must finish on an end node. 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

TypeAliasesWhat it doesRequired configuration
triggerstart, application-triggerEntry point, one per flow—
ruleRuns a Rules Studio decision treeselectedRuleId — the tree's numeric workflow id
pricing_enginepricing-engine, pricingRuns an offer tableselectedPricingEngineId — the offer table id
integrationCalls an integration endpointselectedIntegrationId — a provider_type_id
emailSends an email templateselectedActionId — the template id
smsSends an SMS templateselectedActionId — the template id
decisionBranches 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 nodeIts condition
conditionEvaluates a rule-builder query and routes by the condition-approve / condition-decline handlescondition
delaySuspends the run and resumes on a timerwaitFor {unit, value}
parallelRuns every outgoing branch concurrently—
loopRepeats a branch until its condition holds or it times outIts condition and limit
send_webhooksend-webhookSends an HTTP request to a configured webhookIts webhook settings
wait_webhookwait-webhookSuspends the run until an inbound webhook arrives or it times outIts webhook settings
actionCanvas module node: runs as its data.moduleId (email, sms, integration, delay, send/wait webhook); any other module passes straight throughmoduleId
endTerminal nodeoutputVariables 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 rule node runs a published decision tree by its workflow_id — the same tree you built
    with the decision_trees_* tools. The tree must be published and have a default version.
  • A pricing_engine node runs an offer table. It must be published and active, with a default
    version.
  • Outcomes route the graph. A rule node'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
    outcomeId of 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_draft updates 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_publish runs the same checks as flows_validate and
    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_run executes default_version. Publishing a version does not make it the one that
    runs: pass set_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=true re-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_active takes an explicit boolean, so a repeated
    call is a no-op rather than a flip back.
Flow / version statusMeaning
0 DraftNever published
1 TestedA test run has passed
2 PublishedPublished; the flow has at least one published version

14. Triggers, and what a run creates

trigger_typeStarted byApplication
1 APIA direct call to the flow's run endpointThe run creates a new application
2 ApplicationA call naming an existing applicationThe 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_runflows_test_run
VersionAlways default_versionAny version, including the draft
ApplicationReal: created, or the one you nameA throwaway test application
TraceNoYes — per node, with timings
Integrations, email, SMSReally runReally 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_delay ends the wait and runs the rest of the flow now — every node downstream
    of the delay, at once.
  • flows_suspend stops the run. It does not resume on its own afterwards; a human, or
    flows_rerun, has to restart it.
  • flows_rerun runs 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

FailureCauseFix
Flow is not active.The flow is switched offflows_toggle_active with active=true
No versions configured for this flow.Nothing publishedflows_save_draft, flows_validate, flows_publish
app_id or app_session is required for application trigger flowsAn application-trigger flow was run with no applicationPass app_session
Validation failed; the version was not published.The graph failed validationRead validation.errors, fix the graph, publish again
Branch ending at "…" must finish on an end node.A branch stops shortAdd an end node, or an edge to one
Flow is already processing.A run or a delayed resume is still in flightWait, then check flows_get_execution_path
Invalid workflow ID / Invalid offer table IDA node references something that does not exist for your tenantConfirm with flows_get_node_variables before saving the graph
Integration not found or not active for this tenant.The integration is not enabledEnable 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 applicationPass flow_id
A node runs but does nothingIts reference id is missing from dataCheck 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 changeIt reaches applicantsResult says
Pages, routing, page order, removed pagesWhen a version is published and made livetakes_effect: on_publish
A publish without is_defaultWhen you set that version liveon_set_live
Settings, the product name, opening or closing it, the live version, theme assignment and theme editsImmediatelyimmediately
A custom scriptWhen it is enabledwhen_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_overview shows 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:

RuleDetail
A row holds 1–3 elementsTwo fields side by side are one row with two elements
A control or a widget takes a whole rowPut it in a row of its own
One widget per pagegoogle_place_widget may repeat, but then no other widget
A variable appears once per pageFields and checkbox controls both count
No document upload on the first stepAsk for documents on a later page
Variables exist and fitA 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 pageshow_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 productCase-insensitive
Widgets are availableproducts_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_stepMeaning
{"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_id routes 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_apply a page being created in the same call is reached with "tab_key".
  • products_pages_set_routing is a patch: only the keys you send change, and null clears 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.

WriteAsks for confirmation whenimpact
products_publish with is_default=trueApplications are in flightin_flight_applications, version_live_before, version_live_after
products_set_live_versionApplications are in flight, or the draft has unpublished changes (they are kept as a stale version)in_flight_applications, draft_has_changes
products_scripts_enableAlways: the script runs on the live page at onceplacement, code_sha256
themes_updateOther products use the theme, or it is the tenant's Defaultproducts_using
products_pages_removeOther pages route to it and you gave no reroute_torouted_from
products_restore_draftThe draft has unpublished changesdraft_has_changes
products_set_active with active=falseApplications are in flightin_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_remove deactivates 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_product only sets the link.
  • Enable a custom script without your confirmation.

26. Product Studio failure modes

FailureCauseFix
Unknown variables: ...A field or reference names a variable the tenant does not havevariables_create_simple, or fix the engine name
... needs a numeric variable; 'x' is stringThe input style or rule does not fit the variable's typeChange the style or rule, or use a variable of the right type
a control takes a whole row / a widget takes a whole rowA control or widget shares a rowGive it its own row
A page holds one widgetTwo widgets on one pageSplit the page
A page titled ... already existsTitles are unique per productUpdate that page, or pick another title
next_step.map has outcomes that are not this tree'sThe map keys come from another treeRead the tree's outcomes from products_get_catalog
A page with decision_tree_id routes by outcomeA tree is set but next_step is a single pageUse a by_outcome map
Unknown page '...'A "page:<title>" that matches no pageCheck the titles with products_pages_list
Publish refused: the draft has N error(s)products_validate found errorsFix each on its page (tab_id), validate, publish again
stale_versionThat version was archivedPick a current version from products_list_versions
Disable the script before changing its codeLive code changes only through the enable stepDisable, change, enable again
Assigned product not found from decision_trees_save_metadataThe product is not activeproducts_set_active(active=true), then retry

See also


Did this page help you?