Docs / Getting started / Quick start
Quick start
Accept your first USDT payment from any website or backend in four steps.
1. Get your keys
In the dashboard open Developers and create a key. Use sk_test_… while building — test payments never touch real wallets — and sk_live_… in production. Secret keys belong on your server only.
2. Create a payment
Send the amount and your own order reference. Add an Idempotency-Key so retries never create duplicates.
curl https://api.bit2pay.net/v1/payments \
-H "Authorization: Bearer sk_live_…" \
-H "Idempotency-Key: 7c1f0a52-order-1042" \
-H "Content-Type: application/json" \
-d '{
"amount": "25.00",
"currency": "USDT",
"order_id": "ORD-1042",
"customer_email": "buyer@example.com",
"success_url": "https://yourstore.com/thanks",
"metadata": {"user_id": "42"}
}'Response:
{
"id": "pay_9f2c1a7e3b4d5e6f7a8b9c0d",
"object": "payment",
"status": "pending",
"amount": "25.00",
"currency": "USDT",
"order_id": "ORD-1042",
"checkout_url": "https://pay.bit2pay.net/checkout/6d2f…",
"pay_amount": null,
"expires_at": "2026-11-19T10:30:00Z",
"livemode": true,
"metadata": {"user_id": "42"}
}3. Send the customer to checkout
Redirect them to checkout_url. They choose a USDT network and pay.
4. Fulfil on the webhook
When the payment is confirmed we POST a signed payment.paid event to your endpoint. Verify the signature, then fulfil the order. Return any 2xx within 10 seconds.
{
"id": "evt_4f1d0c2b9a8e7d6c5b4a3f2e",
"type": "payment.paid",
"created": 1763548200,
"data": {
"id": "pay_9f2c1a7e3b4d5e6f7a8b9c0d",
"order_id": "ORD-1042",
"status": "paid",
"amount": "25.00",
"amount_received": "25.00",
"method": "trc20",
"tx_hash": "a1b2c3…",
"confirmations": 21,
"fee": "0.1250",
"metadata": {"user_id": "42"}
}
}import crypto from "node:crypto";
export function verify(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false; // replay window
const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
// Express: use express.raw({ type: "application/json" }) so rawBody is the exact bytes.Test mode
Create a payment with an sk_test_ key, open it in Transactions and press Simulate payment. We send payment.confirming and payment.paid to your test endpoint. Go live by swapping to your sk_live_ key.