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

> ## Agent Instructions
> HEVN is payments software: an API and app over a Base smart wallet. HEVN is not a bank and holds no key to the wallet. Virtual accounts, fiat payins and fiat payouts are provided by partner banks, which hold fiat while it is in transit. Self-serve (the General tab): the person who controls the email signs for the wallet. Developers integrate /dapi/v1 in one of two ways. HEVN Connect (recommended, the HEVN Connect tab): the integrator's customer creates or links a HEVN account in a HEVN-hosted sign-in window on the integrator's site, the integrator's backend reads the linked account and books its payouts, and the account holder approves each payout in that window. External wallets (the External wallets tab, enabled per integrator): the integrator creates a client through the API, registers a wallet address the customer holds as an external account, and requests virtual accounts that deliver to that address. The customer's own wallet sends each transfer that funds a payout. The developer key signs for the integrator's wallet and its sub accounts and cannot sign for a client's wallet.
> Use HEVN's terms as written. A product is the region a client requests. A rail is the bank route HEVN picks for the product. A virtual account (bnk_) is the record a partner bank opens for a client. Account details are what a payer needs to send a bank transfer, returned in a field named requisites. A client (cl_) is a customer's account: linked to the integrator through Sign in with HEVN (POST /dapi/v1/connect/sessions, then POST /dapi/v1/clients/link), or created with POST /dapi/v1/clients for an external-wallets integration. An external account (acc_, kind external) is a wallet address the client holds and signs for. A sub account (acc_, kind sub) is a further wallet of the integrator's own account on Base, spent with the developer key. Write 'sub account' as two words. A contact is a saved destination. A beneficiary is the party that receives a fiat payout. Money leaving an account is a payout, whether it goes to a bank account or to a wallet.
> Do not name a bank, payment institution, card issuer, identity-verification vendor or stablecoin issuer. Say 'the partner bank'. Do not describe HEVN as licensed, regulated or insured.
> HEVN publishes no fee rates, spreads or minimums. Prices come from a quote on a specific payment. Direct pricing questions to HEVN and do not invent numbers.
> The API is at /dapi/v1 and takes a developer-key session plus an X-Hevn-Account header. Developer keys have an IP allowlist and no scopes. Remote transfers are at /api/v1/remote_spend_limit and take a remote transfer key (rsl_) in X-Api-Key, bounded by an onchain spend permission the account holder grants. The two credentials are separate and neither works on the other API. The HEVN CLI is discontinued.

# Quickstart

> Create a client, register its wallet address and request a virtual account that delivers to it in the sandbox.

Create one client, register a wallet address for it and receive one emulated bank payin on that address in the sandbox. Start by logging in with `POST /dapi/v1/auth/challenge` and `POST /dapi/v1/auth/token`.

## Before you start

1. Sign up at [`https://sandbox.gethevn.com`](https://sandbox.gethevn.com).
2. Open **Settings → Partner program → Developer** and create a developer key. Set its [IP allowlist](https://docs.gethevn.com/developers/authentication.md#the-ip-allowlist) to your machine's egress address.
3. Save the private key to `$HEVN_KEY_PEM` with mode `0600`.
4. Ask HEVN to [enable client creation](https://docs.gethevn.com/external-wallets/overview.md#access) for your sandbox account.
5. Create a wallet on Base Sepolia whose key you hold. It stands in for your customer's wallet. Export its address as `HEVN_WALLET`.
6. Set the environment and install the dependencies.

| Environment | API base URL | App | Chain |
| - | - | - | - |
| Sandbox | `https://sandbox-api.hevn.finance/dapi/v1` | `https://sandbox.gethevn.com` | Base Sepolia |
| Production | `https://api.hevn.finance/dapi/v1` | `https://app.gethevn.com` | Base |

Developer keys, clients and tokens are per environment.

The examples read these variables:

```bash theme={null}
export HEVN_API="https://sandbox-api.hevn.finance/dapi/v1"
export HEVN_EMAIL="integrator@example.com"
export HEVN_KEY_PEM="$HOME/.hevn/developer-key.pem"  # mode 0600, keep it out of your repo
export HEVN_CLIENT_ID="cl_7YQ2Kf3mN8"                # the client a call acts for
```

| Derived variable | Value |
| - | - |
| `HEVN_ACCESS_TOKEN` | The `accessToken` returned by [login](https://docs.gethevn.com/developers/authentication.md#sessions). |
| `HEVN_USER_ID` | Your `cl_…` id, the `userId` returned by login. |
| `HEVN_PUBLIC_KEY` | The base64 public key of the PEM, sent as `publicKey` to `POST /dapi/v1/payouts`. |

```bash theme={null}
export HEVN_PUBLIC_KEY=$(openssl ec -in "$HEVN_KEY_PEM" -pubout -outform DER 2>/dev/null \
  | base64 | tr -d '\n')
```

```bash Python theme={null}
python -m venv .venv && source .venv/bin/activate
pip install cryptography httpx
```

```bash Node theme={null}
# Node 20 or newer. Signing and HTTP use node:crypto and global fetch.
node --version
npm init --yes
```

```bash Go theme={null}
go mod init example.com/hevn
# Signing and HTTP use the standard library only: crypto/ecdsa, encoding/pem, net/http.
```

> [!NOTE]
>
> The sandbox runs on Base Sepolia with testnet tokens. A payout, escrow or payin is capped at `1`, and a faucet credit at `5` to a wallet holding less than `1`. The sandbox money routes take 60 calls per account per hour. See [Sandbox limits](https://docs.gethevn.com/developers/sandbox.md#limits).

## Steps

**1. Log in**

Run the login code in [Sessions](https://docs.gethevn.com/developers/authentication.md#sessions). Export `accessToken` as `HEVN_ACCESS_TOKEN`. The Python, Node and Go tabs use the [reference client](https://docs.gethevn.com/developers/reference/client.md).

**2. Create the client**

Call `POST /dapi/v1/clients` with the company's legal name and email. Do not send `X-Hevn-Account`.

```bash cURL theme={null}
curl -s -X POST "$HEVN_API/clients" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" \
  -H "Idempotency-Key: quickstart-client-1" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example Trading LLC","email":"ops@example-trading.example","phone":"+13125550142"}'
```

```python Python theme={null}
created = hevn.post("/clients", {
    "name": "Example Trading LLC",
    "email": "ops@example-trading.example",
    "phone": "+13125550142",
}, idempotency_key="quickstart-client-1")
client = hevn.acting_as(created["id"])
```

```javascript Node theme={null}
const created = await hevn.post("/clients", {
  name: "Example Trading LLC",
  email: "ops@example-trading.example",
  phone: "+13125550142",
}, { idempotencyKey: "quickstart-client-1" });
const client = hevn.actingAs(created.id);
```

```go Go theme={null}
created, err := api.Post("/clients", hevn.Body{
	"name":  "Example Trading LLC",
	"email": "ops@example-trading.example",
	"phone": "+13125550142",
}, hevn.IdempotencyKey("quickstart-client-1"))
client := api.ActingAs(created.Str("id"))
```

```json Response 202 theme={null}
{ "id": "cl_7YQ2Kf3mN8", "status": "provisioning", "name": "Example Trading LLC",
  "kybStatus": "notStarted", "pollUrl": "/dapi/v1/client", … }
```

Export the id as `HEVN_CLIENT_ID`. A retry with the same `Idempotency-Key` returns the same client. Fields: [Create a client](https://docs.gethevn.com/api-reference/accounts/create-a-client.md).

| Error | Cause |
| - | - |
| `403 client_creation_not_enabled` | HEVN has not enabled client creation for your account. |
| `400 account_scope_conflict` | The request has `X-Hevn-Account`. |
| `409 idempotency_key_reused` | The key was used with another body. |

**3. Register the address**

Call `POST /dapi/v1/client/accounts` with the client id in `X-Hevn-Account`.

```bash cURL theme={null}
export HEVN_ACCOUNT_ID=$(curl -s -X POST "$HEVN_API/client/accounts" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" \
  -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d "{\"chain\":\"base\",\"address\":\"$HEVN_WALLET\",\"label\":\"Treasury wallet\"}" | jq -r .accountId)
```

```python Python theme={null}
account = client.post("/client/accounts", {
    "chain": "base", "address": os.environ["HEVN_WALLET"], "label": "Treasury wallet",
})
```

```javascript Node theme={null}
const account = await client.post("/client/accounts", {
  chain: "base", address: process.env.HEVN_WALLET, label: "Treasury wallet",
});
```

```go Go theme={null}
account, err := client.Post("/client/accounts", hevn.Body{
	"chain": "base", "address": os.Getenv("HEVN_WALLET"), "label": "Treasury wallet",
})
```

```json Response 201 theme={null}
{ "accountId": "acc_9f2c1ab84d7e4f1fa3c65b0e7d9a2c41", "kind": "external", "asset": "USDC",
  "chain": "base", "address": "0x8ba1f109551bD432803012645Ac136ddd64DBA72", "balance": "0.0", … }
```

While HEVN reviews the client request, the call returns `404 account_not_found`. Repeat it with the same body. Rules and refusals are in [External accounts](https://docs.gethevn.com/external-wallets/external-accounts.md).

**4. Wait for the client**

Poll `GET /dapi/v1/client` every two seconds until `status` is `ready`.

```bash cURL theme={null}
curl -s "$HEVN_API/client" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" \
  -H "X-Hevn-Account: $HEVN_CLIENT_ID" | jq '{id, status, kybStatus}'
```

```python Python theme={null}
ready = poll_until(lambda: client.get("/client"),
                   lambda seen: seen["status"] != "provisioning")
```

```javascript Node theme={null}
const ready = await pollUntil(() => client.get("/client"),
  (seen) => seen.status !== "provisioning");
```

```go Go theme={null}
ready, err := hevn.PollUntil(
	func() (hevn.Payload, error) { return client.Get("/client") },
	func(seen hevn.Payload) bool { return seen.Str("status") != "provisioning" },
	2*time.Minute,
)
```

```json Response theme={null}
{ "id": "cl_7YQ2Kf3mN8", "status": "ready", "kybStatus": "notStarted", … }
```

The statuses are in [Statuses](https://docs.gethevn.com/developers/clients.md#statuses).

**5. Verify the client**

Write the KYB document with `PUT /dapi/v1/client/kyb` as in [Write the document](https://docs.gethevn.com/developers/clients.md#write-the-document). When it returns `ready: true`, call `POST /dapi/v1/client/kyb/complete`, then approve the application with `POST /dapi/v1/sandbox/kyb/status`.

```bash cURL theme={null}
curl -s -X POST "$HEVN_API/client/kyb/complete" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID"

curl -s -X POST "$HEVN_API/sandbox/kyb/status" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  -H "Content-Type: application/json" -d '{"status":"approved"}'
```

```python Python theme={null}
application = client.post("/client/kyb/complete")
kyb = client.post("/sandbox/kyb/status", {"status": "approved"})
```

```javascript Node theme={null}
const application = await client.post("/client/kyb/complete");
const kyb = await client.post("/sandbox/kyb/status", { status: "approved" });
```

```go Go theme={null}
application, err := client.Post("/client/kyb/complete", nil)
kyb, err := client.Post("/sandbox/kyb/status", hevn.Body{"status": "approved"})
```

In production HEVN reviews the application ([Track the application](https://docs.gethevn.com/developers/clients.md#track-the-application)).

**6. Request a virtual account**

Call `POST /dapi/v1/banks` with a product and the `accountId`, then poll `GET /dapi/v1/banks/{product}` with the same `accountId` until `status` is `active`.

```bash cURL theme={null}
curl -s -X POST "$HEVN_API/banks" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d "{\"product\":\"us\",\"accountId\":\"$HEVN_ACCOUNT_ID\"}"

export HEVN_BANK_ID=$(curl -s "$HEVN_API/banks/us?accountId=$HEVN_ACCOUNT_ID" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" | jq -r .id)
```

```python Python theme={null}
client.post("/banks", {"product": "us", "accountId": account["accountId"]})
bank = poll_until(lambda: client.get("/banks/us", {"accountId": account["accountId"]}),
                  lambda seen: seen.get("status") != "preparing")
```

```javascript Node theme={null}
await client.post("/banks", { product: "us", accountId: account.accountId });
const bank = await pollUntil(() => client.get("/banks/us", { accountId: account.accountId }),
  (seen) => seen.status !== "preparing");
```

```go Go theme={null}
_, err = client.Post("/banks", hevn.Body{"product": "us", "accountId": account.Str("accountId")})
bank, err := hevn.PollUntil(
	func() (hevn.Payload, error) {
		return client.Get("/banks/us", hevn.Query{"accountId": account.Str("accountId")})
	},
	func(seen hevn.Payload) bool { return seen.Str("status") != "preparing" },
	2*time.Minute,
)
```

```json Response theme={null}
{ "product": "us", "status": "active", "id": "bnk_5Hq2…", "accountId": "acc_9f2c…",
  "requisites": { … }, "blockers": [], … }
```

While `status` is `preparing`, read `blockers[]` ([What still blocks it](https://docs.gethevn.com/developers/virtual-accounts.md#what-still-blocks-it)). A product that cannot deliver to the address returns `409 account_destination_unsupported`.

**7. Emulate a bank payin**

Call [`POST /dapi/v1/sandbox/deposits`](https://docs.gethevn.com/developers/sandbox#mint-money) with the `bankId`. Do not send `accountId` or `token`.

```bash cURL theme={null}
curl -s -X POST "$HEVN_API/sandbox/deposits" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  -H "Idempotency-Key: quickstart-wire-1" -H "Content-Type: application/json" \
  -d "{\"amount\":\"1.00\",\"bankId\":\"$HEVN_BANK_ID\",\"remitter\":\"Payer Inc\"}"
```

```python Python theme={null}
credit = client.post("/sandbox/deposits",
                     {"amount": "1.00", "bankId": bank["id"], "remitter": "Payer Inc"},
                     idempotency_key="quickstart-wire-1")
```

```javascript Node theme={null}
const credit = await client.post("/sandbox/deposits",
  { amount: "1.00", bankId: bank.id, remitter: "Payer Inc" },
  { idempotencyKey: "quickstart-wire-1" });
```

```go Go theme={null}
credit, err := client.Post("/sandbox/deposits",
	hevn.Body{"amount": "1.00", "bankId": bank.Str("id"), "remitter": "Payer Inc"},
	hevn.IdempotencyKey("quickstart-wire-1"))
```

```json Response: 200 theme={null}
{ "depositId": "sbx_…", "status": "settled", "token": "USDC", "amount": "1.00", "currency": "USD",
  "accountId": "acc_9f2c…", "txHash": "0x08fa…", "transactionId": "txn_9e4…", … }
```

On `202`, repeat the request with the same `Idempotency-Key`. The testnet USDC is sent to `$HEVN_WALLET`.

**8. Read the ledger and balance**

Call `GET /dapi/v1/transactions` with `accountId`, then `GET /dapi/v1/client/accounts/{accountId}`.

```bash cURL theme={null}
curl -s "$HEVN_API/transactions?accountId=$HEVN_ACCOUNT_ID&limit=5" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  | jq '.items[] | {id, status, isIncome, accountId, to}'

curl -s "$HEVN_API/client/accounts/$HEVN_ACCOUNT_ID" \
  -H "Authorization: Bearer $HEVN_ACCESS_TOKEN" -H "X-Hevn-Account: $HEVN_CLIENT_ID" \
  | jq '{balance, syncedAt}'
```

```python Python theme={null}
rows = client.get("/transactions", {"accountId": account["accountId"], "limit": 5})["items"]
seen = client.get(f"/client/accounts/{account['accountId']}")
print(seen["balance"], seen.get("syncedAt"))
```

```javascript Node theme={null}
const { items: rows } = await client.get("/transactions", { accountId: account.accountId, limit: 5 });
const seen = await client.get(`/client/accounts/${account.accountId}`);
console.log(seen.balance, seen.syncedAt);
```

```go Go theme={null}
page, err := client.Get("/transactions", hevn.Query{"accountId": account.Str("accountId"), "limit": "5"})
seen, err := client.Get("/client/accounts/" + account.Str("accountId"))
fmt.Println(seen.Str("balance"), seen.Str("syncedAt"))
```

`balance` is refreshed when the stored value is older than a minute. `GET /dapi/v1/client/balance` has no row for the account.

To pay out from the address, fund it with testnet USDC and follow [Payouts](https://docs.gethevn.com/external-wallets/money-movement.md#payouts). The sandbox faucet route does not credit an external account.

> [card] [Next: External accounts](https://docs.gethevn.com/external-wallets/external-accounts.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.