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 withloan_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
Step 2: Record repayments
Each repayment is a loan payment split intoPRINCIPAL 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 aLOAN_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