Skip to navigation

TypeScript SDK

The Partner API, events and webhooks for Node.js.

Requirements

RequirementDetail
Node.js22 or later — supported 22, 24 and 26; 24 LTS recommended. Node.js 20 and older are not supported.
Runtime dependenciesNone
Module formatsES modules and CommonJS

Install

Coming at general availability. Until then, this page shows the requirements and how the SDK is used.

Configure

client.ts
import { EvvaPartnerClient } from '@evvahub/partner-sdk';
export const evva = new EvvaPartnerClient({
baseUrl: 'https://api.evvahub.com',
credentials: {
method: 'client_secret_basic', // or 'client_secret_post'
clientId: process.env.EVVA_CLIENT_ID!,
clientSecret: process.env.EVVA_CLIENT_SECRET!,
},
});

private_key_jwt keeps every secret inside your infrastructure — register the public key in the Partner Hub and keep the private key in your secret manager:

private_key_jwt
credentials: { method: 'private_key_jwt', clientId, privateKey: pem, keyId: 'key-2026-12', algorithm: 'ES256' }
Create an ES256 key pair
openssl ecparam -name prime256v1 -genkey -noout | openssl pkcs8 -topk8 -nocrypt -out evva-app.pem
openssl pkey -in evva-app.pem -pubout -out evva-app.pub.pem

Each token request signs a fresh assertion. To rotate, register the new public key, switch keyId and privateKey, then remove the old key. See Requesting tokens.

First calls

first-calls.ts
const me = await evva.app.me();
console.log(me.application.name, me.environment, me.scopes);
const { items } = await evva.accounts.list();
for (const account of items) console.log(account.creatorId, account.scopes);

Every operation of the API reference is reachable and typed — request bodies, queries, path parameters and answers — through the resource helpers or evva.call('<operationId>', …). Lists have async iterators (iterate()).

Receive events and reply

bot.ts
import { EvvaPartnerClient, isEventType } from '@evvahub/partner-sdk';
const me = await evva.app.me();
const stream = evva.eventStream({
consumerId: 'my-bot',
applicationId: me.application.id, // the application's id — never the OAuth client id
handler: async (event) => {
if (!isEventType(event, 'message.received')) return;
await evva.messages.sendText(event.creatorId!, event.data.conversationId, 'Thanks — we will get back to you!', {
idempotencyKey: `reply-to-${event.data.messageId}`,
});
},
});
evva.shutdownOnSignals();
await stream.start();

Give a production consumer durable stores: FileCheckpointStore / FileDedupStore on one host, or your own CheckpointStore and DedupStore on a shared database. The in-memory stores are for tests.

You wantUse
Low latency and no lossevva.eventStream({…}) — realtime plus feed catch-up, one handler, shared deduplication
Batch, cron or replayevva.feedConsumer({…}).drain()
A long-running feed consumerevva.feedConsumer({…}).start()

Errors

ErrorWhen
ValidationError400
AuthError401
PermissionError403
NotFoundError404
ConflictError, IdempotencyConflictError409
CursorExpiredError410 CURSOR_EXPIRED
RateLimitedError429 — retryAfterMs, level
ServerError, NetworkError5xx, no response
ApprovalRequiredError202 APPROVAL_REQUIRED — approvalId, expiresAt. Nothing was done; see Approvals.

Webhooks

webhooks.ts
import { FileDedupStore, WebhookHandler } from '@evvahub/partner-sdk';
const webhooks = new WebhookHandler({
secret: [process.env.EVVA_WEBHOOK_SECRET!, process.env.EVVA_WEBHOOK_SECRET_PREVIOUS!].filter(Boolean),
dedupStore: await FileDedupStore.open('./.evva/dedup.log'),
onEvent: async (event) => queue.push(event),
});
const result = await webhooks.handle({ headers: req.headers, body: rawBody }); // the RAW body
res.status(result.status).end(); // 204 handled/duplicate · 401 signature · 400 payload · 500 retry me

Polling statuses that have no event

waiters.ts
const { state } = await evva.media.waitUntilProcessed(creatorId, mediaAssetId); // ready | failed | unavailable
const post = await evva.content.waitUntilPublished(creatorId, contentId);

Waiters back off with full jitter (1 s doubling to 30 s), honour Retry-After, and give up after 10 minutes.

Next steps