> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdrawal

> Withdraw staked assets on TON with the P2P.org Staking API.

The withdrawal process in the TON network using the Staking API can be done following these steps:

1. Create an unstaking request.
2. Sign and broadcast the transaction to withdraw staked tokens from the pool.

<Warning>
  **Please note**

  For single nominator pools, the unstaking transaction could only be performed by the pool owner. It is also crucial to use the wallet version of the pool owner for the unstaking request.
</Warning>

<Steps>
  <Step title="Create unstaking request">
    Depending on the type of your staking pool, send a POST request either to [/api/v1/ton/\{network}/staking/single-nominator/unstake](/reference/ton-staking-single-nominator-unstake) or to [/api/v1/ton/\{network}/staking/ton-whales/unstake](/reference/ton-staking-ton-whales-unstake). A special memo message for withdrawal will be created.

    Example request (for the single nominator pool in the `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
        --url https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/unstake \
        --header 'accept: application/json' \
        --header 'authorization: Bearer <token>' \
        --header 'content-type: application/json' \
        --data '
      {
        "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6",
        "amount": 200,
        "walletVersion": "V4"
      }
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/unstake", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
      });
      const data = await response.json();
      console.log(data);
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/unstake",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
      )
      print(response.json())
      ```

      ```go Go theme={null}
      package main

      import (
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/unstake", nil)
      	req.Header.Set("Authorization", "Bearer <token>")
      	req.Header.Set("Content-Type", "application/json")
      	resp, _ := http.DefaultClient.Do(req)
      	defer resp.Body.Close()
      	respBody, _ := io.ReadAll(resp.Body)
      	fmt.Println(string(respBody))
      }
      ```
    </CodeGroup>

    * `publicKey` — public key of the nominator for the TON network.
    * `amount` — amount of tokens to unstake in TON.
    * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. `V4` is used by default.

    > Since only an owner of the single nominator pool can perform the transaction, mind specifying the current wallet version of the active pool owner.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "error": null,
          "result": {
            "unsignedTransaction": "b5ee9c7241010101003800006b000010000000000000000001000000039fedeab7a2b56b38f19f60b5b9f70b2f1ba2d89b9c5a756036c7cfad73571fb281887735940193456f7e",
            "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6",
            "amount": "2"
          }
        }
      ```
    </CodeGroup>

    * `unsignedTransaction` — <Tooltip tip="A transaction that must be signed and broadcasted to the blockchain network.">unsigned transaction</Tooltip> in the hexadecimal format. Sign the transaction and submit it to the blockchain to create an unstake request.
    * `publicKey` — public key of the nominator for the TON network.
    * `amount` — amount of tokens to unstake in TON.
  </Step>

  <Step title="Sign and broadcast transaction">
    [Sign and broadcast](/docs/signing-transaction-ton) the `unsignedTransaction` to the TON network.
  </Step>
</Steps>


## Related topics

- [Getting Started](/docs/staking-ton.md)
- [Staking API reference](/reference/ton-staking-single-nominator-stake.md)
