# Lean API flow

LEAN is a payment gateway service provider in the UAE that supports bank transfers from one bank account to another bank account.&#x20;

NymCard is now offering a new feature for loading funds into the card account of the cardholder using direct integration between the fintech and LEAN. This new capability will allow you to build your own user experience for the loading funds feature with other capabilities offered by LEAN to the clients.

Below you can find a HOLD flow. Take the following steps:

1. Generate token

Generate a token using the “[Generate external token](https://nymcard.com/docs/api#tag/Accounts/operation/createAccountToken)” API. In this API you need to pass your NymCard account ID and pass "LEAN" channel. You will receive the token itself and timestamp, which indicates when this token will expire. Expiration time is 60 minutes.

Here you can find request sample:

<details>

<summary><a href="https://nymcard.com/docs/api#tag/Accounts/operation/createAccountToken">POST /accounts/{id}:token</a></summary>

**`{`**

**`"channel": "LEAN"`**

**`}`**

</details>

Here you can find response sample:

<details>

<summary>Response sample</summary>

**`{`**

**`"token": "mn7-RjV04loSfUyueaekjkDrKhrdP1JzQqQa3cchimH8JaLjaVtBNHqKZYezbfphEXBjd8ehwPZKr4C1PPy46w==",`**

**`"expiry": 3600`**

**`}`**

</details>

2. Load Account Funds with Token API:  \[HOLD]

Upon performing “HOLD”, the amount will be set to hold for the prefunded (pool) account and no funds will be credited to the cardholder account yet. Perform the following API:

LEAN HOLD request:

```
curl --location 'https://api.qa.platform.nm-1.nymcard.com/internal/v1/accounts:loadFunds' \
--header 'X-Nymos-Idempotency-Key: sed0083' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json;charset=UTF-8' \
--header 'apikey: tenant2-5aade201-368d-4bde-b194-21c296e7e75c' \
--data '{
    "channel": "LEAN",
    "type": "HOLD", 
    "token": "mn7-RjV04loSfUyueaekjkDrKhrdP1JzQqQa3cchimH8JaLjaVtBNHqKZYezbfphEXBjd8ehwPZKr4C1PPy46w==",
    "amount": 15,
    "dry_run": false 
   
}'
```

You will get the following response:

```
{
    "reference_number": "AHSA4050110433X"
}
```

3. Also you will receive the following webhook:

```
{
  "event": "TRANSACTION",
  "card_transaction": {
    "id": "2fd14380-a687-45cf-810a-c7644a752b81",
    "transaction_timestamp": "2024-02-19T11:04:33.422Z",
    "message_type": "API",
    "transaction_type": "WALLET_TRANSFER",
    "transaction_description": "Wallet Transfer",
    "user_id": "asiddiqui_27_11_23_04",
    "account_id1": "Bussines_account_QA_29DEC23_003",
    "card_product1": "MUHAY TESTING CP 29DEC23_0003",
    "account_id2": "cbeeea69-658f-4b9c-87ce-b342dfec5e0c",
    "card_product2": "bulk issuance product",
    "rrn": "4050110433rL",
    "reference_number": "AHSA4050110433X",
    "transaction_amount": 15,
    "transaction_currency": "AED",
    "fee_amount": 0,
    "fee_details": [],
    "status_code": "0000",
    "transfer_id": "2fd14380-a687-45cf-810a-c7644a752b81",
    "reversal_count": 0,
    "clearing_count": 0,
    "sender_user_id": "Business_Muhay_QA_User_03",
    "source_channel": "LEAN",
    "type": "HOLD",
    "incremental_transaction": false,
    "is_cancelled": "NO",
    "is_cash_advance": false
  }
}
```

4. Once you receive a successful response from NymCard for payment intent, you need to pass the details to LEAN along with token. You also have to add external reference number for reconciliation purposes.

{% hint style="info" %}
For POST/RELEASE scenarios, please coordinate with LEAN.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nymcard.com/get-started/funding-and-transfers/external-funding-source/lean-api-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
