POST /utilities/close-accounts
Reclaim SOL locked as rent in unused token accounts. Use simulation mode to preview recoverable amounts before executing.
Quick Start
cURL
TypeScript
Rust
Go
Python
curl -X POST https://api.launchpad.trade/utilities/close-accounts \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"privateKeys": ["YOUR_PRIVATE_KEY"],
"simulate": true
}'
Parameters
Parameter Type Description privateKeysstring[] Private keys of the wallets to process. Min 1, max 50 mintsstring[] (Optional) Only close accounts for these specific token mints. If omitted, all empty token accounts are closedsimulateboolean (Optional) Preview mode. When true, returns the accounts that would be closed and the rent that would be recovered — without executing any transaction. Default: false
Always run with simulate: true first to see what will be closed and how much SOL you will recover.
Simulation vs Execution
Simulate
Execute
Filter by Mint
Returns a list of closable accounts and the SOL you would recover. No transactions are sent. {
"privateKeys" : [ "5K7gT..." , "3Jd8f..." ],
"simulate" : true
}
The response includes accountsToClose and rentRecoverable fields per wallet. Close the accounts and reclaim the rent SOL. This is the default behavior. {
"privateKeys" : [ "5K7gT..." , "3Jd8f..." ]
}
The response includes closed accounts with rentRecovered, status, and signature fields. Only close accounts for specific tokens — useful after selling a specific token. {
"privateKeys" : [ "5K7gT..." ],
"mints" : [ "7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr" ]
}
Only accounts matching the specified mints are closed. Other empty accounts are left untouched.
Use Cases
Scenario Approach After selling tokens Filter by the sold token mint to clean up Periodic cleanup Sweep all zero-balance accounts to recover accumulated rent Before withdrawing Reclaim all rent before consolidating wallets Audit recoverable rent Use simulate: true to estimate without executing
Each account holds ~0.002 SOL in rent. With many wallets and tokens, the total recoverable amount adds up quickly.
Response
Simulation (200)
Execution (200)
{
"success" : true ,
"data" : {
"simulate" : true ,
"wallets" : [
{
"wallet" : "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" ,
"accountsToClose" : [
{
"ata" : "5jJY9iJhqgbgQPaWxVvkVmbdVnjkGpTyWudwF66JbxZD" ,
"mint" : "GmhDC4CfmF5DYhDB1m911kpf55WeixbFNrb4nnXXpump" ,
"symbol" : "MYTOKEN" ,
"rentRecoverable" : 0.00203928
},
{
"ata" : "6kePrBi8nZf5mETUH8HWpLc5sNRkksy8UbJDpHuivJGF" ,
"mint" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" ,
"symbol" : "USDC" ,
"rentRecoverable" : 0.00203928
}
],
"stats" : {
"accountsToClose" : 2 ,
"rentRecoverable" : 0.00407856
}
}
],
"summary" : {
"totalWallets" : 1 ,
"totalAccountsToClose" : 2 ,
"totalRentRecoverable" : 0.00407856
}
}
}
{
"success" : true ,
"data" : {
"simulate" : false ,
"wallets" : [
{
"wallet" : "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" ,
"closed" : [
{
"ata" : "5jJY9iJhqgbgQPaWxVvkVmbdVnjkGpTyWudwF66JbxZD" ,
"mint" : "GmhDC4CfmF5DYhDB1m911kpf55WeixbFNrb4nnXXpump" ,
"symbol" : "MYTOKEN" ,
"rentRecovered" : 0.00203928 ,
"status" : "SUCCESS" ,
"signature" : "4uMMQLX4CFD6DJJQAmZwCFtkbe5xpu1L9Mphf1nY4d5JGos1vUKeYQf5PauNX9SokgMq936814mGpukd436aVJYJ"
}
],
"stats" : {
"accountsClosed" : 1 ,
"rentRecovered" : 0.00203928
}
}
],
"summary" : {
"totalWallets" : 1 ,
"totalAccountsClosed" : 1 ,
"totalRentRecovered" : 0.00203928
},
"latency" : 720 ,
"message" : "1 account(s) closed"
}
}
The message field is always present in execute mode. When no empty accounts are found, it returns "No empty accounts found".
Errors
{
"success" : false ,
"error" : {
"code" : "ACCOUNT_NOT_EMPTY" ,
"message" : "Token account still has a balance and cannot be closed"
}
}
Code Message Cause INVALID_WALLETInvalid private key One of the private keys is invalid INVALID_MINTInvalid mint address One of the mint addresses is invalid NO_WALLETSNo wallets provided No private keys provided TOO_MANY_WALLETSMaximum 50 wallets per request More than 50 wallets submitted ACCOUNT_NOT_EMPTYAccount has balance Token account still has a balance and cannot be closed RATE_LIMITRate limit exceeded Too many requests — see Rate Limits INTERNAL_ERRORInternal server error Retry or contact support
Notes
Only empty token accounts (zero balance) can be closed
Each wallet pays its own Solana transaction fee for closing its accounts
What’s Next?
Token Info List token accounts and find empty ones
Burn Tokens Burn unwanted tokens from your wallets
Withdraw SOL Consolidate SOL after reclaiming rent
Sell Tokens Sell tokens before closing their accounts