Decide: execute a plan

quoted per request from $0.001 · USDC via x402 · POST /api/decide/execute

Run a decision's plan through Agent402: first-party steps run directly, third-party steps are bought from the seller and resold to you (you pay on Base, or by credits or card) at the seller's price plus a disclosed markup. Send POST /api/decide/execute with no required fields (5 optional) and pay quoted per request from $0.001 over x402 with USDC on Base. It returns a JSON object with runId, decisionId, status, steps, budgetUsd and 5 more.

Priced at the plan's budget (or your maxBudgetUsd, whichever you set) less a valid execution credit; spend stops at that budget, fallbacks are tried in order, and any unspent amount comes back as a credit. A run where no step succeeds is not charged. Also runs a free plan sketch: pass the sketch's tool slugs as steps (no decisionId) with params for step 1, and each later step takes its one required input from the step before, at list price. Takes up to 3 minutes to answer: keep the connection open for at least 210 seconds, because a client that disconnects first loses the answer, or send the paid call with "Prefer: respond-async" to get a job link at once and collect the answer from it (payment still settles only on a delivered result).

Category: Routing & delegation · Tags: agents execute planning router x402

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
decisionIdstringnoFrom POST /api/decide (or pass steps instead)
stepsarray of stringnoInstead of decisionId: the tool slugs of a free plan sketch (from /api/find or /api/route), 2 to 5, in order. Pass params for step 1; a later step takes its one required input from the step before.
creditTokenstringnoexecutionCredit.token from that decision (optional)
maxBudgetUsdnumbernoSpend ceiling for the run (default: the plan's estimate via Agent402)
paramsobjectnoPer-step params overriding the plan's exampleParams, keyed by step number

Example request

curl -i -X POST https://agent402.tools/api/decide/execute \
  -H "Content-Type: application/json" \
  -d '{"decisionId":"dec_2b1c9e0f4a7d4c3e9b8a1f00","creditToken":"dc_...","maxBudgetUsd":0.05}'

Without payment this returns HTTP 402 Payment Required with the exact price for decide-execute; any x402 v2 or MPP client pays it and retries.

Example response

{
  "runId": "run_…",
  "decisionId": "dec_…",
  "status": "complete",
  "steps": [
    {
      "step": 1,
      "status": "ok",
      "tool": {
        "slug": "search",
        "seller": "agent402",
        "firstParty": true
      },
      "costUsd": 0.02,
      "result": {}
    }
  ],
  "budgetUsd": 0.02,
  "spentUsd": 0.02,
  "paidUsd": 0.001,
  "creditAppliedUsd": 0.02,
  "routingFeePct": 5,
  "leftoverCredit": null
}
FieldTypeAlways presentIn the example
runIdstringyesrun_…
decisionIdstringyesdec_…
statusstringyescomplete
stepsarray of objectsyes1 item in the example
budgetUsdnumberyes0.02
spentUsdnumberyes0.02
paidUsdnumberyes0.001
creditAppliedUsdnumberyes0.02
routingFeePctnumberyes5
leftoverCreditnullnonull

From an MCP client

catalog.call {
  "slug": "decide-execute",
  "params": {
    "decisionId": "dec_2b1c9e0f4a7d4c3e9b8a1f00",
    "creditToken": "dc_...",
    "maxBudgetUsd": 0.05
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for decide-execute; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/decide/execute", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "decisionId": "dec_2b1c9e0f4a7d4c3e9b8a1f00",
    "creditToken": "dc_...",
    "maxBudgetUsd": 0.05
  }),
});

Related tools

Decide: tool plan for a task

$0.005 · POST /api/decide

Describe a job and get a call-ready plan: which tools, across this catalog and outside x402 sellers with a recently veri…

Route and execute

$0.01 · POST /api/route/execute

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…

Route and execute (max tier)

$0.55 · POST /api/route/execute-max

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…

Route and execute (plus tier)

$0.05 · POST /api/route/execute-plus

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…

Route and execute (pro tier)

$3.3 · POST /api/route/execute-pro

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…

Attest a settled call on Base

$0.050 · POST /api/attest

Write an on-chain attestation (Ethereum Attestation Service on Base) that binds a call you paid for to the bytes you rec…