Session Keys
private/set_session_key_debug
Takes the same params as private/set_session_key and rebuilds the session-key Action without executing anything, returning the EIP-712 encoded_data, encoded_data_hashed, action_hash, typed_data_hash, domain_separator, action_typehash, module, owner and expected_signer, plus the decoded session key, expiry, protocol scopes and subaccounts. Byte-compare these against your local computation to find why a signature is rejected. Requires a logged-in session.
POST
/
private
/
set_session_key_debug
private/set_session_key_debug
curl --request POST \
--url https://api.derive.xyz/v3/private/set_session_key_debug \
--header 'Content-Type: application/json' \
--header 'X-DeriveSignature: <api-key>' \
--header 'X-DeriveTimestamp: <api-key>' \
--header 'X-DeriveWallet: <api-key>' \
--data '
{
"expiry_sec": 1,
"nonce": "<string>",
"offchain_scopes": [
"<string>"
],
"protocol_scopes": [
"<string>"
],
"public_session_key": "<string>",
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"wallet": "<string>",
"ip_whitelist": [
"<string>"
],
"label": "<string>",
"subaccount_ids": [
1
]
}
'import requests
url = "https://api.derive.xyz/v3/private/set_session_key_debug"
payload = {
"expiry_sec": 1,
"nonce": "<string>",
"offchain_scopes": ["<string>"],
"protocol_scopes": ["<string>"],
"public_session_key": "<string>",
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"wallet": "<string>",
"ip_whitelist": ["<string>"],
"label": "<string>",
"subaccount_ids": [1]
}
headers = {
"X-DeriveWallet": "<api-key>",
"X-DeriveTimestamp": "<api-key>",
"X-DeriveSignature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DeriveWallet': '<api-key>',
'X-DeriveTimestamp': '<api-key>',
'X-DeriveSignature': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
expiry_sec: 1,
nonce: '<string>',
offchain_scopes: ['<string>'],
protocol_scopes: ['<string>'],
public_session_key: '<string>',
signature: '<string>',
signature_expiry_sec: 1,
signer: '<string>',
wallet: '<string>',
ip_whitelist: ['<string>'],
label: '<string>',
subaccount_ids: [1]
})
};
fetch('https://api.derive.xyz/v3/private/set_session_key_debug', 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/set_session_key_debug",
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([
'expiry_sec' => 1,
'nonce' => '<string>',
'offchain_scopes' => [
'<string>'
],
'protocol_scopes' => [
'<string>'
],
'public_session_key' => '<string>',
'signature' => '<string>',
'signature_expiry_sec' => 1,
'signer' => '<string>',
'wallet' => '<string>',
'ip_whitelist' => [
'<string>'
],
'label' => '<string>',
'subaccount_ids' => [
1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-DeriveSignature: <api-key>",
"X-DeriveTimestamp: <api-key>",
"X-DeriveWallet: <api-key>"
],
]);
$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/set_session_key_debug"
payload := strings.NewReader("{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DeriveWallet", "<api-key>")
req.Header.Add("X-DeriveTimestamp", "<api-key>")
req.Header.Add("X-DeriveSignature", "<api-key>")
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/set_session_key_debug")
.header("X-DeriveWallet", "<api-key>")
.header("X-DeriveTimestamp", "<api-key>")
.header("X-DeriveSignature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.derive.xyz/v3/private/set_session_key_debug")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DeriveWallet"] = '<api-key>'
request["X-DeriveTimestamp"] = '<api-key>'
request["X-DeriveSignature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}"
response = http.request(request)
puts response.read_body{
"action_hash": "<string>",
"action_typehash": "<string>",
"domain_separator": "<string>",
"encoded_data": "<string>",
"encoded_data_hashed": "<string>",
"expected_signer": "<string>",
"input_data": {
"data": {
"expiry_sec": 1,
"scopes": [
"<string>"
],
"session_key": "<string>",
"subaccounts": [
1
]
},
"expiry": 1,
"module": "<string>",
"nonce": "<string>",
"owner": "<string>",
"signer": "<string>",
"subaccount_id": 1
},
"module": "<string>",
"owner": "<string>",
"typed_data_hash": "<string>",
"recovered_signer": "<string>"
}{
"error": {
"code": 123,
"message": "<string>",
"data": "<string>"
}
}Authorizations
Body
application/json
Request parameters for registering a scoped session key. Address fields are 0x-prefixed hex strings.
Response
Success
Debug-route payload for one rebuilt action: the EIP-712 hashes plus the action input fields.
private/set_session_key_debug
curl --request POST \
--url https://api.derive.xyz/v3/private/set_session_key_debug \
--header 'Content-Type: application/json' \
--header 'X-DeriveSignature: <api-key>' \
--header 'X-DeriveTimestamp: <api-key>' \
--header 'X-DeriveWallet: <api-key>' \
--data '
{
"expiry_sec": 1,
"nonce": "<string>",
"offchain_scopes": [
"<string>"
],
"protocol_scopes": [
"<string>"
],
"public_session_key": "<string>",
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"wallet": "<string>",
"ip_whitelist": [
"<string>"
],
"label": "<string>",
"subaccount_ids": [
1
]
}
'import requests
url = "https://api.derive.xyz/v3/private/set_session_key_debug"
payload = {
"expiry_sec": 1,
"nonce": "<string>",
"offchain_scopes": ["<string>"],
"protocol_scopes": ["<string>"],
"public_session_key": "<string>",
"signature": "<string>",
"signature_expiry_sec": 1,
"signer": "<string>",
"wallet": "<string>",
"ip_whitelist": ["<string>"],
"label": "<string>",
"subaccount_ids": [1]
}
headers = {
"X-DeriveWallet": "<api-key>",
"X-DeriveTimestamp": "<api-key>",
"X-DeriveSignature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DeriveWallet': '<api-key>',
'X-DeriveTimestamp': '<api-key>',
'X-DeriveSignature': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
expiry_sec: 1,
nonce: '<string>',
offchain_scopes: ['<string>'],
protocol_scopes: ['<string>'],
public_session_key: '<string>',
signature: '<string>',
signature_expiry_sec: 1,
signer: '<string>',
wallet: '<string>',
ip_whitelist: ['<string>'],
label: '<string>',
subaccount_ids: [1]
})
};
fetch('https://api.derive.xyz/v3/private/set_session_key_debug', 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/set_session_key_debug",
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([
'expiry_sec' => 1,
'nonce' => '<string>',
'offchain_scopes' => [
'<string>'
],
'protocol_scopes' => [
'<string>'
],
'public_session_key' => '<string>',
'signature' => '<string>',
'signature_expiry_sec' => 1,
'signer' => '<string>',
'wallet' => '<string>',
'ip_whitelist' => [
'<string>'
],
'label' => '<string>',
'subaccount_ids' => [
1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-DeriveSignature: <api-key>",
"X-DeriveTimestamp: <api-key>",
"X-DeriveWallet: <api-key>"
],
]);
$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/set_session_key_debug"
payload := strings.NewReader("{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DeriveWallet", "<api-key>")
req.Header.Add("X-DeriveTimestamp", "<api-key>")
req.Header.Add("X-DeriveSignature", "<api-key>")
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/set_session_key_debug")
.header("X-DeriveWallet", "<api-key>")
.header("X-DeriveTimestamp", "<api-key>")
.header("X-DeriveSignature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.derive.xyz/v3/private/set_session_key_debug")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DeriveWallet"] = '<api-key>'
request["X-DeriveTimestamp"] = '<api-key>'
request["X-DeriveSignature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expiry_sec\": 1,\n \"nonce\": \"<string>\",\n \"offchain_scopes\": [\n \"<string>\"\n ],\n \"protocol_scopes\": [\n \"<string>\"\n ],\n \"public_session_key\": \"<string>\",\n \"signature\": \"<string>\",\n \"signature_expiry_sec\": 1,\n \"signer\": \"<string>\",\n \"wallet\": \"<string>\",\n \"ip_whitelist\": [\n \"<string>\"\n ],\n \"label\": \"<string>\",\n \"subaccount_ids\": [\n 1\n ]\n}"
response = http.request(request)
puts response.read_body{
"action_hash": "<string>",
"action_typehash": "<string>",
"domain_separator": "<string>",
"encoded_data": "<string>",
"encoded_data_hashed": "<string>",
"expected_signer": "<string>",
"input_data": {
"data": {
"expiry_sec": 1,
"scopes": [
"<string>"
],
"session_key": "<string>",
"subaccounts": [
1
]
},
"expiry": 1,
"module": "<string>",
"nonce": "<string>",
"owner": "<string>",
"signer": "<string>",
"subaccount_id": 1
},
"module": "<string>",
"owner": "<string>",
"typed_data_hash": "<string>",
"recovered_signer": "<string>"
}{
"error": {
"code": 123,
"message": "<string>",
"data": "<string>"
}
}