Skip to content

Calling the Router

Payment wires: every paid endpoint accepts x402 and MPP (Machine Payments Protocol) on the same 402 - see Paying with x402 and Paying with MPP. Agent402 is the applied layer of Agentic Finance: agents that pay and get paid on their own.

The request forms of POST /api/route and every field of its answer. What the router is, how sellers get in and how it ranks them: x402 Index and Router.

Calling the router

# Default - include everything (local + crawled remotes), pick the cheapest healthy match
curl -X POST https://agent402.tools/api/route \
  -H 'content-type: application/json' \
  -d '{"query":"ocr image to text","top":5}'

# Neutral discovery: rank only OTHER x402 sellers (exclude Agent402 itself)
curl -X POST https://agent402.tools/api/route \
  -H 'content-type: application/json' \
  -d '{"query":"ocr image to text","top":5,"include":"external"}'

# Local-only escape hatch (Agent402's catalog only)
curl -X POST https://agent402.tools/api/route \
  -H 'content-type: application/json' \
  -d '{"query":"ocr image to text","top":5,"include":"local"}'

Returns an object, not a bare array. The matches are in results:

{
  "query": "screenshot webpage",
  "include": "all",
  "count": 2,
  "sellers": 2,
  "results": [
    {
      "seller": "https://seller.example",
      "sellerHome": "https://seller.example",
      "sellerName": "seller.example",
      "slug": "screenshot",
      "name": "Screenshot any URL through headless Chromium",
      "method": "POST",
      "route": "/shot",
      "url": "https://seller.example/shot",
      "price": 0.005,
      "priceUsd": 0.005,
      "category": "other",
      "description": "…",
      "tags": ["screenshot", "browser"],
      "score": 13,
      "health": 1,
      "networks": ["eip155:8453"],
      "paymentNetworksKnown": true,
      "routerDispatchEligible": true,
      "routerDispatchReason": "eligible",
      "executeViaCallableNow": true,
      "executeVia": {
        "tool": "route-execute",
        "price": "$0.01",
        "underlyingPriceUsd": 0.005,
        "resaleMarginUsd": 0.005,
        "routingFeeUsd": 0.005
      },
      "untrustedContent": true,
      "source": "https://seller.example"
    }
  ]
}
  • seller is "self" for the local catalog, or the origin URL for a remote seller, so a buyer can address the right seller directly. url is the full callable endpoint.
  • price is whatever the seller published (a number or a string); priceUsd is the normalized number to compare on, and priceKnown says whether that number could actually be read from what the seller published. When it is false, priceUsd is a placeholder and must not be compared.
  • routerDispatchEligible / routerDispatchReason say whether this host's router will buy from the seller right now and why not otherwise (crawl_failed, network_unknown, no_supported_route, url_template, price_unknown, usdc_domain_mismatch, gateway_rail_unsupported, delivery_failing, settlement_self_funded, settlement_required, category_excluded, settlement_checked_at_pay_time, eligible, local_catalog); routable and health are crawl readiness, never a promise to pay. The response's dispatchLegend spells each out and is the full list.
  • Routes that sell personal data about individuals are listed but not bought by the router: they read category_excluded on /api/index?seller=, are not ranked here, and categoryExcluded counts the matching routes left out.
  • executeVia names the cheapest execution rung that covers this result (see the ladder) and appears only on a row the router will pay now (executeViaCallableNow: true). A row that is not dispatch-eligible carries executeViaWhenEligible with executeViaCallableNow: false instead, so a tier name never reads as a callable action. networksInferred: true marks a row whose chains were inherited from its seller rather than read on its own 402.
  • tags is the tool's own tag list (the catalog's for a local row, the crawled listing's for an external one), an empty array when the listing has none.
  • count is the number of results returned; sellers is how many distinct sellers they came from.
  • The response echoes back the resolved include value (invalid values fall back to all).
  • capabilityGap and capabilityGapCovered appear only on a query that asks for a capability this host's catalog does not offer. The list is short and named in the source (src/capability-gaps.js); today it holds four entries, ip-geolocation, coin-price-on-date (the look-back tools answer statistics computed from a coin's history, never a past price), stock-price-history (the price-history tools read coins and tokens; the entry applies while this host lists no stock history tool) and stock-price (a stock's current price: the tokenized-stock tools read a token's pool price, not the share's, so a query that names the token is answered by them and one that asks for the stock is a miss). Such a query is a miss unless a row is named for the capability in its slug or name (a description does not count), and a row that is named for it, an outside seller's included, is ranked first. On a miss the answer carries capabilityGapCovered: false, weakMatches: true, weak: true on every row and a hint saying none of the rows does the task: treat the rows as near word matches, not as answers. Every other query is ranked and answered as before.