# Environments
URL: /docs/getting-started/environments

> Compare test keys and live keys on the SMS Pro API.

SMS Pro has one API, `https://api.smspro.com`. The key you send chooses simulated delivery or carrier delivery.

---

## Key comparison [#key-comparison]

![Test keys and live keys](/images/environments-architecture.svg)

| | `sk_test_` | `sk_live_` |
| :--- | :--- | :--- |
| **Base URL** | `https://api.smspro.com` | `https://api.smspro.com` |
| **Delivery** | Simulated. No handset is contacted. | Sent to the carrier. |
| **Wallet** | Not charged. | Charged per segment. |
| **Result** | `202` with status `ACCEPTED_SANDBOX` and a `sim_` message id. | `202` and a later delivery status. |
| **Magic numbers** | Select a specific simulated outcome. | The same four numbers are still simulated, even on a live key. |
| **Sender ID** | A test name is accepted. | A custom name must be approved. |

---

## Test keys [#test-keys]

A test key checks authentication, scopes, and the request body, then returns a simulated acceptance. It also posts a simulated delivery webhook when you have a webhook URL.

```bash
curl -X POST "https://api.smspro.com/api/v1/public/sms/send" \
  -H "X-Api-Key: sk_test_example" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+233200000001",
    "senderId": "SMSPRO",
    "message": "Testing from local environment."
  }'
```

Read the magic-number outcomes in [Testing in Sandbox](/docs/getting-started/testing-in-sandbox).

---

## Live keys [#live-keys]

A live key sends to the carrier and uses wallet credit.

```bash
curl -X POST "https://api.smspro.com/api/v1/public/sms/send" \
  -H "X-Api-Key: sk_live_example" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+233241234567",
    "senderId": "MYAPP",
    "message": "Your verification code is 491029."
  }'
```

Before live traffic:

1. Keep a prepaid balance.
2. Use an approved `senderId`, or the platform default.
3. Send only to people who have opted in.

---

## Configuring Your Environment [#configuring-your-environment]

We recommend decoupling the gateway URL and API key from your application logic using environment variables.

### Local Development (`.env.local`) [#local-development-envlocal]
```bash title=".env.local"
SMSPRO_BASE_URL=https://api.smspro.com
SMSPRO_API_KEY=sk_test_948f293048a1b2c3d4e5f60718a2b3c4
```

### Production Deployment (`.env.production`) [#production-deployment-envproduction]
```bash title=".env.production"
SMSPRO_BASE_URL=https://api.smspro.com
SMSPRO_API_KEY=sk_live_891024ab9012cd34ef560718a2b3c4d5
```

### Dynamic Client Initialization Example [#dynamic-client-initialization-example]

```ts title="sms-client.ts"
const baseUrl = process.env.SMSPRO_BASE_URL || 'https://api.smspro.com';
const apiKey = process.env.SMSPRO_API_KEY;

if (!apiKey) {
  throw new Error('Missing SMSPRO_API_KEY configuration.');
}

export async function sendSms(to: string, senderId: string, message: string) {
  const response = await fetch(`${baseUrl}/api/v1/public/sms/send`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Api-Key': apiKey,
      'Idempotency-Key': crypto.randomUUID(),
    },
    body: JSON.stringify({ to, senderId, message }),
  });

  return response.json();
}
```

---

## Next Step [#next-step]

Make your very first live API call in [Your First API Request](/docs/getting-started/first-request).