Sandbox Testing Keys

Sandbox guide

Test your integration safely without touching real ANAF infrastructure. The sandbox is free, always available and mirrors the production API exactly.

What is the sandbox?

The sandbox is a completely isolated environment that mirrors the production API. Invoices created in sandbox mode are never submitted to ANAF. Instead, Billyou returns simulated SPV responses so you can test every scenario: confirmations, rejections, errors.

Each account gets 10,000 free test invoices per month in sandbox mode. Sandbox usage never counts toward your paid plan limits.

10,000 test invoices
Per account, reset monthly. Never charged.
Simulated SPV responses
Get confirmed, rejected or pending responses on demand.
Separate key namespace
bly_test_ keys are completely isolated from production.
Webhook testing
All webhook events fire in sandbox mode exactly as in production.
Full API parity
Every production endpoint works in sandbox. No missing features.
No ANAF traffic
Invoices never reach real ANAF servers. Safe for any load test.

Initialize in sandbox mode

Use a key with the bly_test_ prefix and set env: 'sandbox'. The SDK will automatically route all requests to the sandbox environment.

sandbox-init.ts
import Billyou from 'billyou-sdk';

// Use bly_test_ prefix for sandbox mode
const billyou = Billyou.create({
  apiKey: process.env.BILLYOU_TEST_KEY,
  env: 'sandbox',
});

// All invoices in sandbox mode:
// - Are NOT sent to real ANAF
// - Return simulated SPV responses
// - Do not count toward your plan limits

Simulate SPV responses

Use the sandbox.simulateStatus field to force a specific outcome. Useful for testing error handling and edge cases in your integration.

simulate.ts
// Simulate different SPV outcomes
const invoice = await billyou.invoices.create({
  // ... your invoice fields ...
  sandbox: {
    // Force a specific outcome:
    simulateStatus: 'confirmed',
    // or 'rejected', 'in_prelucrare'
  },
});

Common sandbox patterns

Happy path test
Create an invoice with simulateStatus: 'confirmed'. Verify your app handles the confirmation correctly and updates its state.
Rejection handling
Use simulateStatus: 'rejected' with a mock error code. Test that your app surfaces the error clearly and allows the user to correct and resubmit.
Load testing
The sandbox supports high concurrency. Use it to stress-test your integration before going live. No rate limits apply to sandbox keys on enterprise plans.
Webhook testing
Set up a local webhook endpoint using a tunnel (ngrok, Cloudflare Tunnel). All sandbox events fire webhook payloads identical to production.

Next steps