# API access (v2)

> Get an API key, keep it on your backend, and know what it can and cannot do.

> API v2 is deprecated. It stays supported, but new integrations should use the [Khalani API](/) (v3). See [Migrate to v3](/v2/migrate/).

Khalani issues API keys during onboarding. There is no self-serve sign-up. Your account comes with:

- **Your commercial terms**: your commission in basis points and the wallet it is paid to.
- **Your order deadline** (`orderTtl`): how long each order stays open after the build. It lets you override the default deadline and impose your own: ask Khalani to set it. Every build signs it into its order.

Read all of them with `GET /v2/params`.

## Send the key from your backend

Send the key in the `X-API-Key` header:

```bash
curl -s https://api.hyperstream.dev/v2/params -H "X-API-Key: $KHALANI_API_KEY"
```

Call the API from your backend only. Anyone who has your key can use it, so keep it out of browser code and app bundles.

| Route | Auth |
|---|---|
| `GET /v2/params` | API key |
| `GET /v2/quote` | API key |
| `POST /v2/build` | API key |
| `GET /v2/orders` | API key |
| `POST /v2/orders/{orderId}/cancel` | API key |
| `GET /v2/orders/{orderId}` | Public |
| `GET /v2/health` | Public |

## What a key can do

One key is your whole integration. It can build orders under your name, list every order you built along with each depositor and recipient, and read your terms.

It cannot move funds. A deposit is a transaction the user signs, and a cancel needs the user's signature.

## Authentication errors

| Status | `error` | Meaning |
|---|---|---|
| `401` | `X-API-Key required` | The header is missing. |
| `403` | `Unknown or inactive integrator` | The key is not recognised. |
| `403` | `Integrator <integratorId> is not enabled on the integrator registry` | The key is valid, but your account is disabled or not set up yet. |
| `403` | `Integrator <integratorId> owes a commission with no wallet configured` | Your terms are invalid. |
| `403` | `Integrator <integratorId> carries a fee at or above 100%` | Your terms are invalid. |

A `403` is always about your account, so retry logic can treat every `403` as final. Contact Khalani through your onboarding channel to resolve one.

## Check that you are ready

`GET /v2/params` is the readiness check for your key. It reflects your account and keeps working during maintenance, subject to its [per-IP rate limit](/v2/guides/rate-limits/). A `200` means your key works and your account is enabled; a `403` names the problem. Back off and retry a `429`.
