Create Coinbase onramp URL
curl --request POST \
--url https://mainnet.anyspend.com/onramp/coinbase/onramp-url \
--header 'Content-Type: application/json' \
--data '
{
"presetFiatAmount": "100",
"fiatCurrency": "USD",
"defaultAsset": "USDC",
"defaultPaymentMethod": "CARD",
"destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
"blockchains": [
"base"
],
"country": "US",
"orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
"redirectUrl": "https://www.anyspend.com/orders",
"useSessionToken": false
}
'import requests
url = "https://mainnet.anyspend.com/onramp/coinbase/onramp-url"
payload = {
"presetFiatAmount": "100",
"fiatCurrency": "USD",
"defaultAsset": "USDC",
"defaultPaymentMethod": "CARD",
"destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
"blockchains": ["base"],
"country": "US",
"orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
"redirectUrl": "https://www.anyspend.com/orders",
"useSessionToken": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
presetFiatAmount: '100',
fiatCurrency: 'USD',
defaultAsset: 'USDC',
defaultPaymentMethod: 'CARD',
destinationAddress: '0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1',
blockchains: ['base'],
country: 'US',
orderId: '5392f7a7-d472-4d6b-9848-bd07117fb82d',
redirectUrl: 'https://www.anyspend.com/orders',
useSessionToken: false
})
};
fetch('https://mainnet.anyspend.com/onramp/coinbase/onramp-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.anyspend.com/onramp/coinbase/onramp-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'presetFiatAmount' => '100',
'fiatCurrency' => 'USD',
'defaultAsset' => 'USDC',
'defaultPaymentMethod' => 'CARD',
'destinationAddress' => '0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1',
'blockchains' => [
'base'
],
'country' => 'US',
'orderId' => '5392f7a7-d472-4d6b-9848-bd07117fb82d',
'redirectUrl' => 'https://www.anyspend.com/orders',
'useSessionToken' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.anyspend.com/onramp/coinbase/onramp-url"
payload := strings.NewReader("{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.anyspend.com/onramp/coinbase/onramp-url")
.header("Content-Type", "application/json")
.body("{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.anyspend.com/onramp/coinbase/onramp-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Onramp URL created successfully",
"data": {
"url": "https://pay.coinbase.com/buy/select-asset?... ",
"sessionToken": "token_123"
},
"statusCode": 200
}{
"success": false,
"message": "Bad request",
"statusCode": 400
}Onramp
Create Coinbase onramp URL
Creates a Coinbase Onramp buy URL and optionally returns a session token for reuse.
POST
/
onramp
/
coinbase
/
onramp-url
Create Coinbase onramp URL
curl --request POST \
--url https://mainnet.anyspend.com/onramp/coinbase/onramp-url \
--header 'Content-Type: application/json' \
--data '
{
"presetFiatAmount": "100",
"fiatCurrency": "USD",
"defaultAsset": "USDC",
"defaultPaymentMethod": "CARD",
"destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
"blockchains": [
"base"
],
"country": "US",
"orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
"redirectUrl": "https://www.anyspend.com/orders",
"useSessionToken": false
}
'import requests
url = "https://mainnet.anyspend.com/onramp/coinbase/onramp-url"
payload = {
"presetFiatAmount": "100",
"fiatCurrency": "USD",
"defaultAsset": "USDC",
"defaultPaymentMethod": "CARD",
"destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
"blockchains": ["base"],
"country": "US",
"orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
"redirectUrl": "https://www.anyspend.com/orders",
"useSessionToken": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
presetFiatAmount: '100',
fiatCurrency: 'USD',
defaultAsset: 'USDC',
defaultPaymentMethod: 'CARD',
destinationAddress: '0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1',
blockchains: ['base'],
country: 'US',
orderId: '5392f7a7-d472-4d6b-9848-bd07117fb82d',
redirectUrl: 'https://www.anyspend.com/orders',
useSessionToken: false
})
};
fetch('https://mainnet.anyspend.com/onramp/coinbase/onramp-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.anyspend.com/onramp/coinbase/onramp-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'presetFiatAmount' => '100',
'fiatCurrency' => 'USD',
'defaultAsset' => 'USDC',
'defaultPaymentMethod' => 'CARD',
'destinationAddress' => '0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1',
'blockchains' => [
'base'
],
'country' => 'US',
'orderId' => '5392f7a7-d472-4d6b-9848-bd07117fb82d',
'redirectUrl' => 'https://www.anyspend.com/orders',
'useSessionToken' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.anyspend.com/onramp/coinbase/onramp-url"
payload := strings.NewReader("{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.anyspend.com/onramp/coinbase/onramp-url")
.header("Content-Type", "application/json")
.body("{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.anyspend.com/onramp/coinbase/onramp-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"presetFiatAmount\": \"100\",\n \"fiatCurrency\": \"USD\",\n \"defaultAsset\": \"USDC\",\n \"defaultPaymentMethod\": \"CARD\",\n \"destinationAddress\": \"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1\",\n \"blockchains\": [\n \"base\"\n ],\n \"country\": \"US\",\n \"orderId\": \"5392f7a7-d472-4d6b-9848-bd07117fb82d\",\n \"redirectUrl\": \"https://www.anyspend.com/orders\",\n \"useSessionToken\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Onramp URL created successfully",
"data": {
"url": "https://pay.coinbase.com/buy/select-asset?... ",
"sessionToken": "token_123"
},
"statusCode": 200
}{
"success": false,
"message": "Bad request",
"statusCode": 400
}Body
application/json
Request body to create a Coinbase onramp URL
Preset fiat amount for purchase
Example:
"100"
Fiat currency code
Example:
"USD"
Default asset to purchase
Example:
"USDC"
Default payment method identifier
Example:
"CARD"
Destination wallet address
Example:
"0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1"
Supported blockchains for the session
Example:
["base"]
ISO country code of the end user
Example:
"US"
Associated AnySpend order ID
Example:
"5392f7a7-d472-4d6b-9848-bd07117fb82d"
Redirect URL after completing the purchase
Example:
"https://www.anyspend.com/orders"
Whether to create and embed a session token automatically
HypeDuel