> ## Documentation Index
> Fetch the complete documentation index at: https://docs.straddle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox and production environments

> Compare Straddle's sandbox and production API environments, including base URLs, credentials, testing workflows, and how to safely promote integrations to live.

Straddle provides two distinct environments for developers: a sandbox environment for testing and a production environment for live transactions. This guide helps you understand the differences between these environments and how to use them effectively in your development process.

## Overview

Straddle offers two environments:

1. **Sandbox Environment**: `https://sandbox.straddle.com`
2. **Production Environment**: `https://production.straddle.com`

Each environment serves a specific purpose in your development lifecycle.

## Sandbox environment

The sandbox environment (`https://sandbox.straddle.com`) is designed for testing and development purposes. It allows you to integrate and experiment with Straddle's API without affecting real data or triggering actual financial transactions.

### Key features of the sandbox environment

* Simulates the behavior of the production environment
* Uses sandbox API keys
* Does not process real financial transactions
* Provides pre-defined test data and scenarios
* No rate limits or usage restrictions

### When to use the sandbox environment

> [!TIP]
>
> Use the sandbox environment when:
>
> * Developing and testing your integration
> * Experimenting with new features
> * Running automated tests
> * Demonstrating your application without using real data

### Accessing the sandbox environment

To use the sandbox environment, make API requests to `https://sandbox.straddle.com` and use your test API key for authentication.

Example API request to the sandbox environment:

```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/accounts \
  -H "Authorization: Bearer 71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi"
```

```javascript Node.js theme={null}
const apiKey = '71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi'

async function listAccounts() {
  const res = await fetch('https://sandbox.straddle.com/v1/accounts', {
    headers: { 'Authorization': `Bearer ${apiKey}` }
  })
  const json = await res.json()
  console.log(json)
}
listAccounts().catch(err => console.error('Error:', err))
```

```python Python theme={null}
import requests

api_key = '71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi'

headers = {
    'Authorization': f'Bearer {api_key}'
}

response = requests.get('https://sandbox.straddle.com/v1/accounts', headers=headers)

print(response.json())
```

## Production environment

The production environment (`https://production.straddle.com`) is used for live, real-world transactions. This is where your application interacts with actual customer data and processes real financial transactions.

### Key features of the production environment

* Processes real financial transactions
* Uses live API keys
* Interacts with real customer data
* Subject to rate limits and usage restrictions
* Monitored for performance and reliability

### When to use the production environment

> [!TIP]
>
> Use the production environment when:
>
> * Your application is ready for real-world use
> * Processing actual financial transactions
> * Working with real customer data

### Accessing the production environment

To use the production environment, make API requests to `https://production.straddle.com` and use your live API key for authentication.

Example API request to the production environment:

```bash cURL theme={null}
curl https://production.straddle.com/v1/accounts \
  -H "Authorization: Bearer 51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
```

```javascript Node.js theme={null}
const apiKey = '51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1'

async function listAccountsProd() {
  const res = await fetch('https://production.straddle.com/v1/accounts', {
    headers: { 'Authorization': `Bearer ${apiKey}` }
  })
  const json = await res.json()
  console.log(json)
}
listAccountsProd()
```

```python Python theme={null}
import requests

api_key = '51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1'

headers = {
    'Authorization': f'Bearer {api_key}'
}

response = requests.get('https://production.straddle.com/v1/accounts', headers=headers)

print(response.json())
```

## Best practices

To ensure a smooth transition from development to production, follow these best practices:

1. **Use environment variables**: Store your API keys and environment URLs as environment variables to easily switch between sandbox and production.

2. **Thoroughly test in sandbox**: Extensively test your integration in the sandbox environment before moving to production.

3. **Gradual rollout**: When moving to production, consider a phased rollout to minimize potential issues.

4. **Monitor closely**: Keep a close eye on your production transactions and be prepared to switch back to sandbox if issues arise.

5. **Keep environments separate**: Never mix sandbox and production data or API keys.

## Transitioning from sandbox to production

When you're ready to go live with your Straddle integration, follow these steps:

1. Review and test all features in the sandbox environment.
2. Update your API key to the live production key.
3. Change your API endpoint from `https://sandbox.straddle.com` to `https://production.straddle.com`.
4. Update any environment-specific configurations or settings.
5. Perform final testing in production with real data (start with small, controlled transactions).
6. Monitor your production transactions closely for any issues.

> [!WARNING]
>
> Always double-check that you're using the correct environment and API key before processing real transactions. Using sandbox credentials in production can lead to failed transactions and poor user experience.

## Conclusion

Understanding and properly utilizing Straddle's sandbox and production environments is crucial for successful integration and deployment. Follow the guidelines and best practices in this guide to ensure a smooth development process and transition to production.

For more detailed information on specific API endpoints and how they behave in different environments, refer to our [API Reference](https://docs.straddle.com/api-reference) documentation.


## Related topics

- [Sandbox simulation testing for Pay by Bank](https://docs.straddle.com/guides/resources/sandbox-paybybank.md)
- [Straddle API introduction](https://docs.straddle.com/api-reference/introduction.md)
- [Onboard merchants with Straddle Embed](https://docs.straddle.com/guides/embed/onboarding.md)
- [API authentication with bearer tokens](https://docs.straddle.com/api-reference/authentication.md)
- [Authentication and permissions](https://docs.straddle.com/developer-tools/mcp/safety.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.