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

# AgriBackup API Environments: Production and Sandbox

> Learn how to switch between the AgriBackup production and sandbox environments, configure API keys, and avoid cross-environment mistakes.

AgriBackup provides two isolated environments — **Production (Mainnet)** and **Sandbox (Testnet)** — so you can develop, test, and validate your integration without touching live compliance data or incurring real blockchain transactions. The environment you operate in is determined automatically by the prefix of the API key you supply — no extra configuration needed.

## Environment Overview

<CardGroup cols={2}>
  <Card title="Production (Mainnet)" icon="shield-check">
    Live environment connected to real satellite screening pipelines, the Hedera DLT mainnet, and EU TRACES NT. Use only when submitting actual commodity shipment data.

    **Base URL:** `https://live.agribackup.com`

    **Key prefix:** `sk_live_`
  </Card>

  <Card title="Sandbox (Testnet)" icon="flask">
    Isolated test environment with simulated satellite screening and no real blockchain interaction. Safe for development, CI pipelines, and QA validation.

    **Base URL:** `https://sandbox.agribackup.com`

    **Key prefix:** `sk_test_`
  </Card>
</CardGroup>

## What the Sandbox Does (and Does Not) Do

The sandbox mirrors the full API surface of production — every endpoint, every request schema, every response shape. The key differences are:

* **No real satellite screening.** Polygon verification calls return simulated results. You can trigger pass and fail scenarios using test fixture coordinates documented in the developer portal.
* **No real Hedera DLT anchoring.** Blockchain transactions are simulated; no Hedera mainnet fees are incurred and no real consensus timestamps are generated.
* **No TRACES NT submission.** DDS declarations do not reach EU regulatory systems.
* **Isolated data.** Sandbox resources (polygons, batches, declarations, suppliers) are completely separate from production. A polygon ID created in sandbox will never resolve in production.
* **Webhooks are fully functional.** Webhook delivery, signing, and retry logic behave identically to production, making the sandbox ideal for testing your webhook handler.

<Note>
  Sandbox API keys are prefixed `sk_test_`. Generate them from the **Sandbox** section of the AgriBackup developer dashboard — they are a separate credential from your live keys and are never interchangeable.
</Note>

## Switching Environments

### Automatic Inference from Key Prefix

You do not need to set a base URL manually in most cases. All official AgriBackup SDKs inspect the key prefix (`sk_live_` vs `sk_test_`) and route requests to the correct environment automatically.

```text theme={null}
sk_live_... → https://live.agribackup.com
sk_test_... → https://sandbox.agribackup.com
```

Simply replace the API key in your environment configuration and the SDK handles the rest.

***

### Python SDK

```python theme={null}
import os
from agribackup import AgriBackupClient

# Load the key from an environment variable — never hardcode keys
client = AgriBackupClient(
    api_key=os.environ["AGRIBACKUP_API_KEY"]
    # No base_url required — inferred automatically from the key prefix
)

# Sandbox: set AGRIBACKUP_API_KEY=sk_test_...
# Production: set AGRIBACKUP_API_KEY=sk_live_...

polygons = client.polygons.list()
print(polygons)
```

***

### Node.js SDK

```javascript theme={null}
import { AgriBackupClient } from "@agribackup/sdk";

// Load the key from an environment variable — never hardcode keys
const client = new AgriBackupClient({
  apiKey: process.env.AGRIBACKUP_API_KEY,
  // No baseUrl required — inferred automatically from the key prefix
});

// Sandbox: set AGRIBACKUP_API_KEY=sk_test_...
// Production: set AGRIBACKUP_API_KEY=sk_live_...

const polygons = await client.polygons.list();
console.log(polygons);
```

***

### Java SDK

```java theme={null}
import com.agribackup.AgriBackupClient;
import com.agribackup.model.PolygonList;

public class Main {
    public static void main(String[] args) {
        // Load the key from an environment variable — never hardcode keys
        String apiKey = System.getenv("AGRIBACKUP_API_KEY");

        // No baseUrl required — inferred automatically from the key prefix
        AgriBackupClient client = AgriBackupClient.builder()
                .apiKey(apiKey)
                .build();

        // Sandbox: set AGRIBACKUP_API_KEY=sk_test_...
        // Production: set AGRIBACKUP_API_KEY=sk_live_...

        PolygonList polygons = client.polygons().list();
        System.out.println(polygons);
    }
}
```

***

## Environment Variables Pattern

Store your keys in environment variables and load them into your application at runtime. This practice prevents accidental credential leaks and makes switching environments a one-line configuration change.

```bash theme={null}
# .env (development / sandbox)
AGRIBACKUP_API_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxx

# .env.production
AGRIBACKUP_API_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxxxx
```

<Warning>
  **Never use production keys (`sk_live_`) in development or CI environments.** A misconfigured test run can submit real polygon verifications to the satellite screening pipeline, anchor dummy data to Hedera mainnet, and trigger filings in EU TRACES NT — all of which have regulatory and cost implications that cannot be reversed. Always verify which key your application is loading before running any write operations.
</Warning>

## Verifying Your Active Environment

To confirm which environment a key resolves to before running any operations, call the diagnostics endpoint:

```bash theme={null}
curl -X GET https://live.agribackup.com/api/v1/enterprise/eudr/health \
  -H "X-API-Key: sk_live_YOUR_API_KEY"
```

The response includes an `environment` field indicating `production` or `sandbox`. Use this as a sanity check in your integration bootstrap sequence.
