Crypto invoice expiry: how long should an invoice stay open?
Every easyway invoice has an expires_at. Until then the customer can open the checkout, pick a coin and pay the quoted amount; after it, the checkout closes. The time between creation and expires_at is the invoice's lifetime, and you choose it. Too short and a slow payer misses it; too long and a USD quote in a volatile coin stays valid while the price moves. This post shows what the lifetime controls and how to pick one.
What happens before and after expires_at
| When | What the gateway does |
|---|---|
| Invoice created | expires_at = now + lifetime. Nothing is quoted yet for a USD invoice. |
| Customer picks a coin | The crypto amount and the deposit address are fixed until expires_at. Switching coins is allowed until a payment is seen. |
| A payment is detected | The invoice moves to confirming. It no longer expires, even if the confirmations finish later. |
| expires_at passes, nothing sent | Within a minute the invoice becomes expired and invoice.expired is sent. Picking a coin now fails with 409 invoice_expired. |
| Up to 7 days after expires_at | The chosen coin's address is still watched. A payment there is credited, and the invoice turns paid or underpaid with the usual webhook. |
Two details follow from this. First, expiry only stops new payments from starting; a transfer that was already detected finishes normally. Second, the 7-day window exists only for a coin the customer actually chose. A USD invoice that expired before anyone picked a coin has no address, so nothing can arrive late: create a new invoice instead. The underpaid and late payments guide shows how to handle a payment that lands after you gave up on the order.
Where the lifetime is set
Your account has a default, 60 minutes unless you change it under Settings → Business in the dashboard (presets from 15 minutes to 24 hours). Any invoice can override it: pass lifetime, a whole number of minutes from 5 to 1440, on POST /v1/invoices, or choose it in the dashboard's new-invoice form. A value outside that range, or not a whole number, is refused with 400 validation_error before anything is created.
curl -X POST https://api.easyway.cash/v1/invoices \
-H "Authorization: Bearer $EASYWAY_API_KEY" \
-H "Idempotency-Key: b2b-invoice-0193" \
-H "Content-Type: application/json" \
-d '{"amount":"4800.00","currency":"USD","order_id":"B2B-0193",
"allowed_assets":["USDT_TRC20","USDC_ERC20"],"lifetime":1440}'This B2B invoice gives the payer the full 24 hours and accepts only two stablecoins. Stablecoins are priced at exactly $1, so a long lifetime costs you nothing in exchange-rate risk.
Which lifetime for which sale
| Situation | Lifetime | Why |
|---|---|---|
| Checkout on your site or app | 15–30 min | The buyer pays now; a short window also limits a volatile-coin quote |
| Limited stock, tickets, time slots | 15 min | Release the reservation on invoice.expired quickly |
| Default for mixed traffic | 60 min | Room for an exchange withdrawal, which can take a while |
| Invoice sent by e-mail or chat | 12–24 h | The customer may open it hours later |
| Company payer or multisig wallet | 24 h (1440) | Signers need time to approve (see paying from a multisig) |
If you need longer than 24 hours, send a fresh invoice when the old one expires rather than stretching one quote: each new invoice re-quotes at the current rate.
Choosing it in code
// lifetime.mjs - pick the invoice lifetime from the kind of sale (Node 18+, no packages)
const LIFETIME = {
checkout: 30, // the buyer is on your site right now
email: 720, // an invoice sent by e-mail or chat: 12 hours
b2b: 1440, // a company or a multisig needs approvals: the 24-hour maximum
};
export async function createInvoice(order) {
const res = await fetch("https://api.easyway.cash/v1/invoices", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EASYWAY_API_KEY}`,
"Idempotency-Key": `shop-order-${order.id}`, // 8-128 chars
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: (order.cents / 100).toFixed(2),
currency: "USD",
order_id: String(order.id),
lifetime: LIFETIME[order.kind] ?? 60, // 5-1440 minutes; 60 = the account default
}),
signal: AbortSignal.timeout(15_000),
});
const body = await res.json();
if (!res.ok) throw new Error(`easyway ${res.status}: ${body.message ?? body.error}`);
return body; // body.expires_at is when the quote and the checkout close
}Store expires_at from the response next to the order. Show it to the customer, run your own reminders from it, and treat invoice.expired as "stop waiting", not "never paid": a late invoice.paid can still follow within 7 days. All fields are in the API reference, and you can try each case with an sk_test_ key using the sandbox guide.