Guide: Price an approved application

In this walkthrough you build a pricing engine from nothing — two rate tiers keyed on FICO —
publish it, and use it to price an application. A pricing engine (LendAPI calls it an offer
table) is a sheet: each row is a tier, condition columns are matched against the applicant's
variables, and action columns emit the offer.

You drive it in natural language. The prompts below are what you type; the tool calls noted
underneath are what your assistant runs, so you can follow along and check its work.

Before you start

  • The variables the engine reads and writes should exist. This guide creates them in step 1.
  • Know which outcome and product the engine prices for — outcomes_list and products_list
    will show you.

Step 1 — Create the variables the columns map

Create numeric variables fico_score ("FICO Score"), apr ("APR") and loan_term
("Loan Term, months").

Tool: variables_create_simple, once per variable

A pricing engine maps every column to a variable by its engine_name. fico_score will be the
input the engine matches on; apr and loan_term are the outputs the offer carries. If
you already have them, variables_list is enough.

Step 2 — Create the engine

Create a parent pricing engine called "Prime Personal Loan Pricing", described as
"FICO-tiered rate card".

Tool: pricing_engines_create with name, type="parent", description

The response carries two ids, and they are not interchangeable:

  • id — the integer key. This is what attaches the engine to a decision tree.
  • session — the UUID every other pricing_engines_* tool takes.

A parent engine prices applications on its own. A child engine is one a parent chains to for
a second product or tier; you would create it the same way with type="child".

The new engine prices nothing yet: no columns, no rows, no outcome, no version.

Step 3 — Save the table

Give it one condition column on fico_score (operator >=, header "fico"), action columns on
apr and loan_term, and two rows: FICO 720 → 9.99% for 36 months, FICO 640 → 14.99% for 36
months.

Tool: pricing_engines_save_table with columns and rows

Each column says what it does and which variable it maps:

Column typeMeaningOperator
conditionMatched against an input variableRequired: range, =, in, >, >=, <, <=
actionEmits an output (offer) variable—
derivedComputes a value from the other cells of the row—

Rows are cell values in column order. With >=, a row matches when the applicant's value is at
or above the cell, and the first matching row wins — so order tiers from best to worst.

pricing_engines_save_table replaces the whole sheet: always send every column and every row
you want to keep. Your assistant checks the shape locally first, so a row with the wrong number
of cells never reaches LendAPI.

Step 4 — Attach the outcome and the product

Attach the "Approve" outcome and the "Personal Loan" product to it.

Tools: outcomes_list, products_list, then pricing_engines_save_metadata with
assignment_ids and product_ids

This is what makes the engine usable at runtime. An engine prices applications only when it is
published, active, has a default version, and is tied to a product and an outcome — or is chained
from a parent engine as its child.

Only the fields you mention change; everything else is left alone. If an id is wrong you get one
deliberately generic message, "Cannot access the requested resource at this moment." — re-list
the outcomes or products and compare.

Step 5 — Test the draft before publishing

Test it with a FICO of 700.

Tool: pricing_engines_test with params={"fico_score": 700}

You get the row that matched — here the 640 tier, 14.99% for 36 months. Nothing is written: no
version, no offer, no application touched.

This prices the draft, which is the point: you can iterate on pricing_engines_save_table
and re-test until the tiers behave, without publishing anything. If the wrong row matches, look
at the operator and the tier order.

Step 6 — Publish it

Publish it as version 1 and make it the default.

Tool: pricing_engines_publish with description and set_default=true

The draft becomes OfferTableVersion 1, and the first version also marks the engine published.

Watch set_default. Publish with set_default=false and the version is created, but the
draft is then restored from the current default version — replacing the edits you just
snapshotted. That mirrors the studio. Pass true unless you are deliberately staging a version
for later, in which case promote it afterwards with pricing_engines_set_default_version.

If you get "No new changes detected", the draft already matches the default version — there is
nothing to publish.

Step 7 — Price with the published version

What offers does it return for a FICO of 750?

Tools: pricing_engines_list_versions, pricing_engines_get_required_params, then
pricing_engines_run

pricing_engines_run evaluates the published version and returns the candidate offers, keyed by
the output variables' engine names. An engine can return zero, one, or several rows.

This is still an evaluation, not an offer. To put one on an application:

Create a manual offer on application <app_session> with 9.99% APR over 36 months.

Tool: app_create_manual_offer

Step 8 — Wire it into a decision tree

Attach pricing engine <id> to my "Personal Loan Underwriting" tree.

Tool: decision_trees_save_metadata with pricing_engine_id=<id>

Use the integer id from pricing_engines_list, not the session UUID. From then on the tree
prices approved applications through this engine automatically — no pricing_engines_run needed.

Changing a live engine

  • Edit safely. pricing_engines_save_table and pricing_engines_save_metadata only touch
    the draft. The default version keeps pricing until you publish and promote.
  • Roll back. pricing_engines_set_default_version promotes any earlier version. It also
    copies that version back onto the draft, so unpublished edits are replaced.
  • Take it out of production. pricing_engines_toggle_active with active=false deactivates
    the engine and clears published, so it stops pricing immediately. Re-activating does not
    re-publish it — publish again.

If something goes wrong

SymptomLook at
"Unknown variable engine names"The column maps a variable that is not yours — check variables_list
A row is rejected before the callEvery row needs exactly one cell per column
"This pricing engine has no table yet"Save columns and rows before testing or publishing
"Derived expressions are not valid"A derived cell may only reference variables this sheet maps
"No new changes detected"The draft already matches the default version
"Missing required input variables"Add them to params — pricing_engines_get lists the condition columns
The engine returns no offer at runtimeIt must be published, active, have a default version, and be tied to a product and an outcome

Full list: tool reference and
troubleshooting.


Did this page help you?