How sandboxes work
The sandbox feature isolates data through aSandboxable concern applied to core models. When sandbox mode is active, all data operations are scoped to the current sandbox context:
- Sandbox records are only visible when the matching sandbox is active
- Production records (where
sandbox_idis null) are only visible outside of sandbox mode - Each sandbox has its own isolated dataset — customers, invoices, subscriptions, and all other tenant-scoped resources
Sandbox isolation is enforced at the query level through scoped queries, not through a database-level default scope. This means you must use the
.sandboxed scope when querying models to ensure proper isolation.Using sandbox mode
Through the application
Account users can select a sandbox from their account settings. Once a sandbox is selected, all operations within the application are scoped to that sandbox. Switching back to production mode clears the sandbox context.Through the API
API tokens can be associated with a specific sandbox. When an API request is made with a sandbox token, the sandbox context is automatically set based on the token’s configuration. This means:- Production API tokens access production data only
- Sandbox API tokens access sandbox data only
Data isolation
All core domain models support sandbox isolation:| Model | Sandbox support |
|---|---|
| Customers | Yes |
| Products | Yes |
| Prices | Yes |
| Invoices | Yes |
| Line items | Yes |
| Subscriptions | Yes |
| Subscription phases | Yes |
| Subscription phase items | Yes |
| Wallets | Yes |
| Crypto addresses | Yes |
| Crypto transactions | Yes |
| Payment claims | Yes |
| Transaction allocations | Yes |
| Webhook endpoints | Yes |
Creating sandbox API tokens
To test your integration against the API in sandbox mode:Adding sandbox support to new models
If you are extending TRXN with custom models, you can add sandbox support by including theSandboxable concern.
Step 1: Add the migration
Step 2: Include the concern
Webhooks in sandbox mode
Webhook events fired from sandbox data include sandbox context. This means you can set up separate webhook endpoints for sandbox and production, or use a single endpoint that distinguishes between the two based on the payload.Related pages
Crypto payments overview
End-to-end payment flow from product definition to transaction allocation.
Webhooks
Receive real-time notifications for events in your TRXN account.