Payments
Create a payment
POST
/pay/createGenerate a Bitcoin or Lightning payment request. Returns a hosted payment URL, QR data, and the live payment object.
- Returns 201 on success with { success: true, payment:
{…}}. - Errors return 400 with
{ success: false, error, message }.
Authentication
Requires an API key in the X-API-Key header.
Body parameters
typebtclightningoptionaldefaults to btc
amountnumberrequiredpositive number, in currency
currencyCHFUSDEURSATSoptionaldefaults to CHF
descriptionstringoptionalshown on the hosted page
callback_urlstringoptionalwebhooks POST here on status changes
redirect_urlstringoptionalwhere customers go after paying
expiration_minutesnumberoptionaldefault 15 (BTC) / 60 (Lightning)
required_confirmationsnumberoptionalBTC only, default 1
metadataobjectoptionalechoed back on webhooks unchanged
POST
/pay/createcurl --request POST "https://api.trevi.cash/pay/create" \
--header "Content-Type: application/json" \
--header "X-API-Key: $BTPAY_API_KEY" \
--data '{
"type": "btc",
"amount": 49.99,
"currency": "CHF",
"description": "Order #12345",
"callback_url": "https://yoursite.com/webhooks/btpay",
"redirect_url": "https://yoursite.com/orders/thank-you",
"metadata": { "order_id": "12345" }
}'200Sample response
{
"success": true,
"payment": {
"request_id": "pay_abc123def456abc123def456abc123de",
"payment_type": "btc",
"status": "pending",
"amount_sats": 150000,
"amount_btc": "0.00150000",
"amount_fiat": 49.99,
"currency": "CHF",
"description": "Order #12345",
"expires_at": "2026-05-18T12:15:00.000Z",
"time_remaining_seconds": 900,
"qr_data": "bitcoin:bc1qxyz...?amount=0.00150000",
"btc_address": "bc1qxyz...",
"confirmations": 0,
"required_confirmations": 1,
"payment_url": "https://api.trevi.cash/pay/page/pay_abc123def456abc123def456abc123de"
}
}Was this page helpful?
