Request a drawdown
Request part of a loan's funds for the merchant at each stage of a job, and check whether the funds posted.
A drawdown requests part of a loan's funds for the merchant. Use this guide when a loan pays out in stages and the merchant has finished a stage of the job, or the whole job. You request a drawdown through the API only.
For how loans and drawdowns fit together, see the Lending Overview.
The following diagram shows who sends what during a drawdown:
sequenceDiagram
participant P as Your platform
participant Z as Preczn
participant L as Lender
P->>Z: POST /v1/transactions (type: drawdown)
Z->>L: Drawdown request for the loan
L-->>Z: Answer
Z->>P: Transaction with authorization.status
L--)Z: Later: the drawdown posted, and the fee
P->>Z: GET /v1/transactions/{transactionId}
Z->>P: Transaction with loanTransactionData
Prerequisites
- The merchant is assigned to an active plan. Drawdowns skip plan rules, so the plan doesn't need to include the lender. Adding a lender connection doesn't create a default plan, so if your platform has only lender connections, create a plan and assign the merchant to it before its first drawdown. See Create a routing plan and Assign a merchant to a plan.
- The lender connection has credentials on both levels. Your platform's connection to the lender has your credentials, and the merchant's connection to the same lender has the merchant's credentials. See Add a connection to your platform and Manage a merchant's connection.
- You have a loan token for the loan. The token belongs to the same merchant that you request the drawdown for. See Add an existing loan.
- You have an API key for your platform, in the same mode (live or test) as the merchant.
Request the drawdown
-
Optional: check the loan before you draw on it. Call
GET /v1/tokens/{tokenId}with the loan token. Preczn fetches the latest data from the lender, soloanin the response shows the loan's current status, available credit, and balance. -
Call
POST /v1/transactionswithtypeset todrawdownand the loan token inpayment.token.{ "merchantId": "mid_test_{merchantId}", "type": "drawdown", "payment": { "token": "tkn_test_{tokenId}" }, "amount": 125000, "totalJobAmount": 1000000, "drawType": "progress", "invoice": "{invoiceNumber}" }{ "id": "{transactionId}", "type": "drawdown", "merchantId": "mid_test_{merchantId}", "platformId": "{platformId}", "amount": 125000, "totalJobAmount": 1000000, "drawType": "progress", "invoice": "{invoiceNumber}", "plan": { "id": "{planId}", "name": "{planName}" }, "authorization": { "status": "P", "approvedAmount": 125000, "processorTransactionId": "{lenderTransactionId}" } }The response is abbreviated. Set the drawdown fields as follows:
amount: the amount to draw now, in the currency's smallest unit (cents for USD).totalJobAmount: the amount for the whole job, in the same unit.drawType:progressfor a payment partway through the job, orcompletionfor the final payment.invoice: optional. Your invoice number. Preczn returns it on the transaction and passes it to the lender when the lender accepts one.
Preczn sends the drawdown to the lender that holds the loan, whatever your plan's routing rules say. The lender's answer is in
authorization.status. For every request and response field, see the API reference. -
Check whether the funds posted. When the lender reports the drawdown, Preczn adds
loanTransactionDatato the transaction. CallGET /v1/transactions/{transactionId}to read it.{ "id": "{transactionId}", "type": "drawdown", "amount": 125000, "loanTransactionData": { "posted": true, "feeAmount": 8750 } }The response is abbreviated.
postedtells you whether the funds posted to the bank account associated with the loan, andfeeAmountis the fee the lender removed from the drawdown, in the currency's smallest unit.
Errors
If Preczn can't send the drawdown to the lender, the API returns one of the following errors in message.
| Status | Message | What to do |
|---|---|---|
| 400 | No plan associated with merchant. | Assign the merchant to a plan. |
| 400 | Plan not active. | Activate the merchant's plan, or assign an active one. |
| 400 | Loan Token Not Found | Pass a loan token in payment.token. |
| 403 | Token merchantId mismatch | Use the merchantId of the merchant the loan belongs to. |
| 400 | Drawdown is not supported for ACH transactions. Drawdown is only applicable for lending payment methods. | Pass a loan token, not a bank account. |
| 400 | Platform or Merchant Level credentials are missing for {lender} | Add the credentials on your platform's connection and on the merchant's connection to the lender named in the message. |
Each error uses the standard error body. For example, a loan token that belongs to another merchant returns:
{
"statusCode": 403,
"error": "Forbidden",
"message": "Token merchantId mismatch"
}For the error format, see Errors.
Next
- To see what each loan status means, see Loan statuses.
- To hear about loan changes as they happen, see Loan webhook payloads.
- To download many loans at once, see Export loans.
Updated about 16 hours ago
