DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › AI agents

How to Verify x402 Payment Requests Before an Agent Calls an API

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Do not let an agent pay merely because an API returns 402 Payment Required. In an x402 v2 flow, the response is an offer: parse its PAYMENT-REQUIRED header with an x402 library, compare every offered option with your spending and trust policy, then sign only a supported option. Check the scheme, network, asset, recipient, amount semantics, validity limits and replay protections before sending the signed value in PAYMENT-SIGNATURE. On the resource-server side, verify that payload against the exact requirements originally offered before protected work runs. A facilitator can perform verification or settlement, but its version, scheme and network support must be checked and errors must fail closed.

What does an x402 payment request mean?

An x402 response is a machine-readable request for payment, not an authorization to spend. The server returns HTTP 402 with one or more payment requirements. The client chooses an acceptable requirement, creates and signs a payment payload for that requirement, and retries the original request. The server then verifies the payload and follows the selected payment scheme’s fulfillment and settlement rules.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The client and server have different jobs

An agent client decides whether an offer is acceptable. It should enforce the operator’s budget, allowed networks, accepted assets, merchant addresses and time limits before signing. x402 does not define your business budget or risk policy.

The resource server has the protocol’s payment-verification obligation. It must check that the submitted payload is valid for the scheme and network and corresponds to the requirements it actually offered. It must not execute paid work merely because a payload can be decoded.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Which v2 headers carry the exchange?

Stage HTTP element Meaning
Offer PAYMENT-REQUIRED Base64-encoded payment requirements returned with the 402 response.
Retry PAYMENT-SIGNATURE The client’s signed payment payload sent with the retried request.
Result PAYMENT-RESPONSE The server or facilitator’s payment-processing response after verification or settlement.

These are the HTTP conventions for x402 v2. A syntactically valid header is only transport data; it does not prove that the payment is valid, affordable or intended for your request.

What should an agent inspect in the 402 response?

Inspect the decoded payment requirements as a policy decision, not as a quick “price exists” check. Reject an offer when any material field falls outside policy or cannot be interpreted for the selected scheme.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Check What to establish before signing Why it matters
Protocol version Use the version your client library and deployment support, preferably v2 for new integrations. v1 headers and network identifiers are legacy conventions and can be incompatible with v2 implementations.
Scheme Confirm the scheme is explicitly allowed and that your library implements its payload and verification rules. Amount behavior, authorization fields, replay controls and settlement order differ by scheme.
Network Match an allowlist of networks, including the exact network identifier expected by the binding. A familiar asset name or chain name is not enough; network-specific rules determine validity.
Asset Check the token or currency identifier and its decimals according to that network. Identical-looking amounts can represent different values or assets.
Recipient Compare the payee address or account with the merchant or service identity configured for the endpoint. A valid signature does not make an unexpected recipient safe.
Amount Interpret whether the value is exact, a maximum, or another scheme-defined form; enforce your own ceiling. Do not compare numeric strings without applying the selected scheme’s amount semantics.
Validity window Check expiration, authorization time bounds and any required timestamps against a trusted clock. Old or future-dated authorizations can create payment and replay risk.
Resource binding Ensure the requirement belongs to the URL, method, or resource context you are about to call. An offer copied from another response must not be reused for this request.
Unknown or malformed data Reject fields your library cannot parse or whose meaning is undefined for the selected binding. Silently ignoring a new or malformed field can turn an apparently safe offer into an unsafe one.

Why scheme-specific rules cannot be skipped

x402 separates common protocol data from scheme and network payment logic. The common shape tells you what to parse; it does not establish signature validity, recipient ownership, amount interpretation, authorization timing or replay protection. Those checks belong to the selected binding. Treat an object that merely decodes successfully as unverified until the scheme’s validator accepts it.

How should multiple offers be handled?

A 402 response may advertise alternatives. Filter the list against policy first, then choose one option. Do not combine the recipient from one requirement with the amount or network from another, and do not sign an option simply because it is the first item returned.

How can I verify an x402 offer before the agent signs?

Use a library to parse the protocol object, then apply deterministic policy checks before any wallet or signing key is called. The following sequence keeps the spending decision separate from cryptographic signing.

Rank #2
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
  1. Capture the complete 402 response. Preserve the status, request URL and method, and the complete PAYMENT-REQUIRED value. If the header is absent, truncated or malformed, stop; do not guess a price or construct a payment manually.
  2. Parse with an x402 protocol library. Decode the header into the library’s payment-requirements type. Avoid splitting base64 text or assembling protocol objects with string operations; canonical encoding and field types are part of interoperability.
  3. Apply the agent’s policy. Require an allowed scheme and network, an approved asset and recipient, and an amount within the configured limit. Evaluate expiration and other time conditions using the selected binding’s rules. If the policy cannot express a field’s meaning, reject the offer rather than treating it as harmless.
  4. Bind the decision to this request. Record the endpoint, method and the exact requirement selected. A requirement obtained for one resource or response should not be silently carried to a different call.
  5. Construct and sign through the library. Let the scheme-specific implementation produce the payment payload and invoke the wallet only after the checks pass. Signing is the point at which the agent commits to spend; logging or decoding after signing is not a substitute for pre-signing policy.
  6. Retry with the v2 header. Send the resulting encoded payload in PAYMENT-SIGNATURE on the retry of the original request. Keep the original requirement available so the server can compare the payload with what it offered.

Illustrative control flow

response = call_resource_without_payment()
if response.status != 402:
    return response

requirements = x402.parse_payment_required(response.headers['PAYMENT-REQUIRED'])
selected = policy.choose(requirements, request.url, request.method)
if selected is None:
    stop('no permitted payment option')

payment = x402.sign(selected, wallet)
return call_resource(
    request,
    headers={'PAYMENT-SIGNATURE': x402.encode(payment)}
)

The function names above are illustrative. Use the equivalent parse, selection, signing and encoding functions in the maintained x402 library for your language and scheme. Never treat a successful function call as proof that the recipient, network or amount matched your policy; those comparisons should be explicit and testable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does the resource server verify the signed payload?

The server must parse PAYMENT-SIGNATURE with a protocol library and compare it with the exact PaymentRequirements it sent in the 402 response. It then performs the selected scheme’s cryptographic, network and authorization checks, either locally or through a facilitator.

  1. Recover the original offer. Use the requirements associated with this request, not a newly fetched offer or an arbitrary decoded object supplied by the client.
  2. Parse the signature payload. Reject malformed encoding, unsupported versions and fields that do not conform to the selected scheme.
  3. Match requirements exactly. Check the scheme, network, asset, recipient, amount semantics, resource context and validity parameters against the original offer.
  4. Run scheme verification. Validate signatures or authorizations, time bounds and replay protections required by that binding.
  5. Only then execute protected work. In the default authorization flow, verification precedes resource execution. Do not start an expensive or irreversible operation while verification is pending.
  6. Settle in the permitted order. Some schemes settle after fulfillment; others require settlement before fulfillment. Follow the selected scheme rather than assuming one order applies to every network.

Verification and settlement are different events. A verification result says the payload satisfies the scheme’s conditions at that point; settlement is the subsequent payment operation when the scheme requires one. Your response handling should expose which event actually succeeded.

Should I verify locally or use a facilitator?

Neither approach is universally superior. Local verification gives you direct control and avoids a dependency on an external verification service, while a facilitator can reduce infrastructure and chain-integration work. In both cases, you remain responsible for matching the payload to the offered requirements and failing safely.

Approach Advantages Operational costs and risks
Local verification Control over keys, node access, policy and failure handling; no facilitator round trip for verification. You must maintain scheme and network implementations, access reliable network data and keep replay protection correct.
Facilitator verification or settlement Delegates supported-chain operations and can simplify deployment. Adds a service dependency, authentication requirements, response validation and timeout handling.

What must be checked before trusting a facilitator?

Query the facilitator’s /supported endpoint during startup or deployment and confirm support for the exact x402 version, scheme and network you intend to advertise. Do not publish a payment option merely because a facilitator supports a similarly named chain or an older protocol version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Authenticate facilitator traffic according to the provider’s production documentation. Validate the response schema and its relationship to the request, enforce strict connection and response deadlines, and fail closed when the call times out, returns malformed data or encounters a network error. Solana’s facilitator documentation states the operational rule plainly: “A network error or malformed response is not proof of payment.”

When should verification, fulfillment and settlement occur?

The correct order is defined by the payment scheme. The common authorization pattern is verify first, execute the protected resource, then settle. A scheme that requires pre-settlement must complete that step before fulfillment, even if another x402 binding uses post-fulfillment settlement.

Flow stage Default authorization pattern Why the order is important
1. Offer Server returns 402 requirements. Client needs the exact terms before signing.
2. Authorization Client signs; server verifies before work. Prevents unauthorised or replayed payloads from reaching protected code.
3. Fulfillment Server performs the paid operation after required verification. Avoids spending compute or releasing data on an unverified claim.
4. Settlement Often after fulfillment, but scheme-dependent. Some bindings require settlement before fulfillment, so consult that binding’s rules.

If a facilitator performs both verification and settlement, model those as separate responses and states in your application. A successful verification response should not be logged as settled unless the settlement operation also completed.

How do scheme and network choices change the checks?

The same high-level x402 flow can carry different payment semantics. For example, documentation updated by Cloudflare on October 22, 2026 describes exact payments across several networks and upto payments on EVM. Those are documentation examples, not a universal support guarantee; the option is valid only when your selected scheme, network, library and facilitator all support it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision area Questions to answer
Amount model Is the amount exact, a ceiling, or another scheme-defined value? Which units and decimals apply?
Authorization data Which fields are signed, what time window is valid, and how is the resource identified?
Replay prevention What nonce, transaction, sequence or expiry rule prevents reuse, and where is it checked?
Recipient interpretation Is the payee an address, account, contract or another network-specific identifier?
Settlement timing Must settlement happen before fulfillment, after it, or through a separate confirmation?

Document these answers as part of your integration’s policy. Do not infer them from a field name shared by two schemes.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What is different about x402 v2 versus v1?

Use v2 conventions for a new integration. The Solana v2 guide identifies v1’s X-PAYMENT header and legacy network identifiers as old fields and advises against using them for new work.

Integration concern New v2 implementation Legacy v1 material
Payment offer PAYMENT-REQUIRED Legacy naming may appear in older examples.
Signed retry PAYMENT-SIGNATURE X-PAYMENT is a v1 convention.
Server result PAYMENT-RESPONSE Do not assume a v1 response maps directly.
Network identifiers Use the identifiers required by the v2 scheme and network binding. Legacy identifiers can produce incompatible matches.

If you must interoperate with an existing v1 service, isolate that compatibility code and test it separately. Do not mix v1 header handling with v2 requirement matching in one unqualified parser.

How should an agent handle failures and suspicious offers?

Payment failures should stop the paid operation, not trigger an automatic retry with a modified offer. Treat uncertainty as a denial until a fresh, valid response is obtained.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Malformed 402 header: return an integration error and avoid signing.
  • No policy match: tell the caller that the endpoint’s terms are outside the agent’s configured scheme, network, asset, recipient or budget.
  • Expired or not-yet-valid requirement: request a fresh offer only through a deliberate retry policy; never extend the validity window locally.
  • Signature or requirement mismatch: reject the request and record the mismatch category without attempting a different recipient or amount.
  • Facilitator timeout, network error or malformed response: fail closed. Do not interpret an unavailable verifier as approval.
  • Settlement failure after fulfillment: expose the state accurately and invoke a scheme-appropriate recovery process; do not report payment as complete solely because verification succeeded.

What should be in a production verification checklist?

Use this checklist in code review and deployment tests:

  • Parse PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE with a maintained protocol library.
  • Keep the original requirements associated with the request and compare the signed payload against them exactly.
  • Allowlist schemes, networks, assets and recipients instead of accepting any value advertised by a server.
  • Apply a per-request and aggregate spending limit before invoking the signer.
  • Validate amount semantics, decimals, authorization times and replay protections for the selected binding.
  • Use v2 headers and identifiers for new integrations.
  • Check facilitator /supported output for the exact version, scheme and network before advertising an option.
  • Authenticate facilitator calls, validate response contents and enforce strict timeouts.
  • Fail closed on malformed data, mismatches and network errors.
  • Enforce the scheme’s verification, fulfillment and settlement order.
  • Log the selected requirement, policy decision, verification result and settlement state without exposing private signing material.

What remains deployment-specific?

The correct facilitator, network and scheme depend on your agent’s supported assets, risk tolerance, infrastructure and production environment. Before launch, verify the provider’s live /supported output and production documentation for the exact combination you plan to use. A provider’s example list or a decoded payload cannot substitute for that compatibility check.

Frequently Asked Questions

Can an agent use the same signed payment for a second API call?

It should not assume reuse is safe. The payload is tied to the requirements, resource context and replay rules of its original request; a second call needs a fresh offer and a binding-specific determination that reuse is permitted.

What information should be recorded when a payment decision is denied?

Record a non-sensitive request identifier, the offered version, scheme and network, the policy rule that failed, and whether the signer was ever invoked. Never log private keys or raw authorization material merely to make a rejection auditable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does a successful signature check mean the merchant has been paid?

No. Signature or authorization verification and settlement are separate states. Report payment as settled only after the scheme’s settlement step returns a valid result.

How can I test an integration without accidentally spending funds?

Use a network and facilitator environment explicitly designated for testing, configure a zero or minimal spending ceiling, and test malformed, expired, mismatched and timeout responses as well as successful flows. Do not rely on a production wallet with a client-side flag as the only safeguard.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

AI agentsAPI paymentspayment verificationweb3 securityx402

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.