We are developing a Rails app that will include an API for our customers. Let's say that with this API, they can create Puppies. Many services that provide an API, include a 'sandbox' mode, in which they can, for example, create bogus resources to make sure their integration is correct. We'd like to include a 'sandbox' mode to our API.
I am aware that a simple solution for adding a sandbox mode to an API is to create a 'sandbox' environment (similar to production, but without some business logic that should happen only on real production transactions) and ask our customers to call the sandbox environment when making sandbox API calls. However, since Rails 6 now includes support for multiple databases, we are also considering adding a secondary database to the Puppy model to handle sandbox calls (i.e. write and read records that were made on the 'sandbox' mode). We figure we could in theory make this work by creating a custom DatabaseSelector::Resolver that checks the session and decides if it uses the 'sandbox' database or the main one, depending for example if the credentials passed to the API call are 'sandbox' or 'production' credentials.
Do you think this approach is feasible? What would the pros and cons of this approach be vs others? (e.g. sandbox environment, adding a Puppy#is_sandbox column and scoping records, etc.)