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

# Transfer Funds to Bank

> Allows customers to transfer funds from their loan wallet to a bank account.

Customers can use this endpoint to transfer funds from their loan wallet balance to a registered bank account.

<RequestExample>
  ```bash cURL POST theme={null}
  [https://finlend.fincode.software/api/v1/services/user/transfer-funds-to-bank](https://finlend.fincode.software/api/v1/services/user/transfer-funds-to-bank)
  ```
</RequestExample>

## Request Headers

<ParamField header="X-Auth-Token" type="string" required>
  The **JWT Access Token** obtained from the `/login` or `/refresh-token` endpoint.
</ParamField>

<ParamField header="x-idempotency-key" type="string" required>
  Unique idempotency key for the request to prevent duplicate processing.
</ParamField>

<ParamField header="x-fapi-auth-date" type="string" required>
  The date and time at which the request was initiated (ISO 8601 format).
</ParamField>

<ParamField header="x-fapi-customer-ip-address" type="string" required>
  The IP address of the customer making the request.
</ParamField>

<ParamField header="x-fapi-interaction-id" type="string" required>
  Unique identifier for the interaction/session.
</ParamField>

<ParamField header="Content-Type" type="string" required default="application/json">
  Must be `application/json`.
</ParamField>

## Request Body

<ParamField body="customerId" type="string" required>
  The unique identifier (UUID) of the customer making the transfer.
</ParamField>

<ParamField body="amount" type="number" required>
  Amount to transfer from wallet to bank account.
</ParamField>

<ParamField body="bankAccountId" type="string" required>
  The unique identifier (UUID) of the bank account to transfer funds to.
</ParamField>

<ParamField body="accountNumber" type="string" required>
  Bank account number to transfer to.
</ParamField>

<ParamField body="bankCode" type="string" required>
  Bank code of the destination bank.
</ParamField>

<ParamField body="accountName" type="string" required>
  Account holder name as it appears on the bank account.
</ParamField>

<ParamField body="transactionPin" type="string">
  Transaction PIN for authorization (if required).
</ParamField>

<ParamField body="description" type="string">
  Optional description or reference for the transfer.
</ParamField>

## Response

Returns confirmation of the fund transfer with transaction details.

<ResponseField name="status" type="string" default="SUCCESS">
  Overall status of the API request.
</ResponseField>

<ResponseField name="data" type="object">
  Transfer confirmation details.

  <Expandable title="data object">
    <ResponseField name="transactionReference" type="string">
      Unique reference number for the transfer transaction.
    </ResponseField>

    <ResponseField name="transferId" type="string">
      Unique identifier for the transfer.
    </ResponseField>

    <ResponseField name="amount" type="number">
      Amount transferred.
    </ResponseField>

    <ResponseField name="status" type="string">
      Status of the transfer (e.g., `PENDING`, `PROCESSING`, `COMPLETED`, `FAILED`).
    </ResponseField>

    <ResponseField name="transferDate" type="string">
      Date and time when the transfer was initiated.
    </ResponseField>

    <ResponseField name="estimatedSettlementTime" type="string">
      Estimated time for the transfer to be completed.
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request POST 'https://finlend.fincode.software/api/v1/services/user/transfer-funds-to-bank' \
  --header 'X-Auth-Token: YOUR_JWT_ACCESS_TOKEN' \
  --header 'x-idempotency-key: unique-key-12345' \
  --header 'x-fapi-auth-date: 2024-01-15T10:30:00Z' \
  --header 'x-fapi-customer-ip-address: 192.168.1.1' \
  --header 'x-fapi-interaction-id: interaction-12345' \
  --header 'Content-Type: application/json' \
  --data '{
      "customerId": "123e4567-e89b-12d3-a456-426614174000",
      "amount": 10000.00,
      "bankAccountId": "123e4567-e89b-12d3-a456-426614174000",
      "accountNumber": "1234567890",
      "bankCode": "058",
      "accountName": "John Doe",
      "transactionPin": "1234",
      "description": "Transfer to savings account"
  }'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const BASE_URL = 'https://finlend.fincode.software/api/v1/services/user';

  async function transferFundsToBank(accessToken, transferData) {
    try {
      const response = await axios.post(
        `${BASE_URL}/transfer-funds-to-bank`,
        {
          customerId: transferData.customerId,
          amount: transferData.amount,
          bankAccountId: transferData.bankAccountId,
          accountNumber: transferData.accountNumber,
          bankCode: transferData.bankCode,
          accountName: transferData.accountName,
          transactionPin: transferData.transactionPin,
          description: transferData.description || '',
        },
        {
          headers: {
            'X-Auth-Token': accessToken,
            'x-idempotency-key': `key-${Date.now()}`,
            'x-fapi-auth-date': new Date().toISOString(),
            'x-fapi-customer-ip-address': '192.168.1.1',
            'x-fapi-interaction-id': `interaction-${Date.now()}`,
            'Content-Type': 'application/json',
          },
        }
      );

      return response.data.data;
    } catch (error) {
      console.error(
        'Failed to transfer funds:',
        error.response?.data || error.message
      );
      throw error;
    }
  }

  // Usage Example
  const accessToken = 'YOUR_JWT_ACCESS_TOKEN';
  transferFundsToBank(accessToken, {
    customerId: '123e4567-e89b-12d3-a456-426614174000',
    amount: 10000.00,
    bankAccountId: '123e4567-e89b-12d3-a456-426614174000',
    accountNumber: '1234567890',
    bankCode: '058',
    accountName: 'John Doe',
    transactionPin: '1234',
    description: 'Transfer to savings account',
  });
  ```
</CodeGroup>
