@sentdm/sentdm 0.37.0 → 0.39.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 (88) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +31 -0
  3. package/client.d.mts +22 -8
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +22 -8
  6. package/client.d.ts.map +1 -1
  7. package/client.js +10 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +10 -0
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +164 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +164 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +212 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +202 -0
  18. package/core/pagination.mjs.map +1 -0
  19. package/index.d.mts +1 -0
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +1 -0
  22. package/index.d.ts.map +1 -1
  23. package/index.js +3 -1
  24. package/index.js.map +1 -1
  25. package/index.mjs +1 -0
  26. package/index.mjs.map +1 -1
  27. package/internal/tslib.js +17 -17
  28. package/package.json +11 -1
  29. package/pagination.d.mts +3 -0
  30. package/pagination.d.mts.map +1 -0
  31. package/pagination.d.ts +3 -0
  32. package/pagination.d.ts.map +1 -0
  33. package/pagination.js +6 -0
  34. package/pagination.js.map +1 -0
  35. package/pagination.mjs +3 -0
  36. package/pagination.mjs.map +1 -0
  37. package/resources/contacts.d.mts +9 -52
  38. package/resources/contacts.d.mts.map +1 -1
  39. package/resources/contacts.d.ts +9 -52
  40. package/resources/contacts.d.ts.map +1 -1
  41. package/resources/contacts.js +8 -7
  42. package/resources/contacts.js.map +1 -1
  43. package/resources/contacts.mjs +8 -7
  44. package/resources/contacts.mjs.map +1 -1
  45. package/resources/conversations.d.mts +17 -32
  46. package/resources/conversations.d.mts.map +1 -1
  47. package/resources/conversations.d.ts +17 -32
  48. package/resources/conversations.d.ts.map +1 -1
  49. package/resources/conversations.js +17 -16
  50. package/resources/conversations.js.map +1 -1
  51. package/resources/conversations.mjs +17 -16
  52. package/resources/conversations.mjs.map +1 -1
  53. package/resources/index.d.mts +4 -4
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +4 -4
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/index.js.map +1 -1
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/templates.d.mts +162 -65
  60. package/resources/templates.d.mts.map +1 -1
  61. package/resources/templates.d.ts +162 -65
  62. package/resources/templates.d.ts.map +1 -1
  63. package/resources/templates.js +36 -9
  64. package/resources/templates.js.map +1 -1
  65. package/resources/templates.mjs +36 -9
  66. package/resources/templates.mjs.map +1 -1
  67. package/resources/webhooks.d.mts +340 -134
  68. package/resources/webhooks.d.mts.map +1 -1
  69. package/resources/webhooks.d.ts +340 -134
  70. package/resources/webhooks.d.ts.map +1 -1
  71. package/resources/webhooks.js +16 -13
  72. package/resources/webhooks.js.map +1 -1
  73. package/resources/webhooks.mjs +16 -13
  74. package/resources/webhooks.mjs.map +1 -1
  75. package/src/client.ts +80 -6
  76. package/src/core/pagination.ts +428 -0
  77. package/src/index.ts +1 -0
  78. package/src/pagination.ts +2 -0
  79. package/src/resources/contacts.ts +15 -62
  80. package/src/resources/conversations.ts +36 -48
  81. package/src/resources/index.ts +9 -3
  82. package/src/resources/templates.ts +169 -75
  83. package/src/resources/webhooks.ts +404 -163
  84. package/src/version.ts +1 -1
  85. package/version.d.mts +1 -1
  86. package/version.d.ts +1 -1
  87. package/version.js +1 -1
  88. package/version.mjs +1 -1
@@ -3,6 +3,13 @@
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as WebhooksAPI from './webhooks';
5
5
  import { APIPromise } from '../core/api-promise';
6
+ import {
7
+ PagePromise,
8
+ WebhookEventsPage,
9
+ type WebhookEventsPageParams,
10
+ WebhooksPage,
11
+ type WebhooksPageParams,
12
+ } from '../core/pagination';
6
13
  import { buildHeaders } from '../internal/headers';
7
14
  import { RequestOptions } from '../internal/request-options';
8
15
  import { path } from '../internal/utils/path';
@@ -93,15 +100,18 @@ export class Webhooks extends APIResource {
93
100
  *
94
101
  * @example
95
102
  * ```ts
96
- * const webhooks = await client.webhooks.list({
97
- * page: 0,
98
- * page_size: 0,
99
- * });
103
+ * // Automatically fetches more pages as needed.
104
+ * for await (const webhookResponse of client.webhooks.list()) {
105
+ * // ...
106
+ * }
100
107
  * ```
101
108
  */
102
- list(params: WebhookListParams, options?: RequestOptions): APIPromise<WebhookListResponse> {
103
- const { 'x-profile-id': xProfileID, ...query } = params;
104
- return this._client.get('/v3/webhooks', {
109
+ list(
110
+ params: WebhookListParams | null | undefined = {},
111
+ options?: RequestOptions,
112
+ ): PagePromise<WebhookResponsesWebhooksPage, WebhookResponse> {
113
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
114
+ return this._client.getAPIList('/v3/webhooks', WebhooksPage<WebhookResponse>, {
105
115
  query,
106
116
  ...options,
107
117
  headers: buildHeaders([
@@ -163,26 +173,32 @@ export class Webhooks extends APIResource {
163
173
  *
164
174
  * @example
165
175
  * ```ts
166
- * const response = await client.webhooks.listEvents(
176
+ * // Automatically fetches more pages as needed.
177
+ * for await (const webhookListEventsResponse of client.webhooks.listEvents(
167
178
  * 'd4f5a6b7-c8d9-4e0f-a1b2-c3d4e5f6a7b8',
168
- * { page: 0, page_size: 0 },
169
- * );
179
+ * )) {
180
+ * // ...
181
+ * }
170
182
  * ```
171
183
  */
172
184
  listEvents(
173
185
  id: string,
174
- params: WebhookListEventsParams,
186
+ params: WebhookListEventsParams | null | undefined = {},
175
187
  options?: RequestOptions,
176
- ): APIPromise<WebhookListEventsResponse> {
177
- const { 'x-profile-id': xProfileID, ...query } = params;
178
- return this._client.get(path`/v3/webhooks/${id}/events`, {
179
- query,
180
- ...options,
181
- headers: buildHeaders([
182
- { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
183
- options?.headers,
184
- ]),
185
- });
188
+ ): PagePromise<WebhookListEventsResponsesWebhookEventsPage, WebhookListEventsResponse> {
189
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
190
+ return this._client.getAPIList(
191
+ path`/v3/webhooks/${id}/events`,
192
+ WebhookEventsPage<WebhookListEventsResponse>,
193
+ {
194
+ query,
195
+ ...options,
196
+ headers: buildHeaders([
197
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
198
+ options?.headers,
199
+ ]),
200
+ },
201
+ );
186
202
  }
187
203
 
188
204
  /**
@@ -271,6 +287,10 @@ export class Webhooks extends APIResource {
271
287
  }
272
288
  }
273
289
 
290
+ export type WebhookResponsesWebhooksPage = WebhooksPage<WebhookResponse>;
291
+
292
+ export type WebhookListEventsResponsesWebhookEventsPage = WebhookEventsPage<WebhookListEventsResponse>;
293
+
274
294
  /**
275
295
  * Request and response metadata
276
296
  */
@@ -316,6 +336,282 @@ export interface APIResponseWebhook {
316
336
  success?: boolean;
317
337
  }
318
338
 
339
+ /**
340
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
341
+ * this shape and varies only in Payload.
342
+ */
343
+ export interface ChannelEvent {
344
+ /**
345
+ * The specific event within the family, for example message.delivered,
346
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
347
+ * treat it as optional.
348
+ */
349
+ event?: string | null;
350
+
351
+ /**
352
+ * The event family, for example message, templates or contact. Route on this
353
+ * first, then on event for the specific change.
354
+ */
355
+ field?: string;
356
+
357
+ /**
358
+ * Body of a channel event: where one of the customer's channels stands in
359
+ * provisioning and compliance. Delivered when a milestone moves — a registration
360
+ * filed, a verdict returned, a resubmission asked for, a sender gone live — so a
361
+ * customer's own onboarding UI does not have to poll GET /v3/channels.
362
+ *
363
+ * The subject is one item, never the account. A customer's "SMS channel" has no
364
+ * status; a market does. Country, NumberType and SenderValue name which one, so a
365
+ * customer terminating only to Kosovo never receives an event about US 10DLC.
366
+ *
367
+ * Status is the stable half of the contract. It is the same four-value set GET
368
+ * /v3/channels publishes, computed through the same code, so an event and a read
369
+ * of the same market cannot disagree. A subscriber that reads nothing but the
370
+ * status and the subject fields is a correct subscriber. The sub-type on the
371
+ * envelope names the specific milestone and is additive — that vocabulary comes
372
+ * from registries and carriers, which are parties Sent does not control.
373
+ *
374
+ * Status means provisioning and compliance are complete, not that a send will
375
+ * succeed right now. An account can be suspended, or a destination blocked by a
376
+ * routing rule, without either showing up here. Those are separate surfaces and
377
+ * deliberately not modelled on this payload.
378
+ */
379
+ payload?: ChannelEventPayload | null;
380
+
381
+ /**
382
+ * The event-specific body.
383
+ */
384
+ request_id?: string | null;
385
+
386
+ /**
387
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
388
+ * time, not the time the underlying change happened. Use the timestamp inside the
389
+ * payload for the latter.
390
+ */
391
+ timestamp?: string;
392
+ }
393
+
394
+ /**
395
+ * Body of a channel event: where one of the customer's channels stands in
396
+ * provisioning and compliance. Delivered when a milestone moves — a registration
397
+ * filed, a verdict returned, a resubmission asked for, a sender gone live — so a
398
+ * customer's own onboarding UI does not have to poll GET /v3/channels.
399
+ *
400
+ * The subject is one item, never the account. A customer's "SMS channel" has no
401
+ * status; a market does. Country, NumberType and SenderValue name which one, so a
402
+ * customer terminating only to Kosovo never receives an event about US 10DLC.
403
+ *
404
+ * Status is the stable half of the contract. It is the same four-value set GET
405
+ * /v3/channels publishes, computed through the same code, so an event and a read
406
+ * of the same market cannot disagree. A subscriber that reads nothing but the
407
+ * status and the subject fields is a correct subscriber. The sub-type on the
408
+ * envelope names the specific milestone and is additive — that vocabulary comes
409
+ * from registries and carriers, which are parties Sent does not control.
410
+ *
411
+ * Status means provisioning and compliance are complete, not that a send will
412
+ * succeed right now. An account can be suspended, or a destination blocked by a
413
+ * routing rule, without either showing up here. Those are separate surfaces and
414
+ * deliberately not modelled on this payload.
415
+ */
416
+ export interface ChannelEventPayload {
417
+ /**
418
+ * The market's destination country as an ISO 3166-1 alpha-2 code, for example XK.
419
+ * Always present, and the property that identifies this payload among the
420
+ * delivered envelopes — see DeliveredWebhookEvents. Every event in this family
421
+ * reports one market, and a market has a country.
422
+ */
423
+ country: string;
424
+
425
+ /**
426
+ * The account whose market this is, named as on every other family. When an
427
+ * organization receives an event for one of its sender profiles this is the
428
+ * profile, so a reseller compares it with its own id and anything different is one
429
+ * of its profiles.
430
+ */
431
+ account_id?: string;
432
+
433
+ /**
434
+ * The channel this market belongs to: sms, whatsapp, or rcs. Never sent — that
435
+ * value belongs to message events, where it names the smart-routing brand rather
436
+ * than a channel that can be provisioned.
437
+ */
438
+ channel?: string;
439
+
440
+ /**
441
+ * The kind of sender the market uses, for example TEN_DLC, LOCAL, or ALPHANUMERIC.
442
+ * Omitted when the subject has no sender type of its own.
443
+ */
444
+ number_type?: string | null;
445
+
446
+ /**
447
+ * Why the market reached this state, when a reason was given — a correction
448
+ * explained, or a campaign lapse. Free text, passed through from the registry or
449
+ * carrier that wrote it, so treat it as a message to show a human rather than a
450
+ * value to branch on.
451
+ */
452
+ reason?: string | null;
453
+
454
+ /**
455
+ * The sender itself — a number in E.164, or an alphanumeric sender ID.
456
+ *
457
+ * Always present, and null until a sender exists. The key is on every delivery so
458
+ * a subscriber reads one shape rather than branching on whether the field arrived
459
+ * — the same choice template_id makes on the message payload.
460
+ *
461
+ * It can carry a value at any point in the lifecycle, not only once the market is
462
+ * live: a number ordered and not yet active at the carrier is already known during
463
+ * PROVISIONING, and an alphanumeric sender the customer chose themselves is known
464
+ * before anything is filed. It is null while the market is still waiting on a
465
+ * number, which for a US 10DLC registration is every event up to
466
+ * channel.activated.
467
+ */
468
+ sender_value?: string | null;
469
+
470
+ /**
471
+ * Where the market stands: PENDING_REVIEW, ACTION_NEEDED, PROVISIONING, ACTIVE or
472
+ * INACTIVE. PENDING_REVIEW means a registry or a carrier holds it and the wait is
473
+ * theirs; ACTION_NEEDED means it is yours; PROVISIONING means the verdict is in
474
+ * and Sent is acquiring the sender; INACTIVE means it had a working sender and no
475
+ * longer does.
476
+ *
477
+ * Each event name is the transition into one of these, but the two are separate
478
+ * fields and may legitimately differ. A resubmission filed against a market whose
479
+ * sender is already live is channel.submitted carrying ACTIVE: a correction is
480
+ * with the registry and the sender keeps working. Read both.
481
+ */
482
+ status?: string;
483
+
484
+ /**
485
+ * When the transition happened, in UTC (yyyy-MM-ddTHH:mm:ssZ).
486
+ */
487
+ updated_at?: string;
488
+ }
489
+
490
+ /**
491
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
492
+ * this shape and varies only in Payload.
493
+ */
494
+ export interface ContactEvent {
495
+ /**
496
+ * The specific event within the family, for example message.delivered,
497
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
498
+ * treat it as optional.
499
+ */
500
+ event?: string | null;
501
+
502
+ /**
503
+ * The event family, for example message, templates or contact. Route on this
504
+ * first, then on event for the specific change.
505
+ */
506
+ field?: string;
507
+
508
+ /**
509
+ * Body of a contact.opt_in, contact.opt_out or contact.help event. Delivered when
510
+ * a contact signals a consent change or asks for help.
511
+ *
512
+ * These events state the signal outright, so you do not have to recognise keywords
513
+ * in the text of a message.received event. They also cover cases that produce no
514
+ * inbound message at all, such as a network handling an opt-out on your behalf.
515
+ *
516
+ * Fields are ordered identity → resulting state → provenance → join key. Nothing
517
+ * here restates the envelope: which of the three signals occurred is the
518
+ * envelope's event, and when it was emitted is its timestamp. Retries carry the
519
+ * same X-Webhook-Event-ID header, which is what to deduplicate on.
520
+ */
521
+ payload?: ContactEventPayload | null;
522
+
523
+ /**
524
+ * The event-specific body.
525
+ */
526
+ request_id?: string | null;
527
+
528
+ /**
529
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
530
+ * time, not the time the underlying change happened. Use the timestamp inside the
531
+ * payload for the latter.
532
+ */
533
+ timestamp?: string;
534
+ }
535
+
536
+ /**
537
+ * Body of a contact.opt_in, contact.opt_out or contact.help event. Delivered when
538
+ * a contact signals a consent change or asks for help.
539
+ *
540
+ * These events state the signal outright, so you do not have to recognise keywords
541
+ * in the text of a message.received event. They also cover cases that produce no
542
+ * inbound message at all, such as a network handling an opt-out on your behalf.
543
+ *
544
+ * Fields are ordered identity → resulting state → provenance → join key. Nothing
545
+ * here restates the envelope: which of the three signals occurred is the
546
+ * envelope's event, and when it was emitted is its timestamp. Retries carry the
547
+ * same X-Webhook-Event-ID header, which is what to deduplicate on.
548
+ */
549
+ export interface ContactEventPayload {
550
+ /**
551
+ * Whether the contact is opted out after this signal — the state to write to your
552
+ * own record. Same meaning as opt_out on the contact resource. On contact.help
553
+ * this reports the contact's existing state, which help does not change.
554
+ *
555
+ * Two signals from the same contact can arrive out of order, because each one is
556
+ * queued on its own rather than against the contact. Compare the envelope's
557
+ * timestamp before you overwrite a newer state with an older one. That timestamp
558
+ * is second-precision, so treat two signals stamped in the same second as
559
+ * unordered and read the contact resource to settle them.
560
+ */
561
+ opt_out: boolean;
562
+
563
+ /**
564
+ * How the signal reached us. INBOUND_KEYWORD means the contact sent a message
565
+ * whose text matched one of the keywords; PROVIDER_SIGNAL means the network
566
+ * reported it. A provider signal usually carries no message_id or text, so read
567
+ * both for null rather than inferring them from this field.
568
+ */
569
+ source: string;
570
+
571
+ /**
572
+ * The account the contact belongs to. Present so one endpoint can serve several
573
+ * accounts.
574
+ */
575
+ account_id?: string;
576
+
577
+ /**
578
+ * The channel the signal arrived on, for example sms or whatsapp.
579
+ */
580
+ channel?: string;
581
+
582
+ /**
583
+ * The contact who raised the signal. Always populated, including for contact.help
584
+ * from a number you have not messaged before — the contact is created if it does
585
+ * not exist yet, so this identifier is always resolvable against the contacts API.
586
+ */
587
+ contact_id?: string;
588
+
589
+ /**
590
+ * The inbound message that carried the signal, matching message_id on the
591
+ * corresponding message.received event so the two can be joined.
592
+ *
593
+ * Sent as null when the signal did not arrive as a message — for example when a
594
+ * network processed an opt-out on your behalf — and also when the message belongs
595
+ * to a different account than this event, which can happen on a shared WhatsApp
596
+ * number. The field is always present, so read it and check for null rather than
597
+ * checking whether the key exists.
598
+ */
599
+ message_id?: string | null;
600
+
601
+ /**
602
+ * The contact's number in E.164 format. Same value as phone_number on the contact
603
+ * resource.
604
+ */
605
+ phone_number?: string;
606
+
607
+ /**
608
+ * The text the contact sent, for example STOP or UNSUBSCRIBE. Sent as null when
609
+ * the signal did not arrive as text. The field is always present, so read it and
610
+ * check for null rather than checking whether the key exists.
611
+ */
612
+ text?: string | null;
613
+ }
614
+
319
615
  /**
320
616
  * Error information
321
617
  */
@@ -347,15 +643,15 @@ export interface ErrorDetail {
347
643
  */
348
644
  export interface InboundMessageEvent {
349
645
  /**
350
- * The specific event within the family, for example message.delivered or
351
- * message.received. Absent on events that have no subtype, so treat it as
352
- * optional.
646
+ * The specific event within the family, for example message.delivered,
647
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
648
+ * treat it as optional.
353
649
  */
354
650
  event?: string | null;
355
651
 
356
652
  /**
357
- * The event family, for example message or templates. Route on this first, then on
358
- * event for the specific change.
653
+ * The event family, for example message, templates or contact. Route on this
654
+ * first, then on event for the specific change.
359
655
  */
360
656
  field?: string;
361
657
 
@@ -365,6 +661,11 @@ export interface InboundMessageEvent {
365
661
  */
366
662
  payload?: InboundMessageEventPayload | null;
367
663
 
664
+ /**
665
+ * The event-specific body.
666
+ */
667
+ request_id?: string | null;
668
+
368
669
  /**
369
670
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
370
671
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -428,15 +729,15 @@ export interface InboundMessageEventPayload {
428
729
  */
429
730
  export interface MessageEvent {
430
731
  /**
431
- * The specific event within the family, for example message.delivered or
432
- * message.received. Absent on events that have no subtype, so treat it as
433
- * optional.
732
+ * The specific event within the family, for example message.delivered,
733
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
734
+ * treat it as optional.
434
735
  */
435
736
  event?: string | null;
436
737
 
437
738
  /**
438
- * The event family, for example message or templates. Route on this first, then on
439
- * event for the specific change.
739
+ * The event family, for example message, templates or contact. Route on this
740
+ * first, then on event for the specific change.
440
741
  */
441
742
  field?: string;
442
743
 
@@ -447,6 +748,11 @@ export interface MessageEvent {
447
748
  */
448
749
  payload?: MessageEventPayload | null;
449
750
 
751
+ /**
752
+ * The event-specific body.
753
+ */
754
+ request_id?: string | null;
755
+
450
756
  /**
451
757
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
452
758
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -478,6 +784,13 @@ export interface MessageEventPayload {
478
784
  */
479
785
  agent_id?: string | null;
480
786
 
787
+ /**
788
+ * The rendered message body, as plain text. Sent as null when we aren't asserting
789
+ * a body for this event. The field is always present, so read it and check for
790
+ * null rather than checking whether the key exists. Truncated to 3072 characters.
791
+ */
792
+ body?: string | null;
793
+
481
794
  /**
482
795
  * The channel the message went out on, for example sms or whatsapp. A message that
483
796
  * falls back to another channel reports the channel actually used.
@@ -578,15 +891,15 @@ export namespace PaginationMeta {
578
891
  */
579
892
  export interface TemplateEvent {
580
893
  /**
581
- * The specific event within the family, for example message.delivered or
582
- * message.received. Absent on events that have no subtype, so treat it as
583
- * optional.
894
+ * The specific event within the family, for example message.delivered,
895
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
896
+ * treat it as optional.
584
897
  */
585
898
  event?: string | null;
586
899
 
587
900
  /**
588
- * The event family, for example message or templates. Route on this first, then on
589
- * event for the specific change.
901
+ * The event family, for example message, templates or contact. Route on this
902
+ * first, then on event for the specific change.
590
903
  */
591
904
  field?: string;
592
905
 
@@ -596,6 +909,11 @@ export interface TemplateEvent {
596
909
  */
597
910
  payload?: TemplateEventPayload | null;
598
911
 
912
+ /**
913
+ * The event-specific body.
914
+ */
915
+ request_id?: string | null;
916
+
599
917
  /**
600
918
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
601
919
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -625,15 +943,39 @@ export interface TemplateEventPayload {
625
943
  */
626
944
  account_id?: string;
627
945
 
946
+ /**
947
+ * Which consent keyword this template answers, when it is one of Sent's
948
+ * auto-replies: OPT_IN, OPT_OUT, HELP, or OTHER for a customer-defined keyword.
949
+ *
950
+ * Omitted for an ordinary template, so its presence is the answer to "is this an
951
+ * auto-reply". Sent creates the three compliance auto-replies at signup and they
952
+ * go through review like any other template, so their events arrive mixed in with
953
+ * the customer's own with nothing else to tell them apart.
954
+ *
955
+ * Named for the reader rather than after Template.OptAction, which it is mapped
956
+ * from. The MCP tool result deliberately keeps OptAction, OptKeywords and IsOpt:
957
+ * it mirrors the internal shape on purpose and publishes the keywords too, so
958
+ * renaming one of the three there would leave a surface half in each vocabulary.
959
+ * Two names for one concept, each consistent within its own surface, chosen over a
960
+ * rename that breaks MCP clients silently.
961
+ */
962
+ auto_reply_action?: string | null;
963
+
628
964
  /**
629
965
  * The template's category, for example UTILITY, MARKETING, or AUTHENTICATION.
630
966
  */
631
967
  category?: string;
632
968
 
633
969
  /**
634
- * The channel the template applies to.
970
+ * The channel leg this decision is about, for example whatsapp, sms, or rcs. A
971
+ * template is reviewed per channel and the legs come back independently, so each
972
+ * one reports separately.
973
+ *
974
+ * Omitted when the decision applies to the template as a whole rather than to one
975
+ * leg. That event is the broader news: a template-wide rejection blocks every
976
+ * channel, whatever the individual legs say.
635
977
  */
636
- channel?: string;
978
+ channel?: string | null;
637
979
 
638
980
  /**
639
981
  * The template's language code, for example en_US.
@@ -707,48 +1049,6 @@ export interface WebhookResponse {
707
1049
  updated_at?: string | null;
708
1050
  }
709
1051
 
710
- /**
711
- * Standard API response envelope for all v3 endpoints
712
- */
713
- export interface WebhookListResponse {
714
- /**
715
- * A paginated list of webhooks.
716
- */
717
- data?: WebhookListResponse.Data | null;
718
-
719
- /**
720
- * Error information
721
- */
722
- error?: ErrorDetail | null;
723
-
724
- /**
725
- * Request and response metadata
726
- */
727
- meta?: APIMeta;
728
-
729
- /**
730
- * Indicates whether the request was successful
731
- */
732
- success?: boolean;
733
- }
734
-
735
- export namespace WebhookListResponse {
736
- /**
737
- * A paginated list of webhooks.
738
- */
739
- export interface Data {
740
- /**
741
- * Pagination metadata for list responses
742
- */
743
- pagination?: WebhooksAPI.PaginationMeta;
744
-
745
- /**
746
- * The webhooks on this page.
747
- */
748
- webhooks?: Array<WebhooksAPI.WebhookResponse>;
749
- }
750
- }
751
-
752
1052
  /**
753
1053
  * Standard API response envelope for all v3 endpoints
754
1054
  */
@@ -791,78 +1091,34 @@ export namespace WebhookListEventTypesResponse {
791
1091
  }
792
1092
  }
793
1093
 
794
- /**
795
- * Standard API response envelope for all v3 endpoints
796
- */
797
1094
  export interface WebhookListEventsResponse {
798
- /**
799
- * A paginated list of webhook delivery records.
800
- */
801
- data?: WebhookListEventsResponse.Data | null;
1095
+ id?: string;
802
1096
 
803
- /**
804
- * Error information
805
- */
806
- error?: ErrorDetail | null;
1097
+ created_at?: string;
807
1098
 
808
- /**
809
- * Request and response metadata
810
- */
811
- meta?: APIMeta;
1099
+ delivery_attempts?: number;
812
1100
 
813
- /**
814
- * Indicates whether the request was successful
815
- */
816
- success?: boolean;
817
- }
1101
+ delivery_status?: string;
1102
+
1103
+ error_message?: string | null;
818
1104
 
819
- export namespace WebhookListEventsResponse {
820
1105
  /**
821
- * A paginated list of webhook delivery records.
1106
+ * The exact event body that was delivered, or attempted, for this record. One of
1107
+ * the four webhook envelopes: a message status change, an inbound message, a
1108
+ * template status change, or a contact consent signal. Read field and event to
1109
+ * tell which, the same way your endpoint does.
822
1110
  */
823
- export interface Data {
824
- /**
825
- * The events on this page.
826
- */
827
- events?: Array<Data.Event>;
1111
+ event_data?: MessageEvent | InboundMessageEvent | TemplateEvent | ChannelEvent | ContactEvent;
828
1112
 
829
- /**
830
- * Pagination metadata for list responses
831
- */
832
- pagination?: WebhooksAPI.PaginationMeta;
833
- }
834
-
835
- export namespace Data {
836
- export interface Event {
837
- id?: string;
838
-
839
- created_at?: string;
840
-
841
- delivery_attempts?: number;
842
-
843
- delivery_status?: string;
844
-
845
- error_message?: string | null;
846
-
847
- /**
848
- * The exact event body that was delivered, or attempted, for this record. One of
849
- * the three webhook envelopes: a message status change, an inbound message, or a
850
- * template status change. Read field and event to tell which, the same way your
851
- * endpoint does.
852
- */
853
- event_data?: WebhooksAPI.MessageEvent | WebhooksAPI.InboundMessageEvent | WebhooksAPI.TemplateEvent;
854
-
855
- event_type?: string;
1113
+ event_type?: string;
856
1114
 
857
- http_status_code?: number | null;
1115
+ http_status_code?: number | null;
858
1116
 
859
- processing_completed_at?: string | null;
1117
+ processing_completed_at?: string | null;
860
1118
 
861
- processing_started_at?: string | null;
1119
+ processing_started_at?: string | null;
862
1120
 
863
- response_body?: string | null;
864
- }
865
- }
1121
+ response_body?: string | null;
866
1122
  }
867
1123
 
868
1124
  /**
@@ -1047,17 +1303,7 @@ export interface WebhookUpdateParams {
1047
1303
  'x-profile-id'?: string;
1048
1304
  }
1049
1305
 
1050
- export interface WebhookListParams {
1051
- /**
1052
- * Query param
1053
- */
1054
- page: number;
1055
-
1056
- /**
1057
- * Query param
1058
- */
1059
- page_size: number;
1060
-
1306
+ export interface WebhookListParams extends WebhooksPageParams {
1061
1307
  /**
1062
1308
  * Query param
1063
1309
  */
@@ -1092,17 +1338,7 @@ export interface WebhookListEventTypesParams {
1092
1338
  'x-profile-id'?: string;
1093
1339
  }
1094
1340
 
1095
- export interface WebhookListEventsParams {
1096
- /**
1097
- * Query param
1098
- */
1099
- page: number;
1100
-
1101
- /**
1102
- * Query param
1103
- */
1104
- page_size: number;
1105
-
1341
+ export interface WebhookListEventsParams extends WebhookEventsPageParams {
1106
1342
  /**
1107
1343
  * Query param
1108
1344
  */
@@ -1196,6 +1432,10 @@ export declare namespace Webhooks {
1196
1432
  export {
1197
1433
  type APIMeta as APIMeta,
1198
1434
  type APIResponseWebhook as APIResponseWebhook,
1435
+ type ChannelEvent as ChannelEvent,
1436
+ type ChannelEventPayload as ChannelEventPayload,
1437
+ type ContactEvent as ContactEvent,
1438
+ type ContactEventPayload as ContactEventPayload,
1199
1439
  type ErrorDetail as ErrorDetail,
1200
1440
  type InboundMessageEvent as InboundMessageEvent,
1201
1441
  type InboundMessageEventPayload as InboundMessageEventPayload,
@@ -1207,11 +1447,12 @@ export declare namespace Webhooks {
1207
1447
  type TemplateEventPayload as TemplateEventPayload,
1208
1448
  type WebhookEventType as WebhookEventType,
1209
1449
  type WebhookResponse as WebhookResponse,
1210
- type WebhookListResponse as WebhookListResponse,
1211
1450
  type WebhookListEventTypesResponse as WebhookListEventTypesResponse,
1212
1451
  type WebhookListEventsResponse as WebhookListEventsResponse,
1213
1452
  type WebhookRotateSecretResponse as WebhookRotateSecretResponse,
1214
1453
  type WebhookTestResponse as WebhookTestResponse,
1454
+ type WebhookResponsesWebhooksPage as WebhookResponsesWebhooksPage,
1455
+ type WebhookListEventsResponsesWebhookEventsPage as WebhookListEventsResponsesWebhookEventsPage,
1215
1456
  type WebhookCreateParams as WebhookCreateParams,
1216
1457
  type WebhookRetrieveParams as WebhookRetrieveParams,
1217
1458
  type WebhookUpdateParams as WebhookUpdateParams,