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

# Environments

> Test and live environment configuration

The SDK supports two environments for development and production use.

## Available Environments

| Environment | Description            | Use Case                    |
| ----------- | ---------------------- | --------------------------- |
| `test`      | Sandbox environment    | Development, testing, demos |
| `live`      | Production environment | Real data, production use   |

## Configuration

```typescript theme={null}
import { ComplianceSDK } from "@artu-ai/compliance-sdk";

// Test environment
const testSDK = new ComplianceSDK({
  apiKey: process.env.ARTU_API_KEY!,
  environment: "test",
});

// Live environment
const liveSDK = new ComplianceSDK({
  apiKey: process.env.ARTU_API_KEY!,
  environment: "live",
});
```

## API Key Permissions

API keys have scoped permissions that control which environments they can access. A single key can have permissions for test, live, or both environments.

<Info>
  See [API Keys](/concepts/api-keys) for details on the `{env}:{resource}:   {operation}` permission pattern.
</Info>

## Environment Properties

Check the current environment at runtime:

```typescript theme={null}
// Environment name
sdk.environment; // "test" | "live"

// Boolean checks
sdk.isTest; // true if test environment
sdk.isLive; // true if live environment
```

## Test Environment Features

The test environment:

* Uses separate, isolated data from production
* May have relaxed rate limits for testing
* Supports test data patterns for validation

<Info>
  Test data created in the test environment is completely isolated from
  production.
</Info>

## Live Environment Features

The live environment:

* Contains real production data
* Has production rate limits
* Requires validated and verified API keys

<Warning>
  Be careful when working in the live environment. Operations affect real data
  and may have regulatory implications.
</Warning>

## Environment-Specific Logic

You can implement environment-specific logic:

```typescript theme={null}
const sdk = new ComplianceSDK({
  apiKey: process.env.ARTU_API_KEY!,
  environment: process.env.NODE_ENV === "production" ? "live" : "test",
});

// Guard against accidental live operations
async function deleteClient(clientId: string) {
  if (sdk.isLive) {
    const confirmed = await confirmDeletion();
    if (!confirmed) return;
  }

  await sdk.clients.delete(clientId);
}
```

## Best Practices

### Use Environment Variables

```typescript theme={null}
const sdk = new ComplianceSDK({
  apiKey: process.env.ARTU_API_KEY!,
  environment: process.env.ARTU_ENVIRONMENT as "test" | "live",
});
```

### Match Environment to Deployment

```typescript theme={null}
const sdk = new ComplianceSDK({
  apiKey: process.env.ARTU_API_KEY!,
  environment: process.env.NODE_ENV === "production" ? "live" : "test",
});
```

### Add Safety Checks

```typescript theme={null}
// Prevent accidental production operations in development
if (process.env.NODE_ENV !== "production" && sdk.isLive) {
  throw new Error("Cannot use live environment in development mode");
}
```

### Log Environment

```typescript theme={null}
console.log(`SDK initialized in ${sdk.environment} environment`);

if (sdk.isLive) {
  console.warn("⚠️  Running in LIVE environment - real data will be affected");
}
```
