> For the complete documentation index, see [llms.txt](https://lendxyz.gitbook.io/lend/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lendxyz.gitbook.io/lend/reference/api-reference.md). Agents can also search and read this documentation through its [MCP server](https://lendxyz.gitbook.io/lend/~gitbook/mcp).

# API reference

The Lend API is the read/write surface behind the [Lend App](https://app.lend.xyz). This page documents the **user-facing** endpoints: everything the app itself calls on your behalf, plus the read-only endpoints open to integrators.

{% hint style="warning" %}
Administrative and partner-only endpoints — anything that produces a backend signature, mints on behalf of a user, or writes identity records — are deliberately not documented here. If you are building an integration that needs them, get in touch.
{% endhint %}

## Base URLs

| Environment | REST                              | WebSocket                          |
| ----------- | --------------------------------- | ---------------------------------- |
| Production  | `https://api.lend.xyz/v1`         | `wss://api.lend.xyz/v1/ws`         |
| Staging     | `https://api-staging.lend.xyz/v1` | `wss://api-staging.lend.xyz/v1/ws` |

`GET /` returns a health payload: the environment name, whether it is a testnet deployment, and the database and cache status. Live status is at [status.lend.xyz](https://status.lend.xyz).

## Response envelope

Every response uses the same wrapper:

```json
{
  "status": "success",
  "data": { }
}
```

On failure, `data` is `null` and `error` carries the reason:

```json
{
  "status": "failed",
  "data": null,
  "error": "Invalid token"
}
```

| HTTP | `status`       | Meaning                                 |
| ---- | -------------- | --------------------------------------- |
| 200  | `success`      | —                                       |
| 400  | `failed`       | Malformed body, failed validation       |
| 401  | `unauthorized` | Missing, expired or invalid credentials |
| 404  | `not found`    | No such route, or no such resource      |
| 500  | `error`        | Server-side failure                     |

Cached responses carry standard `Cache-Control` and `Age` headers, so a conditional client can avoid re-fetching a list that has not moved.

## Pagination

Paginated routes take the page as a **path segment**, not a query parameter, and pages are 1-based. Omitting it returns page 1.

```
GET /operations          →  page 1
GET /operations/3        →  page 3
```

## Authentication

Three distinct mechanisms, and it matters which one a route uses.

### User authentication — `Authorization: Bearer <jwt>`

The JWT is obtained by signing a [SIWE](https://eips.ethereum.org/EIPS/eip-4361) message with the wallet:

1. `POST /auth/message` with your address → returns the message and its nonce.
2. Sign the message with the wallet. Both EVM and Stellar signatures are accepted.
3. `POST /auth/verify` with the address, the message and the signature → returns a JWT.
4. `GET /auth/refresh` with the JWT → returns a fresh one.

The token carries the canonical address; every `/users/*` route resolves the caller from it, which is why none of them takes an address parameter.

Advisors acting for a client add `X-Client-Address: <client address>`. The relation must exist and be active, otherwise the request is rejected — an advisor cannot read an account that has not accepted their invite.

### App gate — `X-Internal-Token`

Most routes are served to the app's own backend and require an internal token issued by Lend. This is a gate, not an identity: it says *the Lend front end is asking*, it says nothing about which user. Routes marked **App** below need it in addition to any user token.

### API key — `Authorization: <uuid>`

Partner integrations authenticate with an API key and are rate-limited. Those endpoints are out of scope for this page.

***

## Operations

Everything about the projects themselves. All **App**-gated, no user token needed.

| Method | Path                                       | Description                                                        |
| ------ | ------------------------------------------ | ------------------------------------------------------------------ |
| `GET`  | `/operations/` `/operations/{page}`        | Paginated list of published, public operations.                    |
| `GET`  | `/operations/id/{id}`                      | One operation by its UUID.                                         |
| `GET`  | `/operations/name/{slug}`                  | One operation by its slug.                                         |
| `GET`  | `/operations/fopid/{op_id}`                | One operation by its on-chain factory id.                          |
| `GET`  | `/operations/user_ops/{address}` `/{page}` | Operations a given address has invested in.                        |
| `GET`  | `/operations/updates/{op_id}` `/{page}`    | Project updates published for an operation.                        |
| `GET`  | `/operations/supply/{op_id}`               | Total opLend supply per chain: `[{ op_token, chain_id, supply }]`. |
| `GET`  | `/operations/incentives/`                  | All APR incentives.                                                |
| `GET`  | `/operations/incentives/{op_id}`           | Incentives for one operation.                                      |
| `GET`  | `/operations/contract_templates/{op_id}`   | Contract templates attached to an operation.                       |
| `GET`  | `/operations/restitution_metadata/{op_id}` | Redemption terms for a finished operation.                         |

### The operation object

The main fields returned by the endpoints above:

| Field                                                                               | Type           | Notes                                                                                                                |
| ----------------------------------------------------------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------- |
| `id`, `slug`, `title`, `description`                                                | string         | `slug` is the stable public identifier                                                                               |
| `factory_op_id`                                                                     | int            | The operation id on the Factory contract                                                                             |
| `category`                                                                          | enum           | `LONG_TERM_RENTAL`, `SHORT_TERM_RENTAL`, `FLIP_OPERATION`, `PROPERTY_REDEVELOPMENT`, `BOND_FINANCING`, `NO_CATEGORY` |
| `funding_status`                                                                    | enum           | `upcoming`, `predeposit`, `open`, `paused`, `finished`, `closed`, `redemption`, `canceled`                           |
| `payout_interval`                                                                   | enum           | `weekly`, `monthly`, `quarterly`, `yearly`                                                                           |
| `apr`, `real_apr`, `target_apr`                                                     | number         | Advertised, realised, and target yield                                                                               |
| `funding_goal`, `total_shares`, `shares_sold`, `funding_participants`               | string / int   | Primary-market progress                                                                                              |
| `stellar_shares`, `stellar_shares_sold`                                             | string         | The Soroban share of the same operation                                                                              |
| `shares_restitued`                                                                  | string         | Shares already redeemed                                                                                              |
| `trading_price`, `accumulated_revenues`                                             | string         | Secondary-market price and revenue to date                                                                           |
| `supported_chains`                                                                  | array          | `[{ op_token, chain_id, lz_endpoint_id, primary }]`                                                                  |
| `project_start`, `project_end`, `revenues_start`, `estimated_revenues_start`        | timestamp      | Operation timeline                                                                                                   |
| `address`, `region`, `country`, `postcode`                                          | string         | Where the asset is                                                                                                   |
| `banner_image`, `images`, `documents`, `roadmap`, `financial_cost`, `financial_rev` | array / object | Presentation and financial model                                                                                     |
| `insurance_type`                                                                    | string         | See [Guarantee & Insurance](https://lendxyz.gitbook.io/lend/fundamentals/guarantee-and-insurance.md)                 |
| `is_private`, `is_club_deal`, `published`                                           | bool           | Visibility flags                                                                                                     |

***

## Users

All require a user JWT **and** the app gate. The caller is always resolved from the token.

### Profile

| Method | Path                                | Description                                                                 |
| ------ | ----------------------------------- | --------------------------------------------------------------------------- |
| `GET`  | `/users/`                           | The authenticated user's profile.                                           |
| `POST` | `/users/update`                     | Update the profile.                                                         |
| `GET`  | `/users/is_verified/{user_address}` | Whether an address has declared its identity. **Public** — no token needed. |
| `POST` | `/users/register_mailing_list`      | Register an email to the mailing list. **Public**.                          |

The user object: `address`, `user_type` (`evm` | `soroban`), `aml_verified`, `identity_declared`, `is_company`, `is_manager`, `first_name`, `last_name`, `email`, `nationality`, `date_of_birth`, `place_of_birth`, `postal_address`, `company_id`, `company_name`, `points`, `ref_code`, `ref_code_used`.

`POST /users/update` body — the fields required before an investment can be signed:

```json
{
  "is_company": false,
  "first_name": "…",
  "last_name": "…",
  "email": "…",
  "postal_address": "…",
  "place_id": "…",
  "nationality": "FR",
  "date_of_birth": "1990-01-31",
  "place_of_birth": "…",
  "company_id": "…",
  "company_name": "…"
}
```

`nationality` is ISO 3166-1 alpha-2. `date_of_birth` and `place_of_birth` are required for individuals; `company_id` and `company_name` for companies.

### Portfolio

| Method | Path                           | Description                                                                                                            |
| ------ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `GET`  | `/users/balances`              | opLend balances per operation and chain: `[{ op_id, factory_op_id, op_slug, op_title, op_token, chain_id, balance }]`. |
| `GET`  | `/users/operations` `/{page}`  | Operations invested in, with `invested_usdc` and `shares_bought`.                                                      |
| `GET`  | `/users/stats`                 | `total_usdc_invested`, `total_projects`, `average_apy`, plus `total_rewards` per operation.                            |
| `GET`  | `/users/net_worth`             | Estimated wallet net worth.                                                                                            |
| `GET`  | `/users/activity` `/{page}`    | The user's [activity feed](https://lendxyz.gitbook.io/lend/reference/activity-events.md).                              |
| `GET`  | `/users/available_restitution` | Finished operations the user can redeem.                                                                               |

### Rewards and referral

| Method | Path                             | Description                                                                         |
| ------ | -------------------------------- | ----------------------------------------------------------------------------------- |
| `GET`  | `/users/rewards`                 | Merkle proofs for every unclaimed epoch — what you pass to `claimOpEpochs`.         |
| `GET`  | `/users/ref_rewards`             | The referral equivalent.                                                            |
| `GET`  | `/users/claim_status`            | Per-epoch claim status: `[{ factory_op_id, chain_id, max_epoch, claims: [bool] }]`. |
| `GET`  | `/users/ref_claim_status`        | `{ max_epoch, claim_details: [{ epoch, claimed }] }`.                               |
| `GET`  | `/users/rewards_graph` `/{year}` | Rewards over time, plus the available year bounds.                                  |
| `GET`  | `/users/get_ref_code`            | The user's referral code, created on first call.                                    |
| `GET`  | `/users/referees` `/{page}`      | Referred users and their volume.                                                    |

See [Referral Program](https://lendxyz.gitbook.io/lend/fundamentals/referral-program.md) and [Revenues distribution](https://lendxyz.gitbook.io/lend/fundamentals/revenues-distribution.md).

### Fiat

For investments made in fiat, where opLend is held in custody.

| Method | Path                                     | Description                                          |
| ------ | ---------------------------------------- | ---------------------------------------------------- |
| `GET`  | `/users/fiat/holdings` `/{page}`         | Fiat-side holdings.                                  |
| `GET`  | `/users/fiat/rewards`                    | `[{ factory_op_id, already_requested, claimable }]`. |
| `GET`  | `/users/fiat/request_rewards` `/{op_id}` | Request payout, for all operations or one.           |

### Signatures

These produce the proofs the contracts require. They are scoped to the authenticated user — you can only ever obtain a signature for yourself.

| Method | Path                                                  | Description                                                                                                      |
| ------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `POST` | `/users/signatures/mint-proof`                        | Body `{ op_id, amount, contract_id? }`. Returns the nonce and signature for `invest` / `predeposit`.             |
| `GET`  | `/users/signatures/transfer-proof/{op_id}/{chain_id}` | Whitelist signature for `whitelistUser` on an operation's token.                                                 |
| `POST` | `/users/signatures/request_contract_signature`        | Body `{ yousign_payload, factory_op_id, amount }`. Opens a YouSign signature request for the mandatory contract. |
| `GET`  | `/users/signatures/history/all`                       | Every contract of the user.                                                                                      |
| `GET`  | `/users/signatures/history/pending/{op_id}`           | Pending contracts for one operation, plus `{ draft_count, not_minted_count }`.                                   |

{% hint style="info" %}
A mint proof is only issued once the identity is declared and the operation's contract is signed. This is where the [compliance](https://lendxyz.gitbook.io/lend/fundamentals/compliance.md) rules are enforced — the contract itself only checks that the signature is valid.
{% endhint %}

### Advisors

For wealth advisors managing client accounts.

| Method | Path                        | Auth   | Description                                                       |
| ------ | --------------------------- | ------ | ----------------------------------------------------------------- |
| `POST` | `/users/adv/invite/get-msg` | Public | Body `{ address, email }`. Returns the invite message to sign.    |
| `POST` | `/users/adv/invite/accept`  | Public | Body `{ invite_id, message, signature }`. Accepts the mandate.    |
| `POST` | `/users/adv/create-client`  | JWT    | Body `{ email, is_keyless, address? }`. Creates a managed client. |
| `GET`  | `/users/adv/invites-sent`   | JWT    | Invites sent by the advisor.                                      |
| `GET`  | `/users/adv/status`         | JWT    | `{ is_advisor, is_client, advisor_address, available_clients }`.  |

***

## Activity

| Method | Path                                     | Description                                                                                         |
| ------ | ---------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `GET`  | `/activity/op/{id}` `/{page}`            | Activity feed for one operation.                                                                    |
| `GET`  | `/activity/points_leaderboard` `/{page}` | `[{ user_address, points }]`.                                                                       |
| `GET`  | `/activity/points_filters`               | Available point filters.                                                                            |
| `POST` | `/activity/rewards_bars`                 | Body `{ factory_op_id, interval?, page? }`. Returns `{ total_revenues, total_entries, bars_data }`. |

Event shapes are documented in [Activity events](https://lendxyz.gitbook.io/lend/reference/activity-events.md). See [Lend Points](https://lendxyz.gitbook.io/lend/fundamentals/lend-points.md) for how points are earned.

***

## DEX

The secondary market. Orders are signed limit orders; the API stores and serves the book, the chain settles the fills. See [DEX (Secondary market)](https://lendxyz.gitbook.io/lend/fundamentals/dex-secondary-market.md).

### Market data

| Method | Path                                        | Description                                                                                                                                                        |
| ------ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GET`  | `/dex/get_asset_infos/{op_id}`              | `{ trading_price, original_price, apr, real_apr, target_apr, daily_volume, total_volume, primary_sale_date }`.                                                     |
| `GET`  | `/dex/get_market_depth/{token}/{precision}` | Aggregated book: `{ precision, bids, asks }`, each level `{ price, ordersCount, totalBase, totalQuote }`.                                                          |
| `GET`  | `/dex/get_trade_history/{op_id}/{page}`     | Recent trades on an operation.                                                                                                                                     |
| `POST` | `/dex/get_bars`                             | Body `{ factory_op_id, resolution, start_time, end_time }`. OHLCV candles `{ time, open, high, low, close, volume }`.                                              |
| `POST` | `/dex/get_dex_operations`                   | Body `{ page, sort_by, sort_dir }`. Tradable operations with their market stats. `sort_by` ∈ `created_at`, `trading_price`, `apr`, `daily_volume`, `total_volume`. |

### Order book

| Method | Path                                                  | Description                                                                                                    |
| ------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `GET`  | `/dex/get_all_orders/{op_id}/{page}`                  | Every open order on an operation.                                                                              |
| `GET`  | `/dex/get_orders_by_address/{op_id}/{address}/{page}` | One address's orders.                                                                                          |
| `POST` | `/dex/get_simple_orders`                              | Body `{ factory_op_id, page, direction, sort }`. Paginated orders with a computed `price` and `computed_side`. |
| `POST` | `/dex/get_orders_at_price`                            | Body `{ token, price_target, size_target, direction, slippage }`. The orders needed to fill a limit order.     |
| `POST` | `/dex/get_orders_at_price_scaled`                     | Same, with an explicit `precision`.                                                                            |
| `POST` | `/dex/get_orders_at_market`                           | Body `{ token, size_target, direction }`. The orders needed to fill at market.                                 |

`direction` is `bid` or `ask`.

### Trading

| Method | Path                                                   | Auth | Description                                                            |
| ------ | ------------------------------------------------------ | ---- | ---------------------------------------------------------------------- |
| `POST` | `/dex/create_order`                                    | JWT  | Submits a signed limit order.                                          |
| `GET`  | `/dex/get_net_balance/{asset_address}`                 | JWT  | How much of an asset is still free, i.e. not committed to open orders. |
| `GET`  | `/dex/get_user_trade_history/{op_id}/{address}/{page}` | App  | Fills grouped by order.                                                |

`create_order` body — the signed 1inch-style limit order:

```json
{
  "factoryOpId": 12,
  "salt": "…",
  "hash": "0x…",
  "maker": "0x…",
  "receiver": "0x…",
  "makerAsset": "0x…",
  "takerAsset": "0x…",
  "makingAmount": "…",
  "takingAmount": "…",
  "makerTraits": "…",
  "r": "0x…",
  "vs": "0x…"
}
```

An order object read back also carries `order_hash`, `remainingMakingAmount`, `remainingTakingAmount` and `status` (`open`, `filled`, `cancelled`).

***

## Public integrations

Open, rate-limited, no key required.

| Method | Path                                                           | Description                                                  |
| ------ | -------------------------------------------------------------- | ------------------------------------------------------------ |
| `GET`  | `/third_party/op_lend/price_meta/{chain_id}/{op_lend_address}` | Latest oracle price for an operation token on a chain.       |
| `GET`  | `/third_party/op_lend/holdings/{user_address}`                 | Price metadata for every operation token held by an address. |
| `GET`  | `/third_party/merkl/protocol_apr`                              | Average APR per opportunity, in the shape Merkl consumes.    |
| `GET`  | `/glxe/get_user_stats/{address}`                               | Public reward stats for an address.                          |
| `GET`  | `/glxe/get_user_ref_vol/{address}`                             | `{ ref_count, ref_volume }`.                                 |

These are the values published on-chain by the [PriceOracle](https://lendxyz.gitbook.io/lend/reference/smart-contracts/evm.md#priceoracle), served over HTTP.

***

## WebSocket

Connect to `wss://api.lend.xyz/v1/ws` and subscribe by sending a JSON frame:

```json
{
  "channel": "market_depth",
  "filters": { "token": "0x…", "precision": "0.01" }
}
```

The server replies `{"type":"ack","channel":"market_depth"}`, or `{"type":"error","message":"Channel does not exists"}` for an unknown channel. Updates then arrive as `{"type":"…","data":{…}}` whenever the underlying data changes.

| Channel        | Pushes                                  |
| -------------- | --------------------------------------- |
| `asset_infos`  | Price and volume stats for an operation |
| `chart_bars`   | New OHLCV candles                       |
| `market_depth` | Order book updates                      |
| `op_progress`  | Primary-market funding progress         |

Subscriptions are matched on the **exact** filter set — a subscription is only served an update whose filters match yours field for field. Subscribe once per parameter combination you want to watch.

The server pings every 54 seconds and drops a connection with no pong for 60. Client frames are capped at 8 KB.
