agentwallets.si
← Back to articles

AGENTWALLETS · INDEPENDENT PERSPECTIVES

thirdweb x402: Charge an API Without Confusing Authorization and Settlement

A practical reading of thirdweb x402: exact versus upto billing, facilitator wait states, supported tokens and the delivery record an API still needs.

Quick answer

thirdweb supplies an x402 client, server helpers and a facilitator. Its exact and upto schemes support different charging models; verification, submission and confirmation are not interchangeable. The API operator still owns usage measurement, delivery and refund handling.

Article concepts · illustration
01Paid endpoint02Payment proof03Verification

A document-analysis API cannot know the final processing bill before it has read the document. Charging a fixed amount is simple, but either the buyer overpays for a short file or the seller subsidizes a long one. thirdweb’s x402 implementation is useful to examine through this concrete pricing problem.

Review scope: official documentation checked November 1, 2026. We did not connect a wallet, settle a payment or benchmark the service. The example below is an integration design, not a product test.

Choose the charge model before adding middleware

The server guide distinguishes exact from upto. The first charges a specified amount. The second permits settlement against an authorized ceiling, including multiple settlements while the authorization remains valid. For variable work, the guide separates verification from the later charge based on measured usage.

For our document API, the ceiling should appear before processing starts. A buyer agreeing to a maximum has not agreed that every request should consume that maximum. The service needs a reproducible meter: input size, work completed and the rule translating that work into a bill. An explanation generated after the fact is not an adequate accounting record.

The payment path has two different gates

Conceptual flow: Request document analysis → Return price and ceiling; Return price and ceiling → Buyer authorizes payment; Buyer authorizes payment → Verify authorization; Verify authorization → Run and meter work; Run and meter work → Settle measured charge; Settle measured charge → Deliver result and receipt.
Source-informed conceptual flow, not a payment test. Source: thirdweb x402 overview.

Conceptual upto flow based on the server documentation; no live payment is shown. A failed settlement needs an explicit delivery policy.

Verification allows the service to decide whether to start expensive work. Settlement determines what payment outcome has actually occurred. Keep both in the job record. If the analysis finishes but settlement fails, the application needs a defined response: preserve the result, reconcile payment and decide whether the buyer can retrieve it. Starting the same analysis again may waste compute without resolving the original charge.

A successful response depends on the configured wait state

The facilitator reference exposes simulated, submitted and confirmed wait modes. A simulation is not evidence that money moved. Submission is not the same assurance as confirmation. The documented default is confirmation, but an integration can deliberately choose a different trade-off.

Write the chosen state into the service’s payment contract with its own backend. For a costly, non-recoverable result, accepting a simulation may be a different risk from allowing a low-cost cached response after submission. This is an operator decision, not a universal recommendation to prefer speed. Support staff should be able to identify the mode used for the disputed request.

Business event Evidence worth retaining
Buyer accepts the ceiling Resource, network, asset, maximum and expiration
Work is performed Job identifier and the measured billable units
Payment is processed Facilitator result and applicable chain transaction
Result is delivered Response or retrieval record linked to the same job

Compatibility is a concrete configuration

The overview describes a client/server stack around x402 and payment tokens supporting the required authorization mechanisms. That does not make every token on every advertised chain interchangeable. The facilitator provides a supported-method query; use the actual network and token combination rather than a marketing chain count.

Our suggested integration review also checks protocol version, payment headers, scheme and the buyer’s signing capability. A client that understands a fixed exact payment may not implement the variable-usage behavior your API expects. Publish a clear error for unsupported combinations rather than repeatedly presenting an unpayable challenge.

Where this implementation fits

thirdweb is an implementation choice for teams exposing paid resources or consuming them through an existing application. It is not a second independent protocol competing with x402, and the facilitator is not proof that a purchased result was correct.

Before release, test expiration during a long job, concurrent draws against a ceiling, loss of the response after payment and a repeated client request. These are proposed tests, not results we obtained. Keep the thirdweb reference beside the architecture decision, and compare providers on the same billing and delivery semantics rather than the number of lines in a quickstart.

FOLLOW THE SOURCES

Sources