Skip to content

Configuration

Before creating invoices, you need a checkout configuration. Each user has one config that stores their extended public key and default settings.

Get configuration

GET /api/checkout/config

Returns your current checkout config, or 404 if not configured yet.

Response:

json
{
  "config": {
    "id": "uuid",
    "userId": "123",
    "xpub": "zpub6r...",
    "addressIndex": 15,
    "defaultTtlMinutes": 20,
    "unconfirmedWaitMinutes": 480,
    "callbackUrl": "https://yoursite.com/webhook",
    "redirectUrl": "https://yoursite.com/thank-you",
    "createdAt": "2025-01-10T08:00:00.000Z",
    "updatedAt": "2025-01-15T12:00:00.000Z"
  }
}

Create or update configuration

PUT /api/checkout/config

Creates a new config or updates the existing one (upsert). If you change the xpub, the address index resets to 0.

Request body:

FieldTypeRequiredDescription
xpubstringYesExtended public key (xpub, ypub, or zpub). 60–120 characters.
defaultTtlMinutesintegerNoDefault invoice expiration time. 1–1440 (24h). Default: 20.
unconfirmedWaitMinutesintegerNoGrace period after expiry for unconfirmed transactions. 1–2880 (48h). Default: 480 (8h).
callbackUrlstringNoWebhook URL for payment notifications. Must be a valid URL.
redirectUrlstringNoDefault redirect URL after payment confirms. Can be overridden per invoice.

Example:

bash
curl -X PUT \
  -H "X-Api-Key: fc_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "xpub": "zpub6rFR7y4Q2AijBEqTUqiByp...",
    "defaultTtlMinutes": 30,
    "callbackUrl": "https://yoursite.com/webhook"
  }' \
  https://fincobra.com/api/checkout/config

Error responses:

StatusError
400Validation failed (xpub too short, invalid URL, etc.)
409xpub already used by another configuration

Get wallet balance

GET /api/checkout/config/balance

Returns the current wallet balance derived from your xpub via Electrum.

Response:

json
{
  "confirmedBtc": 0.0042,
  "unconfirmedBtc": 0.001,
  "totalBtc": 0.0052,
  "totalUsd": 520.00,
  "btcRate": 100000
}
FieldTypeDescription
confirmedBtcnumberConfirmed balance in BTC
unconfirmedBtcnumberUnconfirmed (mempool) balance in BTC
totalBtcnumberTotal balance (confirmed + unconfirmed)
totalUsdnumberTotal balance converted to USD
btcRatenumberCurrent BTC/USD exchange rate used

Configuration fields reference

FieldDescription
idUnique config ID (UUID). Also used as the HMAC signing secret for webhooks.
userIdOwner user ID
xpubExtended public key for address derivation
addressIndexNext derivation index (auto-incremented)
defaultTtlMinutesDefault time-to-live for new invoices
unconfirmedWaitMinutesHow long to wait after expiry for late transactions
callbackUrlWebhook endpoint for payment events
redirectUrlDefault post-payment redirect URL