> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whitebit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Crypto Lending Quickstart

> Walk through the four Flex endpoints — fetch plans, invest, check status, withdraw — in under 5 minutes.

Base URL

:

The four endpoints below cover the full Flex lifecycle — fetch plans, invest, check status, withdraw — operating against Main balance. Access requires B2B partner permissions plus a key with the Trade permission.

## Prerequisites

* A WhiteBIT account with completed KYC ([register](https://whitebit.com/auth/register))
* An API key with **Trade** permission ([create key](https://whitebit.com/settings/api))
* B2B partner access to the lending endpoints ([institutional services form](https://whitebit.com/institutional-services/b2b))
* Funds in [Main balance](https://docs.whitebit.com/concepts/balances.md) (the lending API operates on Main balance, not Trade balance)
* HMAC-SHA512 signing configured ([authentication guide](https://docs.whitebit.com/api-reference/authentication.md))
* `curl` and `jq` installed (for command-line examples)

> [!NOTE]
>
> Both Flex and Fixed plan endpoints require B2B partner permissions. Request access via the
> [institutional services form](https://whitebit.com/institutional-services/b2b). See the [overview](https://docs.whitebit.com/products/lending/overview.md) for details.

**1. Fetch available Flex plans**

Retrieve the list of available Flex plans to find a plan ID for investment.

> [tab] cURL
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> curl -X POST https://whitebit.com/api/v4/main-account/smart-flex/plans \
>   -H "Content-Type: application/json" \
>   -H "X-TXC-APIKEY: YOUR_API_KEY" \
>   -H "X-TXC-PAYLOAD: YOUR_PAYLOAD" \
>   -H "X-TXC-SIGNATURE: YOUR_SIGNATURE" \
>   -d '{"request": "/api/v4/main-account/smart-flex/plans", "nonce": 1709340000000}'
> ```

> [tab] Python
>
> ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
> import requests, json, hmac, hashlib, base64, time
>
> API_KEY = "YOUR_API_KEY"
> API_SECRET = "YOUR_SECRET"
> BASE_URL = "https://whitebit.com"
>
> def make_request(endpoint, body):
>     nonce = int(time.time() * 1000)
>     body["request"] = endpoint
>     body["nonce"] = nonce
>     data_json = json.dumps(body)
>     payload = base64.b64encode(data_json.encode())
>     signature = hmac.new(
>         API_SECRET.encode(), payload, hashlib.sha512
>     ).hexdigest()
>     headers = {
>         "Content-Type": "application/json",
>         "X-TXC-APIKEY": API_KEY,
>         "X-TXC-PAYLOAD": payload.decode(),
>         "X-TXC-SIGNATURE": signature,
>     }
>     return requests.post(f"{BASE_URL}{endpoint}", headers=headers, data=data_json)
>
> # Fetch available Flex plans
> response = make_request("/api/v4/main-account/smart-flex/plans", {})
> plans = response.json()
> print(json.dumps(plans, indent=2))
> ```

For Go and PHP examples, see [SDKs](https://docs.whitebit.com/sdks.md).

**Expected response:**

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[
  {
    "id": "8f2e9d3c-1a4b-4c2d-9e5f-6a7b8c9d0e1f",
    "ticker": "USDT",
    "minInvestment": "10.0",
    "maxInvestment": "100000.0",
    "maxRate": "0.15"
  },
  "..."
]
```

Save the `id` value from a plan to use in the next step.

**2. Create a Flex investment**

Invest into the selected Flex plan using the plan ID from Step 1. Sign the request as in Step 1
(`make_request` builds the payload and signature); for language clients, see [SDKs](https://docs.whitebit.com/sdks.md).

**Endpoint:** `POST /api/v4/main-account/smart-flex/investments/invest`

| Field | Type | Required | Description |
| - | - | - | - |
| `plan` | string (UUID) | Yes | Plan ID from Step 1 |
| `amount` | string | Yes | Amount to invest |
| `withReinvest` | boolean | No | Enables auto-reinvestment |

**Expected response:**

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "data": {
    "transaction_id": "tx_9f3e0d4c-2b5c-4d3e-8f6g-7a8b9c0d1e2f"
  }
}
```

**3. Check investment status**

Verify the investment was created and check its status. Sign the request as in Step 1.

**Endpoint:** `POST /api/v4/main-account/smart-flex/investments` (no additional fields)

**Expected response:**

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "data": [
    {
      "id": "inv_7e2d9c3b-1a4b-4c2d-9e5f-6a7b8c9d0e1f",
      "planId": "8f2e9d3c-1a4b-4c2d-9e5f-6a7b8c9d0e1f",
      "currency": "USDT",
      "invested": "100.00",
      "withAutoReinvest": true,
      "status": 1,
      "..."
    }
  ],
  "..."
}
```

**4. Withdraw from investment**

Withdraw funds from the Flex investment back to Main balance. Sign the request as in Step 1.

**Endpoint:** `POST /api/v4/main-account/smart-flex/investments/withdraw`

| Field | Type | Required | Description |
| - | - | - | - |
| `plan` | string (UUID) | Yes | The plan to withdraw from |
| `amount` | string | Yes | Amount to withdraw; partial withdrawals supported (use the full invested amount to withdraw everything) |

**Expected response:**

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "data": {
    "transaction_id": "tx_9f3e0d4c-2b5c-4d3e-8f6g-7a8b9c0d1e2f"
  }
}
```

After completing Step 4, the withdrawn amount returns to the [Main balance](https://docs.whitebit.com/concepts/balances.md). Verify by checking the [Main balance endpoint](https://docs.whitebit.com/api-reference/account-wallet/overview.md).

## What's Next

> [card] [Crypto Lending Overview](https://docs.whitebit.com/products/lending/overview.md)
>
> Fixed vs Flex plan mechanics, B2B partner permissions for lending endpoints, \~90 supported assets, and auto-reinvestment behavior.

> [card] [API Reference](https://docs.whitebit.com/api-reference/account-wallet/overview.md)
>
> Full endpoint documentation for all 13 lending endpoints.

For Go and PHP examples, see [SDKs](https://docs.whitebit.com/sdks.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.