Agents paying
A registered agent paying another merchant that answers 402.
A registered agent pays another merchant. The agent's request is sent to the merchant's address; when the merchant answers 402, one of its offers is paid and the request is sent once more. The answer carries the merchant's status, a bounded excerpt of its body, and what was paid.
Status: preview, off by default, built from the providers' documentation and not run against the live providers. Every call answers 409 capability_off (capability agent_credentials) until SKERRY_SELF_HELD_WALLETS=on and SKERRY_WALLET_OWNER are set for the deployment and the wallet provider's app, this API's signer key and the signer's id are set for the environment. The tests run it against stand-ins for the wallet provider and a merchant; nothing here has signed with a real key, paid a real merchant, or issued a real token.
Skerry holds no funds and no keys, and no part of a key. A wallet an agent pays from is a self-held wallet: the person who made it owns it at the wallet provider (Privy), and this API is only the agent's signer, under a policy. The provider keeps each key split in two parts on separate systems and joins them only inside its protected hardware, for the moment of signing, on the owner's authority or within a signer's policy. What Skerry keeps is the provider's id for the wallet, the wallet's address and who owns it.
Operations
| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
POST /agents/{id}/wallets | agents:write | optional | no | Make a self-held wallet the agent pays from. |
GET /agents/{id}/wallets | agents:read | none | no | The agent's wallets, active and retired, with their addresses, owners and how each is recovered; new_wallet_owner says who would own a wallet made now (account or device). |
GET /agents/{id}/wallets/{wallet_id} | agents:read | none | no | One wallet: network, address, state and what its key may sign. |
DELETE /agents/{id}/wallets/{wallet_id} | agents:write | none | no | Retire a wallet: nothing is signed with it again. |
POST /agents/{id}/wallets/{wallet_id}/key-download | agents:write | none | no | Ask to download a wallet's key, as its owner, confirmed with a passkey. |
POST /agent-payments | agent-payments:write | required | yes | Send the agent's request to a merchant and, when it answers 402, pay one offer and send the request once more. |
GET /agent-payments | agent-payments:read | none | no | Attempts to pay merchants, whatever became of them: paid, failed, refused or held. |
GET /agent-payments/{id} | agent-payments:read | none | no | One attempt: the merchant, the protocol and network, the amount, the reference, and the authorisation it ran under. |
Wallets are under the scopes that already govern agents (agents:read, agents:write). Paying has its own: agent-payments:read and agent-payments:write. Only a person makes a wallet, and only with their passkey (owner, 17 Nov 2026: "skerry only creates wallets if passkey is created"): through the console, a member confirming the request with a fresh passkey sign-in at the Praecise account; through the Personal door, the person doing the same. A partner key or an agent's credential gets 403 passkey_required or agent_not_allowed. An agent's own credential may retire its own wallets and pay as itself, and nothing for another agent.
Wallets
POST /agents/{id}/wallets with { network, label?, owner_public_key? } makes a wallet for a registered agent that acts for a customer. network is base-sepolia in sandbox and base in live, and is that when left out; each environment refuses the other's network. The answer carries the address. The wallet is funded by sending USDC to that address; Skerry does not read its balance.
Who owns it
SKERRY_WALLET_OWNER sets one route for the deployment:
| Route | The owner at the provider | Several devices | Every device lost | Key download |
|---|---|---|---|---|
account | The person's Praecise account, as a user at the provider (made once per person and environment, by the account's sub) | Every device the person signs in on with a passkey | An email reset at the Praecise account and a new passkey reach the wallet again | Yes: the person's browser takes it from the provider directly |
device | A P-256 key made on the person's device; the request carries its public half as owner_public_key (base64 DER) | Only that device | Nobody can restore the owner's control | No: it would have to pass through Skerry's servers |
The answer for a wallet says which, with the words the person is shown (owner.recovery, custody.note, key_download). A wallet made before owners were set (sandbox only) signs nothing and says so.
What is asked of the provider
These requests are made of the wallet provider, in this order, so a wallet never exists without its limit and its owner:
- A policy that allows one method,
eth_signTypedData_v4, under two conditions on the EIP-712 domain of what is signed:verifyingContractequals the USDC contract of the wallet's network, andchainIdequals that network's chain. The provider denies any method that has no rule, so the key cannot sign a transaction, a raw message, or typed data for another contract or chain. This holds at the provider, whatever this API asks for. - On the
accountroute, the person's user, the first time only. - A wallet with its owner, that policy, and this API's key quorum (
SKERRY_PRIVY_*_SIGNER_ID) as its one additional signer with the same policy as its own. Each request is signed with this API's key. As a signer, this API cannot change the owner, the signers or the policy, and cannot export the key; the provider refuses those to a signer.
| Network | Chain id | USDC contract |
|---|---|---|
base | 8453 | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
base-sepolia | 84532 | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
DELETE /agents/{id}/wallets/{wallet_id} retires a wallet: nothing is signed with it again. Retiring moves no funds. USDC left at the address stays there, and no operation of this API sends it anywhere: there is no withdrawal, because the wallet's policy allows no transaction and none is built. Spend a wallet down, or accept that what is left stays at its address, before retiring it. Retiring does not remove this API as a signer at the provider, which needs the owner's own signature; it stops this API asking.
Downloading the key
POST /agents/{id}/wallets/{wallet_id}/key-download is the owner asking for their wallet's key. Only the person who owns the wallet may ask, confirming with their passkey; anyone else gets 403. The key never passes through this API: on the account route the owner's browser signs in at the wallet provider with the Praecise account's token and the provider shows the key in its own window. The answer carries the provider's public app id, the address, and what the owner is told first: the key is theirs to keep safe from then on; Skerry cannot recover, replace or cancel it; whoever holds a copy can move everything in the wallet without a passkey and outside every limit; the agent's limits still bind the agent only. The request is recorded (key_download.last_requested_at, event agent_wallet.key_download_requested). On the device route it answers 409 key_download_unavailable.
Paying
POST /agent-payments with:
| Field | Meaning |
|---|---|
agent_id | The registered agent that pays. |
url, method, headers, body | The request sent to the merchant. url must be public and https with a host name; method is GET unless stated; body is a string, or an object sent as JSON, up to 64 KB. |
max_amount, currency | The most that may be paid, in US cents. currency is usd. |
wallet_id | The wallet to sign from. Left out, the agent's newest active wallet is used. |
payment_method_id | A saved payment method to issue a delegated payment token on, for a merchant that takes one. |
external_ref, external_kind | Your own reference, kept on the record. |
An Idempotency-Key is required. The answer is the agent payment: status (paid, failed), protocol, network, amount_minor and currency (atomic units of usdc for x402, cents of usd for a token), pay_to, reference, signed, the authorisation block, and response: { status, body } from the merchant. When the merchant answers anything other than 402 to the first request, nothing is paid or recorded and the answer has status: "no_payment_required" with the merchant's response.
The two protocols
| Protocol | Revision followed | Used when |
|---|---|---|
| x402 | Version 2, HTTP transport, exact scheme on an EVM chain, EIP-3009 transfer, as documented on 2026-11-14 | The agent has a wallet, and the merchant's PAYMENT-REQUIRED carries an offer in USDC on the wallet's own network. |
| Machine Payments Protocol | The Payment authentication scheme with the stripe method and the charge intent, as documented on 2026-11-14 | payment_method_id is named, delegated payment tokens are switched on (SKERRY_AGENT_TOKENS_ENABLED), and the merchant's WWW-Authenticate: Payment challenge is a card charge in US dollars. |
x402. The agent's wallet signs an EIP-3009 TransferWithAuthorization from its address to the merchant's payTo, for the offer's amount, valid until the offer's maxTimeoutSeconds from now, with a random 32-byte nonce. The request is sent again with PAYMENT-SIGNATURE: the accepted offer, unchanged, with the signature and the authorisation. The transaction is read from the merchant's PAYMENT-RESPONSE and kept as the reference.
Machine Payments Protocol. A shared payment token is issued at the card processor on payment_method_id, for the seller profile the challenge names (methodDetails.networkId), limited to the challenge's amount and expiring when the challenge does. The request is sent again with the credential: the challenge echoed exactly, and the token as its proof. The reference is the payment the merchant's Payment-Receipt names, or a fingerprint of the token; never the token.
When both can be paid, the cheaper offer is paid; at the same price, the x402 offer.
What is checked before anything is signed
In this order. Nothing is signed or issued until every step has run.
- The address.
urlgoes through the same guard as every address somebody else supplies (lib/safe-fetch.ts): https, a host name, no credentials, and every address the name resolves to must be public. Redirects are not followed. - The offer. An x402 offer is paid only with the
exactscheme, on the wallet's own network, in that network's USDC, with a positive wholeamount, apayTothat is an address, the token's EIP-712 name and version stated, and a timeout of at most 600 seconds. A challenge is paid only with thestripemethod and thechargeintent, in US cents at or above the 50-cent card minimum, with a seller profile and an expiry that has not gone by. - The ceiling. An offer above
max_amountis refused withagent_payment_over_max. - The controls a payout runs under, through the same code (
lib/spend.ts): the freeze on the customer or the account; the withdrawal allow-list; the hold on a first payment to a new destination, with its cooling-off period; the risk rules; the agent's mandates, and those of every agent it was delegated from, with their limits, counts and allow-lists; budgets; approval. A mandate names the operation asagent_payment.create. - The idempotency key. The key is taken at the moment before signing. A second attempt under it is refused with
agent_payment_already_attempted; a retry of a finished request replays the first answer.
What is signed is the merchant's exact amount, never max_amount. The typed data names this API's own record of the USDC contract, not the merchant's spelling of it.
Who the payee is. The merchant's host name is the payee: a mandate's payee_allow_list and merchant_allow_list are compared with it, and the hold on a first payment applies to it. For x402 the payTo address is a second destination: the hold applies to it too, so a known merchant asking to be paid at a new address is held. The customer's withdrawal allow-list lets the payment through when it lists the host (whatever address the merchant asks for) or the address.
Amounts against limits. An x402 payment counts as usdc in atomic units, which a mandate with scope: "family" counts with US dollars; a token payment counts as usd in cents. A mandate that has a budget spends only from the custody wallet its budget is in, so an agent under such a mandate is refused with outside_budget: an agent's signing wallet is not a custody wallet.
Held for a person. A held payment answers 202 with the approval. Approving it runs the request again: the merchant is asked afresh, and the payment goes ahead only if it now asks for the same destination and no more than was approved (offer_changed otherwise).
Dry run. Skerry-Dry-Run: true (or dry_run: true) sends the first, unpaid request to the merchant to learn what it asks, checks everything, and answers with what would happen. Nothing is signed, issued, reserved or recorded.
After signing
Once a signature or a token exists, the call does not fail: the answer is the payment, paid when the merchant answered the paid request with success and failed otherwise, with signed: true. A failed x402 payment's authorisation stays valid until its time limit, so the merchant could still settle it; what it counted against a limit stays counted. A token that was issued and not accepted is withdrawn at the card processor, and what it counted is given back when the withdrawal succeeds.
What is recorded
Every attempt is kept and can be read with GET /agent-payments: paid, failed, refused (stopped before anything was signed, with the reason), held and, briefly, pending. Each has the merchant's host, the address without its query, the amount, protocol and network, the reference and the authorisation block. Every attempt is in the audit trail.
Never stored or logged: the signature, the token, and the merchant's response headers. The merchant's body is returned as an excerpt of at most 2000 characters and is not kept on the record. It is text a third party wrote: show it, do not act on it. The request as sent, including headers, is stored when a payment is held for approval, so a person approves exactly what was asked.
Events
| Event | Concerns | When |
|---|---|---|
agent_wallet.created | agent_wallet | A person made a self-held wallet, owned by them, for an agent to pay from. |
agent_wallet.retired | agent_wallet | An agent's wallet was retired: nothing is signed with it again. Funds at its address are not moved. |
agent_wallet.key_download_requested | agent_wallet | A wallet's owner asked, with their passkey, to download its key from the wallet provider. The key never passed through Skerry. |
agent_payment.created | agent_payment | An agent's payment to a merchant passed every check and is being paid. |
agent_payment.paid | agent_payment | A merchant accepted an agent's payment. |
agent_payment.failed | agent_payment | An agent's payment was decided and not completed: the signing failed, or the merchant did not answer the paid request with success. signed says whether a signature or token was produced. |
agent_payment.refused | agent_payment | An agent's payment was refused before anything was signed: by a control, a mandate, or because the merchant asked for more than the ceiling or for something that cannot be paid. |
agent_payment.held | agent_payment | An agent's payment is waiting for a person to approve it. An approval.requested event carries the approval. |
A held payment also raises approval.requested.
What is not offered, and why
| Not offered | Why |
|---|---|
x402 offers that name permit2 or erc7710 as the transfer method | Only EIP-3009 is built. Such an offer is passed over with transfer_method_not_offered. |
| x402 on any network or asset other than USDC on Base and Base Sepolia | The wallet's policy allows one contract on one chain. |
The Machine Payments Protocol's tempo method, and its session intent | The documentation read does not state the transaction, voucher or credential formats. They are not built from memory. |
A challenge bound to a request digest (digest), or asking for the credential in a header other than Authorization or Payment-Authorization | How the digest is computed is not in the documentation read. Such a challenge is passed over. |
| A payment token that needs the payer to act | An unattended agent cannot complete it. The token is withdrawn and the call answers token_not_issued. |
| Wallet balances | The provider's documentation shows no call that reads one. Read the address on the chain. |
| Moving funds out of a wallet | The wallet's policy allows no transaction. |
| The wallet provider's webhooks | Their payload and signature are not in the documentation read. |
| The Link wallet for agents | Its HTTP interface is not documented outside the vendor's own tools. |
Where the documentation did not say
Each of these is a choice made here, stated so that it can be checked against the provider before the feature is switched on for live:
- The type of a policy condition's value.
chainIdis sent as a decimal string. - How the typed data's numbers are encoded.
value,validAfterandvalidBeforeare sent as decimal strings;chainIdin the domain is a number. - The encoding of an owner's public key. Sent as base64 DER, the form the provider states for a key quorum's keys; not stated for a wallet's owner.
- A signer's own policy. Sent as
override_policy_idson the signer; the REST reference names onlysigner_id. The same policy is also the wallet's own, so the limit holds either way. - Finding a person's user that already exists. Asked of
POST /api/v1/users/custom_auth/idat the provider's auth host when making it answers 409 or 422. - Whether a policy binds the owner too. The wallet's policy is the same as the signer's; an owner can change it, with their own signature.
- When a signed authorisation starts to be valid.
validAfteris now lessSKERRY_X402_VALID_AFTER_SKEW_SECONDS(60 by default). - Whether issuing a token needs
return_url. It is sent only whenSKERRY_AGENT_PAYMENTS_RETURN_URLis set. - How a payment method saved on a connected account is used to issue a token. The token is issued on the merchant account of the agent's customer, named as every other call names it, with the card processor's pinned preview version. This is the part least certain to work as built.
- Whether an issued token's id is the token. It is treated as the token: used once in the credential, and kept only as a fingerprint.
Configuration
| Variable | Meaning |
|---|---|
SKERRY_SELF_HELD_WALLETS | on switches the feature on for the deployment. |
SKERRY_WALLET_OWNER | account or device: who owns a new wallet. Unset, the feature is off. |
SKERRY_PRIVY_TEST_APP_ID, SKERRY_PRIVY_TEST_APP_SECRET | The wallet provider's app for sandbox. |
SKERRY_PRIVY_LIVE_APP_ID, SKERRY_PRIVY_LIVE_APP_SECRET | The wallet provider's app for live. Live also needs the live interlock open. |
SKERRY_PRIVY_TEST_AUTHORIZATION_KEY, SKERRY_PRIVY_LIVE_AUTHORIZATION_KEY | Required. wallet-auth:<base64 PKCS#8>, this API's signer key: it signs each request to the wallet provider. node scripts/privy-signer.mjs prints its public half. |
SKERRY_PRIVY_TEST_SIGNER_ID, SKERRY_PRIVY_LIVE_SIGNER_ID | Required. The key quorum at the provider holding that public half alone, threshold 1, made once by an operator. |
SKERRY_PRIVY_API_BASE | Points the wallet calls at a stand-in, for tests. Refused for live. |
SKERRY_X402_VALID_AFTER_SKEW_SECONDS | Seconds before now that a signed authorisation starts to be valid, 0 to 600. |
SKERRY_AGENT_PAYMENTS_RETURN_URL | Optional return_url for issuing a token. |
SKERRY_AGENT_TOKENS_ENABLED | Must also be true for a payment with a delegated payment token. |
Secrets can be stored as KMS ciphertext like the other providers' keys; a value still in ciphertext counts as not set. The tables are in db/028_agent_wallets.sql.
Code
| File | What it holds |
|---|---|
lib/pure/agent-pay.ts | Reading offers and challenges, choosing one, the typed data, the PAYMENT-SIGNATURE payload and the credential. |
lib/pure/privy.ts | The wallet provider's request bodies, headers and request signature. |
lib/providers/wallets.ts | The calls to the wallet provider, and the switch. |
lib/agent-wallets.ts | Creating, reading and retiring wallets. |
lib/ops/agent-payment.ts | The payment: asking the merchant, the decision, signing, the record. |
Written and kept by Skerry. Read from https://api.skerry.xyz/guides/agent-payments.md.