Decide: execute a plan
POST /api/decide/executeRun a decision's plan through Agent402: first-party steps run directly, third-party steps are paid on your behalf (paid on Base, or by credits or card) and relayed at the seller's price plus a disclosed routing fee. Send POST /api/decide/execute with the required field decisionId and pay quoted per request from $0.001 over x402 with USDC on an EVM chain. 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.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
decisionId | string | yes | From POST /api/decide |
creditToken | string | no | executionCredit.token from that decision (optional) |
maxBudgetUsd | number | no | Spend ceiling for the run (default: the plan's estimate via Agent402) |
params | object | no | Per-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
}
| Field | Type | Always present | In the example |
|---|---|---|---|
runId | string | yes | run_… |
decisionId | string | yes | dec_… |
status | string | yes | complete |
steps | array of objects | yes | 1 item in the example |
budgetUsd | number | yes | 0.02 |
spentUsd | number | yes | 0.02 |
paidUsd | number | yes | 0.001 |
creditAppliedUsd | number | yes | 0.02 |
routingFeePct | number | yes | 5 |
leftoverCredit | null | no | null |
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
decisionIdis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged: settlement is cancelled when the tool fails.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - Long-running: payment settles after the work finishes, so only EVM exact payments are offered.
- Priced per request: the 402 quotes this body, between $0.001 and $3.
- A
GETorHEADto /api/decide/execute returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again.
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
POST /api/decideDescribe a job and get a call-ready plan: which tools, across this catalog and outside x402 sellers with a recently veri…
Route and execute
POST /api/route/executeDescribe 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)
POST /api/route/execute-maxDescribe 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)
POST /api/route/execute-plusDescribe 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)
POST /api/route/execute-proDescribe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…
agent demand radar
GET /api/demand-radarWhat agents want that no one is serving yet - the paid intelligence layer over Agent402's agent-demand board, for x402 s…