Plans
Plan Claim Rewards
Create a plan to claim protocol rewards
POST
/
accounts
/
{account_id}
/
plan
/
claim-rewards
Plan Claim Rewards
curl --request POST \
--url https://api.example.com/accounts/{account_id}/plan/claim-rewardsimport requests
url = "https://api.example.com/accounts/{account_id}/plan/claim-rewards"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/accounts/{account_id}/plan/claim-rewards', 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.example.com/accounts/{account_id}/plan/claim-rewards",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/accounts/{account_id}/plan/claim-rewards"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/accounts/{account_id}/plan/claim-rewards")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/plan/claim-rewards")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyPlan Claim Rewards
Creates a plan to claim earned protocol rewards (e.g., COMP tokens from Compound). Returns a plan ID and an EIP-712 digest that must be signed to authorize execution.Request
POST /accounts/:account_id/plan/claim-rewards
Path parameters
| Parameter | Type | Description |
|---|---|---|
account_id | string | The sub-account ID |
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
asset | string | Yes | Reward asset to claim (e.g., "COMP") |
Examples
curl -X POST https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/plan/claim-rewards \
-H "Authorization: Bearer $LEGEND_QUERY_KEY" \
-H "Content-Type: application/json" \
-d '{
"asset": "COMP"
}'
const plan = await client.plan.claimRewards("acc_2o0yiljtp378", {
asset: "COMP",
});
plan = await client.plan.claim_rewards(
"acc_2o0yiljtp378",
asset="COMP",
)
use legend_client::ClaimRewardsParams;
let plan = client.plan.claim_rewards("acc_2o0yiljtp378", &ClaimRewardsParams {
asset: "COMP".into(),
}).await?;
Response (201 Created)
{
"plan_id": "pln_71mcui082png",
"details": {
"quark_operation_actions": [...],
"eip712_data": {
"digest": "0x8a3f...b7c2",
"domain_separator": "0x...",
"hash_struct": "0x..."
}
},
"expires_at": "2025-06-15T10:32:00Z"
}
Response fields
| Field | Type | Description |
|---|---|---|
plan_id | string | Unique identifier for this plan (pln_ prefix) |
details | object | Transaction details including EIP-712 signing data |
details.eip712_data.digest | string | The hash to sign with the account’s signer key |
expires_at | string | ISO 8601 timestamp — plan must be executed before this time |
Errors
| Status | Code | Description |
|---|---|---|
| 400 | invalid_params | Missing required parameters |
| 400 | plan_failed | Could not generate a valid plan (e.g., no rewards to claim) |
| 400 | no_wallet | Account has no wallets |
| 408 | timeout | Folio computation timed out |
Notes
- Plans expire after 2 minutes. Sign and execute via Execute Plan before expiry.
- The resulting activity will have
action_type: "CLAIM_REWARDS"in its metadata.
⌘I
Plan Claim Rewards
curl --request POST \
--url https://api.example.com/accounts/{account_id}/plan/claim-rewardsimport requests
url = "https://api.example.com/accounts/{account_id}/plan/claim-rewards"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/accounts/{account_id}/plan/claim-rewards', 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.example.com/accounts/{account_id}/plan/claim-rewards",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/accounts/{account_id}/plan/claim-rewards"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/accounts/{account_id}/plan/claim-rewards")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/plan/claim-rewards")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body