SDK: @hevia/sdkBeta
A typed TypeScript client generated from the OpenAPI document: pagination, safe retries, webhook verification, OAuth.
The package lives in the repository (packages/sdk) and is not on npm yet. It has no runtime dependencies and runs on Node 22 or newer.
Install
In the monorepo it is the workspace package @hevia/sdk:
{ "dependencies": { "@hevia/sdk": "*" } }Outside the monorepo, copy packages/sdk until the first npm release. The package exports TypeScript source; run it with Node 22.6+ (--experimental-strip-types) or any bundler.
Client
import { HeviaClient } from "@hevia/sdk";
const hevia = new HeviaClient({ apiKey: process.env.HEVIA_KEY!, version: "2026-11-09" });| Option | Meaning |
|---|---|
apiKey / accessToken / tokenProvider | Exactly one. tokenProvider is an async function asked before every attempt (use it with OAuth). |
baseUrl | Default https://hevia.app/api/v1. |
version | Sent as Hevia-Version. |
maxRetries | Default 3. |
timeoutMs | Per attempt, default 30 000. |
Every endpoint is a method: contacts.list / listAll / create, conversations.list / get, requests.list / get, deals.list / get / create, quotes.list / get, tasks.list / create / update, objects.list / listTypes, customerSuccess.listHealth, events.send. The API reference shows the call for each endpoint.
Errors
| Class | When |
|---|---|
AuthenticationError | 401 |
PermissionError | 403, code is insufficient_scope or plan_required |
NotFoundError | 404 |
InvalidRequestError | 400, 413, 422; field names the culprit |
ConflictError | 409 |
RateLimitError | 429; retryAfter in seconds |
ApiError | 5xx and anything unexpected |
ConnectionError | No answer: network or timeout |
Retries
Network errors, 429 (honouring Retry-After) and 5xx are retried with exponential backoff and jitter. A write is retried only when it carries an Idempotency-Key; for POST /contacts, /deals and /tasks the client creates one and reuses it on every attempt. POST /events and PATCH /tasks/{id} are never retried automatically.
Regenerate
npm run snapshot -w @hevia/sdk # openapi.json and events.json from the product
npm run generate -w @hevia/sdk # src/generated/*
npm test -w @hevia/sdkA test fails when the committed snapshots differ from the live OpenAPI document or the event catalog, so the SDK cannot fall behind. More in SDK examples.