Skip to main content
POST
/
accounts
/
{external_id}
/
plan
/
execute
Execute Plan
curl --request POST \
  --url https://api.example.com/accounts/{external_id}/plan/execute

Execute Plan

Executes a previously created plan. The plan must have been signed by the sub-account’s signer. This triggers the actual on-chain transaction(s).

Request

POST /accounts/:external_id/plan/execute

Body parameters

ParameterTypeRequiredDescription
plan_idstringYesThe plan ID returned from a plan creation endpoint
signaturestringYesEIP-712 signature over the plan’s digest (0x-prefixed hex)

Examples

curl -X POST https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/plan/execute \
  -H "Authorization: Bearer $LEGEND_QUERY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "plan_id": "pln_71mcui082png",
    "signature": "0x1a2b3c4d5e6f..."
  }'
Response
{
  "plan_id": "pln_71mcui082png",
  "quark_intent_id": 42,
  "status": "executing"
}

Response fields

FieldTypeDescription
plan_idstringThe executed plan’s ID
quark_intent_idintegerInternal intent ID (useful for debugging)
statusstringAlways "executing" on success — the transaction has been submitted

Signing the plan

When you create a plan (earn, withdraw, or transfer), the response includes chart.eip712_data.digest. This is the EIP-712 hash that the account’s signer must sign.
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(privateKey);
const signature = await signer.sign({ hash: plan.chart.eip712_data.digest });

Errors

StatusCodeDescription
400invalid_paramsMissing plan_id or signature
404plan_not_foundPlan doesn’t exist or has expired
409plan_stalePlan’s underlying data has changed — create a new plan
500internal_errorSignature verification or execution failed

Notes

  • Plans expire after 2 minutes. If the plan has expired, create a new one.
  • Once executed, the plan is consumed and cannot be re-executed.
  • The status: "executing" response means the transaction has been submitted but not yet confirmed. Use Activities or Events to track confirmation.
  • The signature must come from the signer key associated with the sub-account. A signature from a different key will be rejected.