Skip to content

Changelog

All notable changes to this project are documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

  • retryMessageSends option on WhatsAppClientConfig (default false). Set it to true to retry message sends on 5xx, network and timeout failures as well as 429. Meta documents no idempotency for sends, so a retry can deliver a message twice.
  • AGENTS-CONSUMER.md is included in the npm package.
  • CI check of the packed package with Are the Types Wrong for the ., ./web and ./testing entry points.
  • Message sends (POST {phoneNumberId}/messages: every sender, sendRaw, mark-as-read and typing indicators) now retry on HTTP 429 only. A transient 5xx on a send now surfaces as an error by default, as do network failures and timeouts. Previously these were retried, which could send the same message twice. Set retryMessageSends: true to get the old behaviour. GET, DELETE and other POST requests keep the existing retry policy.
  • The Cloudflare Workers example now uses @cloudflare/vitest-plugin, the renamed successor of the deprecated @cloudflare/vitest-pool-workers.
  • TypeScript projects using moduleResolution: node10 could not resolve types for @solvejet/whatsapp-cloud-api/web and /testing. package.json now has typesVersions for both. Runtime resolution is unchanged.
  • A request aborted through its signal is no longer retried.
  • A 200 response with a body that is not valid JSON is no longer retried.
  • createWebhookHandler: an event-driven webhook handler. handleVerification answers the handshake, handleDelivery(rawBody, signature) and handleRequest(request) verify X-Hub-Signature-256 over the raw bytes, parse the delivery and call handlers registered with on. Options: appSecrets (one secret or an array for rotation), verifyToken, resolveTenant, allowUnsigned, maxBodyBytes, maxEventAgeSeconds, dedupe, dedupeKey, ackMode, waitUntil, retryOnHandlerError, concurrency and onError.
  • Typed events and parseWebhookEvents: message, status, error, call, flow, template, account, group and unknown, each with a ctx (WABA ID, field, time, metadata, matching contact). Fields the SDK does not model arrive as unknown with the untouched value.
  • createMemoryDedupe and the WebhookDedupe interface, with default keys message:<id> and status:<id>:<status>.
  • @solvejet/whatsapp-cloud-api/web entry point with the handler, parsers, dedupe and verifySignatureAsync. It uses Web Crypto and imports nothing from node:*, so it runs on Cloudflare Workers, Deno, Bun and Node 20+ (all run in CI). Vercel Edge is documented but not run in CI.
  • @solvejet/whatsapp-cloud-api/testing entry point: signWebhookBody, buildWebhookPayload and createTestRequest for testing handlers in-process.
  • Incoming message types order, unsupported, edit and revoke, and interactive.type values product and call_permission_reply.
  • Helpers isKnownMessage, getUserKey and isStale.
  • verifySignature and WebhookHandler accept an array of app secrets, so an old and a new secret can both be valid during rotation.
  • allowUnsigned option for WebhookHandler and createWebhookHandler.
  • CI jobs that run the built web entry on Deno, Bun and Cloudflare workerd, and a Node 20 smoke test of every entry point as ESM and CJS.
  • Examples rewritten on createWebhookHandler, an edge-runtime example for Cloudflare Workers, a lower-level example, and documentation pages for the handler, edge runtimes and testing.
  • The IncomingMessage union has new members (order, unsupported, edit, revoke), and interactive.type is wider. Code that checks a switch on message.type for exhaustiveness with a never assignment no longer compiles until it handles the new cases or has a default branch.
  • Accepting a webhook body without an appSecret now emits a one-time process warning (WHATSAPP_WEBHOOK_UNSIGNED, or console.warn where process.emitWarning is missing). Behaviour is otherwise unchanged. Set allowUnsigned: true to silence it.
  • verifySignature and WebhookHandler now accept an array for the app secret (a widening). Version 1.3.x returned false or threw for an array. An empty array, an array with an empty string and an array with no matching secret still fail closed.
  • package.json exports uses separate types conditions for import and require for every entry point, and adds ./web and ./testing.
  • Accepting unsigned deliveries without allowUnsigned: true. Version 2.0 will require an explicit opt-out; set appSecret (or appSecrets) now.
  • Documentation site at https://solvejet.github.io/whatsapp-cloud-api/, built from the README and docs/, with how-to guides for webhook signature verification, the hub.challenge handshake, templates, media and rate limits, framework recipes, and a generated API reference. It is deployed to GitHub Pages from master.
  • The package homepage now points to the documentation site, so the npm page links to it.
  • Webhook verification now fails closed on a bad secret. verifySignature returns false (it never throws) when the app secret is not a non-empty string, so an empty key can no longer validate a signature. verifyWebhook and verifyWebhookQuery return 403 when the expected verify token is empty or not a string.
  • The WebhookHandler constructor throws WhatsAppWebhookError when appSecret or verifyToken is present but undefined, empty or not a string, so an unset environment variable no longer silently disables verification. Omitting the appSecret key entirely still means no signature enforcement, as documented.
  • The JSON SyntaxError is no longer attached as cause on “not valid JSON” errors, because its message embeds a fragment of the request body.
  • WebhookHandler.parse and parseWebhook reject string and byte bodies larger than 3 MiB (Meta’s documented maximum) before parsing. Configure it with the new maxBodyBytes option (WebhookHandlerConfig.maxBodyBytes, ParseWebhookOptions.maxBodyBytes); false disables the check.
  • Trailing slashes of baseUrl are now trimmed in linear time instead of with a backtracking regular expression.

  • extractMessages and extractStatuses no longer throw RangeError on arrays of about 125,000 or more elements, skip non-object elements of messages and statuses, and treat non-array changes and non-object entry items as empty instead of throwing a TypeError.

  • Byte bodies are decoded with TextDecoder (ignoreBOM). A plain Uint8Array body previously decoded to a comma-separated list of numbers and failed with “not valid JSON”.

  • verifySignature returns false instead of throwing for an unsupported body type such as null, a number or an ArrayBuffer, which used to throw a TypeError (an ArrayBuffer is now supported).

  • The README and the Express, Next.js, Hono and Fastify examples now parse before responding, send text/plain for the verification challenge, return 401 only for a bad signature and 200 (logged) for a signed payload that cannot be parsed, and the Next.js example no longer blocks on awaiting every message in turn.

  • InteractiveNfmReply.name documents flow for Flows responses and address_message for address messages.

  • Behavior change: extractMessages and extractStatuses (and so WebhookHandler.parse) now only read changes whose field is messages, or whose field is not a string. Call status events from the calls field (RINGING, ACCEPTED, REJECTED) are no longer returned as MessageStatus, and a messages array under another field is ignored. Read those payloads from parsed.raw.
  • WebhookHandler.isValid, verifyOrThrow, parse, verifySignature and parseWebhook accept Uint8Array (including Buffer) and ArrayBuffer raw bodies in addition to strings. New exported types WebhookRawBody, ParseWebhookOptions and WebhookMessageReferral.
  • Webhook types gain optional fields only: the played status, recipient_type, recipient_participant_id, recipient_identity_key_hash and biz_opaque_callback_data on statuses, pricing.type and pricing.subtype, href on webhook errors, time on entries, identity_key_hash on contacts, forwarded, frequently_forwarded and referred_product on message context, a Click to WhatsApp referral and errors on incoming messages, media url, sticker animated and location.url. reaction.emoji stays typed string although Meta omits it when a reaction is removed; check it at runtime.
  • Business-scoped user ID (BSUID) and username support. Webhook types gain optional user_id, parent_user_id and profile.username on contacts, from_user_id, from_parent_user_id and group_id on incoming messages, recipient_user_id and recipient_parent_user_id on statuses, and a system message type (SystemIncomingMessage) for phone number and BSUID changes.
  • Every message sender accepts a { bsuid } recipient (BsuidRecipient, MessageRecipient). It is sent as recipient with to omitted. Phone-number strings work as before. SendMessageResponse.contacts[] gains optional user_id and parent_user_id.
  • client.messages.sendRaw(body, options?) posts an arbitrary body to {phoneNumberId}/messages, adds messaging_product: 'whatsapp' when absent, and takes an optional phoneNumberId (SendRawOptions) and a response type parameter.
  • examples/ with Express, Next.js App Router, Hono and Fastify webhook servers and a send script. Each answers the verify-token handshake and verifies the signature against the raw body.
  • README sections for the quickstart, comparison with alternatives, raw-body webhook troubleshooting, BSUIDs, sendRaw and runtime support. Template, Flows, Block, Calling and error-handling reference moved to docs/.
  • The default Graph API version is now v26.0 (was v23.0). apiVersion is still configurable.
  • wa_id, from and recipient_id stay typed string even though Meta may omit them in some username-based events. A future major version may make them optional.
  • The Python and Rust ports line from the README roadmap.
  • Documentation: added the Calling media plane (WebRTC/SIP) to the README roadmap — optional future helpers for the real-time media layer that is currently the caller’s responsibility (the Calling REST signaling and settings are implemented in client.calls).
  • Flows management via client.flows (WABA-scoped, defaults to the configured businessAccountId): create, list, get, update, updateJson, publish, deprecate, delete, listAssets, and getPreview. create validates a non-empty name and a non-empty categories array client-side before sending, and every flow-id method validates a non-empty flowId; update requires at least one editable field. updateJson uploads the Flow JSON as a multipart FLOW_JSON asset (a Blob, Uint8Array, or string wrapped as an application/json Blob) with no manual Content-Type. getPreview requests fields=preview.invalidate(<bool>). Note: only DRAFT flows are deletable. New exported types Flow, FlowList, FlowCategory, FlowStatus, FlowValidationError, CreateFlowPayload, CreateFlowResponse, UpdateFlowPayload, UpdateFlowJsonOptions, UpdateFlowJsonResponse, FlowAsset, FlowAssetList, FlowPreview, FlowJsonInput, ListFlowsOptions, and GetPreviewOptions, plus the FlowsResource class.
  • Block API via client.blocks (phone-number-scoped, defaults to the configured phoneNumberId): block, unblock, and list. block/unblock accept up to 1000 users per call and reject an empty or over-limit array with WhatsAppValidationError before any request. Note: unblock is a DELETE with a JSON body (sent correctly by the HTTP core), only users who messaged the business in the last 24 hours can be blocked, and per-user failures surface in block_users.failed_users even when the overall call succeeds. New exported types BlockedUser, FailedBlockUser, BlockUsersResponse, BlockedUserList, and ListBlockedUsersOptions, plus the BlocksResource class.
  • Calling settings and lifecycle via client.calls (phone-number-scoped, defaults to the configured phoneNumberId): getSettings, updateSettings, initiate, preAccept, accept, reject, and terminate. updateSettings sends { calling: {...} } with camelCase→snake_case mapping and passes callHours/sip through unchanged; the lifecycle methods POST to {id}/calls with the matching action. Scope note: the WhatsApp Business Calling API SDP/WebRTC (and SIP) media plane is OUT OF SCOPE. This SDK wraps the REST signaling + settings endpoints only — the caller owns the WebRTC/SIP media stack, and SDP offers/answers are passed through as opaque strings (never parsed or validated). New exported types CallSdp, CallingSettings, PhoneNumberSettings, CallingSettingsUpdate, UpdateCallSettingsPayload, InitiateCallOptions, and CallResponse, plus the CallsResource class.
  • Expanded the npm package description and keywords to improve discoverability on npm and in search/LLM results — the metadata now names the concrete capabilities (send messages, media, templates, interactive messages; verify webhooks; manage phone numbers, WABAs, and templates) and the runtime (zero dependencies, native fetch, Node.js 20+). No code or API changes.
  • Documentation (README): added a “Why this library” positioning section, a “What you can do” capability table, and an FAQ answering common questions (how to send a message/template, how to verify webhooks, dependencies, supported Node.js versions, official-SDK clarification). Existing usage sections are unchanged.

First stable release. The public API is now considered stable and this project follows Semantic Versioning: breaking changes will only ship in a new major version.

Version 1.0.0 is skipped: a 1.0.0 was published to npm long before this SDK’s current line and later unpublished, and npm permanently reserves unpublished version numbers. 1.0.1 is therefore the first stable (1.x) release on npm.

No functional changes from 0.5.0 — this release marks the existing feature set as stable:

  • Outbound messaging — text, media (image/video/audio/document/sticker), location, contacts, templates, interactive (buttons, lists, CTA URL, flow, location request, product, product list, address message), reactions, mark-as-read, and typing indicator; every sender supports reply threading via replyToMessageId.
  • Inbound webhooks — GET verification handshake, constant-time X-Hub-Signature-256 validation, and typed parsing of incoming messages (including nfm_reply) and status updates.
  • Media lifecycle — upload, URL resolution, download, and delete.
  • Phone number & WABA management — client.phoneNumbers and client.waba.
  • Message-template management — client.templates (list/get/create/edit/delete).
  • Typed errors — the full error hierarchy plus the WhatsAppErrorCode constants map.
  • Client-side validation of documented API limits, raised before the request.
  • Documentation updated to reflect stable 1.x status (README status note and SECURITY supported-versions table).
  • Message-template management via client.templates: list (GET {WABA_ID}/message_templates with optional fields, limit, name, status, category, language, and after/before paging cursors), get (GET {TEMPLATE_ID} with optional field selection), create (POST {WABA_ID}/message_templates), edit (POST {TEMPLATE_ID} for the editable category/components/messageSendTtlSeconds fields; name and language are immutable and editing an approved template resets it to PENDING), and delete (DELETE {WABA_ID}/message_templates?name=..., optionally scoped to one version via hsm_id). The list/create/delete methods accept an optional trailing businessAccountId and fall back to the configured businessAccountId; get/edit are scoped by a required template id. create validates the documented hard limits client-side before sending: name is lowercase alphanumeric plus underscores and at most 512 chars, a non-empty language and a valid category are required, components must be non-empty with exactly one BODY and at most one each of HEADER/BODY/FOOTER, BODY text ≤ 1024, HEADER/FOOTER text ≤ 60, and a BUTTONS component holds at most 10 buttons.
  • New exported types for template management: TemplateCategory, TemplateStatus, TemplateParameterFormat, MessageTemplateComponent (the management-side component union, aliased to avoid colliding with the send-side TemplateComponent), TemplateButton, TemplateNamedParamExample, MessageTemplate, CreateTemplatePayload, EditTemplatePayload, TemplateList, CreateTemplateResponse, plus the TemplatesResource class and its ListTemplatesOptions/DeleteTemplateOptions option types.
  • Ergonomic Graph error-code constants via the exported WhatsAppErrorCode map and its WhatsAppErrorCodeValue type, so callers can compare err.code against named constants (e.g. WhatsAppErrorCode.RE_ENGAGEMENT_MESSAGE) instead of magic numbers. The map covers the common auth, permission, rate-limit, re-engagement, template, media, and phone-number codes, and is now the single source of truth for the auth/rate-limit/re-engagement code sets used by errorFromResponse — error-class mapping behavior is unchanged.
  • Phone-number management via client.phoneNumbers: get (phone number details with optional field selection), requestVerificationCode and verifyCode (the SMS/voice verification flow), register and deregister (Cloud API registration with a six-digit PIN and optional data-localization region), setTwoStepPin (set/change the two-step PIN; there is no API to disable it), and getBusinessProfile/updateBusinessProfile for the WhatsApp Business Profile. Each method accepts an optional trailing phoneNumberId override and falls back to the configured phoneNumberId. New exported types PhoneNumber, BusinessProfile, BusinessProfileUpdate, BusinessProfileVertical, RequestVerificationCodeOptions, and RegisterOptions.
  • WhatsApp Business Account (WABA) management via client.waba: get (account details), listPhoneNumbers (the numbers owned by the account, with paging), listSubscribedApps, subscribeApp, and unsubscribeApp. Each method accepts an optional trailing businessAccountId override and falls back to the configured businessAccountId. New exported types Waba, SubscribedApp, SubscribedAppList, PhoneNumberList, Paging, PagingCursors, ListPhoneNumbersOptions, and the shared SuccessResponse.
  • npm publish failed provenance validation with E422 because package.json URLs used the lowercase owner solvejet while the signed provenance (from the GitHub OIDC claim) uses the canonical SolveJet; npm requires repository.url to match the provenance exactly, case-sensitively. Corrected repository.url, homepage, bugs.url, and the contributor URL to SolveJet. This is the first version actually published to npm with provenance; 0.3.0 was tagged and released on GitHub but never reached npm due to this error.

Note: 0.3.0 was tagged and released on GitHub but never published to npm — its publish failed provenance validation (see 0.3.1). The features below ship in 0.3.1.

  • Typing indicator via client.messages.sendTypingIndicator(messageId, phoneNumberId?): marks an inbound message as read and shows a typing_indicator of type text to the user (dismissed when you send a message or after about 25 seconds). The existing markAsRead signature is unchanged.
  • Interactive address message via client.messages.sendAddressMessage (supported in India and Singapore): a typed AddressMessagePayload (body, required country of IN/SG, optional pre-filled values, savedAddresses, validationErrors, plus the shared header/footer) whose camelCase fields map to the snake_case API shape and are serialized into the JSON-encoded action.parameters string the API requires. Client-side validation rejects a missing/unsupported country, an in_pin_code/sg_post_code longer than 6 characters, and over-limit body/footer/header lengths. New exported types AddressMessagePayload, AddressMessageValues, and AddressMessageSavedAddress.
  • Inbound parsing for address submissions: the interactive webhook union now carries nfm_reply (Native Flow Message reply) with name, the RAW response_json string (left unparsed so a malformed payload never throws — callers JSON.parse it), and an optional body. New exported type InteractiveNfmReply.
  • Release workflow: npm OIDC trusted publishing now works end to end. The publish was failing with a misleading ENEEDAUTH; the actual cause was a case mismatch in the npm trusted-publisher config (solvejet vs the canonical GitHub owner SolveJet), which made npm’s token exchange return 404 package not found. The workflow now uses Node 24’s bundled npm, keeps registry-url while stripping the empty _authToken line setup-node writes, never sets NODE_AUTH_TOKEN, and gained a workflow_dispatch trigger for manual re-runs. Trusted-publisher field names are case-sensitive and must match the GitHub OIDC claims exactly.
  • Media API via client.media: upload (multipart upload of a Blob/File or raw bytes with an explicit content type, returning a reusable media id), getUrl (typed MediaInfo with a short-lived download URL), download/downloadByUrl (fetch the bytes as a Uint8Array with the bearer token and a User-Agent), and delete. Each method accepts an optional phoneNumberId override.
  • HTTP core support for the media lifecycle: multipart FormData request bodies (no manual Content-Type, so fetch sets the boundary), binary responses (responseType: 'binary' returning a Uint8Array), absolute http(s) download targets used verbatim instead of the base URL, and an optional User-Agent header. Non-idempotent multipart uploads run as a single attempt (an unreplayable body is never retried); idempotent GET/DELETE and downloads still follow the retry policy. Error responses always parse the Graph envelope and throw a typed error — binary callers never receive partial bytes on failure.
  • A dependency-audit CI job that runs pnpm audit --audit-level high, failing the build only on high/critical advisories.
  • Upgraded vitest and @vitest/coverage-v8 to v5, resolving the transitive tinypool critical advisories (GHSA-85c8-ppgw-ccpr, GHSA-5gmw-xhrv-c9v3); vitest 5 no longer depends on the affected tinypool.
  • CI dev-tooling checks (lint, typecheck, test, build) now run on Node 22 and 24, since vitest 5 requires Node >= 22.12. The published package continues to support Node 20 (engines.node stays >=20), verified by a dedicated job that imports the built ESM and CJS artifacts on Node 20.
  • Project foundation: TypeScript 6 toolchain, tsup dual ESM/CJS build, vitest, ESLint 10 flat config, and Prettier.
  • Minimal WhatsAppClient skeleton pinned to Graph API v23.0.
  • HTTP core built on native fetch/AbortController with per-attempt timeout, retries on 429/5xx/network errors using jittered exponential backoff (honoring Retry-After), and a typed error hierarchy (WhatsAppApiError, WhatsAppAuthenticationError, WhatsAppRequestError, WhatsAppValidationError).
  • Typed outbound Messages API via client.messages: sendText, sendImage, sendVideo, sendAudio, sendDocument, sendSticker, sendLocation, sendContacts, sendTemplate, sendInteractiveButtons, sendInteractiveList, sendReaction, and markAsRead.
  • Reply/context support: every sender accepts a trailing SendOptions with replyToMessageId, injecting a root-level context: { message_id } into the request body.
  • Five new interactive senders: sendInteractiveCtaUrl, sendInteractiveFlow, sendLocationRequest, sendProduct, and sendProductList.
  • Rich interactive headers for buttons and lists: a plain string, a structured text header, or an image/video/document media header (InteractiveHeader, InteractiveMediaHeader).
  • Full contacts object: ContactName middle name/suffix/prefix plus ContactAddress, ContactOrg, ContactUrl, and Contact addresses/org/urls/birthday.
  • Client-side validation of documented Messages API limits (text/interactive body, footer, header, button counts and ids, list sections/rows, reaction emoji, flow CTA, product-list items), raising WhatsAppValidationError with a field + limit message; nothing is truncated.
  • Typed errors WhatsAppRateLimitError (exposing retryAfterMs when a Retry-After header is present) and WhatsAppReEngagementError, both subclasses of WhatsAppApiError; errorFromResponse maps 429/130429/131056/133016 to rate-limit and 131047 to re-engagement.
  • Framework-agnostic webhooks module: GET verification handshake (verifyWebhook, verifyWebhookQuery) echoing the raw hub.challenge with a constant-time token check; constant-time X-Hub-Signature-256 validation over the raw request body (verifySignature); typed inbound parsing (parseWebhook, extractMessages, extractStatuses, isMessageEvent/isStatusEvent) with a discriminated IncomingMessage union (text, image, video, audio, document, sticker, location, contacts, interactive, button, reaction, plus an unknown fallback) and MessageStatus; a WebhookHandler that binds the verify token and App Secret; and a new WhatsAppWebhookError.
  • CI (Node 20 and 22) and release-on-tag workflows.
  • OSS docs: README, LICENSE, CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, CODEOWNERS.
  • Interactive button and list headers now accept the structured InteractiveHeader type in addition to a plain string (backward compatible).
  • Removed stale “omitted” notes from the contact types now that the full contacts object is modeled.

Independent open-source project. Not affiliated with, endorsed by or sponsored by Meta or WhatsApp. Released under the MIT licence. Source on GitHub.