Sandbox Mode BETA
Sandbox mode allows you to test the API without affecting production data. Perfect for development and integration testing.
Overview
In sandbox mode:
- ✅ Access real product data
- ✅ Orders are simulated (no real orders created)
- ✅ Dummy license keys are generated
- ✅ All business rules are preserved
- ✅ No charges or credit limit impact
Enabling Sandbox Mode
Add the X-Sandbox-Mode header to your requests:
bash
X-Sandbox-Mode: trueExample Request
bash
curl -X POST https://api.attivita.de/api/orders \
-H "Authorization: Bearer YOUR_API_ACCESS_TOKEN" \
-H "X-Sandbox-Mode: true" \
-H "Content-Type: application/json" \
-d '{
"products": [
{
"productId": "507f1f77bcf86cd799439011",
"amount": 2
}
]
}'javascript
const response = await fetch('https://api.attivita.de/api/orders', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_ACCESS_TOKEN',
'X-Sandbox-Mode': 'true',
'Content-Type': 'application/json'
},
body: JSON.stringify({
products: [
{ productId: "507f1f77bcf86cd799439011", amount: 2 }
]
})
});Sandbox Response
Sandbox responses include special indicators:
Response Headers
http
X-Sandbox-Mode: true
X-Sandbox-Notice: This request was processed in sandbox mode. No real orders were affected.Response Body
json
{
"sandboxNotice": "This is a sandbox order. No actual products were purchased, and the licenses are dummy values.",
"customer": 7,
"orderNumber": 1234567,
"orderDate": "2023-07-01T12:00:00Z",
"status": "sandbox-completed",
"items": [
{
"product": "Microsoft Office 2021",
"quantity": 2,
"price": 89.99,
"isReplacement": false,
"licenses": [
{
"licenseKey": "SAND-BOX1-TEST-KEY1"
},
{
"licenseKey": "SAND-BOX2-TEST-KEY2"
}
],
"productId": "507f1f77bcf86cd799439011"
}
],
"subTotal": 179.98,
"discountTotal": 20.00,
"grandTotal": 179.98,
"paymentMethod": "N/A",
"orderFrom": 2
}Key Differences in Sandbox Mode
| Feature | Production | Sandbox |
|---|---|---|
| Order Creation | Real orders | Simulated |
| License Keys | Real licenses | Dummy values |
| Stock Deduction | Yes | No |
| Credit Limit | Enforced | Not affected |
| Order History | Persisted | Not saved |
| Webhooks | Triggered | Not triggered |
Testing Scenarios
1. Test Product Availability
bash
# This will validate stock without consuming it
curl -X POST https://api.attivita.de/api/orders \
-H "X-Sandbox-Mode: true" \
-d '{"products": [{"productId": "...", "amount": 999}]}'2. Test Discount Calculations
bash
# Verify your customer discounts are applied correctly
curl -X POST https://api.attivita.de/api/orders \
-H "X-Sandbox-Mode: true" \
-d '{"products": [{"productId": "...", "amount": 1}]}'3. Test Error Handling
bash
# Test with invalid product ID
curl -X POST https://api.attivita.de/api/orders \
-H "X-Sandbox-Mode: true" \
-d '{"products": [{"productId": "invalid-id", "amount": 1}]}'Best Practices
Development Workflow
- Always use sandbox mode during development
- Test all edge cases (out of stock, invalid products, etc.)
- Verify discount calculations match expectations
- Switch to production only after thorough testing
Limitations
- Sandbox orders are not persisted
- Cannot test webhook deliveries
- Random order numbers are generated
- GET /orders endpoints don't return sandbox orders
Identifying Sandbox Responses
Always check for sandbox indicators:
javascript
// Check response headers
const isSandbox = response.headers.get('X-Sandbox-Mode') === 'true';
// Check response body
if (data.sandboxNotice) {
console.log('This is a sandbox response');
}
// Check order status
if (data.status === 'sandbox-completed') {
console.log('Sandbox order successful');
}Next Steps
- Explore the Orders API endpoints
- Learn about Error Handling
- Read Best Practices for integration