API sandboxes: test an integration before production
An API sandbox is an isolated environment for trying an integration without affecting real users or production transactions. Test accounts, credentials, and endpoints let you check requests, responses, and follow-up events. Do not assume a sandbox is identical to production: supported features, data, external connections, performance, and failure conditions can differ.
An API sandbox is an isolated environment for trying an integration without affecting real users or production transactions. Test accounts, credentials, and endpoints let you check requests, responses, and follow-up events. Do not assume a sandbox is identical to production: supported features, data, external connections, performance, and failure conditions can differ.
Mock or sandbox?
A mock usually returns responses defined by a specification or test code. It is fast and predictable for client branches and error handling, but does not prove the provider's authentication, state transitions, or webhooks work. A provider sandbox offers servers and test accounts or data that resemble its API. It can verify more of the real integration path, with provider-specific limits.
| Question | Mock fits when | Sandbox fits when |
|---|---|---|
| Does the UI handle an error response? | You need repeatable, controlled errors. | You also need to check provider error codes and state. |
| Do authentication, account roles, and async notifications connect? | A mock rarely proves the live connection. | Test credentials and webhooks are available. |
| Must tests be fast and repeatable? | Good for unit and contract tests. | Results can depend on external services and data state. |
A safe test sequence
Read the provider's current instructions for test accounts, credentials, base URLs, and feature limits. Keep test and production credentials in separate configuration, and never copy production secrets into test code or logs.
Create a test account for each role, such as buyer and seller. For example, PayPal supports personal sandbox accounts as buyers and business accounts as sellers.
Define key scenarios: success, decline or validation error, important transitions such as cancellation or refund, and asynchronous webhook delivery. Compare request IDs, response status, stored results, and notifications at each step.
Repeat scenarios to see whether data accumulates or one run depends on another. Check the provider's docs before assuming that deleting an account also removes its transaction history.
Before launch, separately review production settings, permissions, domains, and webhooks, and follow the provider's permitted low-value or non-monetary verification process. Sandbox success alone is not production approval.
PayPal documents virtual buyer and seller accounts and reviewing test transactions in its sandbox. Adyen recommends testing the full client/server integration, supported payment methods, country values, and webhooks in its test environment. These examples show why sandbox scope is provider-specific. Do not assume test data carries into production; explicitly change credentials and endpoints during cutover.
Diagnose results
For an authentication error, first check that the credential type matches the environment and that the endpoint is the test URL.
If the API response succeeds but a later state is missing, inspect the webhook URL, signature verification, and delivery records.
If a repeated run behaves differently, check accumulated sandbox state such as account balance, status, or idempotency keys; consult the provider's reset instructions.
If tests pass but production fails, compare region, permissions, account approval, payment methods, rate limits, network access, and production-only features.
Checklist
Are test and production credentials separated?
Have you checked success, representative errors, and key transitions such as cancellation or refund?
Did you receive and verify asynchronous webhooks?
Have you recorded sandbox limits and production differences?
Is there a cutover step to recheck endpoint, keys, and webhook settings?
Sources
[PayPal sandbox testing guide](https://developer.paypal.com/sandbox-testing/overview/)
[PayPal sandbox accounts and buyer/seller roles](https://developer.paypal.com/sandbox-testing/accounts)
[Adyen testing an online payments integration](https://docs.adyen.com/development-resources/testing/)