Environments
Live vs test mode in ZapAPI — how to use the zap_test_ sandbox for development, CI and end-to-end tests.
ZapAPI has two environments — live and test — selected entirely by the API key you use. There is no separate "sandbox account" and no separate base URL.
| Live | Test | |
|---|---|---|
| Key prefix | zap_live_ | zap_test_ |
| Sats | Real mainnet sats | Test/regtest sats, no real value |
| Invoices | Settle on mainnet | Settle instantly in test |
| Webhooks | livemode: true | livemode: false |
| Rate limits | Higher | Lower |
Test mode is a real sandbox
Test mode is not a mock — it exercises the full ZapAPI pipeline:
- Invoice creation, expiry, cancellation and QR codes.
- Webhook signing, delivery, retries and replay.
- Payment links, refunds, customers, and the CRM.
- Rate limits and idempotency semantics.
The only difference is settlement: test invoices settle instantly against a
test Lightning network, and webhook events are flagged livemode: false.
Using test mode in the SDK
const zap = new ZapAPI(process.env.ZAPAPI_TEST_KEY); // zap_test_…
zap.isTestMode; // true
const invoice = await zap.invoices.create({
amount: 1000,
currency: 'sat',
description: 'Test payment',
});Webhooks in test mode
Webhook events delivered to a test-mode endpoint carry livemode: false.
Always branch on this flag in your handler so you never fulfill a real order
from a test event:
if (event.livemode === false) {
// test event — log it, but don't fulfill a real order
return res.json({ received: true });
}CI and end-to-end tests
Test mode is designed for CI:
- Provision a dedicated test project and test API key in your CI secrets.
- Run your integration tests against the live API with the test key — no mocks, no stubs, full confidence.
- Use the webhook test endpoint to deliver a
synthetic
testevent through the real pipeline.
Promoting to production
When you are ready to go live:
- Create a live API key (
zap_live_…) with the same scopes as your test key. - Deploy it to production via your secrets manager.
- Subscribe a live webhook endpoint (the dashboard distinguishes test and live endpoints).
- Process a small real payment to verify the end-to-end flow.
Your code does not change between test and live — only the key. The base URL, endpoints, request/response shapes and webhook semantics are identical.