# Sandbox and production URLs

Use these for Test, and switch the realm to `prod` for Production. Keep your code environment-agnostic by reading these from config.

### Test / Non-prod values

* **API base URL:** `https://api.test.devs.beadpay.io`
* **OIDC token URL:** `https://identity.beadpay.io/realms/nonprod/protocol/openid-connect/token`
* **Realm:** `nonprod`

### Production switch checklist

1. Change realm from `nonprod` to `prod`\
   `https://identity.beadpay.io/realms/prod/protocol/openid-connect/token`
2. Use your provisioned **Production API base URL**
3. Use your **Production credentials** for the client or terminal identities
4. Keep the same request headers
   * `Authorization: Bearer {access_token}`
   * `Content-Type: application/json`

### Quick token example (Test)

```bash
curl -s -X POST "https://identity.beadpay.io/realms/nonprod/protocol/openid-connect/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=password" \
  -d "client_id=bead-terminal" \
  -d "username={username}" \
  -d "password={password}"
```

The response includes `access_token`. Send it on every API call.

### Create a minimal payment (Test)

```http
POST https://api.test.devs.beadpay.io/payments
Authorization: Bearer {access_token}
Content-Type: application/json

{
  "amount": 19.99,
  "currency": "USD",
  "tenderType": "klarna",
  "orderId": "ord_123",
  "returnUrl": "https://merchant.example.com/checkout/return"
}
```

Redirect the shopper to the returned `hostedUrl`, or use the `paymentUrls.url` if provided.

### Verify you are in the right environment

* Token URL contains `/realms/nonprod` for Test or `/realms/prod` for Production
* API responses will reference the same host you called in `self` or redirect links
* A `401` right after switching usually means the realm or credentials are still pointed at the other environment

### Related pages

* [Authentication & OAuth 2.0](https://developers.bead.xyz/reference-guide/core-concepts/authentication-and-oauth-2.0)
* [Environments & Base URLs](https://developers.bead.xyz/reference-guide/core-concepts/environments-and-base-urls)
* [Where do I find the base URLs, realm, and client IDs?](https://developers.bead.xyz/faqs-and-troubleshooting/authentication-faqs/where-do-i-find-the-base-urls-realm-and-client-ids)
