meta-cloud-api 3.8.0 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,8 +34,8 @@ pnpm add meta-cloud-api
34
34
  import WhatsApp from 'meta-cloud-api';
35
35
 
36
36
  const wa = new WhatsApp({
37
- accessToken: process.env.CLOUD_API_ACCESS_TOKEN,
38
- phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
37
+ accessToken: process.env.CLOUD_API_ACCESS_TOKEN!,
38
+ phoneNumberId: Number(process.env.WA_PHONE_NUMBER_ID),
39
39
  });
40
40
 
41
41
  // Send a text message
@@ -44,12 +44,14 @@ await wa.messages.text({ to: '1234567890', body: 'Hello from TypeScript!' });
44
44
  // Send a template message
45
45
  await wa.messages.template({
46
46
  to: '1234567890',
47
- name: 'hello_world',
48
- language: { code: 'en_US' },
47
+ body: {
48
+ name: 'hello_world',
49
+ language: { code: 'en_US', policy: 'deterministic' },
50
+ },
49
51
  });
50
52
 
51
53
  // Send an image
52
- await wa.messages.image({ to: '1234567890', link: 'https://example.com/image.png' });
54
+ await wa.messages.image({ to: '1234567890', body: { link: 'https://example.com/image.png' } });
53
55
  ```
54
56
 
55
57
  ## Why meta-cloud-api?
@@ -62,11 +64,13 @@ await wa.messages.image({ to: '1234567890', link: 'https://example.com/image.png
62
64
  | Account ban risk | None | None | Yes — violates WhatsApp ToS |
63
65
  | Maintenance | Active (tracks OpenAPI v23) | **Archived since 2023** | Varies |
64
66
  | TypeScript | Strict, full request/response types | Partial | Varies |
65
- | API coverage | 20 modules (Messages, Flows, Calling, Payments, and more) | Messaging-focused | Personal-account features |
66
- | Webhook adapters | Built-in Express.js + Next.js | Manual | Custom event system |
67
+ | API coverage | 22 modules (Messages, Flows, Calling, Payments, and more) | Messaging-focused | Personal-account features |
68
+ | Webhook adapters | Built-in Express.js, Next.js, Hono, Fastify (NestJS via Express) | Manual | Custom event system |
67
69
 
68
70
  If you're building on the official Cloud API and don't want to bet on an unmaintained SDK, this is what the archived one would look like if Meta had kept shipping it.
69
71
 
72
+ **Coming from the `whatsapp` package?** The [migration guide](https://meta-cloud-api.site/getting-started/migrate-from-whatsapp-nodejs-sdk) maps every API of the archived SDK (config, messages, templates, webhooks, errors) to meta-cloud-api, with a checklist.
73
+
70
74
  ## API Coverage
71
75
 
72
76
  ```
@@ -89,6 +93,9 @@ wa.blockUsers // Block/unblock users
89
93
  wa.contactBook // Delete a BSUID contact book entry
90
94
  wa.threadControl // Conversation Routing: pass, release, take threads
91
95
  wa.waba // WhatsApp Business Account management
96
+ wa.business // Business portfolio, pre-verified phone numbers, owned/client WABAs, credit lines
97
+ wa.messageHistory // Message history and history events
98
+ wa.solutions // Multi-Partner Solutions management
92
99
  ```
93
100
 
94
101
  ## Webhooks
@@ -103,8 +110,8 @@ app.use(express.json({ verify: (req, _res, buf) => { (req as any).rawBody = buf.
103
110
 
104
111
  // Handler is automatically cached per phoneNumberId — safe against HMR re-evaluation
105
112
  const Whatsapp = expressWebhookHandler({
106
- accessToken: process.env.CLOUD_API_ACCESS_TOKEN,
107
- phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
113
+ accessToken: process.env.CLOUD_API_ACCESS_TOKEN!,
114
+ phoneNumberId: Number(process.env.WA_PHONE_NUMBER_ID),
108
115
  webhookVerificationToken: process.env.WEBHOOK_VERIFICATION_TOKEN,
109
116
  // Reject forged POSTs: require a valid X-Hub-Signature-256 from Meta
110
117
  appSecret: process.env.APP_SECRET,
@@ -133,11 +140,22 @@ app.get('/webhook', Whatsapp.GET);
133
140
  app.post('/webhook', Whatsapp.POST);
134
141
  ```
135
142
 
143
+ Other frameworks use the same handler object (`GET`, `POST`, `webhook`, `flow`, `processor`, `destroy`):
144
+
145
+ | Framework | Adapter | Guide |
146
+ |---|---|---|
147
+ | Express.js | `expressWebhookHandler` | [Express](https://meta-cloud-api.site/guides/express/) |
148
+ | Next.js App Router | `nextjsAppWebhookHandler` | [Next.js App Router](https://meta-cloud-api.site/guides/nextjs-app/) |
149
+ | Next.js Pages Router | `nextjsPagesWebhookHandler` | [Next.js Pages Router](https://meta-cloud-api.site/guides/nextjs-pages/) |
150
+ | Hono (Node.js, Bun, Deno, Workers, Edge) | `honoWebhookHandler` | [Hono](https://meta-cloud-api.site/guides/hono/) |
151
+ | Fastify | `fastifyWebhookHandler` | [Fastify](https://meta-cloud-api.site/guides/fastify/) |
152
+ | NestJS | `expressWebhookHandler` or `fastifyWebhookHandler` | [NestJS](https://meta-cloud-api.site/guides/nestjs/) |
153
+
136
154
  All 30+ webhook field types are supported — messages, statuses, templates, flows, groups, calls, and more. See the [Webhooks documentation](https://meta-cloud-api.site/) for the full list of handlers.
137
155
 
138
156
  ## Requirements
139
157
 
140
- - **Node.js** 18 LTS or later
158
+ - **Node.js** 20.12+, **Bun**, **Deno**, **Cloudflare Workers** or **Vercel Edge** — no runtime dependencies, no `node:*` imports ([runtime guide](https://meta-cloud-api.site/guides/runtimes))
141
159
  - **TypeScript** 4.5+ (for TypeScript projects)
142
160
 
143
161
  ## Resources