Skip to content

Quick start: buy (F2C)

This guide walks you through creating your first fiat-to-coin checkout session. By the end, you will have a working checkout URL that redirects users to the BTC Direct payment page.

  • API credentials (username and password) from your account manager.
  • A backend environment where you can make HTTP requests (Node.js, PHP, Python, etc.).
  • A valid cryptocurrency wallet address for the selected coin.

Call the POST /api/v1/authenticate endpoint with your partner credentials to get a JWT token.

Terminal window
curl -X POST https://api-sandbox.btcdirect.eu/api/v1/authenticate \
-H "Content-Type: application/json" \
-d '{"username": "YOUR_USERNAME", "password": "YOUR_PASSWORD"}'

Response:

{
"token": "eyJ...",
"refreshToken": "abc123..."
}

The token is valid for 1 hour. Use POST /api/v1/refresh to get a new token before it expires.

Try it out

Authenticate with your partner credentials to get a JWT token.

Call the POST /api/v2/buy/checkout endpoint with your JWT token and the order details.

Terminal window
curl -X POST https://api-sandbox.btcdirect.eu/api/v2/buy/checkout \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"baseCurrency": "BTC",
"quoteCurrency": "EUR",
"paymentMethod": "creditCard",
"quoteCurrencyAmount": 50,
"walletAddress": "bc1...",
"returnUrl": "https://example.com/return"
}'

Response:

{
"checkoutUrl": "https://checkout.btcdirect.eu?...",
"signature": "abc123...",
"partner": "your-partner-slug",
"baseCurrency": "BTC",
"quoteCurrency": "EUR",
"paymentMethod": "creditCard",
"quoteCurrencyAmount": 50
}
Try it out

Create a checkout session. Replace the token and wallet address with your own values.

FieldDescription
baseCurrencyThe cryptocurrency code (e.g. BTC, ETH). See supported currencies.
quoteCurrencyThe fiat currency code. Currently only EUR.
paymentMethodCase-sensitive payment method code. See payment methods.
quoteCurrencyAmount or baseCurrencyAmountThe order amount. Use one or the other, not both.
walletAddressThe destination wallet address. Required. Must be a mainnet address in all environments, including sandbox. See wallet addresses.

For the full list of optional fields like expireTime and partnerOrderIdentifier, see the checkout endpoint specification. To receive order status updates, set up webhooks.

Redirect your user to the checkoutUrl from the response. The BTC Direct hosted checkout page handles the rest: payment processing, user verification, and order completion.

After the user completes (or cancels) payment, they are redirected back to your returnUrl.

The checkout URL is valid for the duration of the selected payment method’s expiration period. After that, the URL expires and a new checkout session must be created.

FieldDescription
checkoutUrlThe URL to redirect your user to.
signatureA server-generated HMAC signature that protects the checkout URL against tampering (e.g. modified wallet address or amount). Generated automatically by the server. If the signature does not match on our end, the checkout is rejected.
partnerYour partner identifier, derived from your authenticated session.
<?php
$authEndpoint = 'https://api-sandbox.btcdirect.eu/api/v1/authenticate';
$checkoutEndpoint = 'https://api-sandbox.btcdirect.eu/api/v2/buy/checkout';
// Step 1: Authenticate
$authData = json_encode(['username' => 'USERNAME', 'password' => 'PASSWORD']);
$authOptions = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => $authData,
],
];
$authResponse = json_decode(file_get_contents($authEndpoint, false, stream_context_create($authOptions)), true);
$token = $authResponse['token'];
// Step 2: Create checkout
$checkoutData = json_encode([
'baseCurrency' => 'BTC',
'quoteCurrency' => 'EUR',
'paymentMethod' => 'creditCard',
'quoteCurrencyAmount' => 50,
'walletAddress' => 'bc1...',
'returnUrl' => 'https://example.com/return',
]);
$checkoutOptions = [
'http' => [
'header' => "Content-type: application/json\r\nAuthorization: Bearer $token\r\n",
'method' => 'POST',
'content' => $checkoutData,
],
];
$checkoutResponse = json_decode(file_get_contents($checkoutEndpoint, false, stream_context_create($checkoutOptions)), true);
// Step 3: Redirect
header('Location: ' . $checkoutResponse['checkoutUrl']);
const AUTH_ENDPOINT = 'https://api-sandbox.btcdirect.eu/api/v1/authenticate';
const CHECKOUT_ENDPOINT = 'https://api-sandbox.btcdirect.eu/api/v2/buy/checkout';
// Step 1: Authenticate
const authResponse = await fetch(AUTH_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'USERNAME', password: 'PASSWORD' }),
});
const { token } = await authResponse.json();
// Step 2: Create checkout
const checkoutResponse = await fetch(CHECKOUT_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
baseCurrency: 'BTC',
quoteCurrency: 'EUR',
paymentMethod: 'creditCard',
quoteCurrencyAmount: 50,
walletAddress: 'bc1...',
returnUrl: 'https://example.com/return',
}),
});
const { checkoutUrl } = await checkoutResponse.json();
// Step 3: Redirect
res.redirect(checkoutUrl);