7 Best Practices for API Sandboxes Posted in Marketing Thomas Bush May 21, 2020 Providing a dedicated testing environment for your API is a surefire way to improve the developer experience and encourage signups. In fact, many of the world’s biggest API providers — from PayPal to Salesforce — already do so in the form of an API sandbox. In this article, we’ll look at seven best practices to get the most out of your API sandbox. But first, what exactly is an API sandbox, and what are the benefits of having one? What Is an API Sandbox? An API sandbox is a service that emulates the behavior of a production API. While there are no hard-and-fast definitions, we think of sandboxes as differing from mock APIs in being targeted primarily towards external developers. They enable risk- and cost-free testing of an API, making them a crucial part of a DX-oriented API strategy. Benefits API sandboxes have numerous benefits, both for developers and API owners. Developers benefit from being able to continuously and aggressively test new or updated integrations, without worrying about accruing a sizable bill (in the case of a paid API) or having their requests blocked. Also, sandboxes can be usually made available to any registered developers, which makes them the perfect way for prospective developer customers to test out an API before committing to a paid plan. Both of these factors lead to an improved developer experience — in and after the onboarding process — which has a definitive upside for API owners. Also, the ability to “try before you buy” helps to grow both registrations and paid subscriptions. Last but not least, running an API sandbox will reduce strain on the all-important production API. Examples PayPal API Sandbox Uber API Sandbox eBay API Sandbox Seven Short ‘n’ Sweet Suggestions for Sandbox Success If you’re looking to launch or optimize your API sandbox, there are quite a few best practices that can maximize your results. In particular, we’ve identified seven suggestions you ought to adhere to: 1. Isolate Your Sandbox Ensure that your API sandbox is isolated from the rest of your platform. A sandbox should allow developers to simulate the behavior of your API; it shouldn’t, however, enable direct interaction with your platform in the same way a production API would. If you’re not careful with your sandbox, it might affect production systems, expose real data, or contribute to billing confusion, so it’s best to build your sandbox from the ground-up in an isolated environment. 2. Provide Free Access Allow developers to access your sandbox free of charge. After all, the main appeal of testing against — or testing out — a sandbox is that it’s free! This is especially true for prospective developer customers who may otherwise need to go through a long-winded approval procedure to get the corporate buy-in for even your most affordable trials. Yes, there are costs associated with hosting an API sandbox… but chalk it up to being a crucial part of customer acquisition and DX. If you can’t justify the costs of an unlimited sandbox, consider giving developers a limited number of free sandbox credits upon registration, which will significantly reduce throughput. 3. Recreate Production Behavior Endeavor to make your sandbox as close as possible to the real thing. For developers, there’s significant value in knowing that what they test with the sandbox will behave identically with the production API. Not knowing this, developers will be forced to run their integrations through the second set of tests with the real API, somewhat defeating the purpose of a sandbox. If your production API supports POST requests, then support POST requests in the sandbox. If your production API implements pagination, then implement pagination in the sandbox. There’s a good chance you’ll base your sandbox on an API specification, so pay close attention to the areas your specification might fall short. 4. Remember About Authorization In particular, don’t forget about the authorization or authentication methods used by your production API! This aspect of API behavior — which is also frequently excluded from API specifications — deserves special recognition, since it’s such a common developer pain point. Of course, it should absolutely be accounted for in your sandbox, whether you rely on API keys or access tokens. 5. Account for Gateways or Proxies When building your sandbox, consider the implications of any gateways or proxies that stand in front of your production API. Sure, they might not be part of the API itself, but they can still very much affect developers’ integrations. Perhaps the best example of this is rate limiting: often implemented at the gateway level, it can significantly affect how integrations behave. It’s up to you to decide if and how to account for these issues. With rate limiting, some API owners limit sandboxes exactly as they do with production APIs, while others — like Salesforce — vastly increase sandbox limits to enable more extensive testing. The author personally favors the approach taken by Evernote: limits for production and sandbox APIs kick in at the same time (after a certain number of calls on the hour), but sandbox users are only rate-limited for 15 seconds, and not for the remainder of the hour. This way, developers can test and handle the rate limit exception without having to wait until the one-hour interval ends to resume interacting with the API. 6. Review Sandbox Usage If resources permit, take the time to review how your API sandbox is used periodically. For one, looking at the sandbox’s logs may help you to identify unexpected use patterns that you can go on to support. More importantly, looking at any frequently occurring errors can highlight common pain points, especially in the onboarding experience, which will improve retention when fixed. 7. Consider A Chaos Mock Last but not least, mature API programs in high-stake industries should consider building a chaos mock alongside their everyday API sandbox. Coined by Microsoft architect Gareth Jones, the chaos mock is an API virtualization that purposefully embodies variability. The goal of a chaos mock is to enable developers to code against all sorts of weird and wonderful API behavior, so they can be confident their integrations will survive under all circumstances. Closing Thoughts We’ve just reviewed seven ways to get the most out of your API sandbox. Follow these pointers, and you’ll end up with an environment that enables accurate and practical testing of your API, among other benefits. Now, how else can you improve the developer experience for your API? The latest API insights straight to your inbox