@sentdm/sentdm 0.38.0 → 0.40.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 (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/client.d.mts +4 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +4 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +2 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +2 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/conversations.d.mts +71 -3
  12. package/resources/conversations.d.mts.map +1 -1
  13. package/resources/conversations.d.ts +71 -3
  14. package/resources/conversations.d.ts.map +1 -1
  15. package/resources/index.d.mts +1 -1
  16. package/resources/index.d.mts.map +1 -1
  17. package/resources/index.d.ts +1 -1
  18. package/resources/index.d.ts.map +1 -1
  19. package/resources/index.js.map +1 -1
  20. package/resources/index.mjs.map +1 -1
  21. package/resources/messages.d.mts +171 -14
  22. package/resources/messages.d.mts.map +1 -1
  23. package/resources/messages.d.ts +171 -14
  24. package/resources/messages.d.ts.map +1 -1
  25. package/resources/messages.js +21 -3
  26. package/resources/messages.js.map +1 -1
  27. package/resources/messages.mjs +21 -3
  28. package/resources/messages.mjs.map +1 -1
  29. package/resources/templates.d.mts +276 -14
  30. package/resources/templates.d.mts.map +1 -1
  31. package/resources/templates.d.ts +276 -14
  32. package/resources/templates.d.ts.map +1 -1
  33. package/resources/templates.js +28 -2
  34. package/resources/templates.js.map +1 -1
  35. package/resources/templates.mjs +28 -2
  36. package/resources/templates.mjs.map +1 -1
  37. package/resources/webhooks.d.mts +693 -22
  38. package/resources/webhooks.d.mts.map +1 -1
  39. package/resources/webhooks.d.ts +693 -22
  40. package/resources/webhooks.d.ts.map +1 -1
  41. package/src/client.ts +10 -0
  42. package/src/resources/conversations.ts +78 -3
  43. package/src/resources/index.ts +4 -0
  44. package/src/resources/messages.ts +182 -14
  45. package/src/resources/templates.ts +289 -14
  46. package/src/resources/webhooks.ts +764 -22
  47. package/src/version.ts +1 -1
  48. package/version.d.mts +1 -1
  49. package/version.d.ts +1 -1
  50. package/version.js +1 -1
  51. package/version.mjs +1 -1
@@ -336,6 +336,454 @@ export interface APIResponseWebhook {
336
336
  success?: boolean;
337
337
  }
338
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. Matches customer_id on GET /v3/channels and the sender
430
+ * profile's id. Together with channel, country, and number_type, it identifies the
431
+ * market.
432
+ */
433
+ account_id?: string;
434
+
435
+ /**
436
+ * The channel this market belongs to: sms, whatsapp, or rcs. Never sent — that
437
+ * value belongs to message events, where it names the smart-routing brand rather
438
+ * than a channel that can be provisioned.
439
+ */
440
+ channel?: string;
441
+
442
+ /**
443
+ * What a market has been given: the identity it registers under, its programme,
444
+ * and any documents attached.
445
+ *
446
+ * What it does not carry is what the market asks for. That is the subject of GET
447
+ * /v3/compliance/requirements, and it is the same answer for every caller — a
448
+ * description of what a compliance regime wants, not a record of one customer's
449
+ * progress through it. It was reported here as well for a while, which put the
450
+ * same array in six response shapes and left a caller deciding which of two
451
+ * sources to believe.
452
+ *
453
+ * Present on a list read for markets that register (carrying brand and campaign),
454
+ * but with documents absent — documents are not fetched for a list, because a
455
+ * catalog lookup and a document read per market would multiply across a page.
456
+ * Absent documents is distinct from an empty list: absent says they were not
457
+ * fetched; empty says the market has been given none. The parent object is null
458
+ * only when the market registers with nobody and compliance was not computed —
459
+ * nothing to show at all.
460
+ */
461
+ compliance?: ChannelEventPayload.Compliance | null;
462
+
463
+ /**
464
+ * The kind of sender the market uses, for example TEN_DLC, LOCAL, or ALPHANUMERIC.
465
+ * Omitted when the subject has no sender type of its own.
466
+ */
467
+ number_type?: string | null;
468
+
469
+ /**
470
+ * Why the market reached this state, when a reason was given — a correction
471
+ * explained, or a campaign lapse. Free text, passed through from the registry or
472
+ * carrier that wrote it, so treat it as a message to show a human rather than a
473
+ * value to branch on.
474
+ */
475
+ reason?: string | null;
476
+
477
+ /**
478
+ * The sender itself — a number in E.164, or an alphanumeric sender ID.
479
+ *
480
+ * Always present, and null until a sender exists. The key is on every delivery so
481
+ * a subscriber reads one shape rather than branching on whether the field arrived
482
+ * — the same choice template_id makes on the message payload.
483
+ *
484
+ * It can carry a value at any point in the lifecycle, not only once the market is
485
+ * live: a number ordered and not yet active at the carrier is already known during
486
+ * PROVISIONING, and an alphanumeric sender the customer chose themselves is known
487
+ * before anything is filed. It is null while the market is still waiting on a
488
+ * number, which for a US 10DLC registration is every event up to
489
+ * channel.activated.
490
+ */
491
+ sender_value?: string | null;
492
+
493
+ /**
494
+ * Where the market stands: PENDING_REVIEW, ACTION_NEEDED, PROVISIONING, ACTIVE or
495
+ * INACTIVE. PENDING_REVIEW means a registry or a carrier holds it and the wait is
496
+ * theirs; ACTION_NEEDED means it is yours; PROVISIONING means the verdict is in
497
+ * and Sent is acquiring the sender; INACTIVE means it had a working sender and no
498
+ * longer does.
499
+ *
500
+ * Each event name is the transition into one of these, but the two are separate
501
+ * fields and may legitimately differ. A resubmission filed against a market whose
502
+ * sender is already live is channel.submitted carrying ACTIVE: a correction is
503
+ * with the registry and the sender keeps working. Read both.
504
+ */
505
+ status?: string;
506
+
507
+ /**
508
+ * When the transition happened, in UTC (yyyy-MM-ddTHH:mm:ssZ).
509
+ */
510
+ updated_at?: string;
511
+ }
512
+
513
+ export namespace ChannelEventPayload {
514
+ /**
515
+ * What a market has been given: the identity it registers under, its programme,
516
+ * and any documents attached.
517
+ *
518
+ * What it does not carry is what the market asks for. That is the subject of GET
519
+ * /v3/compliance/requirements, and it is the same answer for every caller — a
520
+ * description of what a compliance regime wants, not a record of one customer's
521
+ * progress through it. It was reported here as well for a while, which put the
522
+ * same array in six response shapes and left a caller deciding which of two
523
+ * sources to believe.
524
+ *
525
+ * Present on a list read for markets that register (carrying brand and campaign),
526
+ * but with documents absent — documents are not fetched for a list, because a
527
+ * catalog lookup and a document read per market would multiply across a page.
528
+ * Absent documents is distinct from an empty list: absent says they were not
529
+ * fetched; empty says the market has been given none. The parent object is null
530
+ * only when the market registers with nobody and compliance was not computed —
531
+ * nothing to show at all.
532
+ */
533
+ export interface Compliance {
534
+ /**
535
+ * The identity this market registers under, with inherit saying whose it is.
536
+ *
537
+ * Reported here rather than on the profile because it belongs to the registration
538
+ * this market files, and only one market files one. It was a top-level block for a
539
+ * while, which put a per-registration value beside a list of markets and left a
540
+ * caller to work out which market it belonged to.
541
+ *
542
+ * Absent for a market that registers with nobody — such a market asks for no
543
+ * identity, so there is none to report. Absent and null mean different things:
544
+ * absent says this market does not ask, null would say it asks and nothing was
545
+ * supplied.
546
+ *
547
+ * Untyped, like the request side, because its members are declared by the market's
548
+ * own schema rather than by a C# class. A typed pair here would be a second
549
+ * definition of what a market wants, free to drift from the one that validates.
550
+ */
551
+ brand?: { [key: string]: unknown } | null;
552
+
553
+ /**
554
+ * The programme this market registers, with inherit saying whose it is.
555
+ *
556
+ * One, not a list. TcrCampaigns permits several and an account built on the admin
557
+ * side may hold them, but this surface offers one — which is what lets the
558
+ * market's PATCH be an upsert rather than a collection with an addressable create
559
+ * behind it. An account holding several is reported as its first and refused on
560
+ * write, rather than half-edited.
561
+ *
562
+ * Carries no id. Nothing addresses a campaign, and an undeclared key would be
563
+ * refused if the caller sent this object back — which it is meant to be able to
564
+ * do.
565
+ */
566
+ campaign?: { [key: string]: unknown } | null;
567
+
568
+ /**
569
+ * What has been supplied for this market.
570
+ *
571
+ * Files, not values — the declared halves above carry the values. A document
572
+ * cannot be a JSON value, so it is sent as multipart on the channel call and
573
+ * reported here as a reference.
574
+ *
575
+ * Absent on a list read, which fetches identity but does not compute compliance
576
+ * documents per market. Absent and empty mean different things: absent says the
577
+ * documents were not fetched; empty says the market has been given none.
578
+ */
579
+ documents?: Array<Compliance.Document> | null;
580
+ }
581
+
582
+ export namespace Compliance {
583
+ /**
584
+ * A document a market asked for and has been given.
585
+ */
586
+ export interface Document {
587
+ /**
588
+ * Identifier of the upload, for fetching it back through the documents endpoints.
589
+ */
590
+ document_id?: string | null;
591
+
592
+ file_name?: string | null;
593
+
594
+ /**
595
+ * The catalog's name for this document, matching the requirement it satisfies.
596
+ */
597
+ key?: string;
598
+ }
599
+ }
600
+ }
601
+
602
+ /**
603
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
604
+ * this shape and varies only in Payload.
605
+ */
606
+ export interface ContactEvent {
607
+ /**
608
+ * The specific event within the family, for example message.delivered,
609
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
610
+ * treat it as optional.
611
+ */
612
+ event?: string | null;
613
+
614
+ /**
615
+ * The event family, for example message, templates or contact. Route on this
616
+ * first, then on event for the specific change.
617
+ */
618
+ field?: string;
619
+
620
+ /**
621
+ * Body of a contact.opt_in, contact.opt_out, contact.help or
622
+ * contact.custom_keyword event. Delivered when a contact signals a consent change,
623
+ * asks for help, or sends one of your own auto-reply keywords.
624
+ *
625
+ * These events state the signal outright, so you do not have to recognise keywords
626
+ * in the text of a message.received event. They also cover cases that produce no
627
+ * inbound message at all, such as a network handling an opt-out on your behalf.
628
+ *
629
+ * Two of the four change consent and two do not: contact.help and
630
+ * contact.custom_keyword report the state the contact already had. Read opt_out
631
+ * for the state and the envelope's event for what happened, rather than inferring
632
+ * one from the other.
633
+ *
634
+ * Fields are ordered identity → resulting state → provenance → join keys. The two
635
+ * parties are from and to. Note that the message family has not moved to those
636
+ * names yet — message.received still calls the same two parties inbound_number and
637
+ * outbound_number. Nothing here restates the envelope: which signal occurred is
638
+ * the envelope's event, and when it was emitted is its timestamp. Retries carry
639
+ * the same X-Webhook-Event-ID header, which is what to deduplicate on.
640
+ */
641
+ payload?: ContactEventPayload | null;
642
+
643
+ /**
644
+ * The event-specific body.
645
+ */
646
+ request_id?: string | null;
647
+
648
+ /**
649
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
650
+ * time, not the time the underlying change happened. Use the timestamp inside the
651
+ * payload for the latter.
652
+ */
653
+ timestamp?: string;
654
+ }
655
+
656
+ /**
657
+ * Body of a contact.opt_in, contact.opt_out, contact.help or
658
+ * contact.custom_keyword event. Delivered when a contact signals a consent change,
659
+ * asks for help, or sends one of your own auto-reply keywords.
660
+ *
661
+ * These events state the signal outright, so you do not have to recognise keywords
662
+ * in the text of a message.received event. They also cover cases that produce no
663
+ * inbound message at all, such as a network handling an opt-out on your behalf.
664
+ *
665
+ * Two of the four change consent and two do not: contact.help and
666
+ * contact.custom_keyword report the state the contact already had. Read opt_out
667
+ * for the state and the envelope's event for what happened, rather than inferring
668
+ * one from the other.
669
+ *
670
+ * Fields are ordered identity → resulting state → provenance → join keys. The two
671
+ * parties are from and to. Note that the message family has not moved to those
672
+ * names yet — message.received still calls the same two parties inbound_number and
673
+ * outbound_number. Nothing here restates the envelope: which signal occurred is
674
+ * the envelope's event, and when it was emitted is its timestamp. Retries carry
675
+ * the same X-Webhook-Event-ID header, which is what to deduplicate on.
676
+ */
677
+ export interface ContactEventPayload {
678
+ /**
679
+ * Whether the contact is opted out after this signal — the state to write to your
680
+ * own record. Same meaning as opt_out on the contact resource. On contact.help and
681
+ * contact.custom_keyword this reports the contact's existing state, which neither
682
+ * changes.
683
+ *
684
+ * Two signals from the same contact can arrive out of order, because each one is
685
+ * queued on its own rather than against the contact. Compare the envelope's
686
+ * timestamp before you overwrite a newer state with an older one. That timestamp
687
+ * is second-precision, so treat two signals stamped in the same second as
688
+ * unordered and read the contact resource to settle them.
689
+ */
690
+ opt_out: boolean;
691
+
692
+ /**
693
+ * How the signal reached us. INBOUND_KEYWORD means the contact sent a message
694
+ * whose text matched one of the keywords; PROVIDER_SIGNAL means the network
695
+ * reported it. A provider signal usually carries no message_id or text, so read
696
+ * both for null rather than inferring them from this field.
697
+ */
698
+ source: string;
699
+
700
+ /**
701
+ * The account the contact belongs to. Present so one endpoint can serve several
702
+ * accounts.
703
+ */
704
+ account_id?: string;
705
+
706
+ /**
707
+ * The RCS agent the signal reached, when it reached one.
708
+ *
709
+ * Omitted entirely on channels that have no agent, rather than sent as null — an
710
+ * SMS or WhatsApp payload does not carry this key at all. On RCS it is the
711
+ * counterpart to To: a contact reaches an agent rather than a number, so exactly
712
+ * one of the two is populated and never both. If you run more than one agent, this
713
+ * is what tells you which of them the contact acted on.
714
+ */
715
+ agent_id?: string | null;
716
+
717
+ /**
718
+ * The channel the signal arrived on, for example sms or whatsapp.
719
+ */
720
+ channel?: string;
721
+
722
+ /**
723
+ * The contact who raised the signal. Always populated, including for contact.help
724
+ * or contact.custom_keyword from a number you have not messaged before — the
725
+ * contact is created if it does not exist yet, so this identifier is always
726
+ * resolvable against the contacts API.
727
+ */
728
+ contact_id?: string;
729
+
730
+ /**
731
+ * The contact's number, in E.164 format with the leading + — who raised the
732
+ * signal. The same party message.received publishes as inbound_number.
733
+ */
734
+ from?: string;
735
+
736
+ /**
737
+ * The inbound message that carried the signal, matching message_id on the
738
+ * corresponding message.received event so the two can be joined.
739
+ *
740
+ * Sent as null when the signal did not arrive as a message — for example when a
741
+ * network processed an opt-out on your behalf — and also when the message belongs
742
+ * to a different account than this event, which can happen on a shared WhatsApp
743
+ * number. The field is always present, so read it and check for null rather than
744
+ * checking whether the key exists.
745
+ */
746
+ message_id?: string | null;
747
+
748
+ /**
749
+ * The auto-reply template whose keyword the contact matched, joinable against the
750
+ * templates API.
751
+ *
752
+ * This is what identifies which signal arrived on contact.custom_keyword: every
753
+ * custom template reports the same event name, so the event alone cannot tell your
754
+ * booking keyword from your opening-hours one. One template holds as many keywords
755
+ * as you configured, so this is steadier to switch on than text.
756
+ *
757
+ * Populated on the compliance sub-types too, where it names the template that
758
+ * replied. Sent as null when no template was involved — a network-reported opt-out
759
+ * matches no keyword. The field is always present, so read it and check for null.
760
+ */
761
+ template_id?: string | null;
762
+
763
+ /**
764
+ * The text the contact sent, for example STOP or UNSUBSCRIBE. Sent as null when
765
+ * the signal did not arrive as text. The field is always present, so read it and
766
+ * check for null rather than checking whether the key exists.
767
+ */
768
+ text?: string | null;
769
+
770
+ /**
771
+ * The number of yours that received the signal, in E.164 format with the leading
772
+ * +. Tells a multi-number account which of its senders the contact acted on, which
773
+ * nothing else on this payload answers.
774
+ *
775
+ * This is your number, not the contact's. That is the opposite of what to means on
776
+ * POST /v3/messages, where it is the list of recipients you are sending to. Reply
777
+ * to From, not to this field, or the message goes back to yourself.
778
+ *
779
+ * Sent as null when the signal did not arrive at a number of yours — an RCS signal
780
+ * terminates at an agent rather than a number, and a provider-reported opt-out may
781
+ * name no receiving number at all. The field is always present, so read it and
782
+ * check for null rather than checking whether the key exists.
783
+ */
784
+ to?: string | null;
785
+ }
786
+
339
787
  /**
340
788
  * Error information
341
789
  */
@@ -367,15 +815,15 @@ export interface ErrorDetail {
367
815
  */
368
816
  export interface InboundMessageEvent {
369
817
  /**
370
- * The specific event within the family, for example message.delivered or
371
- * message.received. Absent on events that have no subtype, so treat it as
372
- * optional.
818
+ * The specific event within the family, for example message.delivered,
819
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
820
+ * treat it as optional.
373
821
  */
374
822
  event?: string | null;
375
823
 
376
824
  /**
377
- * The event family, for example message or templates. Route on this first, then on
378
- * event for the specific change.
825
+ * The event family, for example message, templates or contact. Route on this
826
+ * first, then on event for the specific change.
379
827
  */
380
828
  field?: string;
381
829
 
@@ -385,6 +833,11 @@ export interface InboundMessageEvent {
385
833
  */
386
834
  payload?: InboundMessageEventPayload | null;
387
835
 
836
+ /**
837
+ * The event-specific body.
838
+ */
839
+ request_id?: string | null;
840
+
388
841
  /**
389
842
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
390
843
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -448,15 +901,15 @@ export interface InboundMessageEventPayload {
448
901
  */
449
902
  export interface MessageEvent {
450
903
  /**
451
- * The specific event within the family, for example message.delivered or
452
- * message.received. Absent on events that have no subtype, so treat it as
453
- * optional.
904
+ * The specific event within the family, for example message.delivered,
905
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
906
+ * treat it as optional.
454
907
  */
455
908
  event?: string | null;
456
909
 
457
910
  /**
458
- * The event family, for example message or templates. Route on this first, then on
459
- * event for the specific change.
911
+ * The event family, for example message, templates or contact. Route on this
912
+ * first, then on event for the specific change.
460
913
  */
461
914
  field?: string;
462
915
 
@@ -467,6 +920,11 @@ export interface MessageEvent {
467
920
  */
468
921
  payload?: MessageEventPayload | null;
469
922
 
923
+ /**
924
+ * The event-specific body.
925
+ */
926
+ request_id?: string | null;
927
+
470
928
  /**
471
929
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
472
930
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -498,6 +956,13 @@ export interface MessageEventPayload {
498
956
  */
499
957
  agent_id?: string | null;
500
958
 
959
+ /**
960
+ * The rendered message body, as plain text. Sent as null when we aren't asserting
961
+ * a body for this event. The field is always present, so read it and check for
962
+ * null rather than checking whether the key exists. Truncated to 3072 characters.
963
+ */
964
+ body?: string | null;
965
+
501
966
  /**
502
967
  * The channel the message went out on, for example sms or whatsapp. A message that
503
968
  * falls back to another channel reports the channel actually used.
@@ -515,6 +980,19 @@ export interface MessageEventPayload {
515
980
  */
516
981
  outbound_number?: string;
517
982
 
983
+ /**
984
+ * message.scheduled only: why the message is held, either because you scheduled it
985
+ * or because the recipient is inside a protected quiet-hours window. Omitted on
986
+ * every other event.
987
+ */
988
+ schedule_reason?: string | null;
989
+
990
+ /**
991
+ * message.scheduled only: when the held message will be released for delivery, in
992
+ * UTC (yyyy-MM-ddTHH:mm:ssZ). Omitted on every other event.
993
+ */
994
+ scheduled_at?: string | null;
995
+
518
996
  /**
519
997
  * The template the message was sent from, when it was sent from one.
520
998
  */
@@ -598,15 +1076,15 @@ export namespace PaginationMeta {
598
1076
  */
599
1077
  export interface TemplateEvent {
600
1078
  /**
601
- * The specific event within the family, for example message.delivered or
602
- * message.received. Absent on events that have no subtype, so treat it as
603
- * optional.
1079
+ * The specific event within the family, for example message.delivered,
1080
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
1081
+ * treat it as optional.
604
1082
  */
605
1083
  event?: string | null;
606
1084
 
607
1085
  /**
608
- * The event family, for example message or templates. Route on this first, then on
609
- * event for the specific change.
1086
+ * The event family, for example message, templates or contact. Route on this
1087
+ * first, then on event for the specific change.
610
1088
  */
611
1089
  field?: string;
612
1090
 
@@ -616,6 +1094,11 @@ export interface TemplateEvent {
616
1094
  */
617
1095
  payload?: TemplateEventPayload | null;
618
1096
 
1097
+ /**
1098
+ * The event-specific body.
1099
+ */
1100
+ request_id?: string | null;
1101
+
619
1102
  /**
620
1103
  * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
621
1104
  * time, not the time the underlying change happened. Use the timestamp inside the
@@ -645,15 +1128,39 @@ export interface TemplateEventPayload {
645
1128
  */
646
1129
  account_id?: string;
647
1130
 
1131
+ /**
1132
+ * Which consent keyword this template answers, when it is one of Sent's
1133
+ * auto-replies: OPT_IN, OPT_OUT, HELP, or OTHER for a customer-defined keyword.
1134
+ *
1135
+ * Omitted for an ordinary template, so its presence is the answer to "is this an
1136
+ * auto-reply". Sent creates the three compliance auto-replies at signup and they
1137
+ * go through review like any other template, so their events arrive mixed in with
1138
+ * the customer's own with nothing else to tell them apart.
1139
+ *
1140
+ * Named for the reader rather than after Template.OptAction, which it is mapped
1141
+ * from. The MCP tool result deliberately keeps OptAction, OptKeywords and IsOpt:
1142
+ * it mirrors the internal shape on purpose and publishes the keywords too, so
1143
+ * renaming one of the three there would leave a surface half in each vocabulary.
1144
+ * Two names for one concept, each consistent within its own surface, chosen over a
1145
+ * rename that breaks MCP clients silently.
1146
+ */
1147
+ auto_reply_action?: string | null;
1148
+
648
1149
  /**
649
1150
  * The template's category, for example UTILITY, MARKETING, or AUTHENTICATION.
650
1151
  */
651
1152
  category?: string;
652
1153
 
653
1154
  /**
654
- * The channel the template applies to.
1155
+ * The channel leg this decision is about, for example whatsapp, sms, or rcs. A
1156
+ * template is reviewed per channel and the legs come back independently, so each
1157
+ * one reports separately.
1158
+ *
1159
+ * Omitted when the decision applies to the template as a whole rather than to one
1160
+ * leg. That event is the broader news: a template-wide rejection blocks every
1161
+ * channel, whatever the individual legs say.
655
1162
  */
656
- channel?: string;
1163
+ channel?: string | null;
657
1164
 
658
1165
  /**
659
1166
  * The template's language code, for example en_US.
@@ -782,11 +1289,30 @@ export interface WebhookListEventsResponse {
782
1289
 
783
1290
  /**
784
1291
  * The exact event body that was delivered, or attempted, for this record. One of
785
- * the three webhook envelopes: a message status change, an inbound message, or a
786
- * template status change. Read field and event to tell which, the same way your
787
- * endpoint does.
788
- */
789
- event_data?: MessageEvent | InboundMessageEvent | TemplateEvent;
1292
+ * the six webhook envelopes:
1293
+ *
1294
+ * message — an outbound message changed status. message with event:
1295
+ * message.received — someone replied to you. templates — a template was approved,
1296
+ * rejected, paused or similar. channel — one of your markets moved in provisioning
1297
+ * or compliance. contact — a consent signal: opt-in, opt-out or help. link — a
1298
+ * tracked short link was clicked or a hosted file downloaded, or one expired or
1299
+ * was revoked.
1300
+ *
1301
+ * Read field and event to tell which, the same way your endpoint does. The two
1302
+ * message envelopes are the reason that is two fields and not one: they share a
1303
+ * field and differ by event.
1304
+ *
1305
+ * Treat the list as open. It has grown twice — channel and then link — and a
1306
+ * handler that rejects an envelope it does not recognise will break on the next
1307
+ * addition rather than ignore it.
1308
+ */
1309
+ event_data?:
1310
+ | MessageEvent
1311
+ | InboundMessageEvent
1312
+ | TemplateEvent
1313
+ | ChannelEvent
1314
+ | ContactEvent
1315
+ | WebhookListEventsResponse.SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload;
790
1316
 
791
1317
  event_type?: string;
792
1318
 
@@ -799,6 +1325,218 @@ export interface WebhookListEventsResponse {
799
1325
  response_body?: string | null;
800
1326
  }
801
1327
 
1328
+ export namespace WebhookListEventsResponse {
1329
+ /**
1330
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
1331
+ * this shape and varies only in Payload.
1332
+ */
1333
+ export interface SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload {
1334
+ /**
1335
+ * The specific event within the family, for example message.delivered,
1336
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
1337
+ * treat it as optional.
1338
+ */
1339
+ event?: string | null;
1340
+
1341
+ /**
1342
+ * The event family, for example message, templates or contact. Route on this
1343
+ * first, then on event for the specific change.
1344
+ */
1345
+ field?: string;
1346
+
1347
+ /**
1348
+ * Body of a link event: something happened to a tracked link Sent published on the
1349
+ * customer's behalf. A link points either at a URL the customer supplied or at a
1350
+ * file Sent hosts for them; LinkKind says which. Delivered when an eligible
1351
+ * request is served, or when a published link reaches the end of its life.
1352
+ *
1353
+ * A click is a request, not a read receipt. link.clicked means the redirect was
1354
+ * served; link.downloaded means bytes went out. Neither proves a person saw
1355
+ * anything — messaging providers and link scanners fetch URLs on their own, which
1356
+ * is what TrafficClass exists to tell apart. Filter on it before reporting a
1357
+ * click-through rate; treat likely_human as a hint, never as delivery
1358
+ * confirmation.
1359
+ *
1360
+ * RecordId identifies the link; the X-Webhook-Event-ID header identifies the
1361
+ * delivery. One link is hit many times, so those are the two keys a subscriber
1362
+ * needs: group by the first, deduplicate on the second — exactly as on every other
1363
+ * family. The payload carries no event identifier of its own, for the same reason
1364
+ * none of the others do.
1365
+ *
1366
+ * Nothing here identifies the visitor. No IP address and no visitor token crosses
1367
+ * this boundary. Country, Device and Browser are coarse buckets derived at the
1368
+ * edge and are absent whenever the request did not supply enough to derive them.
1369
+ */
1370
+ payload?: SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload.Payload | null;
1371
+
1372
+ /**
1373
+ * The event-specific body.
1374
+ */
1375
+ request_id?: string | null;
1376
+
1377
+ /**
1378
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
1379
+ * time, not the time the underlying change happened. Use the timestamp inside the
1380
+ * payload for the latter.
1381
+ */
1382
+ timestamp?: string;
1383
+ }
1384
+
1385
+ export namespace SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload {
1386
+ /**
1387
+ * Body of a link event: something happened to a tracked link Sent published on the
1388
+ * customer's behalf. A link points either at a URL the customer supplied or at a
1389
+ * file Sent hosts for them; LinkKind says which. Delivered when an eligible
1390
+ * request is served, or when a published link reaches the end of its life.
1391
+ *
1392
+ * A click is a request, not a read receipt. link.clicked means the redirect was
1393
+ * served; link.downloaded means bytes went out. Neither proves a person saw
1394
+ * anything — messaging providers and link scanners fetch URLs on their own, which
1395
+ * is what TrafficClass exists to tell apart. Filter on it before reporting a
1396
+ * click-through rate; treat likely_human as a hint, never as delivery
1397
+ * confirmation.
1398
+ *
1399
+ * RecordId identifies the link; the X-Webhook-Event-ID header identifies the
1400
+ * delivery. One link is hit many times, so those are the two keys a subscriber
1401
+ * needs: group by the first, deduplicate on the second — exactly as on every other
1402
+ * family. The payload carries no event identifier of its own, for the same reason
1403
+ * none of the others do.
1404
+ *
1405
+ * Nothing here identifies the visitor. No IP address and no visitor token crosses
1406
+ * this boundary. Country, Device and Browser are coarse buckets derived at the
1407
+ * edge and are absent whenever the request did not supply enough to derive them.
1408
+ */
1409
+ export interface Payload {
1410
+ /**
1411
+ * The link's public identifier — the eight-character code in the short URL, for
1412
+ * example A78B2BU0. Unique across both kinds, and never reused, so it is the
1413
+ * stable key to group one link's events by.
1414
+ */
1415
+ record_id: string;
1416
+
1417
+ /**
1418
+ * Where the request appeared to come from, as an ISO 3166-1 alpha-2 code. Named
1419
+ * separately from the country on a channel event, which is a destination market
1420
+ * the customer registered for — this one is a property of a single visitor and is
1421
+ * absent when the edge could not resolve it.
1422
+ */
1423
+ access_country?: string | null;
1424
+
1425
+ /**
1426
+ * How the request was served, when the edge recorded it. Free text describing the
1427
+ * outcome — show it to a human rather than branching on it.
1428
+ */
1429
+ access_outcome?: string | null;
1430
+
1431
+ /**
1432
+ * The requesting browser family, for example chrome or safari, or unknown. Derived
1433
+ * from the user agent.
1434
+ */
1435
+ browser?: string | null;
1436
+
1437
+ /**
1438
+ * How many bytes were served, for a file access. A ranged request reports the
1439
+ * bytes in that range, not the size of the file, so several accesses of one file
1440
+ * can each report a part.
1441
+ */
1442
+ bytes_served?: number | null;
1443
+
1444
+ /**
1445
+ * The channel the message carrying this link went out on: sms, whatsapp, or rcs.
1446
+ */
1447
+ channel?: string | null;
1448
+
1449
+ /**
1450
+ * The organization the link belongs to. Always the parent account, never a sender
1451
+ * profile — read SenderProfileId for that.
1452
+ *
1453
+ * This family publishes the owner as an explicit pair rather than the single
1454
+ * account_id the other families use. The pair says which organization and which
1455
+ * profile without the subscriber deriving either, which is the trade: one more key
1456
+ * against not having to know that account_id silently becomes the profile when one
1457
+ * exists.
1458
+ */
1459
+ customer_id?: string;
1460
+
1461
+ /**
1462
+ * The requesting device class: mobile, tablet, desktop or unknown. Derived from
1463
+ * the user agent.
1464
+ */
1465
+ device?: string | null;
1466
+
1467
+ /**
1468
+ * What the link points at: url for a destination the customer supplied, file for
1469
+ * media Sent hosts. Always present, and implied by the event — link.clicked is
1470
+ * always url and link.downloaded always file — but published as its own field so a
1471
+ * subscriber can branch on the kind without parsing the event name, the same
1472
+ * separation the channel family keeps between its event and its status.
1473
+ */
1474
+ link_kind?: string;
1475
+
1476
+ /**
1477
+ * The message the link was published in.
1478
+ *
1479
+ * The event can arrive before the message is readable through GET /v3/messages: a
1480
+ * provider may fetch a link within milliseconds of the send, and nothing here
1481
+ * waits for the message row. Retry the read rather than treating an unknown id as
1482
+ * an error.
1483
+ */
1484
+ message_id?: string | null;
1485
+
1486
+ /**
1487
+ * When the access or lifecycle change actually happened, in UTC
1488
+ * (yyyy-MM-ddTHH:mm:ssZ). The envelope's timestamp is when Sent emitted the event;
1489
+ * this is when the thing occurred, and the two differ by the ingest delay.
1490
+ */
1491
+ occurred_at?: string;
1492
+
1493
+ /**
1494
+ * The caller-supplied label tying this link back to a position in the message, for
1495
+ * example body:0 for the first link in the body. Present when the link was created
1496
+ * with one.
1497
+ */
1498
+ reference_key?: string | null;
1499
+
1500
+ /**
1501
+ * The host of the page that linked here, when the request supplied one. The host
1502
+ * only — never a full referring URL.
1503
+ */
1504
+ referrer_host?: string | null;
1505
+
1506
+ /**
1507
+ * The HTTP method of the request that was served, for an access event. Omitted on
1508
+ * link.expired and link.revoked, which describe no request.
1509
+ */
1510
+ request_method?: string | null;
1511
+
1512
+ /**
1513
+ * The sender profile that owns the link, or null when the organization owns it
1514
+ * directly. Always on the wire so a handler reads one shape rather than branching
1515
+ * on whether the key arrived.
1516
+ *
1517
+ * sender_profile_id, not profile_id: the API already publishes
1518
+ * messaging_profile_id and sending_phone_number_profile_id for provider-side
1519
+ * profiles, which are a different thing entirely. The unqualified name would read
1520
+ * as one of those.
1521
+ */
1522
+ sender_profile_id?: string | null;
1523
+
1524
+ /**
1525
+ * The HTTP status Sent answered the request with: 302 for a link, 200 or 206 for a
1526
+ * file. Omitted on lifecycle events.
1527
+ */
1528
+ status_code?: number | null;
1529
+
1530
+ /**
1531
+ * A coarse guess at what made the request: likely_human, provider (a messaging
1532
+ * platform prefetching the link), bot, or unknown. Derived from the user agent, so
1533
+ * it is a hint for filtering noise rather than a fact to bill or report on.
1534
+ */
1535
+ traffic_class?: string | null;
1536
+ }
1537
+ }
1538
+ }
1539
+
802
1540
  /**
803
1541
  * Standard API response envelope for all v3 endpoints
804
1542
  */
@@ -1110,6 +1848,10 @@ export declare namespace Webhooks {
1110
1848
  export {
1111
1849
  type APIMeta as APIMeta,
1112
1850
  type APIResponseWebhook as APIResponseWebhook,
1851
+ type ChannelEvent as ChannelEvent,
1852
+ type ChannelEventPayload as ChannelEventPayload,
1853
+ type ContactEvent as ContactEvent,
1854
+ type ContactEventPayload as ContactEventPayload,
1113
1855
  type ErrorDetail as ErrorDetail,
1114
1856
  type InboundMessageEvent as InboundMessageEvent,
1115
1857
  type InboundMessageEventPayload as InboundMessageEventPayload,