Forebit Payments — Guide for AI Agents
This page contains everything an AI agent (Claude, Cursor, Codex, or any LLM-based coding tool) needs to integrate Forebit Payments into a website. Copy-paste this entire page into your AI agent’s context. You are integrating Forebit Payments, a cryptocurrency payment processing API. Forebit provides a hosted checkout page — you create a payment via the API, redirect the customer to the checkout URL, and listen for webhook events to confirm payment.Architecture Overview
The integration flow is:- Your server creates a payment via the REST API
- The API returns a
urlto a Forebit-hosted checkout page - You redirect the customer to that URL
- The customer selects a cryptocurrency and pays
- Forebit sends a webhook to your server when the payment status changes
- Your server verifies the webhook signature and updates the order
- Optionally, the customer is redirected back to your site via
redirectUrl
Credentials
Obtain these from the Forebit dashboard:| Credential | Where to find it | Purpose |
|---|---|---|
| Business ID | Payments → Settings → Developer | Identifies your business in API URLs |
| API Key | Payments → Settings → Developer | Bearer token for API authentication |
| Webhook Secret | Developer → Webhooks | whsec_... prefix, used with Svix to verify webhook signatures |
Environment variables
API Basics
Base URL
Authentication
Every request requires a Bearer token:Response format
Success:HTTP status codes
| Status | Meaning |
|---|---|
200 | Success |
400 | Invalid parameters or validation error |
401 | Invalid or missing API key |
403 | Insufficient permissions for this business |
404 | Payment or business not found |
Endpoints
All endpoints are scoped to a business:| Method | Endpoint | Description |
|---|---|---|
POST | /v1/businesses/{businessId}/payments | Create a new payment |
GET | /v1/businesses/{businessId}/payments/{paymentId} | Get a single payment |
GET | /v1/businesses/{businessId}/payments | List payments (paginated) |
PUT | /v1/businesses/{businessId}/payments/{paymentId}/note | Update internal note |
Creating a Payment
POST /v1/businesses/{businessId}/payments
Request body
| Field | Type | Required | Description |
|---|---|---|---|
currency | string | Yes | ISO 4217 currency code (e.g. USD, EUR) |
amount | number | Yes | Payment amount (minimum 0.5) |
name | string | No | Display name shown to customer on checkout page |
description | string | No | Internal description, not visible to customers |
customerEmail | string (email) | No | Customer email for receipts and status updates |
customerIp | string | No | Customer IP address. Auto-detected from checkout page visit if omitted |
customerUserAgent | string | No | Customer user-agent. Auto-detected from checkout page visit if omitted |
redirectUrl | string (URI) | No | URL to redirect the customer after payment completes |
notifyUrl | string (URI) | No | Webhook URL for this specific payment (overrides default) |
metadata | object | No | Arbitrary key-value string pairs stored with the payment. Use this to attach your internal order ID |
paymentMethods | object | No | Restrict which payment methods are available to the customer |
feeTransfers | array | No | Fee transfer configuration |
Example request
Example response
id— UUID of the payment, use this to query the payment laterurl— hosted checkout page URL, redirect the customer here
Restricting payment methods
Pass thepaymentMethods object to control which cryptocurrencies are available. If omitted, all methods configured for your business are enabled.
| Type | Description |
|---|---|
FOREBIT_CRYPTO | Native coins and tokens via Forebit wallets |
CONTRACT_CRYPTO | ERC-20 tokens via smart contract |
CONTRACT_TRX | TRC-20 tokens via smart contract |
NONE | No crypto payment method |
- FOREBIT_CRYPTO:
BITCOIN,ETHEREUM,LITECOIN,BITCOIN_CASH,ETH_USD_COIN,ETH_TETHER,MONERO,BNB,ETH_BUSD,ETH_MATIC,ETH_SHIBA_INU,ETH_APE_COIN,ETH_CRONOS,ETH_DAI,ETH_UNISWAP,TRON,TRX_TETHER,TRX_USD_C,SOLANA,SOL_TETHER,SOL_USD_COIN,TON - CONTRACT_CRYPTO:
CONTRACT_ERC20_ETH,CONTRACT_ERC20_USDT,CONTRACT_ERC20_USDC - CONTRACT_TRX:
CONTRACT_TRC20_TRX,CONTRACT_TRC20_USDT,CONTRACT_TRC20_USDC
Retrieving a Payment
GET /v1/businesses/{businessId}/payments/{paymentId}
Response fields
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Payment identifier |
name | string | Display name |
description | string | Internal description |
endAmount | number | Final payment amount |
prePaymentAmount | number | Amount before payment processing |
currency | string | ISO 4217 currency code |
status | PaymentStatus | Current payment status |
createdAt | date-time | When the payment was created |
expiresAt | date-time | When the payment expires |
timeline | array | Status change history |
customer | object | Customer details including email and IP info |
metadata | object | Custom key-value pairs you attached |
selectedPaymentMethod | PaymentMethod | Method chosen by the customer |
forebitCryptoCharge | object | Forebit crypto charge details (if applicable) |
contractCharge | object | Contract charge details (if applicable) |
forebitFee | number | Fee amount |
note | string | Internal note |
netAmountUsd | number | Net amount in USD |
Listing Payments
GET /v1/businesses/{businessId}/payments
Query parameters
| Parameter | Type | Description |
|---|---|---|
PageNumber | integer | Page number |
PageSize | integer | Results per page |
fromTime | date-time | Start of date range |
toTime | date-time | End of date range |
statuses | array | Filter by status (repeat parameter for multiple) |
cryptoCoins | array | Filter by cryptocurrency |
fromAmount | number | Minimum amount |
toAmount | number | Maximum amount |
searchString | string | Free-text search across description, name, note, or customer email |
Payment Statuses
| Status | Description |
|---|---|
AWAITING_PAYMENT | Payment created, waiting for customer to pay |
PENDING | Payment detected on-chain, awaiting confirmation |
PROCESSING | Payment is being processed |
UNDERPAID | Customer sent less than the required amount |
COMPLETED | Payment confirmed and completed — fulfill the order |
FAILED | Payment failed |
CANCELLED | Payment was cancelled |
EXPIRED | Payment expired before completion |
Webhooks
Forebit uses Svix for webhook delivery. Svix provides automatic retries, signature validation, and delivery logs.Webhook events
| Event | Description |
|---|---|
PAYMENT_CREATED | Payment was created |
PAYMENT_METHOD_SELECTED | Customer selected a payment method |
PAYMENT_PENDING | Payment detected, awaiting confirmation |
PAYMENT_UNDERPAID | Customer sent less than required |
PAYMENT_COMPLETED | Payment confirmed — this is the event to fulfill orders on |
PAYMENT_EXPIRED | Payment expired |
PAYMENT_CANCELLED | Payment was cancelled |
Webhook payload structure
EventType, ForPaymentEvents, EndAmount), while the REST API responses use camelCase (e.g. endAmount, currency).
Webhook payload TypeScript types
Verifying webhook signatures
Use the Svix library to verify webhook signatures. This is critical for security — never process a webhook without verifying the signature first. Required headers from the webhook request:svix-id, svix-timestamp, svix-signature.
Node.js:
npm install svix (Node.js) or pip install svix (Python).
Full Integration Examples
Node.js (Express)
Python (Flask)
Next.js (App Router)
Best Practices
Security
- Always verify webhook signatures using Svix before processing any webhook event. Never trust the payload without verification.
- Keep your API key server-side only. Never expose it in client-side code, browser JavaScript, or mobile apps.
- Use HTTPS for all webhook endpoints. Forebit will not deliver webhooks to HTTP URLs in production.
- Store the webhook secret securely in environment variables, never hardcoded.
Payment creation
- Always store the payment
idfrom the create response in your database, linked to your internal order. You need it to reconcile webhooks and query payment status. - Use
metadatato attach your internal order ID, user ID, or any reference data. This data is returned in webhooks and GET requests, making reconciliation easy. - Set
redirectUrlso the customer returns to your site after payment. Without it, they stay on the Forebit checkout page. - Set
notifyUrlper-payment if you have multiple webhook endpoints, or rely on the default configured in the dashboard. - Set
customerEmailso the customer receives email receipts and status updates. - Minimum amount is
0.5in your chosen currency.
Webhook handling
- Respond with
200quickly. Process the webhook asynchronously if your fulfillment logic is slow. Svix will retry on non-2xx responses. - Make your webhook handler idempotent. You may receive the same event more than once due to retries. Use the payment
Idto deduplicate. - Only fulfill orders on
PAYMENT_COMPLETED. Do not fulfill onPENDINGorPROCESSING— these are intermediate states. - Handle
PAYMENT_EXPIREDandPAYMENT_CANCELLEDto clean up pending orders in your system. - Use the raw request body for signature verification. Parsing the JSON first and re-serializing it will break the signature.
Error handling
- Check for non-200 responses from the API and handle them gracefully.
- API errors use RFC 7807 ProblemDetails format with
type,title,status, anddetailfields. - If a payment creation fails, show the user an error and let them retry. Do not create duplicate payments — check your database first.
Testing
- Use small amounts (minimum
0.5) for test payments. - Use the Svix CLI or dashboard to replay webhooks to your endpoint during development.
- Use a tool like ngrok to expose your local webhook endpoint during development.
Supported Cryptocurrencies (Full List)
| Coin | Identifier | Network |
|---|---|---|
| Bitcoin | BITCOIN | BTC |
| Ethereum | ETHEREUM | ETHEREUM |
| Litecoin | LITECOIN | LTC |
| Bitcoin Cash | BITCOIN_CASH | BTC |
| USDC (ERC-20) | ETH_USD_COIN | ETHEREUM |
| USDT (ERC-20) | ETH_TETHER | ETHEREUM |
| Monero | MONERO | — |
| BNB | BNB | ETHEREUM |
| DAI (ERC-20) | ETH_DAI | ETHEREUM |
| Uniswap (ERC-20) | ETH_UNISWAP | ETHEREUM |
| MATIC (ERC-20) | ETH_MATIC | ETHEREUM |
| SHIB (ERC-20) | ETH_SHIBA_INU | ETHEREUM |
| APE (ERC-20) | ETH_APE_COIN | ETHEREUM |
| CRO (ERC-20) | ETH_CRONOS | ETHEREUM |
| BUSD (ERC-20) | ETH_BUSD | ETHEREUM |
| Tron | TRON | TRON |
| USDT (TRC-20) | TRX_TETHER | TRON |
| USDC (TRC-20) | TRX_USD_C | TRON |
| Solana | SOLANA | SOLANA |
| USDT (Solana) | SOL_TETHER | SOLANA |
| USDC (Solana) | SOL_USD_COIN | SOLANA |
| TON | TON | — |
| Contract ETH | CONTRACT_ERC20_ETH | ETHEREUM |
| Contract USDT (ERC-20) | CONTRACT_ERC20_USDT | ETHEREUM |
| Contract USDC (ERC-20) | CONTRACT_ERC20_USDC | ETHEREUM |
| Contract TRX | CONTRACT_TRC20_TRX | TRON |
| Contract USDT (TRC-20) | CONTRACT_TRC20_USDT | TRON |
| Contract USDC (TRC-20) | CONTRACT_TRC20_USDC | TRON |
ETHEREUM, TRON, BTC, LTC, SOLANA