@pilot-status/sdk 0.5.0 → 0.8.0

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.
Files changed (124) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +165 -19
  3. package/dist/client.d.ts +53 -2
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +54 -4
  6. package/dist/client.js.map +1 -1
  7. package/dist/errors.d.ts +58 -0
  8. package/dist/errors.d.ts.map +1 -1
  9. package/dist/errors.js +65 -0
  10. package/dist/errors.js.map +1 -1
  11. package/dist/http.d.ts +6 -0
  12. package/dist/http.d.ts.map +1 -1
  13. package/dist/http.js +3 -0
  14. package/dist/http.js.map +1 -1
  15. package/dist/index.d.ts +12 -5
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +10 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/internal.d.ts +19 -0
  20. package/dist/internal.d.ts.map +1 -0
  21. package/dist/internal.js +27 -0
  22. package/dist/internal.js.map +1 -0
  23. package/dist/resources/api-keys.d.ts +20 -7
  24. package/dist/resources/api-keys.d.ts.map +1 -1
  25. package/dist/resources/api-keys.js +18 -5
  26. package/dist/resources/api-keys.js.map +1 -1
  27. package/dist/resources/billing.d.ts +18 -0
  28. package/dist/resources/billing.d.ts.map +1 -0
  29. package/dist/resources/billing.js +30 -0
  30. package/dist/resources/billing.js.map +1 -0
  31. package/dist/resources/branding.d.ts +18 -0
  32. package/dist/resources/branding.d.ts.map +1 -0
  33. package/dist/resources/branding.js +29 -0
  34. package/dist/resources/branding.js.map +1 -0
  35. package/dist/resources/chatwoot.d.ts +57 -0
  36. package/dist/resources/chatwoot.d.ts.map +1 -0
  37. package/dist/resources/chatwoot.js +117 -0
  38. package/dist/resources/chatwoot.js.map +1 -0
  39. package/dist/resources/conversations.d.ts +16 -0
  40. package/dist/resources/conversations.d.ts.map +1 -0
  41. package/dist/resources/conversations.js +28 -0
  42. package/dist/resources/conversations.js.map +1 -0
  43. package/dist/resources/embed.d.ts +24 -0
  44. package/dist/resources/embed.d.ts.map +1 -0
  45. package/dist/resources/embed.js +37 -0
  46. package/dist/resources/embed.js.map +1 -0
  47. package/dist/resources/flows.d.ts +203 -0
  48. package/dist/resources/flows.d.ts.map +1 -0
  49. package/dist/resources/flows.js +289 -0
  50. package/dist/resources/flows.js.map +1 -0
  51. package/dist/resources/groups.d.ts +37 -1
  52. package/dist/resources/groups.d.ts.map +1 -1
  53. package/dist/resources/groups.js +91 -0
  54. package/dist/resources/groups.js.map +1 -1
  55. package/dist/resources/messages.d.ts +43 -1
  56. package/dist/resources/messages.d.ts.map +1 -1
  57. package/dist/resources/messages.js +105 -1
  58. package/dist/resources/messages.js.map +1 -1
  59. package/dist/resources/meta.d.ts +19 -0
  60. package/dist/resources/meta.d.ts.map +1 -0
  61. package/dist/resources/meta.js +31 -0
  62. package/dist/resources/meta.js.map +1 -0
  63. package/dist/resources/numbers.d.ts +63 -1
  64. package/dist/resources/numbers.d.ts.map +1 -1
  65. package/dist/resources/numbers.js +101 -0
  66. package/dist/resources/numbers.js.map +1 -1
  67. package/dist/resources/service-window.d.ts +20 -0
  68. package/dist/resources/service-window.d.ts.map +1 -0
  69. package/dist/resources/service-window.js +26 -0
  70. package/dist/resources/service-window.js.map +1 -0
  71. package/dist/resources/subscription.d.ts +43 -0
  72. package/dist/resources/subscription.d.ts.map +1 -0
  73. package/dist/resources/subscription.js +60 -0
  74. package/dist/resources/subscription.js.map +1 -0
  75. package/dist/resources/templates.d.ts +31 -1
  76. package/dist/resources/templates.d.ts.map +1 -1
  77. package/dist/resources/templates.js +56 -0
  78. package/dist/resources/templates.js.map +1 -1
  79. package/dist/resources/webhooks.d.ts +53 -0
  80. package/dist/resources/webhooks.d.ts.map +1 -0
  81. package/dist/resources/webhooks.js +97 -0
  82. package/dist/resources/webhooks.js.map +1 -0
  83. package/dist/resources/workspace.d.ts +57 -0
  84. package/dist/resources/workspace.d.ts.map +1 -0
  85. package/dist/resources/workspace.js +73 -0
  86. package/dist/resources/workspace.js.map +1 -0
  87. package/dist/types.d.ts +801 -23
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.js.map +1 -1
  90. package/dist/webhooks/parse.d.ts +16 -0
  91. package/dist/webhooks/parse.d.ts.map +1 -1
  92. package/dist/webhooks/parse.js +49 -0
  93. package/dist/webhooks/parse.js.map +1 -1
  94. package/dist/webhooks/signature.d.ts +42 -0
  95. package/dist/webhooks/signature.d.ts.map +1 -0
  96. package/dist/webhooks/signature.js +40 -0
  97. package/dist/webhooks/signature.js.map +1 -0
  98. package/dist/webhooks/types.d.ts +59 -1
  99. package/dist/webhooks/types.d.ts.map +1 -1
  100. package/package.json +5 -3
  101. package/dist/messages.test.d.ts +0 -2
  102. package/dist/messages.test.d.ts.map +0 -1
  103. package/dist/messages.test.js +0 -107
  104. package/dist/messages.test.js.map +0 -1
  105. package/dist/numbers.test.d.ts +0 -2
  106. package/dist/numbers.test.d.ts.map +0 -1
  107. package/dist/numbers.test.js +0 -57
  108. package/dist/numbers.test.js.map +0 -1
  109. package/dist/resources/groups.test.d.ts +0 -2
  110. package/dist/resources/groups.test.d.ts.map +0 -1
  111. package/dist/resources/groups.test.js +0 -19
  112. package/dist/resources/groups.test.js.map +0 -1
  113. package/dist/resources/newsletters.test.d.ts +0 -2
  114. package/dist/resources/newsletters.test.d.ts.map +0 -1
  115. package/dist/resources/newsletters.test.js +0 -19
  116. package/dist/resources/newsletters.test.js.map +0 -1
  117. package/dist/resources/projects.d.ts +0 -9
  118. package/dist/resources/projects.d.ts.map +0 -1
  119. package/dist/resources/projects.js +0 -23
  120. package/dist/resources/projects.js.map +0 -1
  121. package/dist/resources/templates.test.d.ts +0 -2
  122. package/dist/resources/templates.test.d.ts.map +0 -1
  123. package/dist/resources/templates.test.js +0 -28
  124. package/dist/resources/templates.test.js.map +0 -1
@@ -0,0 +1,19 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { MetaPricingParams, MetaPricingResult } from "../types.js";
3
+ /** The Meta surface that does not belong to a number (`/v1/meta/*`). */
4
+ export declare class MetaResource {
5
+ #private;
6
+ constructor(http: HttpClient);
7
+ /**
8
+ * Meta's PUBLIC rate card by market + currency + category
9
+ * (`GET /v1/meta/pricing`).
10
+ *
11
+ * ⚠️ This is not what your account pays — it is the table Meta publishes. For
12
+ * actual cost use the wallet statement.
13
+ *
14
+ * With no arguments it returns the available markets/currencies/categories;
15
+ * with all three, the price; with `tiers: true`, also the volume tiers.
16
+ */
17
+ pricing(params?: MetaPricingParams): Promise<MetaPricingResult>;
18
+ }
19
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/resources/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAExE,wEAAwE;AACxE,qBAAa,YAAY;;gBAGT,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;OASG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAYxE"}
@@ -0,0 +1,31 @@
1
+ import { compact } from "../internal.js";
2
+ /** The Meta surface that does not belong to a number (`/v1/meta/*`). */
3
+ export class MetaResource {
4
+ #http;
5
+ constructor(http) {
6
+ this.#http = http;
7
+ }
8
+ /**
9
+ * Meta's PUBLIC rate card by market + currency + category
10
+ * (`GET /v1/meta/pricing`).
11
+ *
12
+ * ⚠️ This is not what your account pays — it is the table Meta publishes. For
13
+ * actual cost use the wallet statement.
14
+ *
15
+ * With no arguments it returns the available markets/currencies/categories;
16
+ * with all three, the price; with `tiers: true`, also the volume tiers.
17
+ */
18
+ async pricing(params) {
19
+ return this.#http.requestJson({
20
+ method: "GET",
21
+ path: "/v1/meta/pricing",
22
+ query: compact({
23
+ market: params?.market,
24
+ currency: params?.currency,
25
+ category: params?.category,
26
+ tiers: params?.tiers,
27
+ }),
28
+ });
29
+ }
30
+ }
31
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/resources/meta.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,wEAAwE;AACxE,MAAM,OAAO,YAAY;IACZ,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,CAAC,MAA0B;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAoB;YAC7C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,OAAO,CAAC;gBACX,MAAM,EAAE,MAAM,EAAE,MAAM;gBACtB,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,KAAK,EAAE,MAAM,EAAE,KAAK;aACvB,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from "../http.js";
2
- import type { CreateNumberInput, CreateNumberResult, DeleteNumberResult, NumberConnectResult, NumberDetail, NumberSettingsInput, NumberStatusResult, RemotePairingInput, RemotePairingResult, UpdateNumberInput, UpdateNumberResult, WhatsAppNumberListItem } from "../types.js";
2
+ import type { CheckNumbersInput, CheckNumbersResult, CreateMetaNumberInput, CreateNumberInput, CreateNumberResult, DeleteNumberResult, NumberConnectResult, NumberDetail, NumberLogoutResult, NumberPurgeResult, NumberRestoreResult, NumberSettingsInput, NumberStatusResult, RemotePairingInput, RemotePairingResult, UpdateNumberInput, UpdateNumberResult, WhatsAppNumberListItem } from "../types.js";
3
3
  export declare class NumbersResource {
4
4
  #private;
5
5
  constructor(http: HttpClient);
@@ -50,10 +50,72 @@ export declare class NumbersResource {
50
50
  * ```ts
51
51
  * // stop replaying old messages into the webhook on every reconnect
52
52
  * await client.numbers.updateSettings(id, { webhookHistoricalMessages: false });
53
+ *
54
+ * // stop WhatsApp Channel (`@newsletter`) posts from landing in the chat,
55
+ * // the logs and the webhook — the provider has no gate for them
56
+ * await client.numbers.updateSettings(id, { ignoreNewsletters: true });
53
57
  * ```
54
58
  */
55
59
  updateSettings(id: string, settings: NumberSettingsInput): Promise<UpdateNumberResult>;
60
+ /**
61
+ * ⚠️ **Its meaning changed: this is a 30-day SOFT delete.**
62
+ *
63
+ * Previously, `delete()` erased the line and freed the phone for an immediate
64
+ * reconnect — anyone who deleted-and-recreated relied on that. Now the device
65
+ * is logged out and the line survives until it is purged; the response carries
66
+ * `restorableUntil` so the window is discoverable without reading the docs.
67
+ *
68
+ * - Want the old behavior (destroy now and recreate right after)? →
69
+ * {@link purge}.
70
+ * - Changed your mind within the 30 days? → {@link restore}.
71
+ *
72
+ * It still does NOT reduce the paid capacity: the slot stays free for another
73
+ * number in the same cycle. Reducing the bill is `subscription.scheduleRemoval()`.
74
+ */
56
75
  delete(id: string): Promise<DeleteNumberResult>;
76
+ /**
77
+ * Undoes the soft delete within the window (`POST /v1/numbers/{id}/restore`).
78
+ *
79
+ * ⚠️ It gives back the LINE, not the connection — the device was logged out on
80
+ * delete. That is what the response says with `requiresReconnect: true`: after
81
+ * restoring, call {@link connect} and read the QR / pairing code again.
82
+ */
83
+ restore(id: string): Promise<NumberRestoreResult>;
84
+ /**
85
+ * IMMEDIATE hard delete (`DELETE /v1/numbers/{id}/purge`) — the behavior
86
+ * `delete()` had before the soft delete.
87
+ *
88
+ * It cascades through 13 FKs (chat, messages, templates, keys) and performs
89
+ * the irreversible teardown on Meta. There is no restore after this. Only use
90
+ * it when the flow REALLY is delete-and-recreate the same phone right after.
91
+ */
92
+ purge(id: string): Promise<NumberPurgeResult>;
93
+ /**
94
+ * Logs the paired device out without deleting anything
95
+ * (`POST /v1/numbers/{id}/logout`). The number reconnects with
96
+ * {@link connect}, keeping its id, keys, webhooks and history.
97
+ */
98
+ logout(id: string): Promise<NumberLogoutResult>;
99
+ /**
100
+ * Checks whether phone numbers exist on WhatsApp (`POST /v1/numbers/check`,
101
+ * up to 20).
102
+ *
103
+ * ⚠️ Only for an UNOFFICIAL number (Evolution GO/v2) — a Meta number answers
104
+ * `400 NOT_SUPPORTED_FOR_META`. For a Brazilian mobile (+55) the server also
105
+ * tries the variant with/without the ninth digit, and the `number` of each
106
+ * result is the REGISTERED form (the one you must use when sending), which
107
+ * may differ from what you sent.
108
+ */
109
+ check(input: CheckNumbersInput): Promise<CheckNumbersResult>;
110
+ /**
111
+ * Creates an official Meta Cloud API number with your own credentials
112
+ * (`POST /v1/numbers/meta`).
113
+ *
114
+ * This is the SERVER-SIDE path of the official onboarding — the
115
+ * `/v1/meta-embedded/*` routes exchange a `code` that only exists inside the
116
+ * Facebook JS SDK popup, which is why they have no method here.
117
+ */
118
+ createMeta(input: CreateMetaNumberInput): Promise<CreateNumberResult>;
57
119
  remotePairing(input: RemotePairingInput): Promise<RemotePairingResult>;
58
120
  }
59
121
  //# sourceMappingURL=numbers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/resources/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACR,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACzB,MAAM,aAAa,CAAC;AAErB,qBAAa,eAAe;;gBAGZ,IAAI,EAAE,UAAU;IAItB,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB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K,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAY/E"}
@@ -1,3 +1,4 @@
1
+ import { compact } from "../internal.js";
1
2
  export class NumbersResource {
2
3
  #http;
3
4
  constructor(http) {
@@ -11,6 +12,7 @@ export class NumbersResource {
11
12
  name: input.name,
12
13
  number: input.number,
13
14
  ...(input.linkToApiKey !== undefined ? { linkToApiKey: input.linkToApiKey } : {}),
15
+ ...(input.settings !== undefined ? { settings: input.settings } : {}),
14
16
  },
15
17
  });
16
18
  }
@@ -85,17 +87,116 @@ export class NumbersResource {
85
87
  * ```ts
86
88
  * // stop replaying old messages into the webhook on every reconnect
87
89
  * await client.numbers.updateSettings(id, { webhookHistoricalMessages: false });
90
+ *
91
+ * // stop WhatsApp Channel (`@newsletter`) posts from landing in the chat,
92
+ * // the logs and the webhook — the provider has no gate for them
93
+ * await client.numbers.updateSettings(id, { ignoreNewsletters: true });
88
94
  * ```
89
95
  */
90
96
  async updateSettings(id, settings) {
91
97
  return this.update(id, { settings });
92
98
  }
99
+ /**
100
+ * ⚠️ **Its meaning changed: this is a 30-day SOFT delete.**
101
+ *
102
+ * Previously, `delete()` erased the line and freed the phone for an immediate
103
+ * reconnect — anyone who deleted-and-recreated relied on that. Now the device
104
+ * is logged out and the line survives until it is purged; the response carries
105
+ * `restorableUntil` so the window is discoverable without reading the docs.
106
+ *
107
+ * - Want the old behavior (destroy now and recreate right after)? →
108
+ * {@link purge}.
109
+ * - Changed your mind within the 30 days? → {@link restore}.
110
+ *
111
+ * It still does NOT reduce the paid capacity: the slot stays free for another
112
+ * number in the same cycle. Reducing the bill is `subscription.scheduleRemoval()`.
113
+ */
93
114
  async delete(id) {
94
115
  return this.#http.requestJson({
95
116
  method: "DELETE",
96
117
  path: `/v1/numbers/${encodeURIComponent(id)}`,
97
118
  });
98
119
  }
120
+ /**
121
+ * Undoes the soft delete within the window (`POST /v1/numbers/{id}/restore`).
122
+ *
123
+ * ⚠️ It gives back the LINE, not the connection — the device was logged out on
124
+ * delete. That is what the response says with `requiresReconnect: true`: after
125
+ * restoring, call {@link connect} and read the QR / pairing code again.
126
+ */
127
+ async restore(id) {
128
+ return this.#http.requestJson({
129
+ method: "POST",
130
+ path: `/v1/numbers/${encodeURIComponent(id)}/restore`,
131
+ });
132
+ }
133
+ /**
134
+ * IMMEDIATE hard delete (`DELETE /v1/numbers/{id}/purge`) — the behavior
135
+ * `delete()` had before the soft delete.
136
+ *
137
+ * It cascades through 13 FKs (chat, messages, templates, keys) and performs
138
+ * the irreversible teardown on Meta. There is no restore after this. Only use
139
+ * it when the flow REALLY is delete-and-recreate the same phone right after.
140
+ */
141
+ async purge(id) {
142
+ return this.#http.requestJson({
143
+ method: "DELETE",
144
+ path: `/v1/numbers/${encodeURIComponent(id)}/purge`,
145
+ });
146
+ }
147
+ /**
148
+ * Logs the paired device out without deleting anything
149
+ * (`POST /v1/numbers/{id}/logout`). The number reconnects with
150
+ * {@link connect}, keeping its id, keys, webhooks and history.
151
+ */
152
+ async logout(id) {
153
+ return this.#http.requestJson({
154
+ method: "POST",
155
+ path: `/v1/numbers/${encodeURIComponent(id)}/logout`,
156
+ });
157
+ }
158
+ /**
159
+ * Checks whether phone numbers exist on WhatsApp (`POST /v1/numbers/check`,
160
+ * up to 20).
161
+ *
162
+ * ⚠️ Only for an UNOFFICIAL number (Evolution GO/v2) — a Meta number answers
163
+ * `400 NOT_SUPPORTED_FOR_META`. For a Brazilian mobile (+55) the server also
164
+ * tries the variant with/without the ninth digit, and the `number` of each
165
+ * result is the REGISTERED form (the one you must use when sending), which
166
+ * may differ from what you sent.
167
+ */
168
+ async check(input) {
169
+ return this.#http.requestJson({
170
+ method: "POST",
171
+ path: "/v1/numbers/check",
172
+ body: compact({ numbers: input.numbers, number: input.number }),
173
+ });
174
+ }
175
+ /**
176
+ * Creates an official Meta Cloud API number with your own credentials
177
+ * (`POST /v1/numbers/meta`).
178
+ *
179
+ * This is the SERVER-SIDE path of the official onboarding — the
180
+ * `/v1/meta-embedded/*` routes exchange a `code` that only exists inside the
181
+ * Facebook JS SDK popup, which is why they have no method here.
182
+ */
183
+ async createMeta(input) {
184
+ return this.#http.requestJson({
185
+ method: "POST",
186
+ path: "/v1/numbers/meta",
187
+ body: compact({
188
+ name: input.name,
189
+ number: input.number,
190
+ metaPhoneId: input.metaPhoneId,
191
+ metaWabaId: input.metaWabaId,
192
+ metaAccessToken: input.metaAccessToken,
193
+ metaAppSecret: input.metaAppSecret,
194
+ metaAppId: input.metaAppId,
195
+ linkToApiKey: input.linkToApiKey,
196
+ routeWebhooksToPilot: input.routeWebhooksToPilot,
197
+ }),
198
+ });
199
+ }
99
200
  async remotePairing(input) {
100
201
  return this.#http.requestJson({
101
202
  method: "POST",
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/resources/numbers.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,eAAe;IACf,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAwB;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAqB;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACF,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBAC9B,GAAG,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClF;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA2B;YACpD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,aAAa;SACtB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAA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,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3F;SACF,CAAC,CAAC;IACL,CAAC;CACA"}
@@ -0,0 +1,20 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { ServiceWindowResult } from "../types.js";
3
+ /** Meta's 24h customer service window (`GET /v1/service-window`). */
4
+ export declare class ServiceWindowResource {
5
+ #private;
6
+ constructor(http: HttpClient);
7
+ /**
8
+ * Tells you whether you can send a free-form message to `destinationNumber`
9
+ * right now. NUMBER-scoped key.
10
+ *
11
+ * ⚠️ `open: true` does not mean the same thing on both providers. On a Meta
12
+ * number, `windowType: "META_24H"` and `open` is real — outside the window
13
+ * only an approved template gets through. On a web/unofficial number there is
14
+ * no Meta restriction: `windowType: "NONE"` and `open` is **always** `true`.
15
+ * Branching on `open` alone makes you think you checked a rule that does not
16
+ * exist there; branch on `windowType`.
17
+ */
18
+ get(destinationNumber: string): Promise<ServiceWindowResult>;
19
+ }
20
+ //# sourceMappingURL=service-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-window.d.ts","sourceRoot":"","sources":["../../src/resources/service-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,qEAAqE;AACrE,qBAAa,qBAAqB;;gBAGlB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;OAUG;IACG,GAAG,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAOrE"}
@@ -0,0 +1,26 @@
1
+ /** Meta's 24h customer service window (`GET /v1/service-window`). */
2
+ export class ServiceWindowResource {
3
+ #http;
4
+ constructor(http) {
5
+ this.#http = http;
6
+ }
7
+ /**
8
+ * Tells you whether you can send a free-form message to `destinationNumber`
9
+ * right now. NUMBER-scoped key.
10
+ *
11
+ * ⚠️ `open: true` does not mean the same thing on both providers. On a Meta
12
+ * number, `windowType: "META_24H"` and `open` is real — outside the window
13
+ * only an approved template gets through. On a web/unofficial number there is
14
+ * no Meta restriction: `windowType: "NONE"` and `open` is **always** `true`.
15
+ * Branching on `open` alone makes you think you checked a rule that does not
16
+ * exist there; branch on `windowType`.
17
+ */
18
+ async get(destinationNumber) {
19
+ return this.#http.requestJson({
20
+ method: "GET",
21
+ path: "/v1/service-window",
22
+ query: { destinationNumber },
23
+ });
24
+ }
25
+ }
26
+ //# sourceMappingURL=service-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-window.js","sourceRoot":"","sources":["../../src/resources/service-window.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,MAAM,OAAO,qBAAqB;IACrB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,CAAC,iBAAyB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,EAAE,iBAAiB,EAAE;SAC/B,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,43 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { ExtraNumbersPreview, ExtraNumbersPurchaseResult, ExtraNumbersScheduleResult } from "../types.js";
3
+ /**
4
+ * Paid number capacity (`/v1/subscription/extra-numbers*`). Requires a
5
+ * tenant-scoped credential.
6
+ *
7
+ * ⚠️ **Paid capacity ≠ connected number.** `numbers.delete()` frees the SLOT so
8
+ * another number can be connected, and does not cut a single cent off the bill.
9
+ * Reducing what you pay is {@link scheduleRemoval}, and it only takes effect on
10
+ * the following cycle.
11
+ */
12
+ export declare class SubscriptionResource {
13
+ #private;
14
+ constructor(http: HttpClient);
15
+ /** Cost preview for buying `quantity` extra numbers (default 1). Charges nothing. */
16
+ previewExtraNumbers(params?: {
17
+ quantity?: number;
18
+ }): Promise<ExtraNumbersPreview>;
19
+ /**
20
+ * Buys `quantity` extra numbers. On a FREE plan this CONVERTS the account to
21
+ * On Demand, which is why it requires `confirm: true` — without it the server
22
+ * refuses, so that nobody changes plan by accident. With no card on file, the
23
+ * response carries a `checkoutUrl` instead of charging.
24
+ */
25
+ addExtraNumbers(input?: {
26
+ quantity?: number;
27
+ confirm?: boolean;
28
+ }): Promise<ExtraNumbersPurchaseResult>;
29
+ /**
30
+ * SCHEDULES the return of `quantity` paid slots for the next cycle.
31
+ *
32
+ * Nothing changes right now and there is no refund: paid capacity is a 30-day
33
+ * entitlement. Calling it again OVERWRITES the scheduled target (it does not
34
+ * accumulate). It answers 409 `NUMBER_LIMIT_EXCEEDED` if the target would fall
35
+ * below the numbers currently connected.
36
+ */
37
+ scheduleRemoval(input?: {
38
+ quantity?: number;
39
+ }): Promise<ExtraNumbersScheduleResult>;
40
+ /** Cancels the scheduled reduction — the next cycle keeps the current capacity. A no-op if there was none. */
41
+ cancelScheduledRemoval(): Promise<ExtraNumbersScheduleResult>;
42
+ }
43
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/resources/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,aAAa,CAAC;AAErB;;;;;;;;GAQG;AACH,qBAAa,oBAAoB;;gBAGjB,IAAI,EAAE,UAAU;IAI5B,qFAAqF;IAC/E,mBAAmB,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQvF;;;;;OAKG;IACG,eAAe,CAAC,KAAK,CAAC,EAAE;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQvC;;;;;;;OAOG;IACG,eAAe,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQzF,8GAA8G;IACxG,sBAAsB,IAAI,OAAO,CAAC,0BAA0B,CAAC;CAMtE"}
@@ -0,0 +1,60 @@
1
+ import { compact } from "../internal.js";
2
+ /**
3
+ * Paid number capacity (`/v1/subscription/extra-numbers*`). Requires a
4
+ * tenant-scoped credential.
5
+ *
6
+ * ⚠️ **Paid capacity ≠ connected number.** `numbers.delete()` frees the SLOT so
7
+ * another number can be connected, and does not cut a single cent off the bill.
8
+ * Reducing what you pay is {@link scheduleRemoval}, and it only takes effect on
9
+ * the following cycle.
10
+ */
11
+ export class SubscriptionResource {
12
+ #http;
13
+ constructor(http) {
14
+ this.#http = http;
15
+ }
16
+ /** Cost preview for buying `quantity` extra numbers (default 1). Charges nothing. */
17
+ async previewExtraNumbers(params) {
18
+ return this.#http.requestJson({
19
+ method: "GET",
20
+ path: "/v1/subscription/extra-numbers",
21
+ query: compact({ quantity: params?.quantity }),
22
+ });
23
+ }
24
+ /**
25
+ * Buys `quantity` extra numbers. On a FREE plan this CONVERTS the account to
26
+ * On Demand, which is why it requires `confirm: true` — without it the server
27
+ * refuses, so that nobody changes plan by accident. With no card on file, the
28
+ * response carries a `checkoutUrl` instead of charging.
29
+ */
30
+ async addExtraNumbers(input) {
31
+ return this.#http.requestJson({
32
+ method: "POST",
33
+ path: "/v1/subscription/extra-numbers",
34
+ body: compact({ quantity: input?.quantity, confirm: input?.confirm }),
35
+ });
36
+ }
37
+ /**
38
+ * SCHEDULES the return of `quantity` paid slots for the next cycle.
39
+ *
40
+ * Nothing changes right now and there is no refund: paid capacity is a 30-day
41
+ * entitlement. Calling it again OVERWRITES the scheduled target (it does not
42
+ * accumulate). It answers 409 `NUMBER_LIMIT_EXCEEDED` if the target would fall
43
+ * below the numbers currently connected.
44
+ */
45
+ async scheduleRemoval(input) {
46
+ return this.#http.requestJson({
47
+ method: "DELETE",
48
+ path: "/v1/subscription/extra-numbers",
49
+ body: compact({ quantity: input?.quantity }),
50
+ });
51
+ }
52
+ /** Cancels the scheduled reduction — the next cycle keeps the current capacity. A no-op if there was none. */
53
+ async cancelScheduledRemoval() {
54
+ return this.#http.requestJson({
55
+ method: "DELETE",
56
+ path: "/v1/subscription/extra-numbers/schedule",
57
+ });
58
+ }
59
+ }
60
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/resources/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAOzC;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAoB;IACpB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,mBAAmB,CAAC,MAA8B;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gCAAgC;YACtC,KAAK,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;SACjD,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,KAGrB;QACG,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA6B;YACtD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,gCAAgC;YACtC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SACxE,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CAAC,KAA6B;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA6B;YACtD,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,gCAAgC;YACtC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;SAC/C,CAAC,CAAC;IACP,CAAC;IAED,8GAA8G;IAC9G,KAAK,CAAC,sBAAsB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAA6B;YACtD,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,yCAAyC;SAClD,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,9 +1,39 @@
1
1
  import type { HttpClient } from "../http.js";
2
- import type { TemplateDetail, TemplateListItem } from "../types.js";
2
+ import type { CreateTemplateInput, TemplateDeleteResult, TemplateDetail, TemplateListItem, UpdateTemplateInput } from "../types.js";
3
3
  export declare class TemplatesResource {
4
4
  #private;
5
5
  constructor(http: HttpClient);
6
+ /**
7
+ * ⚠️ Only `sendable: true` can be passed to `messages.send()`. On a Meta
8
+ * number that means a `source: "META"` template with
9
+ * `metaStatus: "APPROVED"` — PILOT_STATUS templates and Meta ones in
10
+ * PENDING/REJECTED show up in the list and do **not** send.
11
+ */
6
12
  list(): Promise<TemplateListItem[]>;
7
13
  get(id: string): Promise<TemplateDetail>;
14
+ /**
15
+ * Creates a template on the key's number (and submits it to Meta, on a Meta
16
+ * number).
17
+ *
18
+ * `examples` is MANDATORY, with one value per `{{variable}}` in the body,
19
+ * otherwise the API rejects with `TEMPLATE_EXAMPLES_REQUIRED`. Only pass `{}`
20
+ * when the body has no variables at all.
21
+ */
22
+ create(input: CreateTemplateInput): Promise<TemplateDetail>;
23
+ /** Rewrites the body (and re-submits it to Meta). `examples` is still mandatory, for the NEW body. */
24
+ update(id: string, input: UpdateTemplateInput): Promise<TemplateDetail>;
25
+ /**
26
+ * Deletes the template (on Meta too, when it is a Meta template). Irreversible.
27
+ *
28
+ * If Meta REFUSES the deletion — a token without permission on the WABA, for
29
+ * instance — the call fails with `409 META_TEMPLATE_DELETE_REFUSED` and
30
+ * **nothing** is deleted. Do not blindly retry: `forceLocalDelete` only
31
+ * removes our copy, and the template SURVIVES on Meta consuming quota and
32
+ * holding the name, until a future sync possibly brings it back. It is an
33
+ * escape hatch for an orphaned row, not a retry.
34
+ */
35
+ delete(id: string, options?: {
36
+ forceLocalDelete?: boolean;
37
+ }): Promise<TemplateDeleteResult>;
8
38
  }
9
39
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,qBAAa,iBAAiB;;gBAGd,IAAI,EAAE,UAAU;IAItB,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAOnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAMjD"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAErB,qBAAa,iBAAiB;;gBAGd,IAAI,EAAE,UAAU;IAI5B;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAOnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO9C;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAejE,sGAAsG;IAChG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ7E;;;;;;;;;OASG;IACG,MAAM,CACR,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7C,OAAO,CAAC,oBAAoB,CAAC;CASnC"}
@@ -1,8 +1,15 @@
1
+ import { compact } from "../internal.js";
1
2
  export class TemplatesResource {
2
3
  #http;
3
4
  constructor(http) {
4
5
  this.#http = http;
5
6
  }
7
+ /**
8
+ * ⚠️ Only `sendable: true` can be passed to `messages.send()`. On a Meta
9
+ * number that means a `source: "META"` template with
10
+ * `metaStatus: "APPROVED"` — PILOT_STATUS templates and Meta ones in
11
+ * PENDING/REJECTED show up in the list and do **not** send.
12
+ */
6
13
  async list() {
7
14
  return this.#http.requestJson({
8
15
  method: "GET",
@@ -15,5 +22,54 @@ export class TemplatesResource {
15
22
  path: `/v1/templates/${encodeURIComponent(id)}`,
16
23
  });
17
24
  }
25
+ /**
26
+ * Creates a template on the key's number (and submits it to Meta, on a Meta
27
+ * number).
28
+ *
29
+ * `examples` is MANDATORY, with one value per `{{variable}}` in the body,
30
+ * otherwise the API rejects with `TEMPLATE_EXAMPLES_REQUIRED`. Only pass `{}`
31
+ * when the body has no variables at all.
32
+ */
33
+ async create(input) {
34
+ return this.#http.requestJson({
35
+ method: "POST",
36
+ path: "/v1/templates",
37
+ body: compact({
38
+ name: input.name,
39
+ body: input.body,
40
+ examples: input.examples,
41
+ category: input.category,
42
+ variables: input.variables,
43
+ language: input.language,
44
+ }),
45
+ });
46
+ }
47
+ /** Rewrites the body (and re-submits it to Meta). `examples` is still mandatory, for the NEW body. */
48
+ async update(id, input) {
49
+ return this.#http.requestJson({
50
+ method: "PUT",
51
+ path: `/v1/templates/${encodeURIComponent(id)}`,
52
+ body: { body: input.body, examples: input.examples },
53
+ });
54
+ }
55
+ /**
56
+ * Deletes the template (on Meta too, when it is a Meta template). Irreversible.
57
+ *
58
+ * If Meta REFUSES the deletion — a token without permission on the WABA, for
59
+ * instance — the call fails with `409 META_TEMPLATE_DELETE_REFUSED` and
60
+ * **nothing** is deleted. Do not blindly retry: `forceLocalDelete` only
61
+ * removes our copy, and the template SURVIVES on Meta consuming quota and
62
+ * holding the name, until a future sync possibly brings it back. It is an
63
+ * escape hatch for an orphaned row, not a retry.
64
+ */
65
+ async delete(id, options = {}) {
66
+ return this.#http.requestJson({
67
+ method: "DELETE",
68
+ path: `/v1/templates/${encodeURIComponent(id)}`,
69
+ query: compact({
70
+ force_local: options.forceLocalDelete ? "true" : undefined,
71
+ }),
72
+ });
73
+ }
18
74
  }
19
75
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IACjB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAqB;YAC9C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;SACxB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,iBAAiB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SAClD,CAAC,CAAC;IACP,CAAC;CACJ"}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,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AC,QAAQ,EAAE;SACvD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CACR,EAAU,EACV,UAA0C,EAAE;QAE5C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAuB;YAChD,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,iBAAiB,kBAAkB,CAAC,EAAE,CAAC,EAAE;YAC/C,KAAK,EAAE,OAAO,CAAC;gBACX,WAAW,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,53 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { CreateWebhookInput, UpdateWebhookInput, Webhook, WebhookDeleteResult, WebhookLogEntry, WebhookLogsParams } from "../types.js";
3
+ /**
4
+ * CRUD of the webhook subscriptions (`/v1/webhooks*`).
5
+ *
6
+ * ⚠️ The signing `secret` NEVER comes back in any of these responses — anyone who
7
+ * could read it would be able to FORGE signed events for the customer's endpoint.
8
+ * It is shown only once, in the dashboard. To validate a received delivery use
9
+ * {@link ../webhooks/signature.js#verifyWebhookSignature}.
10
+ */
11
+ export declare class WebhooksResource {
12
+ #private;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * The webhooks visible to the credential's scope.
16
+ *
17
+ * With a number in play (a number key, or `whatsappNumberId` on the client)
18
+ * the list is STRICTLY that number's webhooks — legacy webhooks with no
19
+ * subscription at all are left out on purpose.
20
+ */
21
+ list(): Promise<Webhook[]>;
22
+ /**
23
+ * Creates a webhook bound to ONE number.
24
+ *
25
+ * An empty or omitted `events` **fires nothing**: there is no implicit
26
+ * subscribe-to-everything — pass `["*"]` for all of them. Events the number's
27
+ * provider does not emit are silently discarded.
28
+ *
29
+ * With a tenant-scoped key and no `whatsappNumberId` on the client, the body's
30
+ * `whatsappNumberId` field is mandatory (400 `NUMBER_REQUIRED`).
31
+ */
32
+ create(input: CreateWebhookInput): Promise<Webhook>;
33
+ get(id: string): Promise<Webhook>;
34
+ /**
35
+ * Partial update. `events` is a REPLACEMENT of the whole list, not a merge —
36
+ * sending `[]` turns off every delivery without deleting the webhook (the same
37
+ * as `active: false`, by a different route).
38
+ *
39
+ * A webhook's number is not editable: delete it and recreate it.
40
+ */
41
+ update(id: string, input: UpdateWebhookInput): Promise<Webhook>;
42
+ /** Irreversible: deletes the subscription and the delivery logs. To merely pause, use `update(id, { active: false })`. */
43
+ delete(id: string): Promise<WebhookDeleteResult>;
44
+ /**
45
+ * Recent delivery attempts (`limit` 1–50).
46
+ *
47
+ * ⚠️ On a per-number OAuth connection this route answers 400 `NUMBER_REQUIRED`
48
+ * without `x-whatsapp-number-id` — build the client with `whatsappNumberId`,
49
+ * or use `client.withNumber(id).webhooks.logs(...)`.
50
+ */
51
+ logs(id: string, params?: WebhookLogsParams): Promise<WebhookLogEntry[]>;
52
+ }
53
+ //# sourceMappingURL=webhooks.d.ts.map