> ## 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.

# Pending Repayments

> Retrieves a paginated list of pending repayments for a user across all their loans.

Fetches all pending repayments that the user needs to make, including due dates and amounts for each installment.

<RequestExample>
  ```bash cURL GET theme={null}
  [https://finlend.fincode.software/api/v1/services/user/pending-repayments/{user-id}](https://finlend.fincode.software/api/v1/services/user/pending-repayments/{user-id})
  ```
</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>

## Path Parameters

<ParamField path="user-id" type="string" required>
  The unique identifier (UUID) of the user whose pending repayments to retrieve.
</ParamField>

## Query Parameters

<ParamField query="page" type="number" default="1">
  Page number for pagination (starts from 1).
</ParamField>

<ParamField query="size" type="number" default="10">
  Number of items per page (maximum recommended: 50).
</ParamField>

## Response

Returns a list of pending repayments with details.

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

<ResponseField name="data" type="array">
  Array of pending repayment objects.

  <Expandable title="data array item">
    <ResponseField name="loanApplicationId" type="string">
      Unique identifier for the loan application.
    </ResponseField>

    <ResponseField name="installmentNumber" type="number">
      Sequential number of the installment.
    </ResponseField>

    <ResponseField name="dueDate" type="string">
      Date when this repayment is due.
    </ResponseField>

    <ResponseField name="amountDue" type="number">
      Amount that needs to be repaid.
    </ResponseField>

    <ResponseField name="principalAmount" type="number">
      Principal portion of the repayment.
    </ResponseField>

    <ResponseField name="interestAmount" type="number">
      Interest portion of the repayment.
    </ResponseField>

    <ResponseField name="status" type="string">
      Status of the repayment (e.g., `PENDING`, `OVERDUE`).
    </ResponseField>

    <ResponseField name="daysOverdue" type="number">
      Number of days the repayment is overdue (if applicable).
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://finlend.fincode.software/api/v1/services/user/pending-repayments/123e4567-e89b-12d3-a456-426614174000?page=1&size=10' \
  --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'
  ```

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

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

  async function getPendingRepayments(accessToken, userId, page = 1, size = 10) {
    try {
      const response = await axios.get(
        `${BASE_URL}/pending-repayments/${userId}`,
        {
          params: {
            page,
            size,
          },
          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()}`,
          },
        }
      );
      repayments.forEach((repayment) => {
        console.log(
          `- Loan ${repayment.loanApplicationId}: ` +
          `${repayment.amountDue} due ${repayment.dueDate} ` +
          `(Status: ${repayment.status})`
        );
      });

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

  // Usage Example
  const accessToken = 'YOUR_JWT_ACCESS_TOKEN';
  const userId = '123e4567-e89b-12d3-a456-426614174000';
  getPendingRepayments(accessToken, userId, 1, 20);
  ```
</CodeGroup>
