Back to Guides
10 min read
Testing & Sandbox
Test your integration in the CoverKit sandbox environment before going live.
Sandbox Environment
The sandbox environment allows you to test your integration without processing real transactions. All sandbox API calls behave identically to production, but with simulated data.
Sandbox
API: sandbox.coverkit.io
- Test API keys (sk_sandbox_*)
- Simulated payments
- Test webhook events
Production
API: api.coverkit.io
- Live API keys (sk_live_*)
- Real transactions
- Production webhooks
Test API Keys
Use sandbox API keys for all testing. These keys are available in your dashboard.
// Initialize with sandbox key
const coverkit = new CoverKit({
apiKey: 'sk_sandbox_your_test_key',
environment: 'sandbox', // Optional, auto-detected from key
});Test Data
Use these test values to simulate different scenarios:
Test Payment Tokens
tok_visa - Successful paymenttok_visa_declined - Declined cardtok_insufficient_funds - Insufficient fundsTest Item Values
itemValue: 10000 - Standard quoteitemValue: 100000 - High-value (triggers review)itemValue: 500000 - Exceeds limits (rejected)Test Claim Amounts
amount: 5000 - Auto-approvedamount: 50000 - Manual reviewamount: 999999 - Auto-denied (fraud check)Testing Webhooks
Use the CLI or dashboard to trigger test webhook events:
CLI
# Trigger a test webhook event
coverkit webhooks trigger policy.created
# Listen for webhooks locally
coverkit webhooks listen --forward-to localhost:3000/webhooks
# View recent webhook deliveries
coverkit webhooks logsIntegration Tests
Example integration test using Jest:
import { CoverKit } from '@coverkit/sdk';
const coverkit = new CoverKit({
apiKey: process.env.COVERKIT_SANDBOX_KEY,
});
describe('CoverKit Integration', () => {
test('creates a quote', async () => {
const quote = await coverkit.quotes.create({
product: 'shipping_protection',
coverage: {
itemValue: 10000,
shippingMethod: 'ground',
origin: { country: 'US', postalCode: '10001' },
destination: { country: 'US', postalCode: '90210' },
},
});
expect(quote.id).toMatch(/^quote_/);
expect(quote.premium).toBeGreaterThan(0);
});
test('binds a policy', async () => {
const quote = await coverkit.quotes.create({...});
const policy = await coverkit.policies.create({
quoteId: quote.id,
payment: { method: 'stripe', token: 'tok_visa' },
customer: { email: 'test@example.com' },
});
expect(policy.status).toBe('active');
});
});Going Live Checklist
All integration tests passing
Webhook endpoint responding with 200 OK
Signature verification implemented
Error handling for all API responses
Production API keys configured
Payment provider in production mode
Monitoring and alerting set up