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 - flat $0.01 covering any tool listed at $0.005 or less, from THIS host's catalog or any external seller in the open index - x402 sellers, or MPP sellers on Tempo (paid on your behalf over x402 or MPP, result relayed). Send POST /api/route/execute with no required fields (5 optional) and pay $0.01 per call over x402 or MPP (there is no free tier). It returns a JSON object with receipt and result.
One payment, one request, result + receipt. /api/route quotes which tier a task needs; pricier tools return a self-correcting 409 with their direct route.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
task | string | no | Plain-language task, e.g. "sha256 hash of a string" - resolved via the same ranker as /api/find. Provide task OR slug. |
slug | string | no | Exact tool slug to execute (skips ranking). Provide task OR slug. |
params | object | no | Input for the resolved tool, matching its inputSchema (default {}) |
include | string | no | Where to route: default runs a tool from THIS host's catalog; "external" routes to the best-matching x402 seller in the OPEN index and pays it on your behalf (result relayed, marked untrustedContent). Requires task (not slug). |
maxUsd | number | no | Refuse tools listed above this underlying price (default and ceiling: $0.005) |
Example request
curl -i -X POST https://agent402.tools/api/route/execute \
-H "Content-Type: application/json" \
-d '{"slug":"hash","params":{"text":"agent402","algo":"sha256"}}'
Without payment this returns HTTP 402 Payment Required with the exact price for route-execute; any x402 v2 or MPP client pays it and retries.
Example response
{
"receipt": {
"slug": "hash",
"route": "POST /api/hash",
"underlyingPriceUsd": 0.001,
"paidUsd": 0.01,
"routingFeeUsd": 0.009,
"seller": "internal",
"resolvedBy": "slug",
"ts": "2026-07-10T00:00:00.000Z",
"callRef": "sha256:… (recomputable: sha256 of {\"nonce\":<payment authorization nonce>,\"slug\":…,\"ts\":…} - null on nonce-less calls)"
},
"result": {
"algo": "sha256",
"hex": "…",
"base64": "…"
}
}
| Field | Type | Always present | In the example |
|---|---|---|---|
receipt | object | yes | 9 fields: slug, route, underlyingPriceUsd, paidUsd, routingFeeUsd, seller |
result | object | yes | 3 fields: algo, hex, base64 |
From an MCP client
catalog.call {
"slug": "route-execute",
"params": {
"slug": "hash",
"params": {
"text": "agent402",
"algo": "sha256"
}
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for route-execute; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
- Every field is optional. An input the tool rejects returns an HTTP 4xx whose body carries
error,tool,expected,requiredandexample. - A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/route/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 (an answer larger than 1 MB is not replayed).
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/route/execute", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"slug": "hash",
"params": {
"text": "agent402",
"algo": "sha256"
}
}),
});
Related tools
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…
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 …
x402 seller dossier
POST /api/seller-dossierEverything Agent402 knows about one x402 seller origin, in one read: identity and crawl history, the catalog with the pr…
AI agent action preflight
POST /api/action-gateDeterministic preflight check for a proposed AI agent action - a tool call, payment, fetch, or write - before it execute…