Onramp Sessions
Create and manage fiat-to-crypto onramp sessions. Sessions handle the entire payment flow from card payment to crypto delivery.
POST
/v1/onramp
Create a new onramp session. Returns a client secret for completing the payment via redirect or embedded widget.
Request Body
wallet_addressstringrequiredRecipient's wallet address where the purchased crypto will be delivered. Must be a valid address for the specified blockchain network (e.g., 0x... for Ethereum/Polygon/Base).
crypto_currencystringrequiredThe cryptocurrency to purchase. Supported: ETH, USDC, USDT, MATIC
fiat_amountnumberrequiredAmount in fiat currency (in smallest unit, e.g., cents). Must be between $10-$10,000.
fiat_currencystringrequiredFiat currency code. Supported: USD, EUR, GBP
networkstringBlockchain network. Defaults based on crypto_currency. Options: ethereum, polygon, base
customer_emailstringCustomer's email for receipt and KYC. Recommended for better conversion.
metadataobjectArbitrary key-value pairs to attach to the session. Useful for tracking orders.
Example Request
bash
-green-400">curl -X POST https://api.web3pay.io/v1/onramp \
-H "X-API-Key: wp3_live_sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f5fB",
"crypto_currency": "ETH",
"fiat_amount": 10000,
"fiat_currency": "USD",
"network": "ethereum",
"customer_email": "user@example.com",
"metadata": {
"order_id": "ord_12345",
"user_id": "usr_67890"
}
}'Response
json
{
"success": true,
"data": {
"session_id": "onramp_sess_abc123xyz",
"client_secret": "onramp_cs_secret_def456",
"redirect_url": "https://onramp.web3pay.io/s/abc123xyz",
"expires_at": "2024-01-15T12:30:00Z",
"estimated_crypto_amount": "0.0412",
"fees": {
"platform_fee": 1.50,
"network_fee": 2.50,
"processing_fee": 2.90,
"total_fee": 6.90
},
"exchange_rate": 2427.18,
"quote_expires_at": "2024-01-15T12:05:00Z"
}
}Response Fields
session_idstringUnique identifier for this session. Use for tracking and status queries.
client_secretstringSecret for completing payment. Pass to SDK or redirect URL.
redirect_urlstringURL to redirect user for hosted checkout experience.
expires_atstringISO 8601 timestamp when session expires (30 minutes from creation).
estimated_crypto_amountstringEstimated crypto amount the user will receive.
feesobjectBreakdown of all fees applied to this transaction.
exchange_ratenumberExchange rate used for the quote (fiat per 1 crypto unit).
quote_expires_atstringWhen the exchange rate quote expires (typically 5 minutes).
GET
/v1/onramp
Retrieve the current status and details of an onramp session.
Query Parameters
session_idstringrequiredThe session ID returned when creating the session.
Example Request
bash
-green-400">curl https://api.web3pay.io/v1/onramp?session_id=onramp_sess_abc123xyz \
-H "X-API-Key: wp3_live_sk_your_api_key"Response
json
{
"success": true,
"data": {
"id": "tx_789xyz",
"session_id": "onramp_sess_abc123xyz",
"status": "completed",
"wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f5fB",
"crypto_currency": "ETH",
"crypto_amount": "0.0408",
"fiat_currency": "USD",
"fiat_amount": 10000,
"network": "ethereum",
"tx_hash": "0x1234567890abcdef...",
"fees": {
"platform_fee": 1.50,
"network_fee": 2.50,
"processing_fee": 2.90
},
"metadata": {
"order_id": "ord_12345",
"user_id": "usr_67890"
},
"created_at": "2024-01-15T12:00:00Z",
"completed_at": "2024-01-15T12:08:00Z"
}
}Session Statuses
| Status | Description |
|---|---|
| pending | Session created, awaiting payment |
| processing | Payment received, crypto transfer in progress |
| completed | Crypto delivered to wallet |
| failed | Payment or delivery failed |
| expired | Session expired before payment |
POST
/v1/onramp/quote
Get a price quote without creating a session. Useful for showing estimated amounts before user commits.
bash
-green-400">curl -X POST https://api.web3pay.io/v1/onramp/quote \
-H "X-API-Key: wp3_live_sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"fiat_amount": 10000,
"fiat_currency": "USD",
"crypto_currency": "ETH",
"network": "ethereum"
}'json
{
"success": true,
"data": {
"fiat_amount": 10000,
"fiat_currency": "USD",
"crypto_currency": "ETH",
"crypto_amount": "0.0412",
"exchange_rate": 2427.18,
"fees": {
"platform_fee": 1.50,
"network_fee": 2.50,
"processing_fee": 2.90,
"total_fee": 6.90
},
"expires_at": "2024-01-15T12:05:00Z"
}
}SDK Examples
JavaScript
javascript
400">import { Web3Pay } 400">from 400">039;@web3pay/sdk039;;
400">const client = 400">new Web3Pay({
apiKey: 400">039;wp3_live_sk_your_api_key039;
});
500">// Create session
400">const session = 400">await client.createSession({
walletAddress: 400">039;0x742d35Cc6634C0532925a3b844Bc9e7595f5fB039;,
cryptoCurrency: 400">039;ETH039;,
fiatAmount: 10000,
fiatCurrency: 400">039;USD039;,
metadata: { orderId: 400">039;ord_12345039; }
});
500">// Get session status
400">const status = 400">await client.getSession(session.session_id);
console.log(status.status); 500">// 400">039;pending039; | 400">039;processing039; | 400">039;completed039; | 400">039;failed039;Python
python
400">import requests
headers = {
400">&500">#039;X-API-Key039;: 400">039;wp3_live_sk_your_api_key039;,
400">&500">#039;Content-Type039;: 400">039;application/json039;
}
500"># Create session
response = requests.post(
400">&500">#039;https://api.web3pay.io/v1/onramp039;,
headers=headers,
json={
400">&500">#039;wallet_address039;: 400">039;0x742d35Cc6634C0532925a3b844Bc9e7595f5fB039;,
400">&500">#039;crypto_currency039;: 400">039;ETH039;,
400">&500">#039;fiat_amount039;: 10000,
400">&500">#039;fiat_currency039;: 400">039;USD039;
}
)
session = response.json()
print(session[400">&500">#039;data039;][400">039;redirect_url039;])