Skip to main content
A flex loan is a business term loan: the business borrows a fixed amount and repays it, plus a fixed fee, over a set period. Repayment is collected automatically as a percentage of the business’s sales (the repayment rate), and each period has a minimum payment. If the amount withheld from sales doesn’t meet the minimum by the end of a period, the remainder is debited from the business’s bank account.
The sales-withheld portion of a flex loan repayment works the same way as a merchant cash advance. The difference is that a flex loan is a loan with a repayment term and a minimum payment, so it can also be repaid by direct bank debits.

Step 1: Create the loan

Create a loan with loan_type set to FLEX_LOAN, original_principal set to the financed amount, and fee_percentage set to the fixed fee. Disburse the full amount up front with a single DISBURSEMENT proceed. Set an external_id so you can reference the loan later without storing Layer’s IDs. The fee_percentage is the fixed fee expressed as a percentage (for example, "15" for a 15% fee on a $20,000 loan).
Request
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/loans \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "loan_type": "FLEX_LOAN",
  "external_id": "flex-001",
  "display_name": "Flex loan",
  "origination_date": "2024-03-01",
  "original_principal": 2000000,
  "fee_percentage": "15",
  "proceeds": [
    {
      "loan_proceed_type": "DISBURSEMENT",
      "amount": 2000000,
      "date": "2024-03-01",
      "method": "ACH"
    }
  ]
}'

Step 2: Record repayments

Each repayment is a loan payment split into PRINCIPAL and FEE. As with MCAs, you can omit splits and Layer derives them from the loan’s fee_percentage (principal = amount / (1 + fee_percentage / 100), fee = remainder); provide explicit splits to override.

Repayments withheld from sales

When a repayment is withheld from the business’s sales, record it exactly as you would for a merchant cash advance: attach it to the payout it was deducted from, or record it as a LOAN_REPAYMENT fee on the invoice payment it was withheld from. See Record repayments in the MCA guide for both flows.

Minimum payments debited from the bank

When a period’s sales don’t meet the minimum payment and the difference is debited directly from the business’s bank account, record that as a standalone loan payment:
Request
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/loans/payments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "loan_external_id": "flex-001",
  "external_id": "flex-001-minimum-2024-03-31",
  "amount": 115000,
  "date": "2024-03-31",
  "method": "ACH"
}'