# Lendtrain Agent API

Use these server-side APIs to help a borrower explore refinancing.
You do not need an API key. Estimates are not loan approvals, rate locks, or commitments to lend.

Atlantic Home Mortgage, LLC dba Lendtrain. NMLS #1844873. Equal Housing Opportunity.

## Choose a route

- `POST https://www.lendtrain.com/api/agents/quote`: structured JSON pricing for a known scenario.
- `POST https://www.lendtrain.com/api/chat`: conversational guidance with OpenAI Luna.
- [OpenAPI schemas](https://www.lendtrain.com/openapi.json)
- [Examples and integration guide](https://www.lendtrain.com/agents)

These are custom HTTP APIs. They do not implement A2A task methods or expose a public MCP transport.
Use these routes for borrower-facing quotes. Do not bypass product filtering through the internal pricer.
The optional Claude Code plugin has a separate [installation guide](https://www.lendtrain.com/docs).

## Structured quote

Send `Content-Type: application/json`. Include every field in this example.
Use null for unknown current-loan details.

```json
{
  "state": "GA",
  "loanBalance": 340000,
  "propertyValue": 500000,
  "creditScore": 740,
  "occupancy": "primary",
  "propertyType": "singleFamily",
  "units": 1,
  "loanPurpose": "rateTermRefi",
  "cashOutAmount": 0,
  "loanTerm": 30,
  "currentLoanType": "conventional",
  "isVeteran": false,
  "currentRate": null,
  "currentMonthlyPayment": null,
  "remainingTermMonths": null,
  "currentMonthlyMip": null,
  "vaFundingFeeType": null
}
```

Supported states: AL, FL, GA, KY, NC, OR, SC, TN, TX, UT.
The OpenAPI schema lists supported terms, property types, and other field values.
Unknown fields and invalid types cause a 400 response.

The response contains:

- `status`: `quoted` or `no_eligible_products`.
- `products`: Conventional and, when explicitly permitted, VA results.
- `recommendedProduct`: an eligible returned product or null.
- `effectiveDate`, `effectiveTime`, `calculatedAt`: source pricing timestamps.
- `savingsAvailable`: whether the request includes all comparison inputs.
- `assumptions`, `notices`, `disclosure`: context that must accompany the estimate.
- `nextStep`: the secure application link and borrower-action requirement.

Only display products with `eligible: true`.
An ineligible result is not a service failure or a loan denial.
The API does not invent a replacement recommendation when the source recommendation points to a removed product.

## Product and pricing rules

Lendtrain does not offer FHA products. An existing FHA loan may receive a Conventional refinance estimate.
VA requires `isVeteran: true` and a confirmed `vaFundingFeeType`: `firstTime`, `subsequent`, or `exempt`.
Never infer VA eligibility or a fee exemption from a current VA loan.
VA rate-and-term pricing from a non-VA or unknown current loan needs loan officer review.

Positive `points` and `dollarAmount` show borrower fees to lower the rate.
Negative values are lender credits toward closing costs, not cash proceeds.
Use `borrowerPaidPoints` and `lenderCredit`, expressed in dollars, to avoid sign confusion.
Display APR with equal prominence to the rate.
Closing costs and savings refer to `parRate`. Other options change points costs and credits.
Do not infer free closing costs, skipped payments, or net cash proceeds from a lender credit.

Savings require current rate, principal-and-interest payment, remaining term, and monthly mortgage insurance.
The API omits savings when any comparison input is unknown.
Cash-out quotes omit savings verdicts. The base loan amount uses balance plus requested cash. VA results separately disclose financed funding fees and total loan amount.
Final loan sizing can change net proceeds. Preserve the returned assumptions.

## Conversation

```json
{
  "stream": false,
  "messages": [{"role": "user", "content": "What details do you need for a refinance estimate?"}]
}
```

With `stream: false`, the JSON response contains `role`, `content`, and `quotes`.
Use `quotes` for numeric comparisons. Do not extract numbers from prose when structured results are available.
For VA pricing, the caller must also set `vaEligibilityConfirmed: true` after the borrower confirms eligibility.
The model cannot grant itself this permission.

When `stream` is absent or true, the response uses Server-Sent Events:

```text
: processing

data: {"text":"Final assistant answer and disclosures"}

data: [DONE]
```

Ignore colon-prefixed comments. Concatenate `text` fields until `[DONE]`.
The server buffers the answer until completion and excludes tool output and model reasoning from the stream.
A stream error contains `error` and `code` before `[DONE]`.
A 200 HTTP status or `[DONE]` alone does not establish that pricing succeeded.

Send conversation history each time. Use only `user` and `assistant` roles.
The server removes leading assistant messages. Include at least one user message.
Limits: 1–50 messages, 1–10,000 characters per message, 100 KB total body.
Do not include SSN, DOB, bank accounts, or passwords in any message.
The API rejects detected SSN and DOB patterns across the full history.

## Timeouts and errors

- Quote upstream timeout: 15 seconds.
- Chat deadline: 90 seconds.
- Pricing limit: 10 requests per minute per IP, shared with the site pricing route.
- Chat limit: 20 requests per minute per IP. Chat pricing calls also consume the pricing limit.

Limits use per-process counters. They are abuse controls, not capacity guarantees.
The server restricts cross-origin browser requests. Use a server-side client.
Check HTTP status and Content-Type before parsing the response.
JSON failures contain `error` and `code`.

| Status | Action |
| --- | --- |
| 400 | Correct invalid input or remove sensitive data. |
| 403 | Use an allowed origin or server-side client. |
| 413 | Reduce the body below 100 KB. |
| 429 | Wait for Retry-After, or 60 seconds for a stream error. |
| 502 / 503 / 504 | Retry later with bounded backoff. Do not substitute guessed pricing. |

## Borrower handoff

Share `nextStep.url` when the borrower wants to apply.
The borrower must complete the secure application: https://lendtrain.my1003app.com/register
These APIs do not submit applications, pull credit, lock rates, reserve products, or send emails.
Sharing the link does not submit an application.

Contact: (678) 528-0253 or team@lendtrain.com.
