x402

Fetch with payment

Fetch any given url. If the url returns HTTP 402 payment required, this endpoint handles payment with the authenticated wallet.

Optionally pass a 'from' query parameter with the authenticated wallet address (server or user wallet) to complete the payment.

If no 'from' parameter is passed, the default project wallet address will be used.

  • Works with any x402 compatible endpoint.
  • Automatically selects a compatible payment method.
  • Signs the appropriate payment payload.
  • Sends the payment to the url.
  • Returns the final result from the url called.

Request body and headers are always passed through to the url called.

Authentication: This endpoint requires wallet authentication for the payment. For frontend usage, include x-client-id and Authorization: Bearer <jwt> headers. For backend usage, include x-secret-key header.

post/v1/payments/x402/fetch

Request

  • Base URL
    https://api.thirdweb.com
  • Auth
    HTTP bearer and API key in header x-client-id

Query parameters

fromstring

The authenticated wallet address (server or user wallet)

Example:0x1234567890123456789012345678901234567890

A valid blockchain address. Accepts Ethereum (0x...) and Solana (base58) addresses, as well as ENS names for Ethereum.

urlstring uri required

The url to fetch

Example:https://api.example.com/paid-api
'POST'
OR
'PUT'
OR
'DELETE'
OR
'PATCH'
OR
'GET'
maxValuestring

The maximum value to fetch in base units of the asset (e.g. 1000000 for 1 USDC)

Example:1000000
assetstring

The asset (token address) to use for the payment. If not provided, the asset from the url's payment requirements will be used.

Example:0x1234567890123456789012345678901234567890

A valid blockchain address. Accepts Ethereum (0x...) and Solana (base58) addresses, as well as ENS names for Ethereum.

string
OR
integer
Example:eip155:1

Request body */*

object required

Optional body to send to the target url if method is POST, PUT, PATCH, or DELETE. Should be a valid javascript object.

Example request

{
  "key": "value"
}

Response

Returns the final result from the API call

Changes

No recorded changes to this operation across all 5 revisions of this API.