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

# Test and Live Environments

> Separate environments for safe development and production deployment

Gameball provides **separate test and live environments** to enable safe development and testing before deploying to production. Both environments share the same configurations but maintain completely isolated data.

***

## API Keys

You have access to three keys in your Gameball Dashboard (**Settings → Admin Settings → Account Integration**):

| Key              | Purpose                            | Usage                                                                 |
| ---------------- | ---------------------------------- | --------------------------------------------------------------------- |
| **Test API Key** | Development & staging              | Use in UAT/staging environments during integration                    |
| **Live API Key** | Production                         | Use in production once you go live                                    |
| **Secret Key**   | Point transactions & high security | Required for sensitive operations (same key works for both test/live) |

<Note>
  **Same Base URL**: Both test and live use `https://api.gameball.co/api/v4.0` — you only change the API key.
</Note>

***

## What's Shared vs Separated

### Shared (Mirrored Configurations)

These apply to both test and live:

* Tiers and VIP levels
* Campaign rules and logic
* Widget configuration
* Point earning/redemption rules
* Experience design

### Separated (Isolated Data)

Test and live maintain separate:

* **Customers list**: Test customers don't appear in live
* **Analytics**: Separate reporting for test vs live
* **Point transactions**: Test points isolated from live points
* **Achievements**: Customer progress tracked separately

<Tip>
  Configure your campaigns and tiers once—they automatically work in both environments. Only the customer data differs.
</Tip>

***

## Dashboard Toggle

Switch between test and live views from your Gameball Dashboard's Admin Settings:

1. Navigate to **Settings → Admin Settings** and open the **General** tab.

2. Scroll to the **Test Data** section and click the toggle.

   <Frame caption="Test Data toggle under Settings → Admin Settings → General">
     <img src="https://mintcdn.com/gameball/3mk7Kv2S20XVhcqI/images/product-docs/integrate-gameball/test-data-settings-toggle.png?fit=max&auto=format&n=3mk7Kv2S20XVhcqI&q=85&s=86cc1b789672bb24103eeb1f86411964" alt="Test Data toggle in Admin Settings" width="1024" height="512" data-path="images/product-docs/integrate-gameball/test-data-settings-toggle.png" />
   </Frame>

3. In the **Data View** confirmation pop-up, choose **Live Data** or **Test Data** from the dropdown and click **Save**.

   <Frame caption="Data View confirmation pop-up">
     <img src="https://mintcdn.com/gameball/3mk7Kv2S20XVhcqI/images/product-docs/integrate-gameball/test-data-confirmation-popup.png?fit=max&auto=format&n=3mk7Kv2S20XVhcqI&q=85&s=740db046ca585f3136bb30b7b5518b3e" alt="Data View confirmation pop-up" width="1024" height="510" data-path="images/product-docs/integrate-gameball/test-data-confirmation-popup.png" />
   </Frame>

Analytics, customer lists, and transactions update based on your selection, letting you inspect test behavior before deploying to production.

<Note>
  While **Test Data** mode is active, a yellow banner appears at the top of every dashboard page. Click the **Go to Settings** link in the banner to return to the Test Data toggle and switch back to Live Data at any time.
</Note>

***

## Development Workflow

<Steps>
  <Step title="Configure in Dashboard">
    Set up tiers, campaigns, point logic, and widget behavior. These configurations apply to both test and live.
  </Step>

  <Step title="Integrate with Test Key">
    Use the **Test API Key** in your staging/UAT environment. Build your integration and test thoroughly.
  </Step>

  <Step title="Validate Test Data">
    Switch dashboard to **Test mode** and verify:

    * Customer registration works
    * Points accrue correctly
    * Campaigns trigger as expected
    * Redemption flows function properly
  </Step>

  <Step title="QA & Edge Cases">
    Test edge cases, error handling, concurrent operations, and campaign expirations using test environment.
  </Step>

  <Step title="Switch to Live Key">
    Replace **Test API Key** with **Live API Key** in your production application. Live customers and data will now be tracked.
  </Step>

  <Step title="Monitor Live Environment">
    Switch dashboard to **Live mode** and monitor real customers, transactions, and analytics.
  </Step>
</Steps>

***

## Key Points

<CardGroup cols={2}>
  <Card title="Data Isolation" icon="shield-check">
    Test and live data never mix. Test customers, points, and transactions are completely separate.
  </Card>

  <Card title="No Migration" icon="ban">
    Test data is disposable. You cannot migrate test customers or transactions to live.
  </Card>

  <Card title="Fresh Start" icon="sparkles">
    When you go live, start with a clean slate. All live data begins from scratch.
  </Card>

  <Card title="Key Rotation" icon="rotate">
    Gameball supports key rotation without disrupting existing integrations.
  </Card>
</CardGroup>

***

## Example: Switching Environments

### Test Environment (Staging)

```javascript theme={null}
// staging.config.js
const GAMEBALL_API_KEY = "test_ue7eh32eiwlsncoko08u8b";
const GAMEBALL_SECRET_KEY = "kz7eh32eiwldlowbo08u5p";
```

### Live Environment (Production)

```javascript theme={null}
// production.config.js
const GAMEBALL_API_KEY = "live_8x4mh92kwjancblp07r9d";
const GAMEBALL_SECRET_KEY = "kz7eh32eiwldlowbo08u5p"; // Same secret key
```

<Warning>
  **Never expose your Live API Key or Secret Key** in client-side code or public repositories. Keep them secure in environment variables or server-side configuration.
</Warning>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use Environment Variables" icon="key">
    Store API keys in environment variables, not hardcoded:

    ```bash theme={null}
    # .env.staging
    GAMEBALL_API_KEY=test_ue7eh32eiwlsncoko08u8b

    # .env.production
    GAMEBALL_API_KEY=live_8x4mh92kwjancblp07r9d
    ```
  </Accordion>

  <Accordion title="Test Thoroughly Before Live" icon="vial">
    * Test all integration points with test key
    * Verify campaign triggers and point calculations
    * Test redemption flows and edge cases
    * Validate error handling and retry logic
  </Accordion>

  <Accordion title="Treat Test Data as Disposable" icon="trash">
    * Don't worry about cleaning up test customers or transactions
    * Test data has no impact on live environment
    * Start fresh when switching to live
  </Accordion>

  <Accordion title="Monitor Both Environments" icon="chart-line">
    * Use dashboard toggle to check test behavior during development
    * Monitor live analytics once in production
    * Compare test vs live to validate expected behavior
  </Accordion>
</AccordionGroup>

***

## High Security Mode

Enable **High Security Mode** in dashboard to require **Secret Key** for all API requests (not just point transactions).

When enabled:

* All endpoints require both `APIKey` and `SecretKey` headers
* Provides additional protection against unauthorized access
* Recommended for high-security requirements

<Warning>
  With High Security Mode enabled, send all requests from **server-side** to prevent exposing the Secret Key.
</Warning>

***

## Related Resources

<CardGroup cols={2}>
  <Card title="Authentication Guide" icon="key" href="/api-reference/overview/authentication">
    Complete guide to API keys and authentication
  </Card>

  <Card title="Get Your API Keys" icon="book-open" href="https://help.gameball.co/en/articles/3467114-get-your-account-integration-details-api-key-and-transaction-key">
    Help Center guide for retrieving keys
  </Card>

  <Card title="Test and Live Data" icon="database" href="https://help.gameball.co">
    Gameball Help Center article
  </Card>
</CardGroup>
