Skerry/ Guides

Paying by the call

Pricing a resource so that automated clients pay for each call to it.

A customer prices a resource, and automated clients pay for each call to it. Skerry builds the 402 in two protocols at once, checks the payment the client sends back, and settles it on the customer's own merchant account at the card processor. It can be used as a hosted service the customer's server calls, or as a drop-in proxy in front of the resource.

Status: preview, off by default. Every call answers 409 capability_off until SKERRY_MACHINE_PAYMENTS_ENABLED=true for the deployment and the customer's merchant account can charge and has stablecoin payments active or a delegated-token profile. Live x402 payments also need a facilitator configured (SKERRY_X402_FACILITATOR_URL); a sandbox uses the public test facilitator by default. The code is lib/machine.ts, lib/pure/x402.ts, lib/pure/mpp.ts and lib/pure/machine-pricing.ts.

Skerry runs no facilitator and holds no keys.

Protocol revisions

As recorded in the code, each as it stood on 2026-11-13:

ProtocolRevision followedHeaders
x402Specification version 2 (protocol version 2, dated 2025-12-09), HTTP transport, exact scheme; extensions payment-identifier and offer-receipt (0.6), read on 2026-11-16402 with PAYMENT-REQUIRED; the client retries with PAYMENT-SIGNATURE; the paid answer carries PAYMENT-RESPONSE.
Machine Payments Protocoldraft-httpauth-payment-01 (9 September 2026) with the charge intent (draft-payment-intent-charge-00) and the method documents for delegated card tokens (draft-stripe-charge-00) and Tempo (draft-tempo-charge-00)402 with one WWW-Authenticate: Payment challenge per method; the client retries with Authorization: Payment <credential>; the paid answer carries Payment-Receipt. Problems are RFC 9457 bodies.
Machine Payments Protocol over MCPdraft-payment-transport-mcp-00, the scheme's JSON-RPC and MCP transport (in tempoxyz/mpp-specs, last changed on its main branch 16 April 2026; not on the IETF datatracker)For a client on MCP 2025-11-25 or earlier, the JSON-RPC error -32042 with the challenges in error.data.challenges; for one on 2026-07-28 or later, a tool result with isError: true and the challenges in structuredContent and _meta["org.paymentauth/payment-required"] (see below); the client retries with the credential in params._meta["org.paymentauth/credential"]; the paid result carries result._meta["org.paymentauth/receipt"].

The Machine Payments Protocol revisions were checked again on 2026-11-14 and none had moved: the datatracker lists draft-httpauth-payment-01 of 9 September 2026 as the latest (https://datatracker.ietf.org/doc/draft-httpauth-payment/), and the specification's repository (github.com/tempoxyz/mpp-specs, specs/) holds draft-payment-intent-charge-00 (last changed 18 August 2026), draft-stripe-charge-00 (9 September 2026) and draft-tempo-charge-00 (26 October 2026), with no later revision of any. The three charge documents are not on the datatracker.

How each is settled:

  • x402. The payment is verified and settled by the configured facilitator, then recorded at the card processor by its transaction. The amount must equal the requirement issued, not merely cover it, as the exact scheme requires.
  • Machine Payments Protocol. A delegated card token is charged on the merchant account; a Tempo transfer the client sent itself is checked by the processor. A challenge's id is bound to its amount, recipient and expiry with an HMAC (SKERRY_MACHINE_PAYMENTS_SECRET, derived from the processor key when unset), so a credential that changed any of them is refused. Each proof is used once.
  • x402 extensions. Every x402 402 declares payment-identifier (not required): a client that names its payment with an id (16 to 128 letters, digits, - or _, in PaymentPayload.extensions["payment-identifier"].info.id) and sends the same payment again, after a lost answer, gets the first answer again and pays once; a different payment under the same id is refused 409. Ids are kept per customer and per thing paid for. When the deployment has its receipt key (SKERRY_RECEIPT_SIGNING_KEY), the 402 also carries offer-receipt: one signed offer per requirement (resourceUrl, scheme, network, asset, payTo, amount, validUntil), and a settled payment's PAYMENT-RESPONSE carries a signed receipt (network, resourceUrl, payer, issuedAt; the transaction is left out, as the extension does by default). Both are compact JWS, EdDSA, with kid did:web:api.skerry.xyz#<key_id>, resolved at /.well-known/did.json. That proves Skerry signed them; for a resource on the customer's own domain, a verifier that wants the domain to have authorised the signer needs the customer to name did:web:api.skerry.xyz for it (for example in a DNS TXT record at _controllers.<domain>, as the extension describes). The extension's file says its wire shape is not yet stable (version 0.6 of 2026-02-04).
  • x402 upto. A resource priced with scheme: "upto" states the most a call can cost (price); the client signs that maximum (a Permit2 witness transfer through the x402 upto proxy, bound to the facilitator by its address), and the customer charges what the call actually cost, after the work. POST /machine-payments/verify checks the authorisation and has the facilitator verify it, moves nothing, and answers paid: true with an authorization (maximum, expires_at); do the work, then POST /machine-payments/settle { authorization_id, amount } with the cost in whole cents, from "0" (nothing is charged) up to the maximum, once, before expires_at. Its answer holds the PAYMENT-RESPONSE (with the amount settled) to send. Through the proxy, the upstream states the cost in a Skerry-Charge response header (a decimal amount); without it the maximum is charged, and an error answer (status 400 or above), or no answer, is charged nothing. The proxy tells the upstream the authorisation in Skerry-Authorization-Id and the maximum in Skerry-Charge-Maximum. upto is offered only where the configured facilitator's GET /supported lists it for the network, with the facilitator address the client must bind to: on 2026-11-16 the public test facilitator (https://x402.org/facilitator) listed it on Base Sepolia, and the hosted facilitator's documentation lists it on Base. An upto resource is paid in stablecoin with x402 only (the Machine Payments Protocol's charge is for a fixed amount), one call at a time, with no prepaid credit. The client needs a Permit2 allowance for the token, or a facilitator that sponsors the approval.
  • Solana, when SKERRY_SOLANA=on. USDC on Solana is offered beside Base and Tempo, paid to the merchant account's own Solana deposit address at the card processor (its deposit-address API takes network=solana). On a sandbox it is paid in devnet USDC, the mint Circle lists (4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU); SKERRY_SOLANA_DEVNET_USDC overrides it.
    • x402: the exact scheme on SVM (specs/schemes/exact/scheme_exact_svm.md in github.com/x402-foundation/x402, read 17 Nov 2026), on solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp (mainnet) or solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 (devnet). The facilitator must list the network in its /supported, which gives the fee payer put in extra.feePayer (and the transaction versions, copied as the scheme says); a facilitator that does not is not offered it. The partially signed transaction is checked here only for being base64 within the scheme's 4096 bytes; the facilitator checks its instructions, signs as fee payer and broadcasts it.
    • Machine Payments Protocol: method solana, intent charge (draft-solana-charge-00, 11 November 2026, https://paymentauth.org/draft-solana-charge-00.html, read 17 Nov 2026). No fee payer is offered, so the client sends the transfer itself and presents its signature (payload.type: "signature", push mode); a signed transaction for Skerry to broadcast ("transaction") is refused as malformed, because Skerry holds no keys and broadcasts nothing. A signature is taken once, whatever challenge it is presented with (section 11.6).
    • Either way the transfer is recorded at the card processor by its signature with network: "solana". The processor's x402 page lists Solana USDC for this kind of recording; its example shows Base only, so the value solana there is the one its deposit-address API uses, not one shown in a recording example.
  • Subscriptions (SKERRY_MPP_SUBSCRIPTIONS=1, off by default). A resource priced with scheme: "subscription" and period: { unit: "day" | "week" | "month", count } is paid with the Machine Payments Protocol's subscription intent on the Stripe rail (draft-payment-intent-subscription-00 and draft-stripe-subscription-00, read 19 Nov 2026; both are drafts). Methods ["agent_token"], a price in whole cents for one period, over HTTP; x402 is not offered. The challenge's request carries amount, currency, periodUnit, periodCount and methodDetails (the business-network profile and the payment method types card and link); the client answers with { paymentMethod: "pm_...", customer?: "cus_..." }. Skerry creates one recurring subscription, collects the first invoice at once (a refused card leaves nothing behind) and answers 200 with a Payment-Receipt carrying the invoice as reference, an opaque subscriptionId and the stripeSubscription. A period counts as paid only when its paid invoice has been seen (invoice.paid), and access runs to the end of the paid period; a failed renewal changes the status, not the date. Where the drafts are silent: a client with a paid period that presents a credential again (a fresh challenge, the same payment method) is answered 200 with the receipt of the invoice that paid the period, without a new charge; a Product is made for each activation. Applies db/048_mpp_subscription.sql.
  • Not offered: the Machine Payments Protocol's session intent. Verifying its vouchers needs a chain to be read, which Skerry does not do.

Pricing a resource

OperationScopeIdempotency-KeyMoves moneyWhat it does
POST /customers/{id}/priced-resourcesmachine:writeoptionalnoPrice a resource.
GET /customers/{id}/priced-resourcesmachine:readnonenoThe customer's priced resources, with the minimum single payment per method.
DELETE /customers/{id}/priced-resources/{resource_id}machine:writenonenoStop charging for a resource.
POST /machine-payments/challengemachine:writenonenoThe 402 to send an unpaid request: status, headers and body, in both protocols.
POST /machine-payments/verifymachine:writenoneyesCheck and settle the payment a client sent, or draw the call from its credit.
POST /machine-payments/settlemachine:writenoneyesCharge what an x402 upto call cost, once, from "0" up to the maximum the client authorised, before the authorisation expires.
POST /machine-payments/creditsmachine:writenoneyesBuy prepaid credit for a resource with one payment.
GET /machine-payments/creditsmachine:readnonenoA customer's credits, newest first: bought, balance, refunded, expiry.
GET /machine-payments/credits/{id}machine:readnonenoOne credit: bought, balance, expiry.
GET /machine-payments/subscriptionsmachine:readnonenoA customer's subscriptions started with the Machine Payments Protocol (SKERRY_MPP_SUBSCRIPTIONS), newest first, up to limit: terms, status, the date the paid period runs to.
GET /machine-payments/subscriptions/{id}machine:readnonenoOne such subscription: terms, status, paid through.
POST /machine-payments/subscriptions/{id}/cancelmachine:writenonenoCancel at the end of the period already paid: access to that date, nothing more charged.
POST /machine-payments/credits/{id}/refundrefunds:writerequiredyesSend back the unused part of a credit, within the customer's policy.
POST /customers/{id}/priced-resources
Authorization: Bearer sk_test_…
Idempotency-Key: 41aa…

{ "url_pattern": "https://data.example/v1/quotes/*", "price": "0.05", "currency": "usd", "methods": ["stablecoin"], "upstream_url": "https://internal.data.example/v1/quotes" }

A price is held in millionths, so a tenth of a cent can be stated. A single payment cannot be that small: the processor states a minimum per way of paying and settles in whole cents.

Paid withSmallest single payment
stablecoin0.01 USD
agent_token0.50 USD

A price below a method's minimum, or with a part of a cent, needs credit_only: true: the client buys prepaid credit with one payment and each call draws it down.

The hosted service

The customer's own server asks for the 402 when a request arrives unpaid:

POST /machine-payments/challenge

{ "resource_id": "res_…", "url": "https://data.example/v1/quotes/EURUSD" }

The answer is the status, headers and body to send, in both protocols. When the client comes back, the server passes on what it presented:

POST /machine-payments/verify

{ "resource_id": "res_…", "headers": { "PAYMENT-SIGNATURE": "…" } }

or, for a call paid from credit, { resource_id, credit_token, idempotency_key }, where the idempotency key makes a retry of the same call draw once. The answer says whether it is paid and gives the headers to answer with.

The proxy

GET  /pay/{resource_id}
POST /pay/{resource_id}

Public, with no key. A request without a payment is answered 402 in both protocols. A request carrying PAYMENT-SIGNATURE, Authorization: Payment …, or a credit token in Skerry-Credit is settled and then forwarded to the customer's registered upstream_url, and only there; the answer comes back with the receipt headers. Cookies and credentials are not forwarded. The upstream is called as every customer-supplied address is (see security.md). Both methods settle a payment, so both are flagged x-moves-money: true in the OpenAPI document; the GET is the only GET that is.

A customer can charge for the tools of its own MCP server, by the call, with the Machine Payments Protocol's JSON-RPC transport (draft-payment-transport-mcp-00). Over MCP only that protocol is defined; x402 is not offered there.

Price the server as a resource with protocol: "mcp", the server's address as upstream_url, and, to charge for some tools only, their names in mcp_tools:

POST /customers/{id}/priced-resources

{ "url_pattern": "https://tools.example/mcp", "price": "0.50", "methods": ["agent_token", "stablecoin"],
  "upstream_url": "https://tools.example/mcp", "protocol": "mcp", "mcp_tools": ["search"] }

Clients then use /pay/{resource_id} as the MCP server's address. initialize, server/discover, tools/list and every other message pass free; the answers to initialize and server/discover name the payment methods taken under capabilities.experimental.payment.methods. A priced call (tools/call for a named tool, or without mcp_tools every tools/call, resources/read and prompts/get) is answered:

{ "jsonrpc": "2.0", "id": 7, "error": { "code": -32042, "message": "Payment Required",
  "data": { "httpStatus": 402, "challenges": [ { "id": "…", "realm": "api.skerry.xyz", "method": "stripe", "intent": "charge",
    "request": { "amount": "50", "currency": "usd", "methodDetails": { … } }, "expires": "…", "opaque": "…" } ] } } }

The client sends the same call again with one challenge echoed unchanged and its proof in params._meta["org.paymentauth/credential"]. The payment is settled, the call goes on to the upstream without the credential (with Skerry-Payment-Id), and the result comes back with result._meta["org.paymentauth/receipt"] (status, method, timestamp, challengeId, reference). A credential that does not verify, has expired or was used before is answered -32043 with fresh challenges and the reason in error.data.failure; one that cannot be read, -32602. A challenge is bound to the call it was issued for (tools/call:search), so a payment for one tool cannot be spent on another. A priced call sent as a notification is not forwarded, and a batch that holds one is refused. The price is one payment per call: prepaid credit is for HTTP.

Which answer, by MCP revision. The two documents conflict. The draft was written against MCP 2025-11-25 and requires -32042 and -32043. MCP 2026-07-28 reserves -32020 to -32099 and says implementations must not emit -32042. The clash is open upstream (tempoxyz/mpp-specs issue 374). The pull request that would have settled it was closed unmerged on 17 November 2026. Until the draft is revised, Skerry answers by the revision the call is made under: params._meta["io.modelcontextprotocol/protocolVersion"], else the MCP-Protocol-Version header (for POST /machine-payments/challenge and /verify, protocol_version in the body).

  • 2025-11-25 or earlier, or not stated: the draft's -32042 and -32043, shown above. error.data carries challenges and never elicitations, so a 2025-11-25 client does not read it as URL elicitation.

  • 2026-07-28 or later: a tools/call is never answered with an error code. An unpaid or refused call gets a tool result:

    { "jsonrpc": "2.0", "id": 7, "result": { "isError": true, "content": [ { "type": "text", "text": "Payment is required for this call." } ],
      "structuredContent": { "httpStatus": 402, "challenges": [ … ] },
      "_meta": { "org.paymentauth/payment-required": { "httpStatus": 402, "challenges": [ … ] } } } }

    A refusal adds failure: { reason, detail } and carries a fresh challenge. This is the shape x402's MCP transport uses, and the one last proposed upstream. A priced resources/read or prompts/get has no tool result, so it gets the codes that proposal named instead, -31042 and -31043, with the same data. Those numbers are provisional.

Either way, the credential is accepted in params._meta["org.paymentauth/credential"] (or the root _meta). The 2026-07-28 shape is Skerry's own reading until mpp-specs settles, and it is checked again at each release.

A customer that runs its own payment step calls the hosted service with the JSON-RPC call it received as message instead of headers. POST /machine-payments/challenge then answers { paid: false, error }, the error to send; POST /machine-payments/verify answers { paid: true, receipt, meta_key }, the receipt to put in result._meta under meta_key, or { paid: false, error }.

Older form, kept. A version 1 x402 client's X-PAYMENT header is still read, and such a client is answered with X-PAYMENT-RESPONSE as well. Build against version 2.

Prepaid credit

POST /machine-payments/credits

{ "resource_id": "res_…", "amount": "1.00" }

Without payment headers the answer is the 402 for that amount; with them, the credit and its token, shown once. Credit lasts SKERRY_MACHINE_CREDIT_DAYS (30 by default). GET /machine-payments/credits/{id} gives what was bought, the balance and the expiry. POST /machine-payments/credits/{id}/refund sends back the unused part as a refund of the payment that bought it, within the customer's credit_refund_days (set with POST /customers/{id}/agentic/settings), and needs an Idempotency-Key.

With links_pay_by_call set in the customer's agentic settings, a payment link's share_url (GET /pay-link/{id}) answers an automated client with the pay-by-the-call challenge for the link's amount instead of a description.

What is recorded

Each payment is an ordinary payment with method: "machine", its protocol, resource_id and the payer's address or token reference in payer_ref. It appears in the ledger, in receipts and in the events like any other (see payments.md).

What needs someone else

  • An x402 facilitator for live payments. Skerry runs none; without SKERRY_X402_FACILITATOR_URL live x402 payments cannot be settled.
  • The card processor's preview access for the merchant account: stablecoin payments active on it, or a profile at the token issuer for delegated card tokens. Without either the routes answer capability_off for that customer.

Written and kept by Skerry. Read from https://api.skerry.xyz/guides/pay-by-the-call.md.

This page as Markdown