Environments
Production and sandbox base URLs, key separation, and environment isolation.
halfin separates test and live data at the API-key level. A test key only sees test invoices, balances, and webhook deliveries. A live key only sees live resources. The key prefix determines the environment — no query parameter needed.
Base URLs
| Environment | Base URL |
|---|---|
| Production | https://api.thehalfin.com |
| Sandbox | https://api-sandbox.thehalfin.com |
The hosted checkout page is at https://checkout.thehalfin.com/{invoiceId}?token=....
Using the SDK
import { createHalfin } from '@halfin/sdk-merchant';
// Sandbox
const sandboxClient = createHalfin({
apiKey: process.env.HALFIN_API_KEY!, // sk_test_...
baseUrl: 'https://api-sandbox.thehalfin.com',
});
// Production
const prodClient = createHalfin({
apiKey: process.env.HALFIN_API_KEY!, // sk_live_...
baseUrl: 'https://api.thehalfin.com',
});Switching environments
Pass an environment query parameter to public endpoints when the response depends on live vs. test offerability:
curl -G https://api-sandbox.thehalfin.com/v1/currencies \
--data-urlencode "environment=test"Going live checklist
Before switching to a live key:
- Verify webhook signatures are working in the sandbox.
- Confirm idempotency keys are stable across retries.
- Test payout creation and completion webhooks end-to-end.
- Rotate to a live key scoped to only the permissions your integration needs.