# Retirar fondos restantes

Esta función se usa para retirar fondos que están atrapados en escrow y no pueden retirarse debido a la forma en que funciona el escrow de liberación múltiple, ya que las disputas en este caso se manejan a nivel de hito.

En las cuentas de escrow de liberación única, este endpoint no es necesario porque las disputas se manejan a nivel de la cuenta de escrow, por lo que si queda algún saldo en el contrato, se abre una disputa y se retira el saldo restante.

### Encabezados

<table><thead><tr><th width="366">Nombre</th><th>Valor</th></tr></thead><tbody><tr><td>Tipo de contenido</td><td><code>application/json</code></td></tr><tr><td>x-api-key</td><td><code>&#x3C;token></code></td></tr></tbody></table>

### API Abierta

## POST /escrow/multi-release/withdraw-remaining-funds

>

```json
{"openapi":"3.0.0","info":{"title":"Trustless Work API","version":"1.0"},"security":[{}],"paths":{"/escrow/multi-release/withdraw-remaining-funds":{"post":{"operationId":"MultiReleaseController_withdrawRemainingFunds","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WithdrawRemainingFunds"}}}},"responses":{"201":{"description":"This endpoint returns an unsigned transaction in XDR format. This XDR is then used to sign the transaction using the “/helper/send-transaction” endpoint.","content":{"application/json":{}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized access"},"429":{"description":"Too Many Requests"},"500":{"description":"Possible errors:\n- Escrow not found\n- None of the amounts to be transferred should be less or equal than 0\n- Only the dispute resolver can execute this function\n- All milestones must be released or dispute-resolved before withdrawing remaining funds\n- The total amount to be transferred cannot be zero\n- Insufficient funds for resolution\n- An unexpected error occurred","content":{"application/json":{}}}},"tags":["Multi Release"]}}},"components":{"schemas":{"WithdrawRemainingFunds":{"type":"object","properties":{"contractId":{"type":"string","description":"ID (address) that identifies the escrow contract"},"disputeResolver":{"type":"string","description":"Address of the user defined to resolve disputes in an escrow"},"distributions":{"description":"Array of distributions detailing address and amount to allocate when withdrawing the remaining funds after resolution or completion. Amounts should sum the remaining escrow balance (post-fees).","type":"array","items":{"type":"array"}}},"required":["contractId","disputeResolver","distributions"]}}}}
```

<figure><img src="/files/d931caf5ebce7b5f28888879254145a228e2401a" alt=""><figcaption></figcaption></figure>

### **¿Qué devuelve este endpoint?**

Este endpoint devuelve la transacción sin firmar para que la transacción pueda ser firmada por medio de la cartera del cliente.

### Ejemplo de uso:

```typescript
import axios from "axios";

const http = axios.create({
  baseURL: "https://dev.api.trustlesswork.com",
  timeout: 10000,
  headers: {
    "Content-Type": "application/json",
    "x-api-key": tu_api_key,
  },
});

export const useExample = async () => {
    // Obtener la dirección del firmante
    const { address } = await kit.getAddress();

    const response = await http.post(
      "/escrow/multi-release/withdraw-remaining-funds",
      {
        // cuerpo solicitado para el endpoint
      },
    ); 
    
    // Obtener el hash de la transacción sin firmar
    const { unsignedTransaction } = response.data;

    // Firmar la transacción con la cartera
    const { signedTxXdr } = await signTransaction(unsignedTransaction, {
      address,
      networkPassphrase: WalletNetwork.TESTNET,
    });

    // Enviar la transacción a la red Stellar
    const tx = await http.post("/helper/send-transaction", {
      signedXdr: signedTxXdr,
    });

    const { data } = tx;

    return data;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.trustlesswork.com/trustless-work/v1-es/api-rest/deploy-1/withdraw-remaining-funds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
