Guide: Set up a loan agreement

From an empty Contract Builder to a signed contract: author a template, publish it, generate the
document for one applicant, and send it for signature.

The through-line is that nothing reaches an applicant by accident. A template is used at
runtime only when four things are true at once — it is published, it is active, it has a default
version, and the application's product and outcome match the ones it is attached to. Everything
below is arranged so you can get each of those right before the last one flips it on.

Before you start

  • The outcome the contract belongs to must already exist. Contracts hang off outcomes, not
    the other way round — see Build a decision workflow.
  • The products the agreement covers.
  • Any variables the wording needs ({{loan_amount}}, {{apr}}, …). Create missing ones with
    variables_create_simple before you write the body.
  • A Live connection if you intend to generate or send a real contract.

The prompts below are what you type. The tool noted underneath each is what your assistant runs.


Step 1 — See what already exists

Show me our contract templates.

Tool: contracts_list

You get one row per template with its session (the id every other contract tool takes), format,
whether it is published and active, and which version is the default. If something close already
exists, clone it rather than starting over.

Show me the loan agreement template.

Tool: contracts_get

This returns the body, the products and outcomes it is attached to, the signer configuration, the
variables the body references, and the editor's warnings. Read the warnings — they are what
stands between you and a contract that renders wrong.


Step 2 — Create or clone the template

Create a contract template called "Personal Loan Agreement".

Tool: contracts_create

It starts empty, unpublished, with primary_signer configured. Nothing can reach an applicant
yet. HTML is the default format; rich_text is the alternative, and pdf builds the template
from a PDF you already use (see Starting from a PDF).

Starting from something that works is usually better:

Clone "Personal Loan Agreement" as "Personal Loan Agreement — CA".

Tool: contracts_clone

A published template is cloned from the version that actually runs, so you copy what applicants
receive rather than a half-finished draft.

Starting from a PDF

Here is our closing-instructions letter (a filled-in example). Turn it into a PDF contract
template, with each per-loan value filled from a variable.

Tools: contracts_create, contracts_pick_pdf, contracts_upload_pdf, contracts_map_pdf_fields

First the file has to reach the template. In claude.ai and Claude Desktop your assistant opens an
upload panel (contracts_pick_pdf): drop the PDF there and it goes straight to LendAPI — not
through the chat — and the panel tells the assistant when it is attached. Elsewhere, upload the
PDF in the Contract Builder, or (Claude Code, scripts) use the curl command the tool returns.

Then your assistant reads the PDF, lists each per-loan value ("Karen Ferguson", "2279-2377",
"2,129.00"), and passes them as replacements with the variable each one should show. LendAPI
deletes those values from the page — they do not linger in the file under a white box — and puts
a form field where each one was, sized so the application's value prints at the same position and
size. Everything else on the page is untouched.

Two things to check before publishing:

  • A PDF template needs at least one signature, initial or date box mapped to a signer; add one
    with contracts_map_pdf_fields if the document has none.
  • A value printed as several short pieces on one line (first, middle and last name) keeps the
    sample's spacing. If one variable holds the whole phrase, replace the phrase instead.

A PDF that already has form fields needs no replacements: upload it and map its fields.


Step 3 — Write the body and attach it

Set the body of the template, attach it to the Personal Loan product and the Approved outcome,
and use Letter page size.

Tool: contracts_update

Three things about this call are worth knowing.

It is partial. Only what you ask for changes. Fields this tool does not model — PDF field
mappings, DocuSign configuration, in-person signing — are left alone, so a wording change cannot
quietly undo someone's work in the portal.

Placeholders are checked before anything is written. Every {{name}} in the body is matched
against your tenant's variables first. A placeholder with no variable behind it does not error at
generation time; it renders as nothing, leaving a blank where an amount should be. The check
turns that into a refusal you can act on.

Signing blocks are not variables. {{primary_signer}} and {{co_signer_1}} are where the
signature boxes go. Each signer role you configure needs its matching block in the body, and each
block needs its role configured — contracts_get reports both mismatches under warnings.

Show me the template again.

Tool: contracts_get

Publish only when warnings is empty.


Step 4 — Publish a version

Publish this template as version 1, described as "initial agreement".

Tool: contracts_publish

A version is immutable — it is what gets generated for applicants, frozen. The first version you
publish becomes the default automatically. Later ones do not unless you say so, which is what
lets you prepare a revision without changing what people are receiving today.

Publishing is refused when another published template already covers the same product and
outcome. That is the rule that keeps contract selection unambiguous at runtime: detach one of
them with contracts_update before publishing the other.

What versions does this template have?

Tool: contracts_list_versions

Make version 2 the default.

Tool: contracts_set_default_version

This is also how you roll back: point at the older number. Contracts already generated keep the
version they were generated from — nothing already in an applicant's hands changes.

To take a template out of service entirely:

Deactivate the old loan agreement template.

Tool: contracts_toggle_active

Check afterwards that every product and outcome you care about is still covered by something
active. If it was the only template for a pair, those applications now get no contract at all.


Step 5 — Generate the contract for an applicant

What would the contract variables come out as for application <session-uuid>?

Tool: app_compute_contract_variables

Pass the variables_used list from contracts_get. This computes what the agreement would say
without creating anything, and overrides lets you try a different figure first. PII values are
never returned, whatever you ask for.

Generate a draft contract for that application from the Personal Loan Agreement.

Tool: app_generate_contract with action="draft"

A draft is editable and invisible to the applicant. There is at most one per contract slot, so
regenerating a draft updates it in place rather than piling up documents.

Generate the final document.

Tool: app_generate_contract with action="generate"

This produces a real document for a real person. The wording always comes from the published
version — you never supply contract text here, so what is generated is what was reviewed and
published. Each generate adds a version and never rewrites a previous one, so a blind retry
leaves two documents behind; if a call seems to have failed, check app_list_contracts before
trying again.

Show me the contracts on this application.

Tool: app_list_contracts

Slots, versions, statuses (Draft, Generated, Not Signed, Signed, Uploaded), when each
was sent and signed, and which template version it came from. No contract bodies — those contain
applicant PII.

Give me a link to the generated contract.

Tool: app_get_contract_download_url

A pre-signed URL that expires in about an hour. Hand it over immediately, do not store or share
it, and do not ask the assistant to read the document back to you.


Step 6 — Send it for signature

Send the contract for signature using the "Sign your agreement" email template.

Tool: app_send_contract_for_signature

This emails a real applicant and cannot be unsent. Have a person confirm the document and the
recipient first — app_get_contract_download_url is how you look at it. Calling it twice emails
them twice.

The email template should contain {{co_signer_url}}; without it the recipient gets a message
with no signing link. contracts_get flags a recipient template missing it under
warnings.email_variable.

Then watch the version move from Not Signed to Signed with app_list_contracts.


What is not here

Uploading a manually signed contract, discovering DocuSign templates, configuring in-person signing, and state-based sub-tenant
overrides are all done in the Contract Builder portal. LendMCP reads, generates and sends the
contracts those produce, but does not configure them.


See also


Did this page help you?