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 — one flat $0.01 price covering any tool listed at $0.005 or less, receipt included. Skips the find-then-call round trip: one payment, one request, result + receipt. Pricier tools return a self-correcting 409 pointing at their direct route.
| Field | Type | Description |
|---|---|---|
task | string | Plain-language task, e.g. "sha256 hash of a string" — resolved via the same ranker as /api/find. Provide task OR slug. |
slug | string | Exact tool slug to execute (skips ranking). Provide task OR slug. |
params | object | Input for the resolved tool, matching its inputSchema (default {}) |
maxUsd | number | Refuse tools listed above this underlying price (default and ceiling: $0.005) |
{
"receipt": {
"slug": "hash",
"route": "POST /api/hash",
"underlyingPriceUsd": 0.001,
"paidUsd": 0.01,
"routingFeeUsd": 0.009,
"seller": "internal",
"resolvedBy": "slug"
},
"result": {
"algo": "sha256",
"hex": "…",
"base64": "…"
}
}
curl -i -X POST https://agent402.tools/api/route/execute \
-H "Content-Type: application/json" \
-d '{"slug":"hash","params":{"text":"agent402","algo":"sha256"}}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
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();
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"
}
}),
});