---
title: TypeScript SDK
description: The generated TypeScript SDK — dated imports, auto-retry, client idempotency, typed errors.
---

# TypeScript SDK

Current API surface: **2026-09** — the version in the reference header, in your import path, and in the SDK's dated entry are the same greppable string. New surfaces ship as new dated entries; existing ones never change under you.

```bash
pnpm add @vortex-api/vortex
```

```ts
import {
  createVortex,
  getMerchantAccountSettlements,
} from "@vortex-api/vortex/2026-09";

const vortex = createVortex({ apiKey: process.env.VORTEX_API_KEY });

const { data, error } = await getMerchantAccountSettlements({
  client: vortex,
  path: { merchantAccountId: "ma_..." },
  query: { environment: "sandbox", merchantAccountId: "ma_..." },
});
```

The key IS the environment (`vp_test_` = sandbox, `vp_live_` = production) — there is no environment option to misconfigure.

## Built into the transport

- **Auto-retry** on 408/429/5xx and network failures — bounded attempts, exponential backoff, `Retry-After` honored. Disable with `retry: { maxAttempts: 1 }`.
- **Client idempotency**: mutating calls carry a generated `Idempotency-Key`, constant across retries, unless you set your own — retries are safe by construction.
- **Errors that identify themselves**: `readVortexError` narrows the `{ error }` result into a `VortexApiError` carrying `status`, `code`, `requestId`, and `docsUrl` — a pasted message alone is enough to debug.
- **Pagination**: `paginate(fetchPage, params)` walks cursor pages until the server reports the end. Operation functions return `{ data, error, response }`, so adapt the page payload first:

```ts
import { paginate, type CursorPageResult } from "@vortex-api/vortex/2026-09";

for await (const settlement of paginate(async (o) => {
  const { data, error } = await getMerchantAccountSettlements({
    client: vortex,
    path: { merchantAccountId },
    query: { environment: "sandbox", merchantAccountId, ...o },
  });
  if (error !== undefined) throw new Error(JSON.stringify(error));
  // `data.data` is the list payload: { items, nextCursor, hasMore }.
  return data.data as CursorPageResult<Settlement>;
}, {})) {
  // one settlement per iteration
}
```

## Local source

- Generated package: `sdks/typescript` — name `@vortex-api/vortex`
- Generator: `@hey-api/openapi-ts` plus the Vortex transport layer

Regenerate with `pnpm run sdk:generate`.
