```mermaid
flowchart LR
  A["Agent: tools/call route_pay<br/>remit.paymentrequired.com/mcp"] --> V["validate()<br/>tools.js"]
  V --> D["callTool route_pay<br/>mcp.js"]
  D --> N{"L402 proof header?"}
  N -->|no| C["challenge: L402 invoice only"]
  N -->|yes| R["router.route: verify proof,<br/>pay target, return response"]
  R --> T(("external x402 service"))
```

# `route_pay` (Remit)

[← Index](../index.md) · [Overview](../overview.md) · [Signer](../signer.md) · [Issued links](../links.md)

> Evidence labels: **CODE** = read in the cited file at the recorded revision/hash; **FIXTURE** = parent-accepted combined cloud fixture run 99/99 (`directory-wave/parent-directory-wave-acceptance.json`), not live; **LIVE-RO** = observed read-only on the live host 2026-10-14 (raw files in `evidence/live-probes/`); **UNVERIFIED** = not executed here. Topology = accepted directory-wave source, **not deployed**. Nothing in this handbook moved money, signed, or activated a card.

## What it does

For agents with native L402: the first call returns a Lightning invoice challenge; after paying, call again with `Authorization: L402 <macaroon>:<preimage>`; the router pays the external x402 service and returns its response.

**Catalog:** remit.paymentrequired.com/mcp (own MCP, independent). **Schema & dispatch:** Definition [`remit:src/tools.js:35`](https://github.com/nuri-com/nuri-clickpesa-remit-mcp/blob/212886c7eedfa314f7de790622ea95632630057b/src/tools.js#L35); dispatch [`remit:src/mcp.js:489`](https://github.com/nuri-com/nuri-clickpesa-remit-mcp/blob/212886c7eedfa314f7de790622ea95632630057b/src/mcp.js#L489)

## Actions / operations

| action | what happens | effect | source |
|---|---|---|---|
| `route_pay` | Pay an external service via Lightning L402 | MONEY MOVE (agent pays Lightning; router pays target) | [`remit:src/mcp.js:489`](https://github.com/nuri-com/nuri-clickpesa-remit-mcp/blob/212886c7eedfa314f7de790622ea95632630057b/src/mcp.js#L489) |

## Prerequisites

No account, registration or API key (instructions text). 

## How to use it (exact `tools/call` JSON)

Endpoint: `POST https://remit.paymentrequired.com/mcp` (JSON-RPC 2.0). Placeholders in `<…>` are never real values; secrets (`session`, `wallet_key`) are never pasted into docs or logs.

**route_pay**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "route_pay",
    "arguments": {
      "url": "https://example.com/paid"
    }
  }
}
```

Expected result (`structuredContent`, shape from code; values illustrative):

```json
{"target":"https://…","targetWants":{…},"payWith":[{"scheme":"l402",…}],"nextAction":"Pay the Lightning invoice with a native L402 client, then call route_pay again with Authorization: L402 <macaroon>:<preimage>. Pay only once."}
```

Plain-JSON form (same handler): `POST /mcp` with `{"tool":"route_pay", …arguments}`; a payment request then comes back as HTTP 402 ([`remit:src/mcp.js:799`](https://github.com/nuri-com/nuri-clickpesa-remit-mcp/blob/212886c7eedfa314f7de790622ea95632630057b/src/mcp.js#L799)).

## Approval, signature and money

The L402 preimage is the payment proof; only the L402 scheme is accepted here. Two proofs at once → `multiple_proofs`.

## Failure, peer-down and retry

Pay only once; repeat the call with the same proof header.

## What was actually observed

UNVERIFIED: not called by this handbook.
