> ## 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 Hyperliquid with the P2P.org Staking API.

The withdrawal process on the Hyperliquid network using the Staking API can be done in a few steps:

1. Undelegate the staked tokens from the P2P validator.

2. Withdraw unstaked tokens after the lock-up period.

After each operation, sign and send the transaction to the network.

Request examples are provided using [cURL](https://curl.se/).

<Steps>
  <Step title="Create undelegate request">
    1. To remove tokens from being actively delegated and transfer them to the staking balance, send a POST request to [/api/v1/hyperliquid/\{network}/staking/undelegate](/reference/hyperliquid-undelegate).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "amount": 10,
        "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "amount": 10,
          "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "amount": 10,
              "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
          },
      )
      print(response.json())
      ```

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

      import (
      	"bytes"
      	"encoding/json"
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	payload := map[string]interface{}{
      		"amount": 10,
      		"delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate", bytes.NewBuffer(body))
      	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>

    * `amount` — amount of tokens to undelegate in HYPE.
    * `delegatorAddress` — delegator account address on the Hyperliquid network.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": "10",
            "unsignedTransaction": "string",
            "createdAt": "2025-10-01T12:00:00Z"
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to undelegate in HYPE.
    * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.
    * `createdAt` — timestamp of the transaction in the ISO 8601 format.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network.

       After the transaction has been successfully executed, undelegated tokens immediately become available at the staking balance for transfer into the user's spot account.

    <Note>
      Note that it takes 7 days to prepare your tokens for withdrawal, which means that the tokens will be locked up during this period.
    </Note>
  </Step>

  <Step title="Create withdrawal request">
    1. After the lock-up period, withdraw delegated tokens by sending a POST request to [/api/v1/hyperliquid/\{network}/staking/withdraw](/reference/hyperliquid-withdraw).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "amount": 10,
        "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "amount": 10,
          "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "amount": 10,
              "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
          },
      )
      print(response.json())
      ```

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

      import (
      	"bytes"
      	"encoding/json"
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	payload := map[string]interface{}{
      		"amount": 10,
      		"delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/undelegate", bytes.NewBuffer(body))
      	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>

    * `amount` — amount of tokens to withdraw in HYPE.
    * `delegatorAddress` — delegator account address on the Hyperliquid network.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": "10",
            "unsignedTransaction": "string",
            "createdAt": "2025-10-01T12:00:00Z"
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to withdraw in HYPE.
    * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.
    * `createdAt` — timestamp of the transaction in the ISO 8601 format.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network.

       Transfers from spot to staking balance have a 7-day unstaking queue, which means that the tokens will be locked up during this period. You can check the pending withdrawals using the [get delegator balances](/reference/hyperliquid-info) endpoint.
  </Step>
</Steps>


## Related topics

- [Sign and Broadcast Transaction](/docs/signing-transaction-hyperliquid.md)
- [Staking API reference](/reference/hyperliquid-transfer.md)
