<!--
Sitemap:
- [Newton Agent NeoBank](/index)
- [Getting Started](/getting-started)
- [Onboard an Agent](/guides/onboard-an-agent)
- [Give an Agent a Budget](/guides/agent-budget)
- [Pay for an API](/guides/pay-for-an-api)
- [Issue a Card](/guides/issue-a-card)
- [Meter Your API](/guides/meter-your-api)
- [SDK Essentials](/reference/sdk)
- [ModularVault](/reference/sdk/modular-vault)
- [PlatformClient](/reference/sdk/platform-client)
- [FacilitatorClient](/reference/sdk/facilitator-client)
- [createX402Fetch](/reference/sdk/create-x402-fetch)
- [buildPolicyParams](/reference/sdk/build-policy-params)
- [Networks & Addresses](/reference/networks)
-->

# FacilitatorClient

Charge agents to call your API. Register a resource server, then verify and settle x402 payments against it.

```typescript
import { FacilitatorClient } from "@newton-xyz/isaac";

const facilitator = new FacilitatorClient({
  baseUrl: "https://api.example.com",
  operatorApiKey: "nab_sk_...", // manages resource servers
  serverApiKey: "...",          // optional, for the payment flow
});
```

Two keys, two jobs: the **operator key** registers and manages resource servers; the **server key** (issued when you create a server) verifies and settles payments. Set `serverApiKey` once you have it, or create a second client.

## Resource servers

```typescript
const { server, apiKey } = await facilitator.createServer({
  name: "My API",
  recipientAddress: "0x...", // where payments land
  vaultAddress: "0x...",
});

const servers = await facilitator.listServers();   // ResourceServer[]
const one = await facilitator.getServer(server.id);
await facilitator.updateServer(server.id, { rateLimitPerMinute: 120 });
const { apiKey: rotated } = await facilitator.rotateServerKey(server.id);
await facilitator.deactivateServer(server.id);
```

`createServer` requires `name`, `recipientAddress`, and `vaultAddress`; everything else defaults server-side. It returns the created `server` and its `apiKey` — store the key, it is not shown again.

## The payment flow

These need the `serverApiKey`.

```typescript
const v = await facilitator.verify(payload); // { valid, paymentHash, settlementMethod }
const s = await facilitator.settle(v.paymentHash); // { status, txHash?, network? }
const status = await facilitator.settleStatus(v.paymentHash);
const supported = await facilitator.supported(); // networks + tokens
```

`verify` checks a payment authorization and reserves it, returning a `paymentHash`. If the agent's policy queues the payment for approval, `verify` returns `policyStatus: "pending_approval"` with a `pendingIntentId` instead. `settle(paymentHash)` submits the reserved payment for on-chain settlement; poll `settleStatus` for the terminal result.

Most integrations don't call `verify`/`settle` directly — they let [createX402Fetch](/reference/sdk/create-x402-fetch) drive the flow from the paying side. Use these methods when you operate the resource server yourself.

## See also

* [Meter Your API](/guides/meter-your-api) — the end-to-end resource-server walkthrough.
* [createX402Fetch](/reference/sdk/create-x402-fetch) — the paying side of x402.
