Skip to main content

Generate Widget URL

Generate a signed widget URL to embed the ramp experience in an iframe. Server-side signing ensures wallet addresses are tamper-proof. Works for both buy (on-ramp) and sell (off-ramp) modes.

POSThttps://api.zenpays.com/payment/api/v1/on-ramp/widget-url
Bearer · API key
POSThttps://api.zenpays.com/payment/api/v1/off-ramp/widget-url
Bearer · API key

The on-ramp endpoint defaults to buy mode; the off-ramp endpoint defaults to sell mode.

Request​

Headers​

HeaderDescription
Content-Type
REQUIRED
application/json
x-request-id
OPTIONAL
Custom request ID for tracing
Public Endpoint

This endpoint does not require authentication headers.

Body Parameters​

ParameterTypeDescription
mode
OPTIONAL
stringbuy, sell, or buy,sell (default depends on endpoint)
defaultFiat
OPTIONAL
stringDefault fiat currency (e.g. usd)
defaultCrypto
OPTIONAL
stringDefault crypto (e.g. btc_bitcoin)
defaultAmount
OPTIONAL
numberDefault amount
wallets
OPTIONAL
stringTokenID:address format (e.g. btc:bc1q...)
networkWallets
OPTIONAL
stringNetworkID:address format (e.g. ethereum:0x...)
walletAddressTags
OPTIONAL
stringTokenID:tag format for memo coins
successRedirectUrl
OPTIONAL
stringURL to redirect on success
failureRedirectUrl
OPTIONAL
stringURL to redirect on failure
onlyFiats
OPTIONAL
stringRestrict fiat options (comma-separated)
onlyCryptos
OPTIONAL
stringRestrict crypto options (comma-separated)
onlyCryptoNetworks
OPTIONAL
stringRestrict networks (comma-separated)
email
OPTIONAL
stringPre-fill user email
uuid
OPTIONAL
stringUnique user identifier
partnerContext
OPTIONAL
stringCustom tracking context

Response​

Success (200 OK)​

{
"success": true,
"data": {
"widgetUrl": "https://buy.onramper.com/?apiKey=...&mode=buy&defaultFiat=usd&defaultCrypto=BTC&wallets=btc:bc1q...&signature=abc123",
"embedMode": "iframe"
},
"message": "Widget URL generated"
}

Response Fields​

ParameterTypeDescription
widgetUrl
OPTIONAL
stringSigned URL to embed in an iframe
embedMode
OPTIONAL
stringAlways iframe

Error Responses​

CodeHTTPMessage
RAMP_WIDGET_URL_FAILED500Failed to generate buy widget URL
OFFRAMP_WIDGET_URL_FAILED500Failed to generate sell widget URL

Embedding the Widget​

<iframe
src="{widgetUrl}"
height="660px"
width="482px"
title="Buy Crypto"
allow="accelerometer; autoplay; camera; gyroscope; payment"
sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-top-navigation"
style="border: none; border-radius: 12px;"
/>

Examples​

# Buy widget
curl -X POST https://api.zenpays.com/payment/api/v1/on-ramp/widget-url \
-H "Content-Type: application/json" \
-d '{
"mode": "buy",
"defaultFiat": "usd",
"defaultCrypto": "BTC",
"wallets": "btc:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"successRedirectUrl": "https://yourapp.com/success"
}'

# Sell widget
curl -X POST https://api.zenpays.com/payment/api/v1/off-ramp/widget-url \
-H "Content-Type: application/json" \
-d '{
"defaultFiat": "usd",
"defaultCrypto": "BTC"
}'

Integration Flow (Widget Mode)​

1. POST /on-ramp/widget-url     → Get signed widget URL
2. Embed widgetUrl in iframe → User completes purchase inside widget
3. User redirected to success/failure URL when done

Next Steps​