Sandbox Testing

The API Express sandbox mirrors production exactly — same endpoints, same response format, same behaviour — but uses mock data and never charges your account. Build confidently before you go live.

Overview

The sandbox is a full mirror of the production API. Every endpoint, every parameter, every response field works the same way. The only differences are:

  • Mock data — Instead of hitting real source databases, responses use curated mock data
  • No charges — Sandbox calls don't count against your quota or billing
  • Deterministic test values — Specific test inputs trigger specific outcomes (success, failure, edge cases)
  • Different base URL — Uses sandbox.api.apiexpress.in instead of the production host
✅
Test the full workflow — from request construction to error handling to webhook callbacks — before writing any production code. This is what the sandbox is for.

Getting Sandbox Keys

When you sign up for API Express, you automatically get both a sandbox key and a production key. Both are available in your dashboard.

Key prefixes

PrefixEnvironmentSafe for client-side?
sk_test_SandboxYes — safe to embed in dev tools and mobile apps
sk_live_ProductionNo — server-side only

Generating additional sandbox keys

You can generate multiple sandbox keys — useful for different developers, environments, or test suites. Navigate to Dashboard → API Keys → Generate Sandbox Key.

⚠️
Sandbox keys never work on production. If you accidentally use a sk_test_ key against the production URL, you'll get a 401 INVALID_API_KEY error. Same for sk_live_ keys against the sandbox.

Sandbox Base URL

The sandbox uses a different host than production. All other path segments stay identical.

EnvironmentBase URL
Productionhttps://api.apiexpress.in
Sandboxhttps://sandbox.api.apiexpress.in

Environment configuration

Configure your code to switch between the two with a single environment variable:

// config.js
const BASE_URL = process.env.NODE_ENV === 'production'
  ? 'https://api.apiexpress.in'
  : 'https://sandbox.api.apiexpress.in';

const API_KEY = process.env.NODE_ENV === 'production'
  ? process.env.API_KEY_LIVE
  : process.env.API_KEY_SANDBOX;

export { BASE_URL, API_KEY };

Then use it everywhere:

// Example: fetch weather from correct environment
const response = await fetch(
  `${BASE_URL}/v1/weather?city=Mumbai`,
  { headers: { 'Authorization': `Bearer ${API_KEY}` } }
);

Mock Data

Sandbox responses use curated mock data. The data is realistic and consistent — the same input always returns the same output. This makes it easy to write automated tests.

Response structure is identical

Every field, every type, every nested object — the sandbox response schema is identical to production. Only the values differ.

Example: Weather API in sandbox

{
  "status": "success",
  "city": "Mumbai",
  "temp": 28.5,
  "humidity": 65,
  "condition": "Clear",
  "wind_speed": 12.3,
  "rain_chance": 10,
  "uv_index": 6,
  "updated": "2026-10-05T10:00:00Z"
}

The structure matches production exactly. Weather values are static mock values that don't change.

Example: KYC verification in sandbox

{
  "status": "success",
  "verified": true,
  "name_match": "exact",
  "pan_status": "active",
  "category": "Individual"
}

Test Scenarios

Use specific test inputs to trigger specific outcomes. This lets you test both success paths and error handling.

Test mobile numbers (Recharge API)

Mobile numberResult
9876543210Success — Airtel, Maharashtra
9123456780Success — Jio, Delhi
9000000001Failure — operator network error
9000000002Pending — operator timeout
1234567890Invalid — triggers validation error

Test PAN numbers (KYC API)

PAN numberResult
ABCDE1234FVerified — name match: exact
AAAAA0000AVerified — name match: partial
ZZZZZ9999ZNot verified — record not found
INVALIDPANError — invalid format

Test RC numbers (Vehicle RC API)

RC numberResult
MH12AB1234Verified — Maharashtra, valid insurance
DL01CD5678Verified — Delhi, expired insurance
KA05XY0000Not found — no record
INVALIDRCError — invalid format

Test bank accounts (UPI/Bank Verification API)

Account / IFSCResult
50100123456789 / HDFC0001234Verified — name match: exact
50100999999999 / HDFC0001234Verified — name match: partial
00000000000001 / ICIC0000123Not verified — account inactive
00000000000002 / ICIC0000123Error — invalid IFSC

Test UPI VPAs (UPI/Bank Verification API)

UPI VPAResult
success@hdfcbankVerified — name matches
partial@okaxisVerified — name match: partial
invalid@okiciciNot verified — VPA not found

Test cities (Weather, AQI, Fuel APIs)

CityResult
Mumbai, Delhi, BengaluruSuccess — full data
TestUnknownCityError — city not found (INVALID_CITY)
TestServerErrorError — simulates 500 (INTERNAL_ERROR)
💡
Triggering specific error codes: Any request with a ref_id starting with test_err_ will return the error code indicated (e.g., test_err_401 returns a 401 Unauthorized).

Going to Production

When your integration is tested and working in sandbox, switching to production is a one-line change — swap the base URL and the API key.

Pre-launch checklist

  • ✅ All API calls work with sandbox keys and return expected data
  • ✅ Error handling covers all status codes (400, 401, 403, 404, 422, 429, 5xx)
  • ✅ Webhooks verify signatures before processing
  • ✅ Retry logic implements exponential backoff
  • ✅ Idempotency keys are used for write operations (recharge, verification)
  • ✅ Production API keys are stored in environment variables (not source code)
  • ✅ Monitoring is set up for error rates and response times
  • ✅ Usage alerts configured in the dashboard

Switch to production

# .env (development)
NODE_ENV=development
API_KEY_SANDBOX=sk_test_1a2b3c4d5e6f...
API_KEY_LIVE=

# .env (production)
NODE_ENV=production
API_KEY_SANDBOX=
API_KEY_LIVE=sk_live_1a2b3c4d5e6f...

Deploy the change, verify a small volume of calls succeed, then ramp up traffic. If anything breaks, roll back instantly — the sandbox is always available.

⚠️
Start with low volume in production. Deploy the change, monitor error rates for 24 hours, then scale up. Any production-specific issues (e.g., rate limits, IP whitelisting) surface early this way.

Best Practices

Write automated tests against the sandbox

The sandbox is deterministic — the same input always returns the same output. This makes it ideal for automated testing. Write unit and integration tests that hit the sandbox to verify your integration works end-to-end.

Test error scenarios first

Most developers test the happy path first and handle errors later. Reverse this: trigger every error scenario in the sandbox before writing the success flow. Robust error handling is what separates production-quality code from prototype code.

Use both sandbox keys in CI/CD

Use one sandbox key for local development and another for CI/CD pipelines. This isolates usage between developers and automation, and makes it easy to revoke a specific environment's key without affecting others.

Never ship sandbox keys to production

It's easy to accidentally deploy with a sandbox key. Add a sanity check in your deployment script that fails the build if a sk_test_ key is found in production environment variables.

# deployment-check.sh
if [[ "$NODE_ENV" == "production" ]] && [[ "$API_KEY" == sk_test_* ]]; then
  echo "ERROR: Sandbox key detected in production!"
  exit 1
fi

Keep sandbox and production code paths identical

Never write code like if (env === 'sandbox') { ... } else { ... } — the entire point of a sandbox is to mirror production. The only difference should be the base URL and the API key.

✅
Want a Postman collection for the sandbox? Download it from your dashboard. It comes pre-configured with all endpoints, environment variables, and example requests.

Related Documentation

Ready to test?

Start Building in Sandbox — No Credit Card Required

Sign up free, get your sandbox key instantly, and test all 10 APIs with mock data. Zero charges, zero risk, full production parity.

No credit card required Full API access Mock data included Zero charges