@unlimited-messaging/sdk 0.1.21 → 0.1.22

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 (75) hide show
  1. package/package.json +1 -1
  2. package/src/api/resources/webhooks/client/Client.d.ts +130 -11
  3. package/src/api/resources/webhooks/client/Client.js +130 -11
  4. package/src/api/resources/webhooks/types/WebhookEndpointCreateRequestEventTypesItem.d.ts +2 -1
  5. package/src/api/resources/webhooks/types/WebhookEndpointCreateRequestEventTypesItem.js +1 -0
  6. package/src/api/resources/webhooks/types/WebhookEndpointCreateResponseEventTypesItem.d.ts +2 -1
  7. package/src/api/resources/webhooks/types/WebhookEndpointCreateResponseEventTypesItem.js +1 -0
  8. package/src/api/resources/webhooks/types/WebhookEndpointFindOneResponseEventTypesItem.d.ts +2 -1
  9. package/src/api/resources/webhooks/types/WebhookEndpointFindOneResponseEventTypesItem.js +1 -0
  10. package/src/api/resources/webhooks/types/WebhookEndpointListResponseDataItemEventTypesItem.d.ts +2 -1
  11. package/src/api/resources/webhooks/types/WebhookEndpointListResponseDataItemEventTypesItem.js +1 -0
  12. package/src/api/resources/webhooks/types/WebhookEndpointUpdateRequestEventTypesItem.d.ts +2 -1
  13. package/src/api/resources/webhooks/types/WebhookEndpointUpdateRequestEventTypesItem.js +1 -0
  14. package/src/api/resources/webhooks/types/WebhookEndpointUpdateResponseEventTypesItem.d.ts +2 -1
  15. package/src/api/resources/webhooks/types/WebhookEndpointUpdateResponseEventTypesItem.js +1 -0
  16. package/src/api/types/WebhookEventMessageSent.d.ts +10 -0
  17. package/src/api/types/WebhookEventMessageSent.js +5 -0
  18. package/src/api/types/WebhookEventMessageSentData.d.ts +8 -0
  19. package/src/api/types/WebhookEventMessageSentData.js +5 -0
  20. package/src/api/types/WebhookEventMessageSentDataChannel.d.ts +9 -0
  21. package/src/api/types/WebhookEventMessageSentDataChannel.js +5 -0
  22. package/src/api/types/WebhookEventMessageSentDataChannelAccount.d.ts +7 -0
  23. package/src/api/types/WebhookEventMessageSentDataChannelAccount.js +5 -0
  24. package/src/api/types/WebhookEventMessageSentDataChannelConversation.d.ts +9 -0
  25. package/src/api/types/WebhookEventMessageSentDataChannelConversation.js +5 -0
  26. package/src/api/types/WebhookEventMessageSentDataChannelType.d.ts +9 -0
  27. package/src/api/types/WebhookEventMessageSentDataChannelType.js +11 -0
  28. package/src/api/types/WebhookEventMessageSentDataMessage.d.ts +29 -0
  29. package/src/api/types/WebhookEventMessageSentDataMessage.js +5 -0
  30. package/src/api/types/WebhookEventMessageSentDataMessageAttachmentsItem.d.ts +10 -0
  31. package/src/api/types/WebhookEventMessageSentDataMessageAttachmentsItem.js +5 -0
  32. package/src/api/types/WebhookEventMessageSentDataMessageDirection.d.ts +8 -0
  33. package/src/api/types/WebhookEventMessageSentDataMessageDirection.js +10 -0
  34. package/src/api/types/WebhookEventMessageSentDataMessageReplyTo.d.ts +7 -0
  35. package/src/api/types/WebhookEventMessageSentDataMessageReplyTo.js +5 -0
  36. package/src/api/types/WebhookEventMessageSentType.d.ts +7 -0
  37. package/src/api/types/WebhookEventMessageSentType.js +9 -0
  38. package/src/api/types/index.d.ts +11 -0
  39. package/src/api/types/index.js +11 -0
  40. package/src/serialization/resources/webhooks/types/WebhookEndpointCreateRequestEventTypesItem.d.ts +1 -1
  41. package/src/serialization/resources/webhooks/types/WebhookEndpointCreateRequestEventTypesItem.js +1 -0
  42. package/src/serialization/resources/webhooks/types/WebhookEndpointCreateResponseEventTypesItem.d.ts +1 -1
  43. package/src/serialization/resources/webhooks/types/WebhookEndpointCreateResponseEventTypesItem.js +1 -0
  44. package/src/serialization/resources/webhooks/types/WebhookEndpointFindOneResponseEventTypesItem.d.ts +1 -1
  45. package/src/serialization/resources/webhooks/types/WebhookEndpointFindOneResponseEventTypesItem.js +1 -0
  46. package/src/serialization/resources/webhooks/types/WebhookEndpointListResponseDataItemEventTypesItem.d.ts +1 -1
  47. package/src/serialization/resources/webhooks/types/WebhookEndpointListResponseDataItemEventTypesItem.js +1 -0
  48. package/src/serialization/resources/webhooks/types/WebhookEndpointUpdateRequestEventTypesItem.d.ts +1 -1
  49. package/src/serialization/resources/webhooks/types/WebhookEndpointUpdateRequestEventTypesItem.js +1 -0
  50. package/src/serialization/resources/webhooks/types/WebhookEndpointUpdateResponseEventTypesItem.d.ts +1 -1
  51. package/src/serialization/resources/webhooks/types/WebhookEndpointUpdateResponseEventTypesItem.js +1 -0
  52. package/src/serialization/types/WebhookEventMessageSent.d.ts +17 -0
  53. package/src/serialization/types/WebhookEventMessageSent.js +48 -0
  54. package/src/serialization/types/WebhookEventMessageSentData.d.ts +15 -0
  55. package/src/serialization/types/WebhookEventMessageSentData.js +46 -0
  56. package/src/serialization/types/WebhookEventMessageSentDataChannel.d.ts +17 -0
  57. package/src/serialization/types/WebhookEventMessageSentDataChannel.js +48 -0
  58. package/src/serialization/types/WebhookEventMessageSentDataChannelAccount.d.ts +13 -0
  59. package/src/serialization/types/WebhookEventMessageSentDataChannelAccount.js +44 -0
  60. package/src/serialization/types/WebhookEventMessageSentDataChannelConversation.d.ts +15 -0
  61. package/src/serialization/types/WebhookEventMessageSentDataChannelConversation.js +46 -0
  62. package/src/serialization/types/WebhookEventMessageSentDataChannelType.d.ts +10 -0
  63. package/src/serialization/types/WebhookEventMessageSentDataChannelType.js +41 -0
  64. package/src/serialization/types/WebhookEventMessageSentDataMessage.d.ts +37 -0
  65. package/src/serialization/types/WebhookEventMessageSentDataMessage.js +68 -0
  66. package/src/serialization/types/WebhookEventMessageSentDataMessageAttachmentsItem.d.ts +16 -0
  67. package/src/serialization/types/WebhookEventMessageSentDataMessageAttachmentsItem.js +47 -0
  68. package/src/serialization/types/WebhookEventMessageSentDataMessageDirection.d.ts +10 -0
  69. package/src/serialization/types/WebhookEventMessageSentDataMessageDirection.js +41 -0
  70. package/src/serialization/types/WebhookEventMessageSentDataMessageReplyTo.d.ts +13 -0
  71. package/src/serialization/types/WebhookEventMessageSentDataMessageReplyTo.js +44 -0
  72. package/src/serialization/types/WebhookEventMessageSentType.d.ts +10 -0
  73. package/src/serialization/types/WebhookEventMessageSentType.js +41 -0
  74. package/src/serialization/types/index.d.ts +11 -0
  75. package/src/serialization/types/index.js +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlimited-messaging/sdk",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "TypeScript / Node.js SDK for the Unlimited Messaging API — send and receive WhatsApp messages programmatically",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -66,8 +66,12 @@ export declare namespace Webhooks {
66
66
  *
67
67
  * ### Ordering and duplicates
68
68
  *
69
- * Delivery is at least once: the same event can arrive twice, so deduplicate on `eventId` (a message
70
- * is also never announced twice: `message.externalId` is unique per account).
69
+ * Delivery is at least once: the same event can arrive twice, so deduplicate on `eventId` (equal to
70
+ * the `webhook-id` header and kept across retries). `eventId` is per endpoint: two endpoints
71
+ * receiving the same event get two ids, so deduplicate across endpoints on the message's `id` or
72
+ * `externalId` instead. A message is also never announced twice: `message.externalId` is unique per
73
+ * account, and each message is announced by one of `message.received`, `message.self_sent` or
74
+ * `message.sent`, never by two.
71
75
  *
72
76
  * **Events are not delivered in the order things happened.** Retries reorder them, and a message with
73
77
  * media is only announced once its media is stored, a few seconds after it arrived: a text sent right
@@ -76,12 +80,13 @@ export declare namespace Webhooks {
76
80
  *
77
81
  * | Event | Order on |
78
82
  * | ----- | -------- |
79
- * | `message.received`, `message.self_sent` | `data.message.sentAt` (WhatsApp's timestamp) |
83
+ * | `message.received`, `message.self_sent`, `message.sent` | `data.message.sentAt` (WhatsApp's timestamp) |
80
84
  * | `message.status` | `data.message.at`, and `previousStatus` to ignore a stale one |
81
85
  * | `message.reaction` | `data.reaction.sentAt` |
82
86
  * | `message.edited` | `data.edit.editedAt` |
83
87
  * | `message.deleted` | `data.deletion.deletedAt` |
84
88
  * | `account.status_changed` | `data.account.at` |
89
+ * | `group.updated` | `data.at` |
85
90
  *
86
91
  * `GET /message` returns the same `sentAt`.
87
92
  *
@@ -97,14 +102,128 @@ export declare namespace Webhooks {
97
102
  * | Type | When |
98
103
  * | ---- | ---- |
99
104
  * | `message.received` | A message arrived. |
100
- * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. Same shape as `message.received`, with `direction: "OUT"` and `fromMe: true`. |
101
- * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. Only effective changes fire: a late `DELIVERED` after `READ` does not. |
102
- * | `message.reaction` | Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). |
103
- * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. Phones encrypt an edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing` for a message the account received before it was linked, `decryption_failed` otherwise), the edit is still announced, with `newContent` and `kind` null, and the stored content is left as it was. |
104
- * | `message.deleted` | A message was deleted for everyone, by its author or a group admin (`deletedBy`). The stored message is kept, with `deletedAt` set. |
105
- * | `message.history` | Past messages, in batches, for an account linked with `syncHistory` (see below). |
106
- * | `group.updated` | A group the account is in changed: members `added`, `removed`, `promoted` or `demoted`, a new `name` or `topic`. |
107
- * | `account.status_changed` | An account's status changed: disconnected, logged out, restricted by WhatsApp (`BLOCKED`, with `blockedUntil`), reconnected... `reason` is a machine-readable code (`device_removed` when the device was removed from the phone, `logged_out` when WhatsApp refused the session), `transportCode` WhatsApp's own numeric code for diagnosis. |
105
+ * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. |
106
+ * | `message.sent` | A message you sent through the API reached the channel. Carries its content. |
107
+ * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. |
108
+ * | `message.reaction` | Someone reacted to a message, or took their reaction back. |
109
+ * | `message.edited` | A message was edited. |
110
+ * | `message.deleted` | A message was deleted for everyone. |
111
+ * | `message.history` | Past messages, in batches, for an account linked with `syncHistory`. |
112
+ * | `group.updated` | A group the account is in changed. |
113
+ * | `account.status_changed` | An account's status changed. |
114
+ *
115
+ * An endpoint receives only the types listed in its `eventTypes`: there is no "every event" option,
116
+ * and a type added later is never turned on for existing endpoints. To start receiving one, send the
117
+ * full list you want with `PATCH /webhooks/{id}` (`eventTypes` replaces the previous list).
118
+ *
119
+ * The four `message.received`, `message.self_sent`, `message.sent` and `message.history` events carry
120
+ * the same message object (`data.message`, or each item of `data.messages`): `id` (UnlimitedMessaging),
121
+ * `externalId` (WhatsApp), `direction` (`IN` or `OUT`), `fromMe`, `content`, `sentAt` (the channel's
122
+ * timestamp), `receivedAt` (when UnlimitedMessaging recorded it), `sender`, `senderId`, `senderName`,
123
+ * `participant`, `replyTo`, `transcript`, the media fields described below, and for email `subject`,
124
+ * `html` and `attachments`. Message events also carry `data.channel`: `type` (`WHATSAPP`, `EMAIL`),
125
+ * `account` (`id`, `name`) and `conversation` (`id`, `isGroup`, `address`, and `participants` for a
126
+ * group).
127
+ *
128
+ * #### message.received
129
+ *
130
+ * A message arrived on one of your accounts, in a 1:1 conversation or a group. Fired once per message:
131
+ * a message WhatsApp delivers twice, or that a history sync brings again, is not announced again. A
132
+ * message with media is announced once its media is stored, so it carries `mediaUrl` (or
133
+ * `mediaError`). `direction` is `IN`, `fromMe` is `false`. Not fired for the account's own messages:
134
+ * those are `message.self_sent` or `message.sent`.
135
+ *
136
+ * #### message.self_sent
137
+ *
138
+ * The account's own phone, or another device linked to it, sent a message by hand, outside the API.
139
+ * Same shape as `message.received`, with `direction: "OUT"`, `fromMe: true`, and `sender` the
140
+ * account's own number. Fired once per message. Never fired for a message sent through the API, even
141
+ * though WhatsApp echoes those back too: that is `message.sent`.
142
+ *
143
+ * #### message.sent
144
+ *
145
+ * A message you sent through the API (`POST /message`, a reply) reached the channel. Same shape as
146
+ * `message.self_sent`: `direction: "OUT"`, `fromMe: true`, with the `content`, `externalId`, `sentAt`,
147
+ * the conversation it went to (`conversation.id`, `isGroup`, `address`, and `participants` for a group
148
+ * when they could be read) and, for a media message, `mediaUrl`, `mediaType`, `mimeType` and
149
+ * `mediaFilename`. `id` is the one `POST /message` returned.
150
+ *
151
+ * It fires exactly once per message, when the message first reaches the channel: on its move from
152
+ * `PENDING` or `SENDING` to `SENT`, or straight to `DELIVERED` or `READ` when the channel skips `SENT`.
153
+ * By then its `externalId` is known. Later receipts (`DELIVERED`, `READ`) never fire it again, nor does
154
+ * a retry or a duplicate receipt. A message that never goes out (`FAILED`, `UNDELIVERABLE`) never fires
155
+ * it: watch `message.status` for those. Not fired for a message typed on the phone
156
+ * (`message.self_sent`) or for a received message. A message that had already reached the channel
157
+ * before this event existed is not announced.
158
+ *
159
+ * `message.sent` and the `message.status` reporting `SENT` come from the same change and are delivered
160
+ * independently: either can arrive first.
161
+ *
162
+ * #### message.status
163
+ *
164
+ * A message you sent changed status. `data.message` holds `id`, `externalId`, `status`,
165
+ * `previousStatus`, `error` (why a `FAILED` or `UNDELIVERABLE` message did not go through), `at` (when
166
+ * the status changed) and `sentAt`. No content: that is `message.sent`. Fired once per effective
167
+ * change to `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`; `PENDING` and `SENDING` are
168
+ * UnlimitedMessaging's own queueing steps and are not reported. A receipt arriving out of order (a
169
+ * `DELIVERED` after a `READ`) changes nothing and fires nothing. A failed message that is retried goes
170
+ * through `SENT` again from `SENDING`. Receipts WhatsApp reports for a message typed on the phone
171
+ * (stored as `SENT`) fire it too.
172
+ *
173
+ * #### message.reaction
174
+ *
175
+ * Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). The
176
+ * account's own reactions are included, with `fromMe: true`. `data.reaction` holds `emoji`, `removed`,
177
+ * `reactedToExternalId`, `reactedToMessageId` (null when that message is not stored, see below),
178
+ * `sender`, `senderId`, `senderName`, `participant` (in a group), `fromMe` and `sentAt`. Nothing is
179
+ * stored: a reaction is not a message.
180
+ *
181
+ * #### message.edited
182
+ *
183
+ * A message was edited, by its author. `data.edit` holds `externalId`, `messageId`, `newContent`,
184
+ * `kind` (`text`, or `caption` for the caption of an image, video or document), `error`, `editedAt`,
185
+ * `sender`, `senderId`, `participant` and `fromMe`. The stored content is updated. Phones encrypt an
186
+ * edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing`
187
+ * for a message the account received before it was linked, `decryption_failed` otherwise), the edit is
188
+ * still announced, with `newContent` and `kind` null, and the stored content is left as it was.
189
+ *
190
+ * #### message.deleted
191
+ *
192
+ * A message was deleted for everyone, by its author or a group admin. `data.deletion` holds
193
+ * `externalId`, `messageId`, `deletedAt`, `deletedBy`, `deletedById`, `participant` and `fromMe`. The
194
+ * stored message is kept, with `deletedAt` set.
195
+ *
196
+ * #### message.history
197
+ *
198
+ * Past messages, in batches of up to 100, for an account linked with `syncHistory` (see History
199
+ * below), or asked for with `POST /account/{accountId}/history`. `data` holds `syncType`,
200
+ * `chunkOrder`, `progress`, `isLatest`, `channel` (`type`, `account`) and `messages`, each shaped like
201
+ * the message of `message.received` plus its own `conversation`. Only messages stored for the first
202
+ * time are included. Never sent to an endpoint that did not subscribe to it, and never fired for an
203
+ * account that did not ask for its history.
204
+ *
205
+ * #### group.updated
206
+ *
207
+ * A group the account is in changed (beta accounts). `data` holds `group.id`, `by` (who made the
208
+ * change, when the channel says), `at`, `name`, `topic`, and the members `added`, `removed`,
209
+ * `promoted` and `demoted` (+E164, or an id when the number is hidden). A field that did not change is
210
+ * null or empty.
211
+ *
212
+ * #### account.status_changed
213
+ *
214
+ * An account's status changed: connected, disconnected, logged out, restricted by WhatsApp
215
+ * (`BLOCKED`, with `blockedUntil`), reconnected, deleted... `data.account` holds `id`, `name`,
216
+ * `status`, `previousStatus`, `reason`, `transportCode`, `blockedUntil` and `at`. Fired on every
217
+ * effective change only: a status reported again unchanged fires nothing. `reason` is a
218
+ * machine-readable code (`connected`, `disconnected`, `device_removed` when the device was removed
219
+ * from the phone, `logged_out` when WhatsApp refused the session, `temporary_ban`, `restricted`,
220
+ * `restriction_lifted`, `deleted`, `linking_started`...); treat an unknown value as "changed for another
221
+ * reason", the list grows. `transportCode` is WhatsApp's own numeric code, for diagnosis.
222
+ *
223
+ * #### message.transcribed
224
+ *
225
+ * Reserved for the text extracted from media (OCR, PDF text, voice transcription). It is not fired yet
226
+ * and cannot be subscribed to; `transcript` is `null` on messages until it is.
108
227
  *
109
228
  * The schema of each payload is published with this reference, under `WebhookEvent*`.
110
229
  *
@@ -99,8 +99,12 @@ const errors = __importStar(require("../../../../errors/index"));
99
99
  *
100
100
  * ### Ordering and duplicates
101
101
  *
102
- * Delivery is at least once: the same event can arrive twice, so deduplicate on `eventId` (a message
103
- * is also never announced twice: `message.externalId` is unique per account).
102
+ * Delivery is at least once: the same event can arrive twice, so deduplicate on `eventId` (equal to
103
+ * the `webhook-id` header and kept across retries). `eventId` is per endpoint: two endpoints
104
+ * receiving the same event get two ids, so deduplicate across endpoints on the message's `id` or
105
+ * `externalId` instead. A message is also never announced twice: `message.externalId` is unique per
106
+ * account, and each message is announced by one of `message.received`, `message.self_sent` or
107
+ * `message.sent`, never by two.
104
108
  *
105
109
  * **Events are not delivered in the order things happened.** Retries reorder them, and a message with
106
110
  * media is only announced once its media is stored, a few seconds after it arrived: a text sent right
@@ -109,12 +113,13 @@ const errors = __importStar(require("../../../../errors/index"));
109
113
  *
110
114
  * | Event | Order on |
111
115
  * | ----- | -------- |
112
- * | `message.received`, `message.self_sent` | `data.message.sentAt` (WhatsApp's timestamp) |
116
+ * | `message.received`, `message.self_sent`, `message.sent` | `data.message.sentAt` (WhatsApp's timestamp) |
113
117
  * | `message.status` | `data.message.at`, and `previousStatus` to ignore a stale one |
114
118
  * | `message.reaction` | `data.reaction.sentAt` |
115
119
  * | `message.edited` | `data.edit.editedAt` |
116
120
  * | `message.deleted` | `data.deletion.deletedAt` |
117
121
  * | `account.status_changed` | `data.account.at` |
122
+ * | `group.updated` | `data.at` |
118
123
  *
119
124
  * `GET /message` returns the same `sentAt`.
120
125
  *
@@ -130,14 +135,128 @@ const errors = __importStar(require("../../../../errors/index"));
130
135
  * | Type | When |
131
136
  * | ---- | ---- |
132
137
  * | `message.received` | A message arrived. |
133
- * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. Same shape as `message.received`, with `direction: "OUT"` and `fromMe: true`. |
134
- * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. Only effective changes fire: a late `DELIVERED` after `READ` does not. |
135
- * | `message.reaction` | Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). |
136
- * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. Phones encrypt an edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing` for a message the account received before it was linked, `decryption_failed` otherwise), the edit is still announced, with `newContent` and `kind` null, and the stored content is left as it was. |
137
- * | `message.deleted` | A message was deleted for everyone, by its author or a group admin (`deletedBy`). The stored message is kept, with `deletedAt` set. |
138
- * | `message.history` | Past messages, in batches, for an account linked with `syncHistory` (see below). |
139
- * | `group.updated` | A group the account is in changed: members `added`, `removed`, `promoted` or `demoted`, a new `name` or `topic`. |
140
- * | `account.status_changed` | An account's status changed: disconnected, logged out, restricted by WhatsApp (`BLOCKED`, with `blockedUntil`), reconnected... `reason` is a machine-readable code (`device_removed` when the device was removed from the phone, `logged_out` when WhatsApp refused the session), `transportCode` WhatsApp's own numeric code for diagnosis. |
138
+ * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. |
139
+ * | `message.sent` | A message you sent through the API reached the channel. Carries its content. |
140
+ * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. |
141
+ * | `message.reaction` | Someone reacted to a message, or took their reaction back. |
142
+ * | `message.edited` | A message was edited. |
143
+ * | `message.deleted` | A message was deleted for everyone. |
144
+ * | `message.history` | Past messages, in batches, for an account linked with `syncHistory`. |
145
+ * | `group.updated` | A group the account is in changed. |
146
+ * | `account.status_changed` | An account's status changed. |
147
+ *
148
+ * An endpoint receives only the types listed in its `eventTypes`: there is no "every event" option,
149
+ * and a type added later is never turned on for existing endpoints. To start receiving one, send the
150
+ * full list you want with `PATCH /webhooks/{id}` (`eventTypes` replaces the previous list).
151
+ *
152
+ * The four `message.received`, `message.self_sent`, `message.sent` and `message.history` events carry
153
+ * the same message object (`data.message`, or each item of `data.messages`): `id` (UnlimitedMessaging),
154
+ * `externalId` (WhatsApp), `direction` (`IN` or `OUT`), `fromMe`, `content`, `sentAt` (the channel's
155
+ * timestamp), `receivedAt` (when UnlimitedMessaging recorded it), `sender`, `senderId`, `senderName`,
156
+ * `participant`, `replyTo`, `transcript`, the media fields described below, and for email `subject`,
157
+ * `html` and `attachments`. Message events also carry `data.channel`: `type` (`WHATSAPP`, `EMAIL`),
158
+ * `account` (`id`, `name`) and `conversation` (`id`, `isGroup`, `address`, and `participants` for a
159
+ * group).
160
+ *
161
+ * #### message.received
162
+ *
163
+ * A message arrived on one of your accounts, in a 1:1 conversation or a group. Fired once per message:
164
+ * a message WhatsApp delivers twice, or that a history sync brings again, is not announced again. A
165
+ * message with media is announced once its media is stored, so it carries `mediaUrl` (or
166
+ * `mediaError`). `direction` is `IN`, `fromMe` is `false`. Not fired for the account's own messages:
167
+ * those are `message.self_sent` or `message.sent`.
168
+ *
169
+ * #### message.self_sent
170
+ *
171
+ * The account's own phone, or another device linked to it, sent a message by hand, outside the API.
172
+ * Same shape as `message.received`, with `direction: "OUT"`, `fromMe: true`, and `sender` the
173
+ * account's own number. Fired once per message. Never fired for a message sent through the API, even
174
+ * though WhatsApp echoes those back too: that is `message.sent`.
175
+ *
176
+ * #### message.sent
177
+ *
178
+ * A message you sent through the API (`POST /message`, a reply) reached the channel. Same shape as
179
+ * `message.self_sent`: `direction: "OUT"`, `fromMe: true`, with the `content`, `externalId`, `sentAt`,
180
+ * the conversation it went to (`conversation.id`, `isGroup`, `address`, and `participants` for a group
181
+ * when they could be read) and, for a media message, `mediaUrl`, `mediaType`, `mimeType` and
182
+ * `mediaFilename`. `id` is the one `POST /message` returned.
183
+ *
184
+ * It fires exactly once per message, when the message first reaches the channel: on its move from
185
+ * `PENDING` or `SENDING` to `SENT`, or straight to `DELIVERED` or `READ` when the channel skips `SENT`.
186
+ * By then its `externalId` is known. Later receipts (`DELIVERED`, `READ`) never fire it again, nor does
187
+ * a retry or a duplicate receipt. A message that never goes out (`FAILED`, `UNDELIVERABLE`) never fires
188
+ * it: watch `message.status` for those. Not fired for a message typed on the phone
189
+ * (`message.self_sent`) or for a received message. A message that had already reached the channel
190
+ * before this event existed is not announced.
191
+ *
192
+ * `message.sent` and the `message.status` reporting `SENT` come from the same change and are delivered
193
+ * independently: either can arrive first.
194
+ *
195
+ * #### message.status
196
+ *
197
+ * A message you sent changed status. `data.message` holds `id`, `externalId`, `status`,
198
+ * `previousStatus`, `error` (why a `FAILED` or `UNDELIVERABLE` message did not go through), `at` (when
199
+ * the status changed) and `sentAt`. No content: that is `message.sent`. Fired once per effective
200
+ * change to `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`; `PENDING` and `SENDING` are
201
+ * UnlimitedMessaging's own queueing steps and are not reported. A receipt arriving out of order (a
202
+ * `DELIVERED` after a `READ`) changes nothing and fires nothing. A failed message that is retried goes
203
+ * through `SENT` again from `SENDING`. Receipts WhatsApp reports for a message typed on the phone
204
+ * (stored as `SENT`) fire it too.
205
+ *
206
+ * #### message.reaction
207
+ *
208
+ * Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). The
209
+ * account's own reactions are included, with `fromMe: true`. `data.reaction` holds `emoji`, `removed`,
210
+ * `reactedToExternalId`, `reactedToMessageId` (null when that message is not stored, see below),
211
+ * `sender`, `senderId`, `senderName`, `participant` (in a group), `fromMe` and `sentAt`. Nothing is
212
+ * stored: a reaction is not a message.
213
+ *
214
+ * #### message.edited
215
+ *
216
+ * A message was edited, by its author. `data.edit` holds `externalId`, `messageId`, `newContent`,
217
+ * `kind` (`text`, or `caption` for the caption of an image, video or document), `error`, `editedAt`,
218
+ * `sender`, `senderId`, `participant` and `fromMe`. The stored content is updated. Phones encrypt an
219
+ * edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing`
220
+ * for a message the account received before it was linked, `decryption_failed` otherwise), the edit is
221
+ * still announced, with `newContent` and `kind` null, and the stored content is left as it was.
222
+ *
223
+ * #### message.deleted
224
+ *
225
+ * A message was deleted for everyone, by its author or a group admin. `data.deletion` holds
226
+ * `externalId`, `messageId`, `deletedAt`, `deletedBy`, `deletedById`, `participant` and `fromMe`. The
227
+ * stored message is kept, with `deletedAt` set.
228
+ *
229
+ * #### message.history
230
+ *
231
+ * Past messages, in batches of up to 100, for an account linked with `syncHistory` (see History
232
+ * below), or asked for with `POST /account/{accountId}/history`. `data` holds `syncType`,
233
+ * `chunkOrder`, `progress`, `isLatest`, `channel` (`type`, `account`) and `messages`, each shaped like
234
+ * the message of `message.received` plus its own `conversation`. Only messages stored for the first
235
+ * time are included. Never sent to an endpoint that did not subscribe to it, and never fired for an
236
+ * account that did not ask for its history.
237
+ *
238
+ * #### group.updated
239
+ *
240
+ * A group the account is in changed (beta accounts). `data` holds `group.id`, `by` (who made the
241
+ * change, when the channel says), `at`, `name`, `topic`, and the members `added`, `removed`,
242
+ * `promoted` and `demoted` (+E164, or an id when the number is hidden). A field that did not change is
243
+ * null or empty.
244
+ *
245
+ * #### account.status_changed
246
+ *
247
+ * An account's status changed: connected, disconnected, logged out, restricted by WhatsApp
248
+ * (`BLOCKED`, with `blockedUntil`), reconnected, deleted... `data.account` holds `id`, `name`,
249
+ * `status`, `previousStatus`, `reason`, `transportCode`, `blockedUntil` and `at`. Fired on every
250
+ * effective change only: a status reported again unchanged fires nothing. `reason` is a
251
+ * machine-readable code (`connected`, `disconnected`, `device_removed` when the device was removed
252
+ * from the phone, `logged_out` when WhatsApp refused the session, `temporary_ban`, `restricted`,
253
+ * `restriction_lifted`, `deleted`, `linking_started`...); treat an unknown value as "changed for another
254
+ * reason", the list grows. `transportCode` is WhatsApp's own numeric code, for diagnosis.
255
+ *
256
+ * #### message.transcribed
257
+ *
258
+ * Reserved for the text extracted from media (OCR, PDF text, voice transcription). It is not fired yet
259
+ * and cannot be subscribed to; `transcript` is `null` on messages until it is.
141
260
  *
142
261
  * The schema of each payload is published with this reference, under `WebhookEvent*`.
143
262
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointCreateRequestEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointCreateRequestEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointCreateRequestEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointCreateRequestEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointCreateRequestEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointCreateResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointCreateResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointCreateResponseEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointCreateResponseEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointCreateResponseEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointFindOneResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointFindOneResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointFindOneResponseEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointFindOneResponseEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointFindOneResponseEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointListResponseDataItemEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointListResponseDataItemEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointListResponseDataItemEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointListResponseDataItemEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointListResponseDataItemEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointUpdateRequestEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointUpdateRequestEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointUpdateRequestEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointUpdateRequestEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointUpdateRequestEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type WebhookEndpointUpdateResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted";
4
+ export type WebhookEndpointUpdateResponseEventTypesItem = "message.received" | "message.self_sent" | "message.status" | "message.reaction" | "message.edited" | "account.status_changed" | "message.history" | "group.updated" | "message.deleted" | "message.sent";
5
5
  export declare const WebhookEndpointUpdateResponseEventTypesItem: {
6
6
  readonly MessageReceived: "message.received";
7
7
  readonly MessageSelfSent: "message.self_sent";
@@ -12,4 +12,5 @@ export declare const WebhookEndpointUpdateResponseEventTypesItem: {
12
12
  readonly MessageHistory: "message.history";
13
13
  readonly GroupUpdated: "group.updated";
14
14
  readonly MessageDeleted: "message.deleted";
15
+ readonly MessageSent: "message.sent";
15
16
  };
@@ -14,4 +14,5 @@ exports.WebhookEndpointUpdateResponseEventTypesItem = {
14
14
  MessageHistory: "message.history",
15
15
  GroupUpdated: "group.updated",
16
16
  MessageDeleted: "message.deleted",
17
+ MessageSent: "message.sent",
17
18
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as UnlimitedMessagingApi from "../index";
5
+ export interface WebhookEventMessageSent {
6
+ type: UnlimitedMessagingApi.WebhookEventMessageSentType;
7
+ eventId: string;
8
+ occurredAt: Date;
9
+ data: UnlimitedMessagingApi.WebhookEventMessageSentData;
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as UnlimitedMessagingApi from "../index";
5
+ export interface WebhookEventMessageSentData {
6
+ message: UnlimitedMessagingApi.WebhookEventMessageSentDataMessage;
7
+ channel: UnlimitedMessagingApi.WebhookEventMessageSentDataChannel;
8
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as UnlimitedMessagingApi from "../index";
5
+ export interface WebhookEventMessageSentDataChannel {
6
+ type: UnlimitedMessagingApi.WebhookEventMessageSentDataChannelType;
7
+ account: UnlimitedMessagingApi.WebhookEventMessageSentDataChannelAccount;
8
+ conversation: UnlimitedMessagingApi.WebhookEventMessageSentDataChannelConversation;
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface WebhookEventMessageSentDataChannelAccount {
5
+ id: string;
6
+ name: string | null;
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface WebhookEventMessageSentDataChannelConversation {
5
+ id: string | null;
6
+ isGroup: boolean;
7
+ address: string | null;
8
+ participants?: string[];
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type WebhookEventMessageSentDataChannelType = "WHATSAPP" | "SMS" | "EMAIL";
5
+ export declare const WebhookEventMessageSentDataChannelType: {
6
+ readonly Whatsapp: "WHATSAPP";
7
+ readonly Sms: "SMS";
8
+ readonly Email: "EMAIL";
9
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebhookEventMessageSentDataChannelType = void 0;
7
+ exports.WebhookEventMessageSentDataChannelType = {
8
+ Whatsapp: "WHATSAPP",
9
+ Sms: "SMS",
10
+ Email: "EMAIL",
11
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as UnlimitedMessagingApi from "../index";
5
+ export interface WebhookEventMessageSentDataMessage {
6
+ id: string;
7
+ externalId: string | null;
8
+ direction: UnlimitedMessagingApi.WebhookEventMessageSentDataMessageDirection;
9
+ fromMe: boolean;
10
+ content: string | null;
11
+ sentAt: Date;
12
+ receivedAt: Date;
13
+ sender: string | null;
14
+ senderId: string;
15
+ senderName: string | null;
16
+ participant: string | null;
17
+ replyTo: UnlimitedMessagingApi.WebhookEventMessageSentDataMessageReplyTo | null;
18
+ mediaUrl?: string;
19
+ mediaType?: string;
20
+ mimeType?: string;
21
+ mediaFilename?: string;
22
+ mediaSize?: number;
23
+ durationSec?: number;
24
+ mediaError?: string;
25
+ transcript: string | null;
26
+ subject?: string;
27
+ html?: string;
28
+ attachments?: UnlimitedMessagingApi.WebhookEventMessageSentDataMessageAttachmentsItem[];
29
+ }