private/withdraw
Submits a signed request to withdraw a spot asset out of a subaccount. You provide the subaccount id, asset name, amount in underlying units, a nonce, the signer, an EIP-712 signature with its expiry, and the maximum sequencer fee (in USD) you authorise; setting force_batch controls whether the withdrawal is batched. Requires a session key with withdraw permission, and returns the accepted operation id and its uuid for tracking.
curl --request POST \
--url https://api.derive.xyz/v3/private/withdraw \
--header 'Content-Type: application/json' \
--data '
{
"amount_in_underlying": "<string>",
"asset_name": "<string>",
"force_batch": true,
"max_fee_usd": "<string>",
"nonce": 123,
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"subaccount_id": 1,
"recipient": null
}
'import requests
url = "https://api.derive.xyz/v3/private/withdraw"
payload = {
"amount_in_underlying": "<string>",
"asset_name": "<string>",
"force_batch": True,
"max_fee_usd": "<string>",
"nonce": 123,
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"subaccount_id": 1,
"recipient": None
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount_in_underlying: '<string>',
asset_name: '<string>',
force_batch: true,
max_fee_usd: '<string>',
nonce: 123,
signature: '<string>',
signature_expiry_sec: 1,
signer: '<string>',
subaccount_id: 1,
recipient: null
})
};
fetch('https://api.derive.xyz/v3/private/withdraw', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.derive.xyz/v3/private/withdraw",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount_in_underlying' => '<string>',
'asset_name' => '<string>',
'force_batch' => true,
'max_fee_usd' => '<string>',
'nonce' => 123,
'signature' => '<string>',
'signature_expiry_sec' => 1,
'signer' => '<string>',
'subaccount_id' => 1,
'recipient' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.derive.xyz/v3/private/withdraw"
payload := strings.NewReader("{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.derive.xyz/v3/private/withdraw")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.derive.xyz/v3/private/withdraw")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}"
response = http.request(request)
puts response.read_body{
"op_uuid": "<string>",
"operation_id": 1
}Body
Maximum sequencer fee the signer authorises, in USD, as a decimal string (e.g. "1.5") or a JSON number.
x >= 0x >= 0L1 address the funds are paid out to. Defaults to the subaccount's owner wallet when omitted.
A non-owner signer (session key) may only pay out to an address on the owner's whitelisted_recipients, unless the key holds Admin.
curl --request POST \
--url https://api.derive.xyz/v3/private/withdraw \
--header 'Content-Type: application/json' \
--data '
{
"amount_in_underlying": "<string>",
"asset_name": "<string>",
"force_batch": true,
"max_fee_usd": "<string>",
"nonce": 123,
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"subaccount_id": 1,
"recipient": null
}
'import requests
url = "https://api.derive.xyz/v3/private/withdraw"
payload = {
"amount_in_underlying": "<string>",
"asset_name": "<string>",
"force_batch": True,
"max_fee_usd": "<string>",
"nonce": 123,
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"subaccount_id": 1,
"recipient": None
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount_in_underlying: '<string>',
asset_name: '<string>',
force_batch: true,
max_fee_usd: '<string>',
nonce: 123,
signature: '<string>',
signature_expiry_sec: 1,
signer: '<string>',
subaccount_id: 1,
recipient: null
})
};
fetch('https://api.derive.xyz/v3/private/withdraw', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.derive.xyz/v3/private/withdraw",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount_in_underlying' => '<string>',
'asset_name' => '<string>',
'force_batch' => true,
'max_fee_usd' => '<string>',
'nonce' => 123,
'signature' => '<string>',
'signature_expiry_sec' => 1,
'signer' => '<string>',
'subaccount_id' => 1,
'recipient' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.derive.xyz/v3/private/withdraw"
payload := strings.NewReader("{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.derive.xyz/v3/private/withdraw")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.derive.xyz/v3/private/withdraw")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_underlying\": \"<string>\",\n \"asset_name\": \"<string>\",\n \"force_batch\": true,\n \"max_fee_usd\": \"<string>\",\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"subaccount_id\": 1,\n \"recipient\": null\n}"
response = http.request(request)
puts response.read_body{
"op_uuid": "<string>",
"operation_id": 1
}