Documentation Index Fetch the complete documentation index at: https://docs.baanx.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This endpoint initiates a withdrawal from the authenticated user’s credit wallet to their registered external wallet address. The withdrawal is processed on-chain on the Linea network, and the net amount received equals the requested amount minus network gas fees.
Prerequisites:
User must have a registered external wallet (completed delegation flow)
Credit wallet must have sufficient balance to cover withdrawal amount + fees
User must be verified and in good standing
Process Flow:
Check available balance with GET /v1/wallet/credit
Estimate fees with GET /v1/wallet/credit/withdraw-estimation
Initiate withdrawal with this endpoint
Monitor transaction on blockchain using returned txHash
Verify completion with GET /v1/wallet/history
Authentication
Your public API client key that identifies your environment
Bearer token obtained from OAuth flow or direct login
Query Parameters
Set to true to route request to US backend environment (if available for your client)
Request Body
Amount to withdraw in USDC (decimal string). Must not exceed available balance.
Response
Blockchain transaction hash of the withdrawal. Use this to track transaction status on the Linea network.
200 - Success
400 - Bad Request
401 - Authentication Error
403 - Authorization Error
422 - Validation Error
500 - Internal Server Error
{
"txHash" : "0xb92de09d893e8162b0861c0f7321f68df02212efbc58f208839ae3f176d89638"
}
Code Examples
cURL
Python
JavaScript
TypeScript
curl -X POST "https://dev.api.baanx.com/v1/wallet/credit/withdraw" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": "10.00"
}'
Complete Withdrawal Flow
Check Balance
Verify sufficient funds are available const wallet = await fetch ( '/v1/wallet/credit' );
const { balance } = await wallet . json ();
Estimate Fees
Get current network fee estimate const fees = await fetch ( '/v1/wallet/credit/withdraw-estimation' );
const { usdc : feeAmount } = await fees . json ();
Calculate Net Amount
Show user what they’ll receive const netAmount = parseFloat ( balance ) - parseFloat ( feeAmount );
// Display: "You will receive ~${netAmount} USDC"
Initiate Withdrawal
Execute the withdrawal const result = await fetch ( '/v1/wallet/credit/withdraw' , {
method: 'POST' ,
body: JSON . stringify ({ amount: '10.00' })
});
const { txHash } = await result . json ();
Monitor Transaction
Track blockchain confirmation // Poll blockchain or use webhook
const txUrl = `https://lineascan.build/tx/ ${ txHash } ` ;
// Wait for confirmations (typically 1-3 minutes on Linea)
Important Notes
Insufficient Balance : The withdrawal amount plus estimated fees must not exceed available balance. Always validate balance before calling this endpoint.
Network Fees : Fees are deducted from the withdrawal amount. If withdrawing 10 USDC with 0.02 USDC fee, user receives 9.98 USDC.
Transaction Monitoring : Use the returned txHash to track transaction status on Linea block explorer. Typical confirmation time is 1-3 minutes.
Error Handling
Common Errors
Insufficient Balance
{
"message" : "Insufficient balance for withdrawal"
}
Solution: Check balance with GET /v1/wallet/credit and ensure amount + fees < balance.
No External Wallet
{
"message" : "No external wallet registered"
}
Solution: User must complete delegation flow to register an external wallet first.
Invalid Amount
{
"message" : "amount must be a positive number"
}
Solution: Validate amount format and ensure it’s a positive decimal string.
Withdrawal Not Allowed
{
"message" : "Withdrawals are not allowed for this wallet"
}
Solution: Check isWithdrawable flag on GET /v1/wallet/credit before attempting withdrawal.
Edge Cases
Minimum Withdrawal Amounts
Gas fees make very small withdrawals uneconomical:
const minViableWithdrawal = 1.00 ;
if ( parseFloat ( amount ) < minViableWithdrawal ) {
alert ( 'Minimum withdrawal is 1.00 USDC due to network fees' );
}
Concurrent Withdrawals
Only one withdrawal can be processed at a time per wallet:
let withdrawalInProgress = false ;
async function safeWithdraw ( amount ) {
if ( withdrawalInProgress ) {
throw new Error ( 'Withdrawal already in progress' );
}
withdrawalInProgress = true ;
try {
return await withdrawFromCredit ( amount );
} finally {
withdrawalInProgress = false ;
}
}
Network Congestion
During high traffic, transactions may take longer:
Implement retry logic with exponential backoff
Display estimated confirmation time to users
Consider queuing withdrawals for later processing