Start here
Installation
Set up the server-side Node.js SDK or call Yanola's versioned REST API directly.
What this guide covers
- Install the ESM-first @yanola/whatsapp package in a supported Node.js service.
- Keep SDK and REST API usage in server-only code.
- Configure the API key through your deployment platform's secret storage.
Requirements
- Node.js 20 or newer.
- A server-side ESM application, worker, or route handler.
- A Yanola API key created for the target Agent Project and environment.
The SDK imports Node.js runtime APIs and holds an Agent Project credential. Browser, React client-component, and mobile application usage is not supported.
Install the beta package
The SDK is currently pre-1.0. Pin the beta dist-tag and review the changelog before upgrading because breaking SDK changes may occur before 1.0.
npm install @yanola/whatsapp@betapnpm add @yanola/whatsapp@betayarn add @yanola/whatsapp@betaInitialize one reusable client
Create the client once in a server-only module and reuse it. By default it calls https://api.yanola.ai/v1, times out after 30 seconds, and retries eligible failures up to two times.
import { WhatsAppClient } from "@yanola/whatsapp"
const apiKey = process.env.YANOLA_API_KEY
if (!apiKey) {
throw new Error("Missing YANOLA_API_KEY")
}
export const yanola = new WhatsAppClient({
apiKey,
timeoutMs: 30_000,
maxRetries: 2,
})| Option | Default | Purpose |
|---|---|---|
apiKey | Required | Yanola API key from YANOLA_API_KEY. |
baseUrl | https://api.yanola.ai/v1 | Override only for an approved local or test deployment. |
timeoutMs | 30000 | Timeout applied to each request attempt. |
maxRetries | 2 | Retries for network, timeout, rate-limit, and eligible server failures. |
headers | None | Additional default headers; cannot replace authorization or request IDs. |
Framework placement
| Runtime | Use the SDK in | Avoid |
|---|---|---|
Next.js | Route handlers, Server Actions, server-only modules, and jobs | Client Components and NEXT_PUBLIC_ variables |
Express or NestJS | Backend services, controllers, and workers | HTML templates and browser-delivered configuration |
Queues and cron jobs | Worker processes with secret-manager access | Serialized job payloads containing API keys |
Serverless | Server functions with encrypted environment secrets | Edge runtimes without Node.js compatibility |
Use the REST API without the SDK
All SDK operations use the same versioned /v1 contract. Send the Yanola API key as Bearer credentials when calling REST directly.
curl "https://api.yanola.ai/v1/senders" \
--header "Accept: application/json" \
--header "Authorization: Bearer $YANOLA_API_KEY"Use the Authorization header. Query strings can be captured by browser history, proxies, analytics, and access logs.
Upgrade safely
- Read @yanola/whatsapp/CHANGELOG.md before changing beta versions.
- Run your TypeScript build and integration tests after an upgrade.
- Keep the REST /v1 base URL unchanged unless Yanola provides a migration path.