- In your backend, generate a JWT, following the CDP authentication steps
-
(Preferred) In your backend, generate a One Click Buy URL using the Create Onramp Session API.
- Pass this URL to your frontend to load the Onramp experience for the client.
-
If you would prefer using our frontend util:
- Generate a one time use session token in your backend using the JWT from Step 1 and the generateSessionToken endpoint
- Pass this session token to your frontend
- Use the getOnrampBuyUrl util with the getOnrampURLWithSessionTokenParams to generate a URL with default parameters
Frontend developers love using our
<FundCard />
and <FundButton />
, customizable React components to fund a wallet without leaving your App!- Manually generate a URL with required parameters
- Most commonly used on the
Backend
- Most commonly used on the
Full API endpoint listFor a complete list of all API endpoints supported by Onramp/Offramp, visit our API Reference section.
Backend URL creation
For Apps with a backend, use our APIs to create a One-Click-Buy URL - a prefilled URL which takes users straight to the preview screen (existing Coinbase users) or Apple Pay + debit card (Guest checkout). This enables you to pass a user’s wallet addresses via API and avoid using query params for sensitive fieldsExample URL
The URL should look like this:Onramp URL parameters:
Parameter | Required | Type | Description |
---|---|---|---|
sessionToken | Yes | String | Token generated by the Onramp Session Token API. |
defaultNetwork | No | String | Default network that should be selected when multiple networks are present |
defaultAsset | No | String | Default asset that should be selected when multiple assets are present |
presetCryptoAmount | No | Number | Preset crypto amount value |
presetFiatAmount | No | Number | Preset fiat amount value (for USD, CAD, GBP, EUR only). Ignored if presetCryptoAmount is also set. |
defaultExperience | No | ’send’, ‘buy’ | Default visual experience: either (1) Transfer funds from Coinbase (‘send’) or (2) Buy assets (‘buy’) |
defaultPaymentMethod | No | String | Default payment method used to purchase the asset |
fiatCurrency | No | String | e.g: USD, CAD, GBP, etc. |
handlingRequestedUrls | No | Boolean | Prevents the widget from opening URLs directly & relies on onRequestedUrl entirely for opening links |
partnerUserId | No | String | Unique ID representing the end-user. Must be less than 50 chars. Use with the Transaction Status API to retrieve transactions made during the session. |
redirectUrl | No | String | URL to redirect the user to when they successfully complete a transaction. |
Getting a Session Token
Developers can create and use a session token to securely authenticate users and manage sessions.Authentication
To authenticate your requests to the Session Token API, you’ll need to:- Create a CDP Secret API Key
- Follow the instructions for CDP API key authentication to make signed requests
sessionToken
query string parameter when generating the Coinbase Onramp or Offramp URL.
See an example of how to generate a JWT and session token.
The token expires after a short period of time and can only be used once. A new token must be obtained for every new session.
Full API endpoint list
For a complete list of all API endpoints supported by Onramp/Offramp, visit our API Reference section.
Method
URL
Request Parameters
The Session Token API is an RPC endpoint that accepts parameters as JSON in the request body.Name | Type | Req | Description |
---|---|---|---|
addresses | Address[] | Y | List of addresses that the purchased crypto should be sent to. Each entry in this array is an object containing an address and a list of blockchains the address supports. |
assets | String[] | N | List of assets that will be available for the user to buy/send. Assets can either be symbols e.g. “ETH” or “BTC”, or UUIDs retrieved from the Buy Options API. This optional parameter acts as a filter on the addresses parameter. If it is included then only the assets in this list that are available on one of the supported blockchains in the Addresses list will be available to the user. See the See the Buy Options API for the full list of assets. |
Address Parameters
An Address object accepts the following parameters:Parameter | Req’d | Type | Description |
---|---|---|---|
address | Yes | String | Destination address where the purchased tokens will be sent. |
blockchains | Yes | String[] | List of blockchains enabled for the associated address. All tokens available per blockchain are displayed to the user. Available blockchains include: “ethereum”, “bitcoin”, “base”, “avacchain”, “optimism”, “solana”, “polygon”, “arbitrum”, “stellar” and many more. See the Buy Options API for the full list. |