Skip to content

docs(x402): the settle token, one settlement per payment, metered payments, x402-fetch 0.3.0, x402 0.8.1 and CLI 0.4.1 - #33

Merged
JeanBrasse merged 8 commits into
mainfrom
docs/x402-latest
Oct 5, 2026
Merged

JeanBrasse merged 8 commits into
mainfrom
docs/x402-latest

Conversation

@JeanBrasse

@JeanBrasse JeanBrasse commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The x402, SDK, x402-fetch, CLI and facilitator content of the docs catches up with Parallel's releases of 28 September to 2 October:

  • @parallel-protocol/x402 0.8.0 and 0.8.1;
  • @parallel-protocol/x402-fetch 0.2.3 and 0.3.0;
  • @parallel-protocol/cli 0.4.1;
  • the facilitator's settle token, single settlement and verify checks.

This PR leaves out:

Sources:

Pages

agents/x402/quickstart

  • A warning to use @parallel-protocol/x402 0.8.1 or later (0.8.1 since 8774ba3, see the last round). Since 1 October 2026 the facilitator settles only when the settle presents the token it issued at verify. Earlier versions do not send it, and their settlements are refused with SETTLE_TOKEN_REQUIRED.
    • Source: the x402 0.8.0 README. The date is Parallel's.
    • Reproduced offline, with 0.7.1 and with 0.8.0, against a facilitator that requires the token.
  • "What happens behind the scenes" now covers:
    • what verify checks;
    • the token;
    • one settlement per payment;
    • the 402 PAYMENT_SETTLEMENT_FAILED with its reason;
    • the single retry of a settle whose outcome is unknown.
    • Source: the x402 0.8.0 README.
  • The Next.js tab compiles in strict TypeScript. payTo is as const, and the handler returns NextResponse.json, as withPayment's handler type requires and as the package README writes it.
    • Checked with tsc (strict) against x402 0.8.0 and Next 15.5.27.
    • The tab did not compile before this PR either.

agents/x402/concepts

  • The payment flow:
    • what verify checks;
    • the settle token;
    • one settlement per payment: a repeated settle returns what was recorded, the confirmation, marked alreadySettled, or the refusal;
    • SETTLE_TOKEN_REQUIRED and SETTLE_TOKEN_INVALID.
    • Source: the x402 0.8.0 README, including its table of the codes the facilitator returns.
  • "Exact and metered payments":
    • an upto payment signs a cap, valid 3,600 s at most, in USDp only;
    • the escrow refunds the rest;
    • the SDK keeps up to two minutes of the window for the settlement and its retry: the handler gets maxTimeoutSeconds minus 120 s, and 30 s at least;
    • AMOUNT_MISMATCH.
    • Source: the x402 README ("Metered routes") and the published 0.8.0 package.

agents/x402/agent-quickstart

  • Install:
    • x402-fetch signs through the CLI's engine, which it installs as a regular dependency;
    • 0.2.3 accepts the CLI's 0.4 line, so a fresh install gets 0.4.1, which prepares a USDp or sUSDp payment on Base in about 0.5 s instead of about 5 s;
    • with that release and the facilitator update shipped alongside it, Parallel measured a paid call on Base at 3.5 s, down from 9.4 s.
    • Source: npm (x402-fetch 0.2.3's dependencies, CLI 0.4.1) and Parallel's figures.
  • Options and codes:
    • the options dailyBudget, timeoutMs and allowInsecure, and the chain default;
    • the codes UNKNOWN_CHAIN, BUDGET_EXCEEDED, UNSUPPORTED_SCHEME and ENGINE_NOT_FOUND, and engineCode.
    • Source: the x402-fetch 0.2.3 README and its published type definitions.
  • Metered invoices. Source: the x402-fetch README.
  • When the settlement fails: every reason the SDK can report now gets advice that cannot make the agent pay twice.
    • A new payment for INSUFFICIENT_BALANCE, PAYMENT_EXPIRED and TX_REVERTED, and later for RELAYER_UNAVAILABLE: the payment was not taken, and the facilitator recorded the failure, so it will not settle it.
    • A check with the merchant first for every other reason:
      • SETTLE_TIMEOUT, FACILITATOR_UNAVAILABLE, FACILITATOR_INVALID_RESPONSE, SETTLE_IN_PROGRESS, RECEIPT_UNAVAILABLE, AMOUNT_MISMATCH, SETTLE_TOKEN_REQUIRED and SETTLE_TOKEN_INVALID: for each, x402 0.8.0 sends the agent exactly that advice in its message (published package).
      • SUBMISSION_FAILED: the facilitator also returns it when a settlement is interrupted after a transaction went out, so the payment may still settle.
      • UNKNOWN: the SDK's reason for an answer that carries no code it can read (x402 0.8.0 README). Its message gives no advice.
      • PAYMENT_NOT_VERIFIED: the facilitator also answers a repeated settle with it after a first attempt whose transaction it could not confirm, and that transaction may still be mined.
      • PARALLELIZER_PAUSED and SERVICE_UNAVAILABLE: refused before anything is sent, so the same settle can still go through until the authorization expires.
      • AUTHORIZATION_USED: the facilitator answers it with a 409. The authorization is "no longer usable on-chain (consumed or cancelled)" and was "not settled by this facilitator". If someone else settled it, the merchant was paid.
      • Any reason the list does not name. The error codes page gives the detail.
    • The merchant settles once its handler has answered, before it sends the response.
  • The safety model:
    • a wrapper signs one payment at a time, which keeps dailyBudget exact, and it never retries;
    • it does not set aside what it has signed, so two payments signed together can each fit a balance that covers only one;
    • the chain then refuses the second settlement with INSUFFICIENT_BALANCE, possibly after the merchant has served.
    • Reproduced offline: one wrapper holding 0.015 USDp signed two payments of 0.01.

agents/x402/index and agents/cli/index

  • The CLI is MIT-licensed.
  • Source: npm (the license field, and the LICENSE file shipped in 0.4.1).

agents/cli/commands

  • pay prepare --scheme upto, and --valid-for (3,600 at most).
  • Since 0.4.1, the signing domain comes from the token's DOMAIN_SEPARATOR() instead of version(), which is faster on Base.
  • ROUTE_UNAVAILABLE for a token whose domain matches no known version.
  • Source: CLI 0.4.1's --help and the published package. Each statement was run offline.

agents/faq

  • "What happens if the facilitator goes down?": the single retry, and the 402 that tells the agent to check with the merchant before paying again.
  • Source: the x402 0.8.0 README.

agents/recipes/migrate-from-coinbase-x402

  • Install @parallel-protocol/x402 0.8.1 or later: 0.8.0 for the settle token, 0.8.1 for the facilitator URL checks.
  • Source: as for the quickstart.

security/risks

  • The facilitator row of the table now lists one settlement per payment, bound to the merchant that verified.
  • Section 9:
    • MIT for the CLI;
    • the settle retry;
    • the settle token;
    • one settlement per payment;
    • verify's shape, asset and recipient checks;
    • SETTLE_TIMEOUT;
    • the failed settlement's 402;
    • an alert on AMOUNT_MISMATCH.
  • The "120-second verify window" is removed. A settle that comes after that time is no longer refused. Only an expired authorization (PAYMENT_EXPIRED) or a payment never verified (PAYMENT_NOT_VERIFIED) is refused.
  • "Each signer is rate-limited hourly" stays: it describes the facilitator as it runs today.

Not documented as done

These are still open at Parallel, and this PR states only what ships:

  • changes to the rate limits;
  • upto in USDC;
  • external signers and ERC-1271;
  • concurrent signing and automatic retry in x402-fetch.

Checks

All runs were offline, under sandbox-exec with localhost only, at 60e0b2b.

  • pnpm typecheck: clean.
  • pnpm test: 348/348, in 32 files.
  • pnpm build: passes. Offline, the share-card font from brand.parallel.best does not load, and pages keep the static og-image.png.
  • Links: linkinator dist/public --recurse --clean-urls --check-fragments, with external links skipped: all 414 internal links OK.
  • Anchors: every link and anchor of the built HTML was checked: 10,273 internal links, 904 of them with an anchor.
    • The 9 changed pages have no broken link and no missing anchor, including /agents/x402/concepts#exact-and-metered-payments, #metered-invoices and #when-the-settlement-fails.
    • The only 4 broken links of the site are older than this PR, on /products/parallel-v2: old GitBook paths.
  • pnpm generate:sidebar was not run. No page was added.

Round: x402-fetch 0.3.0 and x402 0.8.1 (33e04cf)

Both were published on 2 October.

agents/x402/agent-quickstart

  • The version line. x402-fetch 0.3.0 is the version a fresh install gets, still with the CLI 0.4.1. A project on 0.2 moves by installing it, since a ^0.2 range does not reach 0.3.
  • A paid request the merchant answers with 402 now rejects with X402FetchError instead of returning the response:
    • PAYMENT_REFUSED, in a new section, "When the merchant refuses the payment";
    • SETTLEMENT_FAILED: "When the settlement fails" now says where an agent on 0.3.0 reads the reason and the Retry-After (err.reason, err.retryAfter), and where one on an earlier version does (the body and the header).
    • The code sample's comment and the refusals table name the two codes, which come after the payment is sent.
  • The safety model: the engine gets only the settings it needs, not the caller's whole environment.
  • Source: the x402-fetch 0.3.0 changelog, README and type definitions.

agents/x402/quickstart and agents/recipes/migrate-from-coinbase-x402

  • The facilitator URL must use https; plain http is accepted only on localhost, 127.0.0.1 and [::1].
  • The SDK never follows a redirect: a redirect fails the call with FACILITATOR_UNAVAILABLE.
  • Both since x402 0.8.1. Source: its changelog and README.

Also:

  • No page mentions FacilitatorClient.pay(), which 0.8.1 deprecates.
  • Three items have shipped, so they leave "Not documented as done":
    • x402-fetch's typed error for a refused paid request;
    • the SDK's redirect refusal;
    • the engine's environment whitelist.
  • The api-reference and error-codes pages are not changed here.

Checks at 33e04cf:

  • pnpm typecheck is clean, pnpm test passes 348/348 in 32 files, and pnpm build passes.
  • The agent-quickstart code sample compiles in strict TypeScript against the published x402-fetch 0.3.0. A fresh install of it resolves the CLI 0.4.1.
  • Links: linkinator with --check-fragments, external links skipped: all 414 internal links OK.
  • Anchors: the built HTML has 10,276 internal links, 907 of them with an anchor.
    • The 3 changed pages have no broken link and no missing anchor, including the new #when-the-merchant-refuses-the-payment.
    • The only 4 broken links are the old ones on /products/parallel-v2.
  • pnpm generate:sidebar was not run.

Round: the receipt is read after the payment (21dcdfc)

agents/x402/agent-quickstart

  • The code sample. decodePaymentResponse throws INVALID_INVOICE when the payment-response header cannot be decoded (x402-fetch 0.3.0, dist/index.js). That happens after the request was paid, but the call sat inside the try whose comment says every code other than PAYMENT_REFUSED and SETTLEMENT_FAILED is raised before any payment, so an agent retrying on it would pay twice. The try now wraps payFetch alone and rethrows, and the receipt is decoded after it, with a comment saying the request is already paid. In 0.3.0, the only X402FetchError codes payFetch raises after the paid request are those two, so the comment holds.
  • The refusals table: the INVALID_INVOICE row says decodePaymentResponse also throws it, after the payment.
  • The safety model: the environment list does not cover files on disk. The CLI 0.4.1 still loads a .env file from the agent's working directory or any parent directory (the engine runs in that directory). Source: the published CLI 0.4.1 (findEnvFile) and x402-fetch 0.3.0 (execFile with no cwd).

Checks at 21dcdfc:

  • pnpm typecheck is clean, pnpm test passes 348/348 in 32 files, and pnpm build passes, offline.
  • The code sample compiles in strict TypeScript (strict, NodeNext, TypeScript 5.9.3) against the published x402-fetch 0.3.0, with the DOM lib, and with Node's types alone under skipLibCheck (without the DOM lib, a dependency's own type definitions need it).
  • Links and anchors on the page: none broken. The only 4 broken links on the site are the old ones on /products/parallel-v2.
  • pnpm generate:sidebar was not run.

Round: 0.8.1 minimum, and three precisions (8774ba3)

agents/x402/quickstart and agents/recipes/migrate-from-coinbase-x402

  • The minimum is now @parallel-protocol/x402 0.8.1 on both pages. 0.8.0 is the first version to send the settle token; 0.8.1 adds the https-only facilitator URL and the no-redirect rule, which both pages already describe. Each page now says so in a sentence.

agents/x402/agent-quickstart

  • The .env fallback. When no .env is found walking up from the working directory, the CLI 0.4.1 walks up from its own install directory, inside the project's node_modules, and so finds the project's .env. The safety model now says so. Source: the published CLI 0.4.1 (loadEnv calls findEnvFile a second time, from the directory of its own script).
  • The receipt comment says "Any payment was sent by now" instead of "The request is paid by now". Nothing is paid when the first answer was not a 402, or when the merchant does not settle. The conclusion stays: INVALID_INVOICE from decodePaymentResponse is no reason to pay again.
  • The refusals section says the two codes that come after the payment are those from payFetch, since decodePaymentResponse can also throw after it.

Checks at 8774ba3:

  • pnpm typecheck is clean, pnpm test passes 348/348 in 32 files, and pnpm build passes, offline.
  • The code sample compiles in strict TypeScript (strict, NodeNext, TypeScript 5.9.3) against the published x402-fetch 0.3.0.
  • Links and anchors on the three changed pages: none broken. The only 4 broken links on the site are the old ones on /products/parallel-v2.
  • pnpm generate:sidebar was not run.

Round: config.toml, and the causes of INVALID_INVOICE (12f8573)

agents/x402/agent-quickstart

  • The safety model no longer says the CLI reads ~/.parallel/config.toml. The CLI 0.4.1 reads it only for defaults: the chain when --chain is missing, and the keystore when --wallet has no value. x402-fetch 0.3.0 always passes --chain and --wallet env, so a payment does not read it. The sentence on the .env file stays.
  • The INVALID_INVOICE row now reads: "An invoice field is malformed: a payTo or asset that is not an address, an amount that is not a positive integer, or decimals that contradict the token catalog or fall outside 0 to 36." The sentence on decodePaymentResponse follows unchanged. Source: the x402-fetch 0.3.0 README and resolvePayment in its dist/index.js. A 402 without a readable invoice is not one of these: payFetch returns it as it is.

Checks at 12f8573:

  • The branch still merges cleanly with main (1168335), so main was not merged in.
  • pnpm typecheck is clean, pnpm test passes 348/348 in 32 files, and pnpm build passes, offline.
  • The code sample compiles in strict TypeScript against the published x402-fetch 0.3.0.
  • Links and anchors on the page: none broken.
  • pnpm generate:sidebar was not run.

🤖 Generated with Claude Code

…ments, x402-fetch 0.2.3 and CLI 0.4.1

- quickstart, migration recipe: @parallel-protocol/x402 0.8.0 or later; the
  facilitator has required the settle token since 1 October 2026, and older
  versions' settlements are refused with SETTLE_TOKEN_REQUIRED. What happens
  behind the scenes: the token from verify to settle, a failed settlement's
  402 with its reason, the one retry of a settle whose outcome is unknown.
- concepts: what verify checks (BAC-375), the token, one settlement per
  payment and alreadySettled (BAC-376), and exact and metered (upto)
  payments: USDp only, a window of 3,600 s at most, the two minutes the SDK
  keeps for the settlement and its retry, AMOUNT_MISMATCH.
- agent quickstart: x402-fetch 0.2.3 on CLI ^0.4.0 and the faster signing of
  0.4.1; the dailyBudget, timeoutMs and allowInsecure options and the chain
  default; UNKNOWN_CHAIN, BUDGET_EXCEEDED, UNSUPPORTED_SCHEME and
  ENGINE_NOT_FOUND; metered invoices; what the agent gets when a settlement
  fails; one payment at a time, no automatic retry.
- CLI: MIT; pay prepare's --scheme upto and --valid-for, and the signing
  domain read from DOMAIN_SEPARATOR() since 0.4.1.
- FAQ, x402 overview, risks: the settle retry, the token, one settlement per
  payment, verify's checks, MIT for the CLI; the "120-second verify window"
  is gone, since a settle after it is rebuilt from the verified payment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs-parallel Ready Ready Preview Oct 5, 2026 3:23am UTC
parallel-docs Ready Ready Preview Oct 5, 2026 3:23am UTC

…not prevent, which settlement failures ask for a check with the merchant, and a Next.js tab that compiles

- agent-quickstart, the safety model: a wrapper's queue keeps dailyBudget
  exact but does not set aside what it signed; two payments signed together
  can each fit a balance that covers one, and the chain refuses the second
  settlement (INSUFFICIENT_BALANCE), possibly after the merchant has served.
  QA reproduced it with 0.015 USDp and two 0.01 payments.
- agent-quickstart, when the settlement fails: FACILITATOR_INVALID_RESPONSE,
  AMOUNT_MISMATCH and SETTLE_TOKEN_REQUIRED/INVALID ask for a check with the
  merchant, as the message @parallel-protocol/x402 0.8.0 sends the agent for
  each says. So does AUTHORIZATION_USED: the facilitator answers it as a 409,
  consumed or cancelled on-chain and not settled by it, and if someone else
  settled the authorization, the merchant was paid. The SDK settles once the
  handler has answered, before it sends the response.
- quickstart, Next.js tab: payTo as const, and the handler returns
  NextResponse.json as withPayment's handler type requires; it compiles in
  strict TypeScript against x402 0.8.0 and Next 15.5.27 (it did not before
  this PR either).
- concepts: the metered handler gets maxTimeoutSeconds minus 120 s, and 30 s
  at least.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a repeated settle returns the confirmation or the refusal

- agent-quickstart, when the settlement fails: SUBMISSION_FAILED joins the
  reasons that ask for a check with the merchant before paying again. The
  facilitator also returns it when a settlement is interrupted after a
  transaction went out, an outcome it cannot know yet, so paying again could
  pay twice.
- concepts: a settle repeated after a lost answer returns what was recorded,
  the confirmation, marked alreadySettled, or the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ake the agent pay twice

When the settlement fails, in the agent quickstart:
- TX_REVERTED joins the reasons that ask for a new payment. Like
  INSUFFICIENT_BALANCE, PAYMENT_EXPIRED and RELAYER_UNAVAILABLE, the payment
  was not taken and the facilitator will not settle it.
- Four reasons join the ones that ask for a check with the merchant first:
  - UNKNOWN: the SDK could not read why the settlement failed;
  - PAYMENT_NOT_VERIFIED: a repeated settle also gets it after a first
    attempt whose transaction may still be mined;
  - PARALLELIZER_PAUSED and SERVICE_UNAVAILABLE: refused before anything was
    sent, the payment can still be settled until it expires.
- Any reason the list does not name asks for a check with the merchant too,
  and the error codes page gives the detail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Joh077

Joh077 commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks, this is accurate for x402-fetch 0.2.3 and x402 0.8.0. Two releases went out that change a few lines:

  • @parallel-protocol/x402-fetch 0.3.0: a paid request answered with 402 no longer comes back as a response. payFetch rejects with X402FetchError, code SETTLEMENT_FAILED (or PAYMENT_REFUSED when the merchant re-issues an invoice), with reason and retryAfter. In agent-quickstart, "payFetch hands that response back as it is" no longer holds, the reason list stays valid but is read from err.reason, and the error table needs PAYMENT_REFUSED and SETTLEMENT_FAILED. Code that read a 402 after paying must now catch the error.
  • @parallel-protocol/x402 0.8.1: the facilitator URL must use https (plain http only on localhost) and a redirect is never followed. The quickstart warning can recommend 0.8.1.
  • The title and description mention 0.2.3 and 0.8.0.

#32 now carries the settlement routes table (A to L and U, verify-vs-settle#settlement-routes) and the metered route configuration (api-reference#metered-routes-upto). Once it is merged, concepts can link there instead of the package README. I left the concepts of metered payments to this PR to avoid saying it twice.

…FetchError, and x402 0.8.1 calls the facilitator over https only

agent-quickstart
- x402-fetch 0.3.0 is the version a fresh install gets, still with the
  CLI 0.4.1. A project on 0.2 moves by installing it, since a ^0.2
  range does not reach 0.3.
- A paid request the merchant answers with 402 now rejects with
  X402FetchError instead of returning the response:
  - PAYMENT_REFUSED when the merchant asks for payment again (a new
    section);
  - SETTLEMENT_FAILED when it could not settle.
  Both carry reason and retryAfter. The code sample, the refusals table
  and "When the settlement fails" say where the agent reads them on
  0.3.0, and on earlier versions.
- The safety model: the engine now gets only the settings it needs,
  not the caller's whole environment.

quickstart and migrate-from-coinbase-x402
- The facilitator URL must use https, plain http being accepted only on
  localhost, 127.0.0.1 and [::1]. A redirect is never followed: it
  fails the call with FACILITATOR_UNAVAILABLE. Both since x402 0.8.1.

No page mentions FacilitatorClient.pay(), which 0.8.1 deprecates.

Sources: the changelogs, READMEs and type definitions of x402-fetch
0.3.0 and x402 0.8.1 on npm (sdk-merchant #62 and #63, published by
#64).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JeanBrasse JeanBrasse changed the title docs(x402): the settle token, one settlement per payment, metered payments, x402-fetch 0.2.3 and CLI 0.4.1 docs(x402): the settle token, one settlement per payment, metered payments, x402-fetch 0.3.0, x402 0.8.1 and CLI 0.4.1 Oct 4, 2026
decodePaymentResponse throws INVALID_INVOICE when the receipt header
cannot be decoded, after the request was paid. In the quickstart it ran
inside the try whose comment says every other code comes before any
payment, so an agent following it could pay twice. It now runs after the
try, with a comment saying the request is already paid.

Also say that CLI 0.4.1 still loads a .env file from the working
directory or a parent, and ~/.parallel/config.toml: the environment list
does not cover files on disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Merchant quickstart and Coinbase migration recipe: use
  @parallel-protocol/x402 0.8.1 or later. 0.8.0 is the first to send the
  settle token; 0.8.1 adds the https-only facilitator URL and the
  no-redirect rule these pages already describe.
- Agent quickstart:
  - CLI 0.4.1 falls back to a .env found from its install directory,
    which is the project's, when none is found from the working directory;
  - the receipt comment says any payment was sent by now, rather than
    that the request is paid;
  - the two codes that come after the payment are those from payFetch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uses

- The safety model no longer says the CLI reads ~/.parallel/config.toml.
  The CLI 0.4.1 reads it only for defaults that x402-fetch already passes
  (--chain and --wallet), so a payment does not read it.
- The INVALID_INVOICE row names the malformed invoice fields, as in the
  x402-fetch 0.3.0 README: payTo or asset not an address, an amount that
  is not a positive integer, or decimals that contradict the token
  catalog or fall outside 0 to 36. A 402 without a readable invoice is
  not one of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JeanBrasse
JeanBrasse merged commit 7ba3758 into main Oct 5, 2026
3 checks passed

This branch was successfully deployed

2 active deployments
Preview – docs-parallel — 12f8573e Deployed Oct 5, 2026 by vercel[bot]
Preview – parallel-docs — 12f8573e Deployed Oct 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants