# Welcome!

Welcome to the Lenme API Documentation!  We are thrilled to have you here and are eager to help you get started with integrating our platform into your projects.

<figure><img src="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2F8Qirf59JWiYCDocxXuGS%2FLenme05%20(4).png?alt=media&amp;token=900aaa0d-edd6-4309-aaea-067bdb5b166c" alt=""><figcaption></figcaption></figure>

## Welcome to Lenme API

Our API provides you with a powerful tool to access and utilize the features and functionality of Lenme, making it easier for you to build innovative and personalized experiences for your users.

Whether you're a seasoned developer or just starting out, our documentation is designed to be user-friendly and comprehensive, providing you with all the information and resources you need to get up and running quickly. So dive in, explore, and let's build something amazing together!

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Visit Our Website</strong></td><td>Visit our website to learn more about Lenme.</td><td></td><td><a href="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2FwWU3TiU7u9ygP6hKhSsi%2FWebsite.png?alt=media&amp;token=6a998edd-bf1c-4570-8c96-ca4872f28a88">Website.png</a></td><td><a href="https://lenme.com">https://lenme.com</a></td></tr><tr><td><strong>Sign-up now and get your api-secret keys</strong></td><td>Register your business and get your keys to authenticate and use lenme platform</td><td></td><td><a href="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2FQN6GDdnuiFPrOxlDhdnZ%2FSing-up%20Now%20and%20Get%20your%20API.png?alt=media&amp;token=7c7b8e4b-835e-4b15-b6b6-ed3faa29f591">Sing-up Now and Get your API.png</a></td><td><a href="/authenticate-with-api-secret-keys#sign-in-with-lenme-api-and-secret-keys-authentication">Authenticate with Api-secret keys</a></td></tr></tbody></table>

## Using Lenme is as easy as three steps

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Integrate</strong></td><td></td><td></td><td><a href="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2FaPAtqholhJBEky5iDtdM%2FIntegrate.png?alt=media&amp;token=ef9c3fc7-5328-4984-af5f-2f5c4cccef63">Integrate.png</a></td></tr><tr><td><strong>Offer</strong> </td><td></td><td></td><td><a href="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2FDWETXza0yA0nZrT9BczS%2FOffer.png?alt=media&amp;token=f823d25e-d083-4748-bb36-a311a61e2174">Offer.png</a></td></tr><tr><td><strong>Fund</strong></td><td></td><td></td><td><a href="https://394068367-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMCqEkBjU5Eq36JLf8K92%2Fuploads%2FGerVCkqYQcvZMYuqLdUT%2FFund.png?alt=media&amp;token=0dbbf498-7316-4099-acbb-abd437f93ae9">Fund.png</a></td></tr></tbody></table>

Feeling like an eager beaver? Go to authentication docs and get making your first request:

{% content-ref url="/pages/tR3aLYIkEjlRS3KKXCLm" %}
[Authenticate with Api-secret keys](/authenticate-with-api-secret-keys)
{% endcontent-ref %}

## Want to dive deep?

Dive a little deeper and start exploring our API reference to get an idea of everything that's possible with the API:

{% content-ref url="/pages/2jhcRgFEhNrAxJ5vpYJB" %}
[API Reference](/reference/api-reference)
{% endcontent-ref %}


# Authenticate with Api-secret keys

{% hint style="info" %}
**Good to know:** A quick start guide can be good to help folks get up and running with your API in a few steps. Some people prefer diving in with the basics rather than meticulously reading every page of documentation!
{% endhint %}

## Sign In With Lenme API And Secret Keys Authentication

#### Request API and Secret Keys

At present, you have the opportunity to request API and secret keys for accessing our API.    These keys are displayed only once and cannot be retrieved again. The API key serves as your unique identifier, while the secret key is utilized to generate an HMAC for each timestamp, ensuring the security of your information.

#### Generating an HMAC Key using secret key and timestamp <a href="#generating-an-api-key" id="generating-an-api-key"></a>

You have the capability to create a fresh HMAC key by combining your secret key with the request's timestamp. This HMAC key remains valid for a duration of 5 minutes. Post this period, you can conveniently generate a new one by employing the script provided below.

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X POST "lenme_server_endpoint" \
     -H "accept: application/json" \
     -H "X-API-KEY: your-api-key-here" \
     -H "X-Timestamp: current-timestamp" \
     -H "X-HMAC: generated-signature" \

```

{% endtab %}

{% tab title="Python" %}

```python
import hmac
import hashlib
import time

def generate_client_hmac(secret_key):
    timestamp = str(int(time.time()))

    message = f"{timestamp}:{secret_key}"

    hmac_signature = hmac.new(secret_key.encode(), message.encode(), hashlib.sha256).hexdigest()

    return hmac_signature, timestamp

secret_key = "your_secret_key"

hmac_signature, timestamp = generate_client_hmac(secret_key)
print("HMAC Signature:", hmac_signature)
print("Timestamp:", timestamp)
```

{% endtab %}

{% tab title="Java" %}

```java
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.time.Instant;

public class Main {
    public static String generateClientHmac(String secretKey) throws Exception {
        String timestamp = String.valueOf(Instant.now().getEpochSecond());
        String message = timestamp + ":" + secretKey;

        Mac hmac = Mac.getInstance("HmacSHA256");
        SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
        hmac.init(secretKeySpec);

        byte[] hash = hmac.doFinal(message.getBytes(StandardCharsets.UTF_8));
        return String.format("%064x", new BigInteger(1, hash)) + "," + timestamp;
    }

    public static void main(String[] args) throws Exception {
        String secretKey = "your_secret_key";
        String[] result = generateClientHmac(secretKey).split(",");
        System.out.println("HMAC Signature: " + result[0]);
        System.out.println("Timestamp: " + result[1]);
    }
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'openssl'
require 'time'

def generate_client_hmac(secret_key)
  timestamp = Time.now.to_i.to_s
  message = "#{timestamp}:#{secret_key}"

  hmac = OpenSSL::HMAC.hexdigest('sha256', secret_key, message)
  return hmac, timestamp
end

secret_key = "your_secret_key"
hmac_signature, timestamp = generate_client_hmac(secret_key)
puts "HMAC Signature: #{hmac_signature}"
puts "Timestamp: #{timestamp}"
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const crypto = require('crypto');

function generateClientHmac(secretKey) {
    const timestamp = Math.floor(Date.now() / 1000).toString();
    const message = `${timestamp}:${secretKey}`;

    const hmac = crypto.createHmac('sha256', secretKey).update(message).digest('hex');
    return [hmac, timestamp];
}

const secretKey = "your_secret_key";
const [hmacSignature, timestamp] = generateClientHmac(secretKey);
console.log("HMAC Signature:", hmacSignature);
console.log("Timestamp:", timestamp);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function generateClientHmac($secretKey) {
    $timestamp = time();
    $message = $timestamp . ':' . $secretKey;

    $hmacSignature = hash_hmac('sha256', $message, $secretKey);
    return array($hmacSignature, $timestamp);
}

$secretKey = "your_secret_key";
list($hmacSignature, $timestamp) = generateClientHmac($secretKey);
echo "HMAC Signature: " . $hmacSignature . "\n";
echo "Timestamp: " . $timestamp . "\n";
?>
```

{% endtab %}
{% endtabs %}

Upon generating the HMAC key, you will also receive the current timestamp. These two pieces of information are crucial for the authentication of each request you make. In the subsequent step, you will utilize these values.

#### Remember

It's important to note that the HMAC key has a validity period of only five minutes. Once this time has elapsed, the key becomes invalid, necessitating the generation of a new HMAC key for continued access.

#### Making A Request

All REST requests must contain the following headers:

* `X-API-KEY`   Your API key identifier
* `X-Timestamp` Timestamp for your request (generated in the above script)
* `X-HMAC` Messgae Signature of your secret key

All request bodies should have content type `application/json` and be valid JSON.

#### Error Handling

Errors can occur due to various reasons such as invalid requests for invalid API-key, time stamp of the request out of range, invalid HMAC or internal server issues. Each error response will include a JSON body with a clear `detail` to help you understand what went wrong.

Example Error Response:

```json
{
  "detail": "Timestamp out of range"
}
```

**Common Error Codes**

* `Authentication credentials were not provided` - The request is missing a required parameter or is malformed.
* `Invalid HMAC` - The HMAC has been expired or&#x20;
* `Invalid API Key` - The API-Key is not found or maybe revoked.

#### Sample Request

Once you have authenticated, you can start using our APIs. Please, refer to API reference for an example that shows you steps to fund loans.

#### Conclusion

In conclusion, by adhering to our established protocols for authentication and error handling, you can ensure a strong and secure integration with our API. This approach not only fortifies your application's security but also enhances the user experience. Stay updated with our changelog for the latest updates and features we introduce.


# Lenme Agentic Investing

Connect an AI agent to your Lenme account to browse loan requests, review your investments, and place funding offers through the Model Context Protocol (MCP).

## Agentic investing overview

Lenme's MCP connector lets you use an AI agent — such as Claude — to work with\
your Lenme investing data in plain language. You can ask your agent to surface\
loan requests that fit your criteria, review your active investments and\
transaction history, and place funding offers, all from inside your agent.

{% hint style="info" %}
Agentic investing is available to **active Lenme lenders**. If your account isn't currently lending, you'll be able to sign in but not connect until you're an active lender.
{% endhint %}

### What's an MCP connector?

The **Model Context Protocol (MCP)** is an open standard that lets AI agents connect securely to external apps and services. Lenme runs an MCP server that exposes a focused set of tools your agent can call on your behalf, only after you sign in and explicitly grant access.

### What your agent can do

Once connected, your agent can, on your behalf:

* **Browse borrower loan requests** available for you to fund, and filter them by risk level, credit score, loan amount, term, borrower state, and more.
* **Review a borrower's loan history** and banking data before you decide.
* **View your investments** — your loans (pending, funded, in collection, or in default), funding offers, balances, and payment schedules.
* **View your transactions**, including your funding and repayment history.
* **Place funding offers** on loan requests at an interest rate you choose.

{% hint style="warning" %}
**Placing a funding offer requires explicit confirmation.** Your agent will not submit an offer unless the action is confirmed. Your agent is designed to confirm with you first, and your AI client will also prompt you before it runs.
{% endhint %}

#### Example prompts

* "Show me low-risk loan requests between $500 and $2,000 with a 3–12 month term."
* "What's this borrower's loan history for request 12345?"
* "List my loans that are currently in collection."
* "Summarize my funding and repayment activity this month."

### What your agent can access

When you connect your Lenme account, your agent can process the following data:

* All details about your investments, funding offers, and balances
* All details about your transactions, including funding and repayment history
* Loan requests available for you to fund, and the borrower information Lenme provides for them

### Risks

{% hint style="danger" %}
You are solely responsible for your investment decisions and for any funding\
offers placed in your account through an AI agent.
{% endhint %}

* AI agents can make mistakes and may misinterpret your instructions.
* Instructions you submit through an agent are based on your own investment decisions. You are responsible for reviewing and verifying every funding offer before it is placed.
* You are solely responsible for determining the suitability of any particular loan request or investment strategy.
* An AI agent is a third-party service and is **not** affiliated with Lenme. Lenme cannot guarantee the availability, accuracy, or timeliness of an agent's output and is not responsible for its content, including any claims or opinions related to investing or the financial markets

See [Disclosures](#disclosures) for the full terms.

### Connect your AI agent

You'll connect Lenme as a custom connector in your AI client, then sign in and\
grant access.

{% hint style="info" %}
**Lenme MCP endpoint:** `https://api.lenmo.app/mcp`
{% endhint %}

{% tabs %}
{% tab title="Claude (claude.ai)" %}

1. Go to **Settings → Connectors**.
2. Select **Add custom connector**.
3. Enter the Lenme MCP endpoint: `https://api.lenmo.app/mcp`.
4. Select **Add**, then **Connect**.
5. Sign in with your Lenme credentials and review the access request.
6. Select **Allow** to finish connecting.
   {% endtab %}

{% tab title="Claude Desktop" %}

1. Open **Settings → Connectors**.
2. Select **Add custom connector**.
3. Enter the Lenme MCP endpoint: `https://api.lenmo.app/mcp`.
4. Complete the sign-in and consent flow when prompted.
   {% endtab %}

{% tab title="Claude Code" %}
Run:

```bash
claude mcp add --transport http lenme https://api.lenmo.app/mcp
```

Then open Claude Code and complete the sign-in and consent flow in your browser when prompted.
{% endtab %}

{% tab title="Other clients" %}
Any MCP-compatible client can connect using the Lenme MCP endpoint `https://api.lenmo.app/mcp` over streamable HTTP. Your client will open Lenme's sign-in page to complete authorization.
{% endtab %}
{% endtabs %}

### Revoke access

You can revoke an agent's access to your Lenme account at any time by contacting **Lenme support**. Once revoked, the agent can no longer read your data or act on your account until you connect again.

### Troubleshooting

* **The connector won't add** — double-check the MCP endpoint URL and that your client supports remote MCP connectors over HTTP.
* **You can sign in but can't connect** — agentic investing is available to active lenders only. If you're not currently lending, you won't be able to grant access.
* **Sign-in popup closes immediately** — allow pop-ups and third-party sign-in for the Lenme domain, then try again.
* **"Access denied" after signing in** — make sure you're signing in with the email tied to your Lenme lender account.
* **The agent can't see recent activity** — ask it to fetch again; results reflect your account at the time of the request.

### Disclosures

When entering and submitting your instructions via an external AI agent, you are solely responsible for your investment decisions and for any funding offers placed in your account pursuant to such instructions. All instructions entered by you through an external AI agent via our API are based on your own investment decisions, and Lenme will not be liable for any of your investment choices or for any losses resulting from such instructions. You are solely responsible for determining the suitability of any particular loan request or investment strategy. Furthermore, you are solely responsible for reviewing and verifying all details of your instructions, and funding offers you submit through your AI agent.

Your use of an AI agent to access your Lenme account(s) is subject to all the terms and conditions contained in the agreement(s) governing your account(s), including but not limited to the Lenme Investor Agreement, relating to the use of APIs to access your Lenme account(s). Please review these terms before allowing an agent to access your account(s).


# Lenme Webhooks

Welcome to the Lenme Webhook System documentation. This guide provides comprehensive details on how Lenme tracks changes to resources and notifies you in real-time through webhooks.

### Lenme Webhooks Overview

Here, you will find detailed information on how Lenme tracks resource changes through events and how you can subscribe to and manage these webhook notifications effectively.

#### How Webhooks Work

When a change occurs to a resource within the Lenme system, an Event object is created. This Event object includes essential information such as the webhook UUID, the event topic, and the event data. If you have subscribed to webhooks, you will receive notifications whenever these events occur, enabling you to process and respond to them in real-time.

#### Next Steps

For a detailed description of the webhook event structure and how to handle incoming webhooks effectively, please refer to [Lenme Webhook Events](/lenme-webhooks/lenme-webhook-events).


# Lenme Webhook Events

This page will provide detailed descriptions and updates for all Lenme webhooks.

### Overview

The Lenme system tracks any changes to resources (like Loan Requests, Loan Payments, etc..) by creating an **Event object** whenever an action occurs. These events are formatted consistently and include:

* **Webhook UUID:** Identifies your webhook uuid value.
* **Event topic:** Identifies the type of change.
* **Event data:** Data Collection for an occurred Event.

If you've subscribed to webhooks, you'll receive notifications whenever relevant events occur within your integration.

### Webhook Topics

Topics identify the events that have occurred. Each topic is included in the header and payload to specify the event and its details. This section of the documentation will be updated frequently with new webhook event topics as they are added to our system. Currently, we have one topic: `new_loan_request_created`. As new topics are introduced, they will be documented here.

#### Table of Topics

<table><thead><tr><th width="248">Topic Name</th><th>Description</th></tr></thead><tbody><tr><td>new_loan_request_created</td><td><p>When a new loan request is created, the provided data will include five variables:</p><ol><li>Loan Request ID</li><li>Loan Request Amount</li><li>Loan Request Type: Either Cash or Crypto.</li><li>Has Banking Data: Indicates whether the loan request has data aggregation.</li><li>Automated Loan Request: Whether the loan request was automated or created manually.</li></ol></td></tr></tbody></table>

### Subscribe to Lenme Webhooks

To request a subscription, provide a valid URL and a registered email. We will supply you with a webhook secret key, used to encode the webhook payload for data verification and reception. The webhook payload will contain a JWT-encoded token with the necessary data.

### Webhook request details <a href="#webhook-request-details" id="webhook-request-details"></a>

**Webhook Delivery:**

When you configure a webhook subscription, Lenme will create events for resource changes and send them asynchronously to your designated URL. These notifications arrive as POST requests containing a JSON-encoded payload (the event data) and additional HTTP headers.

**Focus on Event Details:**

Webhook payloads are designed to be lightweight, containing only essential details about the triggered event.

### Webhook headers  <a href="#webhook-headers" id="webhook-headers"></a>

**Lenme Webhook Headers:**

Several HTTP headers accompany Lenme webhook notifications to aid your application in processing the request:

* **X-Lenme-Topic:** This header identifies the general event category included in the payload (e.g., "new\_loan\_request\_created").
* **Content-Type:** specifies the media type of the resource or the data being sent.

**Example of header:**

* **X-Lenme-Topic:** new\_loan\_request\_created
* **Content-Type:** application/json

### Webhook payload  <a href="#webhook-payload" id="webhook-payload"></a>

All webhook payloads will include an Event object which will follow the same format as explained into [#lenme-events](#lenme-events "mention"), these events will contain the following:

<table><thead><tr><th width="182">Value</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td>webhook_uuid</td><td>string</td><td>Universally unique identifier for an event.</td></tr><tr><td>topic</td><td>string</td><td>Identify the event that occurred.</td></tr><tr><td>data</td><td>JSON</td><td>The event's JSON data.</td></tr></tbody></table>

### Example webhook payload

```json
{
   "webhook_uuid":"189bd761-cf7d-4e94-9655-dd7ce70c979a",
   "topic":"new_loan_request_created",
   "data":{
      "loan_request_id":987234,
      "loan_request_amount":500.0,
      "loan_request_type":"crypto",
      "has_banking_data":true,
      "automated_loan_request":false
   }
}
```

### Webhook Delivery and Retry Mechanism

By default, we will send you the webhook immediately after the event occurs. We will wait for up to 60 seconds for your server to respond. If your server does not respond within this time frame, we will mark the event as not sent and retry sending the webhook.

If your server cannot receive the webhook initially, our system will retry sending it every hour for up to 24 hours. If no 200 response is received within this period, your subscription will be deactivated until you request reactivation.

### Next Steps

For detailed information on how to integrate and handle Lenme webhooks in your application, please proceed to the next section.


# Integrating Lenme Webhooks

Integrating real time Lenme webhook notifications into your server side

## Integrating Lenme Webhooks into Your Server

Webhooks provide real-time notifications about events, allowing your server to stay updated as changes occur. Lenme's webhook functionality enables your server to receive these notifications seamlessly. This guide will walk you through the integration process using multiple programming languages such as Python, Java, PHP, and more.

#### Verification and Data Extraction

The integration process involves verifying and extracting data from the webhook payload and headers. When a webhook notification is received, it includes a JSON payload encoded as a JWT token. This token contains all the necessary event data. Additionally, headers such as `X-Lenme-Topic` identify the type of event.

To ensure the integrity and authenticity of the received data, the webhook payload is signed using a secret key provided during subscription. This secret key allows your server to decode the JWT token and verify its authenticity. Once verified, the data can be extracted and processed accordingly.

This guide will provide step-by-step instructions on how to handle these tasks, including:

* Setting up your server to receive webhook notifications.
* Verifying the JWT token using the provided secret key.
* Extracting event data from the payload.
* Processing the data based on the event type indicated in the headers.

### Code examples for verification incoming webhooks

{% tabs %}
{% tab title="Python" %}

```python
import json
import jwt

secret_key = "your-webhook-secret-key-here"

def validate_lenme_webhook(request_body, headers):
    body = json.loads(request_body)
    token = body.get("token")
    topic = headers.get("X-Lenme-Topic")
    data = jwt.decode(token, secret_key, algorithms=["HS256"])
    return data
```

{% endtab %}

{% tab title="Java" %}

```java
import org.json.JSONObject;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.Claims;

public class ValidateLenmeWebhook {
    private static final String SECRET_KEY = "your-webhook-secret-key-here";

    public static Claims validateLenmeWebhook(String requestBody, Map<String, String> headers) {
        JSONObject body = new JSONObject(requestBody);
        String token = body.getString("token");
        String topic = headers.get("X-Lenme-Topic");

        Claims data = Jwts.parser()
                          .setSigningKey(SECRET_KEY.getBytes())
                          .parseClaimsJws(token)
                          .getBody();
        return data;
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'json'
require 'jwt'

SECRET_KEY = 'your-webhook-secret-key-here'

def validate_lenme_webhook(request_body, headers)
  body = JSON.parse(request_body)
  token = body['token']
  topic = headers['X-Lenme-Topic']

  decoded = JWT.decode(token, SECRET_KEY, true, algorithm: 'HS256')[0]
  return decoded
end

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const jwt = require('jsonwebtoken');

const SECRET_KEY = 'your-webhook-secret-key-here';

function validateLenmeWebhook(requestBody, headers) {
  const body = JSON.parse(requestBody);
  const token = body.token;
  const topic = headers['X-Lenme-Topic'];

  const data = jwt.verify(token, SECRET_KEY);
  return data;
}

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';
use \Firebase\JWT\JWT;

$secret_key = "your-webhook-secret-key-here";

function validate_lenme_webhook($request_body, $headers) {
    $body = json_decode($request_body, true);
    $token = $body['token'];
    $topic = $headers['X-Lenme-Topic'];

    $decoded = JWT::decode($token, $secret_key, array('HS256'));
    return $decoded;
}
?>

```

{% endtab %}
{% endtabs %}


# API Reference

Dive into the specifics of each API endpoint by checking out our complete documentation.

## <mark style="color:blue;">Step 1:</mark> List Borrower's Loan Request&#x20;

{% content-ref url="/pages/WMA0IXpoyL54q29cJQZq" %}
[List borrower's loan request](/reference/list-borrowers-loan-request)
{% endcontent-ref %}

## <mark style="color:blue;">Step 2:</mark> Offer a loan request

After listing all loan requests of the prior 30 days, the investor can initiate an offer with an interest rate for a loan request.

{% content-ref url="/pages/qG7Bu7hC5fAZ01exFgf3" %}
[Offer Loan Requests](/reference/offer-loan-requests)
{% endcontent-ref %}

## <mark style="color:blue;">Step 3:</mark>  Fund an accepted offer

After the borrower accepts the offer, the investor can fund the loan. This requires a call from the investor to the fund loan endpoint.

{% content-ref url="/pages/XOwylZjBWIJ94Fo7M66C" %}
[Fund Loan](/reference/fund-loan)
{% endcontent-ref %}

## Get transfer history

The investor can check the transfer history related to their funded loans in the life cycle of the loan.

{% content-ref url="/pages/tcHwUgK0c3BfUPbJ2cYy" %}
[Fetch Transfer History](/reference/fetch-transfer-history)
{% endcontent-ref %}

## Get Loan and payments details&#x20;

Investors can check their associated loans in different states with their respective data using the following APIs.

{% content-ref url="/pages/eHy3J3BRHOX26JDgb6nn" %}
[Get Loans](/reference/get-loans)
{% endcontent-ref %}

{% content-ref url="/pages/x2alhc3ZnjShBagN4jwe" %}
[Get Loan payments](/reference/get-loan-payments)
{% endcontent-ref %}

## Get data aggregation from the borrower bank.

The investor can get further information about the borrower's banking data, if available, before initiating an offer to loan requests.

{% content-ref url="/pages/sRuAbjBuKj0eSvGwvfKz" %}
[Fetch Banking Data](/reference/fetch-banking-data)
{% endcontent-ref %}

## Fetch Third Part Services

The "Fetch Third Party Service" endpoint in Lenme's API allows developers to access various third-party services, like machine learning models and borrower data, using the loan request ID and provider name.

{% content-ref url="/pages/MPLS2p65AQV4iTyZmW9z" %}
[Fetch Third Party Service](/reference/fetch-third-party-service)
{% endcontent-ref %}


# List borrower's loan request

This endpoint retrieves a list of loan requests based on specific criteria. The returned active loan requests will only include those issued within the last 30 days

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loan_requests/`

This endpoint retrieves a list of loan requests based on specific criteria. The returned loan requests will only include those issued within the last 30 days. and exclude requests where:

#### Path Parameters

| Name                | Type           | Description                                                                                                                                                                                                                        |
| ------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| lenmo\_color        | Integer        | <p>0 : Low Risk<br>1 : Medium Risk</p><p>2 : High Risk</p><p>3 : Facebook Friends<br>4 : Crypto-backed Loans</p>                                                                                                                   |
| credit\_score       | NumericRange   | Loan requests associated to borrower with credit score in between a range.                                                                                                                                                         |
| loan\_amount        | NumericRange   | Loan requests with respective amount range                                                                                                                                                                                         |
| loan\_terms         | NumericRange   | Loan requests of a certain range of loan terms.                                                                                                                                                                                    |
| completed\_loans    | Numeric Filter | <p>Loan requests associated to borrower that have this completed loan count. Accepts numeric choices or numeric range or both. <br>Examples:<br>?completed\_loans=1,2,3<br>?completed\_loans=1-3<br>?completed\_loans=1,2,3-10</p> |
| invited\_borrowers  | Boolean        | Loan requests associated to invited borrowers.                                                                                                                                                                                     |
| previous\_borrowers | Boolean        | Loan requests associated to previous borrowers with completed loans.                                                                                                                                                               |
| state               | string         | Loan requests associated to one or multiple state (Note: you can enter NY or New York and it's not case sensitives ) you can also add multiple states by separating between them with , (e.g. CA,NY,..)                            |
| zip\_code           | String         | Loan requests associated to one or multiple zip code you can add more than one by separating between them with,                                                                                                                    |
| nearby\_zipcodes    | Boolean        | Loan requests linked to one or more zip codes of the lender aligned with the zip codes of borrowers.                                                                                                                               |

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| Accept                                        | String |                                                                             |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

## Sample Request

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loan_requests/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" lineNumbers="true" %}

```python
import requests

url = 'https://api.lenmo.app/api/v3/loan_requests/'

headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REUQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://api.lenmo.app/api/v3/loan_requests/");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();

            con.setRequestMethod("GET");
            con.setRequestProperty("Accept", "application/json");
            con.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            con.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            con.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String inputLine;
            StringBuilder content = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                content.append(inputLine);
            }
            in.close();

            System.out.println(content.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="Ruby" %}
{% code overflow="wrap" lineNumbers="true" %}

```ruby
require 'net/http'
require 'uri'
require 'json'

url = 'https://api.lenmo.app/api/v3/loan_requests/'
uri = URI.parse(url)

headers = {
  "Accept" => "application/json",
  "X-API-KEY" => "YOUR_API_KEY",
  "X-Timestamp" => "REQUEST_TIMESTAMP",
  "X-HMAC" => "REQUEST_HMAC"
}

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
headers.each { |key, value| request[key] = value }

response = http.request(request)
puts response.body
```

{% endcode %}
{% endtab %}

{% tab title="Node.Js" %}

```go
const fetch = require('node-fetch');

const url = 'https://api.lenmo.app/api/v3/loan_requests/';

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.lenmo.app/api/v3/loan_requests/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "X-API-KEY: YOUR_API_KEY";
$headers[] = "X-Timestamp: REQUEST_TIMESTAMP";
$headers[] = "X-HMAC: REQUEST_HMAC";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

echo $result;
?>
```

{% endtab %}
{% endtabs %}

## Sample Response

{% tabs %}
{% tab title="200: OK Returns a paginated list of the queried loan requests" %}

```javascript
{
  "count": 5155,
  "next": "https://api.lenmo.app/api/v3/loan_requests/?page=2",
  "previous": null,
  "results": [
    {
      "id": 147132,
      "borrower": {
        "id": 541966,
        "avatar": 1,
        "initial": "TM",
        "lenmo_score": 68,
        "credit_score": "620 - 630",
        "lenmo_color": 4,
        "hard_inquiries": 1,
        "deregatory_mark": 0,
        "total_accounts": 2,
        "credit_utilization": 1.02,
        "annual_income": 24000,
        "payment_history": 100,
        "completed_loans_count": 0
      },
      "borrower_card_color": 4,
      "loan_amount": "200.00",
      "loan_terms": 1,
      "total_amount": "203.11",
      "total_fees": "3.11",
      "fee_legislative": "0.11",
      "fee_extra": "0.00",
      "fee_lenmo": "3.00",
      "created": "2023-02-12T22:59:57.355382Z",
      "fav_loan_request_id": null,
      "lenme_prediction_purchased": false,
      "count_views": 5,
      "census_tract_geo_id": "12345",
      "max_interest_rate": 0.25,
      "borrower_data_aggs": {
        "avg_credit": 83.39,
        "avg_debit": 0,
        "sum_values": [
          {
            "CREDIT": 0,
            "DEBIT": 0
          },
          {
            "CREDIT": 0,
            "DEBIT": 0
          },
          {
            "CREDIT": 250,
            "DEBIT": 0
          }
        ]
      },
      "crypto_currency": "BTC",
      "crypto_amount": "0.000001",
      "crypto_interest_rate": 0.25,
      "crypto_logo": "www.example.com/btc-logo",
      "crypto_name": "Bitcoin",
      "crypto_market_value": "100000",
      "highlight": {
        'status': 0,
        'title': 'New loan alert!',
        'message': 'Be the first to grab a fantastic opportunity!'
      }
    },
    {
      "id": 147133,
      "borrower": {
        "id": 541955,
        "avatar": 1,
        "initial": "TM",
        "lenmo_score": 68,
        "credit_score": "620 - 630",
        "lenmo_color": 1,
        "hard_inquiries": 1,
        "deregatory_mark": 0,
        "total_accounts": 2,
        "credit_utilization": 1.02,
        "annual_income": 24000,
        "payment_history": 100,
        "completed_loans_count": 0
      },
      "borrower_card_color": 1,
      "loan_amount": "200.00",
      "loan_terms": 1,
      "total_amount": "203.11",
      "total_fees": "3.11",
      "fee_legislative": "0.11",
      "fee_extra": "0.00",
      "fee_lenmo": "3.00",
      "created": "2023-02-12T22:59:57.355382Z",
      "fav_loan_request_id": null,
      "lenme_prediction_purchased": false,
      "count_views": 5,
      "census_tract_geo_id": "12345",
      "max_interest_rate": 0.25,
      "borrower_data_aggs": {
        "avg_credit": 83.39,
        "avg_debit": 0,
        "sum_values": [
          {
            "CREDIT": 0,
            "DEBIT": 0
          },
          {
            "CREDIT": 0,
            "DEBIT": 0
          },
          {
            "CREDIT": 250,
            "DEBIT": 0
          }
        ]
      },
      "highlight": {
        'status': 0,
        'title': 'New loan alert!',
        'message': 'Be the first to grab a fantastic opportunity!'
      }
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

## Response Parameters

<table data-full-width="false"><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>Number</td><td>This is the loan request ID </td></tr><tr><td>Borrower's id</td><td>Number</td><td>This is the borrower's ID the requested the loan</td></tr><tr><td>intial</td><td>String</td><td>Borrower's Intial</td></tr><tr><td>lenmo_color</td><td>Integer</td><td>Lenme scoring model that measure the risk level.</td></tr><tr><td>credit_score</td><td>String</td><td>Credit score range - borrower's credit score range in a 10-point range. </td></tr><tr><td>hard_inquiries</td><td>Integer</td><td>Number of hard inquires as per the credit report of the borrower.</td></tr><tr><td>deregatory_mark</td><td>Integer</td><td>Deregatory mark as per the credit report of the borrower.</td></tr><tr><td>total_accounts</td><td>Integer</td><td>Number of total accounts as per the credit report of the borrower.</td></tr><tr><td>credit_utilization</td><td>Float</td><td>Credit utilization as per the credit report of the borrower.</td></tr><tr><td>annual_income</td><td>Float</td><td>TransUnion annual income.</td></tr><tr><td>payment_history</td><td>Float</td><td>TransUnion Payment History</td></tr><tr><td>completed_loans_count</td><td>Integer</td><td>Number of completed loans for this borrower.<br><a href="https://app.gitbook.com/o/1TDBk1DdywBla6GQIs90/s/MCqEkBjU5Eq36JLf8K92/~/changes/58/reference/get-borrower-loan-history">Retrive Borrower's loan history.</a></td></tr><tr><td>borrower_card_color</td><td>Integer</td><td>An integer value that reflect the risk level of the borrower.</td></tr><tr><td>loan_amount</td><td>Float</td><td>The amount of loan in USD</td></tr><tr><td>loan_terms</td><td>Integer</td><td>Number of loan terms for this loan request</td></tr><tr><td>total_amount</td><td>Float</td><td>The total amount of loan including fees</td></tr><tr><td>total_fees</td><td>Float</td><td>The total fees for the loan</td></tr><tr><td>fee_legislative</td><td>Float</td><td>Legislative fees for the loan</td></tr><tr><td>fee_extra</td><td>Float</td><td>Lenme extra fees</td></tr><tr><td>fee_lenmo</td><td>Float</td><td>Lenme fees</td></tr><tr><td>created</td><td>Date</td><td>Date of loan request creation</td></tr><tr><td>fav_loan_request_id</td><td>Long</td><td>Id of a favourite loan request</td></tr><tr><td>lenme_prediction_purchased</td><td>Boolean</td><td>Is LenmePredict purchased for this loan?</td></tr><tr><td>count_views</td><td>Integer</td><td>Number of loan requests views</td></tr><tr><td>crypto_currency</td><td>String</td><td>Type of crypto currency if crypto loan request.</td></tr><tr><td>crypto_amount</td><td>Float</td><td>Crypto amount if crypto loan request.</td></tr><tr><td>crypto_logo</td><td>String</td><td>URL for the crypto currency logo if crypto loan request.</td></tr><tr><td>crypto_name</td><td>String</td><td>Name of the crypto currency if crypto loan request.</td></tr><tr><td>crypto_market_value</td><td>Float</td><td>The market value of the crypto currency if crypto loan request.</td></tr><tr><td>census_tract_geo_id</td><td>String</td><td>Census tract GEO ID: A unique Geographic Identifier used by the United States Census Bureau to uniquely identify a specific census tract. It is a concatenation of several codes that uniquely define the geographic location.</td></tr><tr><td>max_interest_rate</td><td>Float</td><td>The maximum interest rate that can be offered for this loan request. The maximum interest rate varies based on different parameters, including the borrower's state, type of loan, and other factors.</td></tr><tr><td>borrower_data_aggs</td><td>JSON</td><td>Aggregation of the borrower's financial activities over the last 90 days.</td></tr><tr><td>Highlight</td><td>JSON</td><td><p>The highlight object is used to inform lenders about the status of the loan request.</p><p>A highlight object consists of:</p><ol><li><p>status:</p><p>The status of the loan request. Possible values:</p><p>    1: new loan request.</p><p>    2: the loan request was viewed.</p><p>    3: the loan request was offered.</p></li><li><p>title:</p><p>The title of the highlight. </p></li><li><p>message:</p><p>Shows how many views or offers for this loan request.</p></li></ol></td></tr></tbody></table>


# Get Borrower Loan History

This endpoint is used to retrieve a borrower's loan history.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loan_requests/{loan_request_id}/borrower_loan_history/`

This endpoint takes an active loan request ID and returns the associated borrower's loan history.

#### Path Parameters

| Name              | Type    | Description         |
| ----------------- | ------- | ------------------- |
| loan\_request\_id | Integer | The loan request ID |

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| Accept                                        | String |                                                                             |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loan_requests/50/borrower_loan_history/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"

```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" lineNumbers="true" %}

```python
import requests

loan_request_id = 50
url = f'https://api.lenmo.app/api/v3/loan_requests/{loan_request_id}/borrower_loan_history/'

headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REUQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
}

r = requests.get(url, headers=headers)

print(r.json())
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            int loanRequestId = 50;
            String urlString = "https://api.lenmo.app/api/v3/loan_requests/" + loanRequestId + "/borrower_loan_history/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuffer response = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

loan_request_id = 50
url = URI("https://api.lenmo.app/api/v3/loan_requests/#{loan_request_id}/borrower_loan_history/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"

response = http.request(request)
puts JSON.parse(response.body)

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const loanRequestId = 50;
const url = `https://api.lenmo.app/api/v3/loan_requests/${loanRequestId}/borrower_loan_history/`;

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$loanRequestId = 50;
$url = "https://api.lenmo.app/api/v3/loan_requests/$loanRequestId/borrower_loan_history/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    $json = json_decode($response, true);
    print_r($json);
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

## Sample Response

{% tabs %}
{% tab title="200: OK Returns a paginated list of the borrower's completed loans" %}

```json
{
  "count": 3,
  "next": null,
  "previous": null,
  "results": [
    {
      "lender": {
        "initial": "TT",
        "avatar": 3
      },
      "borrower": {
        "initial": "AE",
        "avatar": 1
      },
      "borrower_card_color": 2,
      "loan_amount": "508.11",
      "payment_terms": 3,
      "interest_rate": "1.85"
    },
    {
      "lender": {
        "initial": "JC",
        "avatar": 3
      },
      "borrower": {
        "initial": "FT",
        "avatar": 1
      },
      "borrower_card_color": 1,
      "loan_amount": "203.11",
      "payment_terms": 1,
      "interest_rate": "1.65"
    },
    {
      "lender": {
        "initial": "JC",
        "avatar": 3
      },
      "borrower": {
        "initial": "FT",
        "avatar": 1
      },
      "borrower_card_color": 1,
      "loan_amount": "53.11",
      "payment_terms": 1,
      "interest_rate": "1.34"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

## Response Parameters

<table data-full-width="false"><thead><tr><th width="247">Parameter</th><th width="116">Type</th><th width="351">Description</th></tr></thead><tbody><tr><td>count</td><td>Number</td><td>Number of objects in page.</td></tr><tr><td>next</td><td>String</td><td>Next page URL.</td></tr><tr><td>previous</td><td>String</td><td>Previous page URL.</td></tr><tr><td>results</td><td>JSON</td><td>The borrower loan history data.</td></tr><tr><td>lender</td><td>JSON</td><td>Contains the lender initail and avatar.</td></tr><tr><td>borrower</td><td>JSON</td><td>Contains the borrower initail and avatar.</td></tr><tr><td>borrower_card_color</td><td>Integer</td><td>An integer value that reflect the risk level of the borrower.</td></tr><tr><td>loan_amount</td><td>Float</td><td>The amount of loan in USD</td></tr><tr><td>payment_termns</td><td>Number</td><td>The loan payment terms.</td></tr><tr><td>interest_rate</td><td>Float</td><td>The loan interest rate.</td></tr></tbody></table>


# Offer Loan Requests

This endpoint is used to make an offer for a loan request, given a loan request id.

## HTTPS Request

<mark style="color:green;">`POST`</mark> `https://api.lenmo.app/api/v3/loan_requests/{id}/make_offer/`

#### Path Parameters

| Name                                 | Type | Description                        |
| ------------------------------------ | ---- | ---------------------------------- |
| id<mark style="color:red;">\*</mark> | Long | The loan request id to be offered. |

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

#### Request Body

| Name                                                | Type    | Description                                                                                                                |
| --------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| offered\_interest<mark style="color:red;">\*</mark> | Float   | A Float value between 0.03 and 2.0                                                                                         |
| automate\_fund                                      | Boolean | Boolean flag to specify whether to automatically fund the loan after offer acceptance (defaults to false if not provided). |

{% tabs %}
{% tab title="201: Created An offer is created for that loan request." %}

```json
{
    "id": 1,
    "offered_interest": 0.03,
     "offer_status": "pending",
      "lender": { 
        // ...lender data...
      }, 
      "loan_request": { 
        // ...loan request data... 
      },
      "monthly_payment": 100,
      "loan_gain": 100.02,
      "created": "2022-05-27T10:37:14.658672Z",
      "offer_status_changed": "2020-05-06 17:25:01 Etc/GMT",
      "processed_on_dwolla": true,
      "automate_fund": true
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied " %}

1. If  authentication credentials are invalid&#x20;

   ```json
   {
       "detail": "Authentication credentials were not provided."
   }
   ```
2. If the investor is currently borrowing

   ```json
   {
       "message": "Borrower can not offer."
   }
   ```

{% endtab %}

{% tab title="400: Bad Request" %}
**Cases:**

1. Offered interest is more than the loan request max interest rate

   ```json
   {
       "message": "The maximum interest rate allowed for this loan request is {loan_request_max_interest_rate}"
   }
   ```
2. The investor does not have sufficient balance to offer the loan (applicable only if automate\_fund is True).

   <pre class="language-json"><code class="lang-json"><strong>{
   </strong><strong>    "message": "Your balance isn't enough to offer this loan. Please add {REQUIRED_AMOUNT} to proceed."
   </strong>}
   </code></pre>
3. The loan request has been canceled

   ```json
   {
       "message": "This Loan Request has been Canceled"
   }
   ```
4. The loan request has been signed

   ```json
   {
       "message": "You can't make an offer to a Signed Loan Request"
   }
   ```
5. The investor already made an offer for this loan request

   <pre class="language-json"><code class="lang-json"><strong>{
   </strong><strong>    "message": "You have already made an offer for this Loan Request"
   </strong><strong>}
   </strong></code></pre>
6. Borrower accepted another offer

   ```json
   {
       "message": "You can't make an offer as the borrower has already accepted another offer"
   }
   ```
7. The investor has no verified bank account.

   ```json
   {
       "message": "We cannot process this request as it appears that your bank account has not been verified. Please verify your bank account and try again later."
   }
   ```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST "https://api.lenmo.app/api/v3/loan_requests/$loan_request_id/make_offer/" \
    -H "accept: application/json" \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
    -d '{
            "offered_interest": 0.3,
            "automate_fund": true
        }'
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

lq_id = 126315

url = "https://api.lenmo.app/api/v3/loan_requests/{}/make_offer/".format(lq_id)

headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
}

body = {"offered_interest": 1, "automate_fund": True}

r = requests.post(url, json=body, headers=headers)
print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            int lqId = 126315;
            String urlString = "https://api.lenmo.app/api/v3/loan_requests/" + lqId + "/make_offer/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");
            connection.setRequestProperty("Content-Type", "application/json; utf-8");
            connection.setDoOutput(true);

            String jsonInputString = "{\"offered_interest\": 1}";
            try(OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

lq_id = 126315
url = URI("https://api.lenmo.app/api/v3/loan_requests/#{lq_id}/make_offer/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"
request.body = { offered_interest: 1 }.to_json

response = http.request(request)
puts response.body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const lqId = 126315;
const url = `https://api.lenmo.app/api/v3/loan_requests/${lqId}/make_offer/`;

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
    "Content-Type": "application/json",
};

const body = {
    offered_interest: 1
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(body)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$lqId = 126315;
$url = "https://api.lenmo.app/api/v3/loan_requests/$lqId/make_offer/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC",
    "Content-Type: application/json"
];

$body = json_encode([
    "offered_interest" => 1
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Response Parameters

| Parameter                                               | Type    | Description                                                              |
| ------------------------------------------------------- | ------- | ------------------------------------------------------------------------ |
| id                                                      | Long    | Offer id                                                                 |
| offered\_interest                                       | Float   | The interest rate of the offer                                           |
| offer\_status                                           | String  | Status of the offer .e.g `pending`, `accepted`, `rejected`, `expired` .. |
| lender                                                  | Dict    | Contains lender data for loan                                            |
| [loan\_request](/reference/list-borrowers-loan-request) | Dict    | Contains loan request details for this offer                             |
| monthly\_payment                                        | Float   | Monthly payment of the offer                                             |
| loan\_gain                                              | Float   | The loan gain of the offered loan request                                |
| created                                                 | Date    | UTC time of the offer creation on the database                           |
| offer\_status\_changed                                  | Date    | UTC time of the last action took on this offer                           |
| processed\_on\_dwolla                                   | Boolean | Status of transfer associated with the offer                             |


# Fund Loan

API endpoint to fund loans for mobile users.

## HTTPS Request

<mark style="color:green;">`POST`</mark> `https://api.lenmo.app/api/v3/accepted_offers/{id}/fund/`

We only fund loan using the user's balance now, not balance and bank as done previously. Validation needed for the API endpoint to work:&#x20;

1\. Offer has to be not processed on dwolla before; `processed_on_dwolla` attribute have to be False.

2\. Offer has to be `Accepted`.&#x20;

3\. LoanRequest status has to be `Offered`.&#x20;

4\. Borrower has a primary funding resource.&#x20;

5\. Investor's Balance exceeds the `total_amount` attribute of the Loan.

#### Path Parameters

| Name                                 | Type | Description                         |
| ------------------------------------ | ---- | ----------------------------------- |
| id<mark style="color:red;">\*</mark> | Long | The accepted offer id to be funded. |

#### Headers

| Name                                            | Type   | Description                                                                     |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------- |
| Accept                                          | String | The content type of the response.                                               |
| Authorization<mark style="color:red;">\*</mark> | String | The bearer token that give the user the authentication to perform this request. |

{% tabs %}
{% tab title="201: Created A loan is successfully funded" %}

```javascript
{
    'message': 'Loan is started to fund, We will notify you just finish.'
}
```

{% endtab %}

{% tab title="400: Bad Request A loan cannot be funded" %}

```javascript
{
    "detail": // reason for not being able to fund the loan.
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "https://api.lenmo.app/api/v3/accepted_offers/125944/fund/" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

offer_id = 126315

headers = {
    'Accept': 'application/json',
    'Content-Type: application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

body = {}

# Fund
url_fund = f'https://api.lenmo.app/api/v3/accepted_offers/{offer_id}/fund/'
response = requests.post(url_fund, json=body, headers=headers)
print(response.json())
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            int offerId = 126315;
            String urlString = "https://api.lenmo.app/api/v3/accepted_offers/" + offerId + "/fund/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");
            connection.setDoOutput(true);

            String jsonInputString = "{}";
            try(OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

offer_id = 126315
url = URI("https://api.lenmo.app/api/v3/accepted_offers/#{offer_id}/fund/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"
request.body = {}.to_json

response = http.request(request)
puts JSON.parse(response.body)

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const offerId = 126315;
const url = `https://api.lenmo.app/api/v3/accepted_offers/${offerId}/fund/`;

const headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

const body = {};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$offerId = 126315;
$url = "https://api.lenmo.app/api/v3/accepted_offers/$offerId/fund/";

$headers = [
    "Accept: application/json",
    "Content-Type: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$body = json_encode([]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    $json = json_decode($response, true);
    print_r($json);
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}


# Fetch Banking Data

Fetch data aggregation associated with loan request.

## HTTPS Request

<mark style="color:green;">`POST`</mark> `https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/`

This endpoint receives loan\_request\_id and returns the data\_aggregation associated with this loan\_request.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

#### Request Body

| Name                                                | Type | Description                                         |
| --------------------------------------------------- | ---- | --------------------------------------------------- |
| loan\_request\_id<mark style="color:red;">\*</mark> | Long | loan request id for the needed aggregation to fetch |

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC" \
    -d "{\"loan_request_id\": 1}"
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

url = 'https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/'

headers = {
    'Accept': 'application/json',
    'Content-Type: application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

body = {'loan_request_id': 1}

r = requests.post(url, json=body, headers=headers)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String urlString = "https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");
            connection.setDoOutput(true);

            String jsonInputString = "{\"loan_request_id\": 1}";
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

url = URI("https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"
request.body = { loan_request_id: 1 }.to_json

response = http.request(request)
puts response.body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const url = 'https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/';

const headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

const body = {
    loan_request_id: 1
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(body)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.lenmo.app/api/v3/data_marketplace/data_aggregation/fetch_loan_request_data_aggs/";

$headers = [
    "Accept: application/json",
    "Content-Type: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$body = json_encode([
    "loan_request_id" => 1
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Sample Response

{% tabs %}
{% tab title="200: OK Aggregation is found and successfully fetched" %}

```json
{
  "created": "2022-05-27T10:37:14.658672Z",
  "borrower_bank_name_at_loan_request": "SANDBOX TEST BANK",
  "borrower_bank_balance": "0.00",
  "data_aggregation": {
    "Status": {
      "Severity": "Info",
      "StatusCode": 0,
      "StatusDesc": "Success"
    },
    "DepAcctTrns": {
      "FIAcctId": {
        "AcctId": 6161846,
        "AcctType": "DDA",
        "ExtAcctType": "DDA"
      },
      "BankAcctTrnRec": [
        {
          "Memo": "BOB'S DISCOUNT F DES:PAYROLL ID **003624X INDN:Smith, Jane CO ID:9006",
          "TrnID": 25835773,
          "CurAmt": {
            "Amt": 250.17,
            "CurCode": "USD"
          },
          "TrnType": "Credit",
          "Category": "Earned Income",
          "PostedDt": "2022-05-27",
          "CreatedOnDt": "2022-05-27T11:27:28-07:00",
          "SubCategory": "Wages & Salary"
        },
        {
          "Memo": "BOB'S DISCOUNT F DES:PAYROLL ID **016227X INDN:Smith, Jane CO ID:9006",
          "TrnID": 25835774,
          "CurAmt": {
            "Amt": 359.94,
            "CurCode": "USD"
          },
          "TrnType": "Credit",
          "Category": "Earned Income",
          "PostedDt": "2023-12-12",
          "CreatedOnDt": "2024-06-07T11:27:28-07:00",
          "SubCategory": "Wages & Salary"
        }
      ],
      "SelectionCriterion": {
        "SelRangeDt": {
          "EndDt": "2022-05-27",
          "StartDt": "2021-05-27"
        }
      }
    }
  },
  "agg_90": {
    "avg_credit": 0,
    "avg_debit": 0,
    "credit_30": 0,
    "debit_30": 0,
    "credit_60": 0,
    "debit_60": 0,
    "credit_90": 0,
    "debit_90": 0,
    "total_credit": 0,
    "total_debit": 0,
    "misc_spending_last90": 0,
    "entertainment_spending_last90": 0,
    "lifestyle_spending_last90": 0,
    "education_spending_last90": 0,
    "bank_fees_spending_last90": 0,
    "donations_spending_last90": 0,
    "goods_and_merch_spending_last90": 0,
    "home_expense_spending_last90": 0,
    "services_spending_last90": 0,
    "utilities_spending_last90": 0,
    "credit_payment_spending_last90": 0,
    "transportation_spending_last_90": 0,
    "food_spending_last90": 0,
    "cash_advance_last90": 0,
    "misc_spending_percentage_from_total": 0,
    "entertainment_spending_percentage_from_total": 0,
    "lifestyle_spending_percentage_from_total": 0,
    "education_spending_percentage_from_total": 0,
    "bank_fees_spending_percentage_from_total": 0,
    "donations_spending_percentage_from_total": 0,
    "goods_and_merch_spending_percentage_from_total": 0,
    "home_expense_spending_percentage_from_total": 0,
    "services_spending_percentage_from_total": 0,
    "utilities_spending_percentage_from_total": 0,
    "credit_payment_spending_percentage_from_total": 0,
    "transportation_spending_percentage_from_total": 0,
    "food_spending_percentage_from_total": 0,
    "cash_advance_percentage_from_total": 0,
    "negative_balance_count": 0
  }
}
```

{% endtab %}

{% tab title="400: Bad Request A loan cannot be funded" %}

```javascript
{
    'message': 'Please provide a valid loan_request id'
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}

{% tab title="404: Not Found Aggregation is not found" %}

```javascript
{
    'message': 'wrong loan_request id or loan_request does not have any data aggs associated with it.'
}
```

{% endtab %}
{% endtabs %}

#### Response Parameters

<table><thead><tr><th width="356">Parameter</th><th width="86">Type</th><th>Description</th></tr></thead><tbody><tr><td>created</td><td>Date</td><td>UTC time of data aggregation saved in the database.</td></tr><tr><td>borrower_bank_name_at_loan_request</td><td>String</td><td>Name of the borrower bank from which aggregation is fetched</td></tr><tr><td>borrower_bank_balance</td><td>String</td><td>Borrower balance in the bank provided the aggregation</td></tr><tr><td>data_aggregation</td><td>JSON</td><td>JSON object containing the data aggregation from the borrower's bank. It contains aggregation data provided by fiserv. Please, refer to <code>DepAcctTrnInqRs</code>entry in fiserv client's response.</td></tr><tr><td>agg_90</td><td>JSON</td><td>A JSON object containing aggregated data from the borrower's bank transactions in the last 90 days <strong>from the date of the loan request creation</strong>.</td></tr><tr><td>avg_credit</td><td>Float</td><td>Average income in the last 90 days.</td></tr><tr><td>avg_debit</td><td>Float</td><td>Average spending in the last 90 days.</td></tr><tr><td>credit_30</td><td>Float</td><td>Total income in the last 30 days.</td></tr><tr><td>debit_30</td><td>Float</td><td>Total spending in the last 30 days.</td></tr><tr><td>credit_60</td><td>Float</td><td>Total income in the last 30-60 days.</td></tr><tr><td>debit_60</td><td>Float</td><td>Total spending in the last 30-60 days.</td></tr><tr><td>credit_90</td><td>Float</td><td>Total income in the last 60-90 days.</td></tr><tr><td>debit_90</td><td>Float</td><td>Total spending in the last 60-90 days.</td></tr><tr><td>total_credit</td><td>Float</td><td>Total income in last 90 days.</td></tr><tr><td>total_debit</td><td>Float</td><td>Total spending in last 90 days.</td></tr><tr><td>misc_spending_last90</td><td>Float</td><td>Total amount spent in the miscellaneous expenses category in the last 90 days.</td></tr><tr><td>entertainment_spending_last90</td><td>Float</td><td>Total amount spent in the entertainment category in the last 90 days.</td></tr><tr><td>lifestyle_spending_last90</td><td>Float</td><td>Total amount spent in the Health &#x26; Lifestyle category in the last 90 days.</td></tr><tr><td>education_spending_last90</td><td>Float</td><td>Total amount spent in the Education category in the last 90 days.</td></tr><tr><td>bank_fees_spending_last90</td><td>Float</td><td>Total amount spent in the Bank Fees &#x26; Charges category in the last 90 days.</td></tr><tr><td>donations_spending_last90</td><td>Float</td><td>Total amount spent in the Donations category in the last 90 days.</td></tr><tr><td>goods_and_merch_spending_last90</td><td>Float</td><td>Total amount spent in the Goods &#x26; Merchandise category in the last 90 days.</td></tr><tr><td>home_expense_spending_last90</td><td>Float</td><td>Total amount spent in the Home Expenses category in the last 90 days.</td></tr><tr><td>services_spending_last90</td><td>Float</td><td>Total amount spent in the Services category in the last 90 days.</td></tr><tr><td>utilities_spending_last90</td><td>Float</td><td>Total amount spent in the Utilities category in the last 90 days.</td></tr><tr><td>credit_payment_spending_last90</td><td>Float</td><td>Total Amount spent in the Transfers &#x26; Adjustments category in the last 90 days.</td></tr><tr><td>transportation_spending_last_90</td><td>Float</td><td>Total Amount spent in the Travel &#x26; Transportation category in the last 90 days.</td></tr><tr><td>food_spending_last90</td><td>Float</td><td>Total Amount spent in the Food &#x26; Dining category in the last 90 days.</td></tr><tr><td>cash_advance_last90</td><td>Float</td><td>Total Amount spent in the Cash Advance subcategory in the last 90 days.</td></tr><tr><td>misc_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Miscellaneous expenses category from the total.</td></tr><tr><td>entertainment_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Entertainment category from the total.</td></tr><tr><td>lifestyle_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Health &#x26; Lifestyle category from the total.</td></tr><tr><td>education_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Education category from the total.</td></tr><tr><td>bank_fees_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Bank Fees &#x26; Charges category from the total.</td></tr><tr><td>donations_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Donations category from the total.</td></tr><tr><td>goods_and_merch_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Goods &#x26; Merchandise category from the total.</td></tr><tr><td>home_expense_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Home Expenses category from the total.</td></tr><tr><td>services_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Services category from the total.</td></tr><tr><td>utilities_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Utilities category from the total.</td></tr><tr><td>credit_payment_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Transfers &#x26; Adjustments category from the total.</td></tr><tr><td>transportation_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Travel &#x26; Transportation category from the total.</td></tr><tr><td>food_spending_percentage_from_total</td><td>Float</td><td>Percentage spent on Food category from the total.</td></tr><tr><td>cash_advance_percentage_from_total</td><td>Float</td><td>Percentage spent on Cash Advance subcategory from the total.</td></tr><tr><td>negative_balance_count</td><td>Integer</td><td>The number of times the borrower's bank balance went negative</td></tr></tbody></table>


# Fetch Transfer History

The investor can use this endpoint to fetch their transfer history on Lenme.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/transfer_history/`

Transfer history is returned in a paginated response.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A paginated list of transfer history is returned" %}

```json
{
   "count":2,
   "next":null,
   "previous":null,
   "results":[
      {
         "date":"2023-03-07",
         "transactions":[
            {
               "transfer_status":"pending",
               "transfer_type":"Fund Loans",
               "transfer_amount":"-53.11",
               "transfer_source_dest":"to MP",
               "loan_request_id":781768,
               "loan_id":837,
               "borrower_id":2894
            }
         ]
      },
      {
         "date":"2023-03-02",
         "transactions":[
            {
               "transfer_status":"processed",
               "transfer_type":"Withdrawal",
               "transfer_amount":"-20.00",
               "transfer_source_dest":"to Checking",
               "loan_request_id":null,
               "loan_id":null,
               "borrower_id":null
            }
         ]
      }
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/transfer_history/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" lineNumbers="true" %}

```python
import requests

url = 'https://api.lenmo.app/api/v3/transfer_history/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String urlString = "https://api.lenmo.app/api/v3/transfer_history/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

url = URI("https://api.lenmo.app/api/v3/transfer_history/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"

response = http.request(request)
puts response.body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const url = 'https://api.lenmo.app/api/v3/transfer_history/';

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.lenmo.app/api/v3/transfer_history/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Response Parameters

<table><thead><tr><th>Parameter</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td>date</td><td>Date</td><td>Transfer Date</td></tr><tr><td>transactions</td><td>List of transfer obj.</td><td>A list of transactions grouped by transfer date</td></tr><tr><td>TransferHistory.transfer_status</td><td>String</td><td>Status of a transfer .e.g <code>pending</code>, <code>processed</code> or <code>failed</code></td></tr><tr><td>TransferHistory.transfer_type</td><td>String</td><td>Type of a transfer .e.g <code>Add Money</code>, <code>Withdrawal</code>, <code>Fund Loans</code>, <code>Monthly Payments</code>, <code>Collection</code>, <code>Lender Subscription</code>, <code>Default Crypto</code>, <code>Liquidate Crypto</code>, <code>Reward</code>, <code>Refund</code></td></tr><tr><td>TransferHistory.transfer_amount</td><td>String</td><td>Amount of transfer in USD</td></tr><tr><td>TransferHistory.transfer_source_dest</td><td>String</td><td>Indicates the transfer initiation either to or from source</td></tr><tr><td>TransferHistory.loan_request_id</td><td>Long</td><td>Id of the loan request associated with the transfer</td></tr><tr><td>TransferHistory.loan_id</td><td>Long</td><td>Id of the loan associated with the transfer</td></tr><tr><td>TransferHistory.borrower_id</td><td>Long</td><td>Id of the borrower associated with the transfer</td></tr></tbody></table>


# Get Loans

The investor can use these endpoints to fetch details of their loans, including those in pending, completed, in collection, or in default status.

## Get Current Loans

The investor can use this endpoint to fetch their loans either in pending or in funded statuses.

### HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loans/current_loan/`

This endpoint returns a paginated response for loans that are associated with the investor, and they are completed.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A paginated list of loans either pending or funded" %}

```javascript
{
   "count":2,
   "next":null,
   "previous":null,
   "results":[
      {
         "id": 1,
         "borrower_card_color": 3,
         "loan_amount": 103213.009,
         "payment_terms": 4,
         "monthly_payment_amount": 40.5,
         "loan_return": 123213.009,
         "is_approved": True,
         "loan_paid_off":  False,
         "loan_balance": 2221.21,
         "interest_rate": 0.03,
         "lender": {
            // ... lender data ...
         },
         "next_payment_date": "2018-10-16 00:00:00+00:00",
         "borrower": {
            // ... borrower data ...
         },
         "status": "funded",
         "loan_due_amount": 900.01,
         "created_date": "2018-10-16 00:00:00+00:00",
         "original_debt": 122.031,
         "collected_amount": 900.1,
         "remaining_debt": 100,
         "collection_fee": 5,
         "collected_percentage": 70.0,
         "net_collected": 800,
         "loan_request_id": 2,
      }, ...
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loans/current_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://api.lenmo.app/api/v3/loans/current_loan/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String urlString = "https://api.lenmo.app/api/v3/loans/current_loan/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

url = URI("https://api.lenmo.app/api/v3/loans/current_loan/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"

response = http.request(request)
puts response.body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const url = 'https://api.lenmo.app/api/v3/loans/current_loan/';

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.lenmo.app/api/v3/loans/current_loan/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

## Get Completed Loans

The investor can use this endpoint to fetch their completed loans.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loans/completed_loan/`

This endpoint returns a paginated response for loans that are associated with the investor, and they are completed.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A paginated list of loans either pending or funded" %}

```javascript
{
   "count":2,
   "next":null,
   "previous":null,
   "results":[
      {
         "id": 1,
         "borrower_card_color": 3,
         "loan_amount": 103213.009,
         "payment_terms": 4,
         "monthly_payment_amount": 40.5,
         "loan_return": 123213.009,
         "is_approved": True,
         "loan_paid_off":  False,
         "loan_balance": 2221.21,
         "interest_rate": 0.03,
         "lender": {
            // ... lender data ...
         },
         "next_payment_date": "2018-10-16 00:00:00+00:00",
         "borrower": {
            // ... borrower data ...
         },
         "status": "funded",
         "loan_due_amount": 900.01,
         "created_date": "2018-10-16 00:00:00+00:00",
         "original_debt": 122.031,
         "collected_amount": 900.1,
         "remaining_debt": 100,
         "collection_fee": 5,
         "collected_percentage": 70.0,
         "net_collected": 800,
         "loan_request_id": 2,
      }, ...
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loans/completed_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# Fetch completed loans for the investor
url = 'https://api.lenmo.app/api/v3/loans/completed_loan/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)curl -X GET "https://api.lenmo.app/api/v3/loans/completed_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"curl -X GET "https://api.lenmo.app/api/v3/loans/completed_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}
{% endtabs %}

## Get Collection Loans

The investor can use this endpoint to fetch their funded loans which are in collection status.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loans/collection_loan/`

This endpoint returns a paginated response for loans in collection status that are associated with the investor.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A paginated list of loans either pending or funded" %}

```javascript
{
   "count":2,
   "next":null,
   "previous":null,
   "results":[
      {
         "id": 1,
         "borrower_card_color": 3,
         "loan_amount": 103213.009,
         "payment_terms": 4,
         "monthly_payment_amount": 40.5,
         "loan_return": 123213.009,
         "is_approved": True,
         "loan_paid_off":  False,
         "loan_balance": 2221.21,
         "interest_rate": 0.03,
         "lender": {
            // ... lender data ...
         },
         "next_payment_date": "2018-10-16 00:00:00+00:00",
         "borrower": {
            // ... borrower data ...
         },
         "status": "funded",
         "loan_due_amount": 900.01,
         "created_date": "2018-10-16 00:00:00+00:00",
         "original_debt": 122.031,
         "collected_amount": 900.1,
         "remaining_debt": 100,
         "collection_fee": 5,
         "collected_percentage": 70.0,
         "net_collected": 800,
         "loan_request_id": 2,
      }, ...
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loans/collection_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# Fetch loans in collection status for the investor
url = 'https://api.lenmo.app/api/v3/loans/collection_loan/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endtab %}
{% endtabs %}

## Get Default Loans

The investor can use this endpoint to fetch their loans in default status.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loans/default_loan/`

This endpoint returns a paginated response for loans that are associated with the investor, and they are default.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A paginated list of loans either pending or funded" %}

```javascript
{
   "count":2,
   "next":null,
   "previous":null,
   "results":[
      {
         "id": 1,
         "borrower_card_color": 3,
         "loan_amount": 103213.009,
         "payment_terms": 4,
         "monthly_payment_amount": 40.5,
         "loan_return": 123213.009,
         "is_approved": True,
         "loan_paid_off":  False,
         "loan_balance": 2221.21,
         "interest_rate": 0.03,
         "lender": {
            // ... lender data ...
         },
         "next_payment_date": "2018-10-16 00:00:00+00:00",
         "borrower": {
            // ... borrower data ...
         },
         "status": "funded",
         "loan_due_amount": 900.01,
         "created_date": "2018-10-16 00:00:00+00:00",
         "original_debt": 122.031,
         "collected_amount": 900.1,
         "remaining_debt": 100,
         "collection_fee": 5,
         "collected_percentage": 70.0,
         "net_collected": 800,
         "loan_request_id": 2,
      }, ...
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loans/default_loan/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# Fetch loans in default status for the investor
url = 'https://api.lenmo.app/api/v3/loans/default_loan/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endtab %}
{% endtabs %}

## Response Parameters

| Parameter                | Type    | Description                                                   |
| ------------------------ | ------- | ------------------------------------------------------------- |
| borrower\_card\_color    | Integer | An integer value that reflect the risk level of the borrower. |
| loan\_amount             | Float   | The amount of loan in USD                                     |
| payment\_terms           | Integer | Number of payments to pay back the loan                       |
| monthly\_payment\_amount | Float   | Payment amount in a month                                     |
| loan\_return             | Float   | Loan return after it is paid off                              |
| is\_approved             | Boolean | Approval status for the loan                                  |
| loan\_paid\_off          | Boolean | Status on the completion of the loan                          |
| loan\_balance            | Float   | Current remaining loan balance to be paid off                 |
| interest\_rate           | Float   | A value between 0.03 to 2.0 for the interest rate of the loan |
| lender                   | Dict    | Contains lender data for loan                                 |
| next\_payment\_date      | Date    | UTC time for the upcoming loan payment                        |
| borrower                 | Dict    | Contains borrower data for loan                               |
| status                   | String  | Current Loan Status                                           |
| loan\_due\_amount        | Float   | The loan due amount                                           |
| created\_date            | Date    | UTC time for loan creation                                    |
| original\_debt           | Float   | Amount of debt for this loan                                  |
| collected\_amount        | Float   | Collected amount of the loan in USD                           |
| remaining\_debt          | Float   | Amount of debt to be collected later                          |
| collection\_fee          | Float   | Fee of collection                                             |
| collected\_percentage    | Float   | Percentage of the collection amount                           |
| net\_collected           | Float   | The net value of the collection amount                        |
| loan\_request\_id        | Integer | Loan request id, associated with this loan                    |


# Get Loan payments

The investor can use this endpoint to fetch payments of a given loan.

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loans/{id}/payments/`

This endpoint returns a list of payments related to the requested loan id.

#### Path Parameters

| Name                                 | Type   | Description                            |
| ------------------------------------ | ------ | -------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | Id of the loan related to the payments |

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |

{% tabs %}
{% tab title="200: OK A list of loan payments" %}

```javascript
[
   {
      "id":301,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:15:11.126587Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.239865Z",
      "modified":"2019-03-25T22:37:49.881808Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":302,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:15:06.187661Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.251581Z",
      "modified":"2019-03-25T22:37:50.168568Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":309,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-16T22:17:40.334406Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.334358Z",
      "modified":"2019-03-25T22:37:58.022141Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":310,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"Missed Payment",
      "payment_status_changed":"2022-11-29T11:21:08.291956Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.347821Z",
      "modified":"2022-11-29T11:21:48.807060Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":307,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:14:39.254253Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.308230Z",
      "modified":"2019-03-25T22:37:56.294834Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":308,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-16T22:17:40.319419Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.319377Z",
      "modified":"2019-03-25T22:37:56.260690Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":306,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:14:45.328520Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.296727Z",
      "modified":"2019-03-25T22:37:54.251698Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":304,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:14:56.220972Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.273940Z",
      "modified":"2019-03-25T22:37:53.324683Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":305,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:14:50.743028Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.285214Z",
      "modified":"2019-03-25T22:37:52.091427Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":303,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-16",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-21T16:15:01.349985Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.263157Z",
      "modified":"2019-03-25T22:37:52.036709Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":311,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-17",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-16T22:17:40.358601Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.358558Z",
      "modified":"2019-03-25T22:38:00.654317Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   },
   {
      "id":312,
      "loan":43,
      "payment_amount":"91.17",
      "payment_due_date":"2018-10-17",
      "payment_status":"paid",
      "payment_status_changed":"2018-10-16T22:17:40.369242Z",
      "late_payment_fees_amount":null,
      "created":"2018-10-16T22:17:40.369201Z",
      "modified":"2019-03-25T22:37:59.900152Z",
      "is_late_payment":false,
      "processed_on_dwolla":true,
      "delayed_days_count":0,
      "pay_later_fees":null
   }
]
```

{% endtab %}

{% tab title="403: Forbidden Permission Denied" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```clike
curl -X GET "https://api.lenmo.app/api/v3/loans/43/payments/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

# Fetch payments for a given loan id
loan_id = 43
url = f'https://api.lenmo.app/api/v3/loans/{loan_id}/payments/'

headers = {
    'Accept': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY',
    'X-Timestamp': 'REQUEST_TIMESTAMP',
    'X-HMAC': 'REQUEST_HMAC'
}

r = requests.get(url, headers=headers)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            int loanId = 43;
            String urlString = "https://api.lenmo.app/api/v3/loans/" + loanId + "/payments/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

loan_id = 43
url = URI("https://api.lenmo.app/api/v3/loans/#{loan_id}/payments/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"

response = http.request(request)
puts response.body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const loanId = 43;
const url = `https://api.lenmo.app/api/v3/loans/${loanId}/payments/`;

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$loanId = 43;
$url = "https://api.lenmo.app/api/v3/loans/$loanId/payments/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Response Parameters

| Parameter                   | Type    | Description                                                 |
| --------------------------- | ------- | ----------------------------------------------------------- |
| loan                        | Long    | Id of the loan associated with this payment                 |
| payment\_amount             | Float   | USD amount of the payment                                   |
| payment\_due\_date          | Date    | UTC time for the payment due date.                          |
| payment\_status             | String  | Status of the payment                                       |
| payment\_status\_changed    | Date    | UTC time for last action, took on this payment              |
| late\_payment\_fees\_amount | Float   | If applicable, the late fees of the payment                 |
| created                     | Date    | UTC time of the payment creation in our database            |
| modified                    | Date    | UTC time of the last modification applied to the payment    |
| is\_late\_payment           | Boolean | Payment status to indicate of it was not fulfilled in time. |
| processed\_on\_dwolla       | Boolean | Payment status to indicate if a transfer is initiated       |
| delayed\_days\_count        | Integer | Number of days over the due time.                           |
| pay\_later\_fees            | Float   | Fees for a pay later option.                                |


# Fetch Third Party Service

The "Fetch Third Party Service" endpoint is a crucial component of Lenme's API ecosystem designed to facilitate the retrieval of third-party services integrated with our platform.

These services can encompass a wide range of functionalities, including machine learning scoring models or data pertaining to each borrower within a loan request.

To utilize this API endpoint, developers need to provide two essential parameters: the "loan request ID" and the "Provider Name." With these inputs, the endpoint empowers developers to seamlessly access the specific service offered by the designated third-party provider. Whether it's extracting valuable insights from machine learning models or accessing borrower-specific data, the "Fetch Third Party Service" endpoint simplifies the process of integrating and utilizing external services within the Lenme ecosystem.

## HTTP Request

<mark style="color:green;">`POST`</mark> `https://api.lenmo.app/api/v3/data_marketplace/data_integration/`

This endpoint returns the requested service score for the requested loan ID.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| Content-Type                                  | String | The type of the request body                                                |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |

#### Request Body

| Name                                                | Type   | Description                 |
| --------------------------------------------------- | ------ | --------------------------- |
| loan\_request\_id<mark style="color:red;">\*</mark> | Int    | Loan Request ID             |
| provider\_name<mark style="color:red;">\*</mark>    | String | The requested provider name |

{% tabs %}
{% tab title="200: Third Party Score was found" %}
See the [Available Service Options](#available-service-options) section for a sample response for each provider.
{% endtab %}

{% tab title="403: Authentication Failure" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}

{% tab title="404: Third Party Score not found" %}

```json
{"message": "Service provider score not found for the given loan request ID"}
```

{% endtab %}

{% tab title="404: Loan request not found" %}

```json
{"message": "No active loan request found for the given ID."}
```

{% endtab %}

{% tab title="400: Invalid provider name" %}

```json
{"message": "Please enter a valid provider name"}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST "https://api.lenmo.app/api/v3/data_marketplace/data_integration/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC" \
    -H "Content-Type: application/json" \
    -d '{"loan_request_id": 1, "provider_name": "salus"}'
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'

url = 'https://api.lenmo.app/api/v3/data_marketplace/data_integration/'

headers = {
    'Accept': 'application/json',
    "Content-Type": "application/json",
    'X-API-KEY': api_key,
    'X-Timestamp': 'YOUR_TIME_STAMP',
    'X-HMAC': 'YOUR_HMAC_KEY'
}

loan_request_id = 1
provider_name = "salus"
data = {
    "loan_request_id": loan_request_id,
    "provider_name": provider_name
}

r = requests.post(url, headers=headers, json=data)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "YOUR_API_KEY";
            String apiSecret = "YOUR_API_SECRET";
            String urlString = "https://api.lenmo.app/api/v3/data_marketplace/data_integration/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("X-API-KEY", apiKey);
            connection.setRequestProperty("X-Timestamp", "YOUR_TIME_STAMP");
            connection.setRequestProperty("X-HMAC", "YOUR_HMAC_KEY");
            connection.setDoOutput(true);

            int loanRequestId = 1;
            String providerName = "salus";
            String jsonInputString = String.format("{\"loan_request_id\": %d, \"provider_name\": \"%s\"}", loanRequestId, providerName);

            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'openssl'
require 'time'

api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
url = URI('https://api.lenmo.app/api/v3/data_marketplace/data_integration/')

timestamp = Time.now.to_i.to_s
message = timestamp + url.to_s
signature = OpenSSL::HMAC.hexdigest('sha256', api_secret, message)

headers = {
  'Accept' => 'application/json',
  'Content-Type' => 'application/json',
  'X-API-KEY' => api_key,
  'X-Timestamp' => timestamp,
  'X-HMAC' => signature
}

data = {
  loan_request_id: 1,
  provider_name: "salus"
}.to_json

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url, headers)
request.body = data

response = http.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const url = 'https://api.lenmo.app/api/v3/data_marketplace/data_integration/';

const headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": apiKey,
    "X-Timestamp": "YOUR_TIME_STAMP",
    "X-HMAC": "YOUR_HMAC_KEY",
};

const data = {
    loan_request_id: 1,
    provider_name: "salus"
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$url = "https://api.lenmo.app/api/v3/data_marketplace/data_integration/";

$headers = [
    "Accept: application/json",
    "Content-Type: application/json",
    "X-API-KEY: $apiKey",
    "X-Timestamp: YOUR_TIME_STAMP",
    "X-HMAC: YOUR_HMAC_KEY"
];

$body = json_encode([
    "loan_request_id" => 1,
    "provider_name" => "salus"
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Available Service Options

<table><thead><tr><th width="159">Provider Name</th><th width="110">Price</th><th width="117">Description</th><th>Sample Response</th></tr></thead><tbody><tr><td>salus</td><td>Unlimited access for $200 per month.</td><td><a href="#salus-score-description">Salus Score Description*</a></td><td><pre class="language-json"><code class="lang-json">{
  "loan_request_id": 123456,
  "model_version": "648bc628aeae01aeab885d35",
  "salus_score": 12,
  "salus_score_request_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "timestamp": "2022-08-29T09:12:33.001Z"
}
</code></pre></td></tr><tr><td>pave</td><td>$1.50 per API request, billed monthly.</td><td><a href="#pave-score-description">Pave Score Description*</a></td><td><p></p><pre class="language-json" data-full-width="true"><code class="lang-json">{
  "p2p_score": {
    "date": "2024-08-16",
    "score": 21,
    "score_band": "poor",
    "loan_request_id": "781991",
  },
  "attributes": {
    "date": "2024-08-16",
    "loan_request_id": "781991",
    "attributes": {
      // Calculated banking attributes here.
    }
  }
}
</code></pre></td></tr></tbody></table>

#### Salus Score Description \*

Salus Score uses credit data and transaction data to highlight the historically observed default rate of a given loan application based on similar historical applications, going beyond traditional measures like credit score. Users of the Salus Score acknowledge that the Salus Score is for informational purposes only and should not be solely relied on to make credit decisions; it is not guaranteed to generate default rates consistent with historical patterns used to generate the score. Salus Score is provided by Lenme’s data partner, Salus Financial Technology, Inc. Salus Financial Technology, Inc. is not a credit reporting agency. Information like age, sex, race, or marital status are not used in the creation of the Salus Score. Users of the Salus Score allow Lenme to share loan data with Salus Financial Technology, Inc.

***

#### Pave Score Description\*

The Pave Score identifies healthy borrowers, optimizes credit limits, and enhances collection outcomes. It is composed of two key components:

1. **P2P Score**: This score represents the user’s ability to repay the loan. The P2P Score is categorized as follows:
   * **Excellent**: 75 to 100
   * **Good**: 50 to 75
   * **Average**: 25 to 50
   * **Poor**: 0 to 25
2. **Bank Attributes**: This component includes over 4,000 attributes related to the user’s cash flow and financial profile. These attributes cover areas such as debt payment history, past and expected income, bank fees, cash advance defaults, account balances, and more.


