Q&A
Strategy for testing APIs that call third-party services — mock, contract, or live?
Ajitesh MohantaAmbassador
May 1, 2026 1,353 0
Our payments API calls Stripe, our notifications API calls SendGrid, and our geolocation API calls Google Maps. All have sandbox environments.
For each external dependency I'm unsure whether to:
1. **Mock at the HTTP level** — fastest, but drifts from reality
2. **Use sandbox/test modes** — real integration, but flaky, slow, costs money
3. **Contract tests** — validates the interface without calling live services
Is the answer just "it depends" or is there a principled framework for deciding? Also curious how you handle the case where the sandbox doesn't behave identically to production.