---
title: "Consolidate unspents (advanced)"
method: POST
path: "/api/v2/{coin}/wallet/{walletId}/consolidateUnspents"
tags: ["Wallet"]
---

# Consolidate unspents (advanced)

`POST /api/v2/{coin}/wallet/{walletId}/consolidateUnspents`

Build a transaction to consolidate unspents in a wallet. Once built, you must sign and sent the transaction. Consolidating unspents is only for UTXO-based assets.

## Path parameters

- `coin` string, required — A cryptocurrency or token ticker symbol.
- `walletId` string, required

## Request body

- ConsolidateUnspentsRequest
  - `feeRate` union
    - string — Custom fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte. If the `feeRate` is less than the minimum required network fee, then the minimum fee applies. For example, 1000 sat/kvByte, a flat 1000 microAlgos, or a flat 10 drops of xrp. For XRP, the actual fee is usually 4.5 times the open ledger fee. Note: The `feeRate` overrides the `maxFeeRate` and `minFeeRate`.
    - integer — Custom fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte. If the `feeRate` is less than the minimum required network fee, then the minimum fee applies. For example, 1000 sat/kvByte, a flat 1000 microAlgos, or a flat 10 drops of xrp. For XRP, the actual fee is usually 4.5 times the open ledger fee. Note: The `feeRate` overrides the `maxFeeRate` and `minFeeRate`.
  - `maxFeeRate` union
    - string — (BTC only) The maximum fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte. The `maxFeeRate` limits the fee rate generated by both `feeMultiplier` and `numBlocks`. Note: The `feeRate` overrides the `maxFeeRate`.
    - integer — (BTC only) The maximum fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte. The `maxFeeRate` limits the fee rate generated by both `feeMultiplier` and `numBlocks`. Note: The `feeRate` overrides the `maxFeeRate`.
  - `maxFeePercentage` integer — Maximum relative portion that can be spent towards fees
  - `feeTxConfirmTarget` integer — Block target for fee estimation
  - `bulk` boolean — Build multiple transactions at the same time. This enables you to increase the maximum number of unspents on the `limit` parameter up to 2,000. If true, you must pass the `txFormat` as `psbt` and you can't pass the `targetAddress` or `numUnspentsToMake` parameters.
  - `minValue` union
    - string
    - integer
  - `maxValue` union
    - string
    - integer
  - `minHeight` integer — Minimum height of unspents on the block chain to use
  - `minConfirms` integer — Minimum confirmation threshold for external inputs
  - `enforceMinConfirmsForChange` boolean — Flag for enforcing minConfirms for change inputs
  - `limit` integer — Maximum number of unspents to use in the transaction
  - `numUnspentsToMake` integer — Number of new unspents to make
  - `targetAddress` string — address to use for generated outputs. Must be wallet address.
  - `txFormat` 'legacy' | 'psbt' | 'psbt-lite' — [UTXO only] Format of the returned transaction hex serialization. `legacy` for serialized transaction in custom bitcoinjs-lib format. `psbt` for BIP174 serialized transaction

## Response `200`

OK

- WalletConsolidateUnspentsResponse
  - `txHex` union
    - string — Serialized transaction hex
    - string — BIP174 serialization of a PSBT
  - `txInfo` UtxoTxInfo — txInfo (UTXO)
    - `changeAddresses` AddressString3[]
    - `nOutputs` integer — Number of outputs
    - `nP2SHInputs` integer
    - `nSegwitInputs` integer
    - `unspents` Unspent[]
      - `id` string — The id of the unspent in the form <txid>:<tx_index>
      - `address` string — The address of this unspent
      - `value` integer
      - `valueString` string
      - `blockHeight` integer — The block this Unspent was created in
      - `date` string, date-time — The date this unspent was created
      - `coinbase` boolean — True if this unspent came from the coinbase transaction
      - `wallet` string
      - `fromWallet` string
      - `chain` integer — The type of this unspent's address (P2SH, P2WSH, etc...)
      - `index` integer — A monotonic counter used when creating new addresses
      - `redeemScript` string — The Script program used to cryptographically verify spending this unspent
      - `witnessScript` string — The segwit Script program used to cryptographically verify spending this unspent
      - `isSegwit` boolean
    - `walletAddressDetails` Address21
      - `id` string
      - `address` string
      - `chain` 0 | 1 | 10 | 11 | 20 | 21 | 30 | 31 | 40 | 41
      - `index` integer
      - `coin` string
      - `lastNonce` integer
      - `wallet` string
      - `coinSpecific` object — Properties which are specific to certain coin types
        - `xlm` AddressCoinSpecificXlm
          - `memoId` string — Latest memo id generated for the wallet
          - `rootAddress` string — Root address of the wallet
        - `txlm` AddressCoinSpecificXlm
          - `memoId` string — Latest memo id generated for the wallet
          - `rootAddress` string — Root address of the wallet
      - `balance` object — Balance of the address. In case of Eth and Celo, if returnBalancesForToken is passed with includeBalances, then it will return token balance in the address object. This field will be present only when `includeBalances` query param is passed as true.
        - `updated` string, date-time — The last time a transaction affected the balance of this address
        - `balance` integer — The cleared balance of the address
        - `balanceString` string — String representation of `balance`. Guaranteed to not lose precision.
        - `totalReceived` integer — The total amount received on this address (in the chain's base unit)
        - `totalSent` integer — The total amount send from this address (in the chain's base unit)
        - `confirmedBalanceString` string — The total balance of confirmed transactions for the address (in the chain's base unit). Guaranteed to not lose precision.
        - `spendableBalanceString` string — The total balance of the address (in the chain's base unit) which may be used as inputs for creating new transactions in string representation. Guaranteed to not lose precision.
      - `label` string, nullable — A human-readable label for the address.
      - `addressType` 'p2sh' | 'p2shP2wsh' | 'p2wsh' | 'p2tr' | 'p2trMusig2'
  - `feeInfo` UtxoFeeInfo — feeInfo (UTXO)
    - `size` integer — Estimated size of the transaction in bytes
    - `fee` integer — Estimated fee in base unit for the transaction
    - `feeRate` union
      - string — Custom minimum fee rate in a coin's base unit per kilobyte (or virtual kilobyte)--for example, satoshis per kvByte or microAlgos per kByte. If the applied `feeRate` does not meet a coin's required minimum transaction fee amount, the minimum is still applied (for example, 1000 sat/kvByte or a flat 1000 microAlgos).
      - integer — Custom minimum fee rate in a coin's base unit per kilobyte (or virtual kilobyte)--for example, satoshis per kvByte or microAlgos per kByte. If the applied `feeRate` does not meet a coin's required minimum transaction fee amount, the minimum is still applied (for example, 1000 sat/kvByte or a flat 1000 microAlgos).
    - `payGoFee` integer — BitGo fee of the transaction (in base units)
    - `payGoFeeString` integer — BitGo fee of the transaction (in base units) represented as a String

## Other responses

- `400` — Bad Request

---

[API](https://skmtc.net/bitgo/apis/bitgo-api.md) · [All operations](https://skmtc.net/bitgo/apis/bitgo-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bitgo/bitgo-api/revisions/e445c15e5bee/schema)
