@sentdm/sentdm 0.39.0 → 0.41.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 (55) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/client.d.mts +2 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -0
  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 +126 -3
  12. package/resources/conversations.d.mts.map +1 -1
  13. package/resources/conversations.d.ts +126 -3
  14. package/resources/conversations.d.ts.map +1 -1
  15. package/resources/me.d.mts +21 -0
  16. package/resources/me.d.mts.map +1 -1
  17. package/resources/me.d.ts +21 -0
  18. package/resources/me.d.ts.map +1 -1
  19. package/resources/me.js +5 -0
  20. package/resources/me.js.map +1 -1
  21. package/resources/me.mjs +5 -0
  22. package/resources/me.mjs.map +1 -1
  23. package/resources/messages.d.mts +239 -14
  24. package/resources/messages.d.mts.map +1 -1
  25. package/resources/messages.d.ts +239 -14
  26. package/resources/messages.d.ts.map +1 -1
  27. package/resources/messages.js +21 -3
  28. package/resources/messages.js.map +1 -1
  29. package/resources/messages.mjs +21 -3
  30. package/resources/messages.mjs.map +1 -1
  31. package/resources/templates.d.mts +130 -1
  32. package/resources/templates.d.mts.map +1 -1
  33. package/resources/templates.d.ts +130 -1
  34. package/resources/templates.d.ts.map +1 -1
  35. package/resources/templates.js.map +1 -1
  36. package/resources/templates.mjs.map +1 -1
  37. package/resources/webhooks.d.mts +616 -30
  38. package/resources/webhooks.d.mts.map +1 -1
  39. package/resources/webhooks.d.ts +616 -30
  40. package/resources/webhooks.d.ts.map +1 -1
  41. package/resources/webhooks.js +3 -1
  42. package/resources/webhooks.js.map +1 -1
  43. package/resources/webhooks.mjs +3 -1
  44. package/resources/webhooks.mjs.map +1 -1
  45. package/src/client.ts +2 -0
  46. package/src/resources/conversations.ts +140 -3
  47. package/src/resources/me.ts +22 -0
  48. package/src/resources/messages.ts +259 -14
  49. package/src/resources/templates.ts +143 -1
  50. package/src/resources/webhooks.ts +678 -31
  51. package/src/version.ts +1 -1
  52. package/version.d.mts +1 -1
  53. package/version.d.ts +1 -1
  54. package/version.js +1 -1
  55. package/version.mjs +1 -1
@@ -169,7 +169,9 @@ export class Webhooks extends APIResource {
169
169
  }
170
170
 
171
171
  /**
172
- * Retrieves a paginated list of delivery events for the specified webhook.
172
+ * Retrieves a paginated list of delivery events for the specified webhook. If the
173
+ * webhook is cloned onto your sender profiles, the list includes what those clones
174
+ * received; read payload.account_id to tell whose event it is.
173
175
  *
174
176
  * @example
175
177
  * ```ts
@@ -426,7 +428,9 @@ export interface ChannelEventPayload {
426
428
  * The account whose market this is, named as on every other family. When an
427
429
  * organization receives an event for one of its sender profiles this is the
428
430
  * profile, so a reseller compares it with its own id and anything different is one
429
- * of its profiles.
431
+ * of its profiles. Matches customer_id on GET /v3/channels and the sender
432
+ * profile's id. Together with channel, country, and number_type, it identifies the
433
+ * market.
430
434
  */
431
435
  account_id?: string;
432
436
 
@@ -437,6 +441,27 @@ export interface ChannelEventPayload {
437
441
  */
438
442
  channel?: string;
439
443
 
444
+ /**
445
+ * What a market has been given: the identity it registers under, its programme,
446
+ * and any documents attached.
447
+ *
448
+ * What it does not carry is what the market asks for. That is the subject of GET
449
+ * /v3/compliance/requirements, and it is the same answer for every caller — a
450
+ * description of what a compliance regime wants, not a record of one customer's
451
+ * progress through it. It was reported here as well for a while, which put the
452
+ * same array in six response shapes and left a caller deciding which of two
453
+ * sources to believe.
454
+ *
455
+ * Present on a list read for markets that register (carrying brand and campaign),
456
+ * but with documents absent — documents are not fetched for a list, because a
457
+ * catalog lookup and a document read per market would multiply across a page.
458
+ * Absent documents is distinct from an empty list: absent says they were not
459
+ * fetched; empty says the market has been given none. The parent object is null
460
+ * only when the market registers with nobody and compliance was not computed —
461
+ * nothing to show at all.
462
+ */
463
+ compliance?: ChannelEventPayload.Compliance | null;
464
+
440
465
  /**
441
466
  * The kind of sender the market uses, for example TEN_DLC, LOCAL, or ALPHANUMERIC.
442
467
  * Omitted when the subject has no sender type of its own.
@@ -444,13 +469,20 @@ export interface ChannelEventPayload {
444
469
  number_type?: string | null;
445
470
 
446
471
  /**
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.
472
+ * Why the market reached this state, as a sentence to show a person: the specific
473
+ * explanation when one was given (a correction explained, a campaign lapse),
474
+ * otherwise what reason_code means for this market. Not a value to branch on.
451
475
  */
452
476
  reason?: string | null;
453
477
 
478
+ /**
479
+ * Why the market is not ACTIVE, as a stable code: an ErrorCodes CHANNEL_xxx value
480
+ * such as CHANNEL_001 (something you owe) or CHANNEL_002 (a correction was
481
+ * requested). The same code the channels resource reports for the market. Switch
482
+ * on this rather than on reason. Omitted while ACTIVE.
483
+ */
484
+ reason_code?: string | null;
485
+
454
486
  /**
455
487
  * The sender itself — a number in E.164, or an alphanumeric sender ID.
456
488
  *
@@ -487,6 +519,95 @@ export interface ChannelEventPayload {
487
519
  updated_at?: string;
488
520
  }
489
521
 
522
+ export namespace ChannelEventPayload {
523
+ /**
524
+ * What a market has been given: the identity it registers under, its programme,
525
+ * and any documents attached.
526
+ *
527
+ * What it does not carry is what the market asks for. That is the subject of GET
528
+ * /v3/compliance/requirements, and it is the same answer for every caller — a
529
+ * description of what a compliance regime wants, not a record of one customer's
530
+ * progress through it. It was reported here as well for a while, which put the
531
+ * same array in six response shapes and left a caller deciding which of two
532
+ * sources to believe.
533
+ *
534
+ * Present on a list read for markets that register (carrying brand and campaign),
535
+ * but with documents absent — documents are not fetched for a list, because a
536
+ * catalog lookup and a document read per market would multiply across a page.
537
+ * Absent documents is distinct from an empty list: absent says they were not
538
+ * fetched; empty says the market has been given none. The parent object is null
539
+ * only when the market registers with nobody and compliance was not computed —
540
+ * nothing to show at all.
541
+ */
542
+ export interface Compliance {
543
+ /**
544
+ * The identity this market registers under, with inherit saying whose it is.
545
+ *
546
+ * Reported here rather than on the profile because it belongs to the registration
547
+ * this market files, and only one market files one. It was a top-level block for a
548
+ * while, which put a per-registration value beside a list of markets and left a
549
+ * caller to work out which market it belonged to.
550
+ *
551
+ * Absent for a market that registers with nobody — such a market asks for no
552
+ * identity, so there is none to report. Absent and null mean different things:
553
+ * absent says this market does not ask, null would say it asks and nothing was
554
+ * supplied.
555
+ *
556
+ * Untyped, like the request side, because its members are declared by the market's
557
+ * own schema rather than by a C# class. A typed pair here would be a second
558
+ * definition of what a market wants, free to drift from the one that validates.
559
+ */
560
+ brand?: { [key: string]: unknown } | null;
561
+
562
+ /**
563
+ * The programme this market registers, with inherit saying whose it is.
564
+ *
565
+ * One, not a list. TcrCampaigns permits several and an account built on the admin
566
+ * side may hold them, but this surface offers one — which is what lets the
567
+ * market's PATCH be an upsert rather than a collection with an addressable create
568
+ * behind it. An account holding several is reported as its first and refused on
569
+ * write, rather than half-edited.
570
+ *
571
+ * Carries no id. Nothing addresses a campaign, and an undeclared key would be
572
+ * refused if the caller sent this object back — which it is meant to be able to
573
+ * do.
574
+ */
575
+ campaign?: { [key: string]: unknown } | null;
576
+
577
+ /**
578
+ * What has been supplied for this market.
579
+ *
580
+ * Files, not values — the declared halves above carry the values. A document
581
+ * cannot be a JSON value, so it is sent as multipart on the channel call and
582
+ * reported here as a reference.
583
+ *
584
+ * Absent on a list read, which fetches identity but does not compute compliance
585
+ * documents per market. Absent and empty mean different things: absent says the
586
+ * documents were not fetched; empty says the market has been given none.
587
+ */
588
+ documents?: Array<Compliance.Document> | null;
589
+ }
590
+
591
+ export namespace Compliance {
592
+ /**
593
+ * A document a market asked for and has been given.
594
+ */
595
+ export interface Document {
596
+ /**
597
+ * Identifier of the upload, for fetching it back through the documents endpoints.
598
+ */
599
+ document_id?: string | null;
600
+
601
+ file_name?: string | null;
602
+
603
+ /**
604
+ * The catalog's name for this document, matching the requirement it satisfies.
605
+ */
606
+ key?: string;
607
+ }
608
+ }
609
+ }
610
+
490
611
  /**
491
612
  * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
492
613
  * this shape and varies only in Payload.
@@ -506,17 +627,25 @@ export interface ContactEvent {
506
627
  field?: string;
507
628
 
508
629
  /**
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.
630
+ * Body of a contact.opt_in, contact.opt_out, contact.help or
631
+ * contact.custom_keyword event. Delivered when a contact signals a consent change,
632
+ * asks for help, or sends one of your own auto-reply keywords.
511
633
  *
512
634
  * These events state the signal outright, so you do not have to recognise keywords
513
635
  * in the text of a message.received event. They also cover cases that produce no
514
636
  * inbound message at all, such as a network handling an opt-out on your behalf.
515
637
  *
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.
638
+ * Two of the four change consent and two do not: contact.help and
639
+ * contact.custom_keyword report the state the contact already had. Read opt_out
640
+ * for the state and the envelope's event for what happened, rather than inferring
641
+ * one from the other.
642
+ *
643
+ * Fields are ordered identity → resulting state → provenance → join keys. The two
644
+ * parties are from and to. Note that the message family has not moved to those
645
+ * names yet — message.received still calls the same two parties inbound_number and
646
+ * outbound_number. Nothing here restates the envelope: which signal occurred is
647
+ * the envelope's event, and when it was emitted is its timestamp. Retries carry
648
+ * the same X-Webhook-Event-ID header, which is what to deduplicate on.
520
649
  */
521
650
  payload?: ContactEventPayload | null;
522
651
 
@@ -534,23 +663,32 @@ export interface ContactEvent {
534
663
  }
535
664
 
536
665
  /**
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.
666
+ * Body of a contact.opt_in, contact.opt_out, contact.help or
667
+ * contact.custom_keyword event. Delivered when a contact signals a consent change,
668
+ * asks for help, or sends one of your own auto-reply keywords.
539
669
  *
540
670
  * These events state the signal outright, so you do not have to recognise keywords
541
671
  * in the text of a message.received event. They also cover cases that produce no
542
672
  * inbound message at all, such as a network handling an opt-out on your behalf.
543
673
  *
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.
674
+ * Two of the four change consent and two do not: contact.help and
675
+ * contact.custom_keyword report the state the contact already had. Read opt_out
676
+ * for the state and the envelope's event for what happened, rather than inferring
677
+ * one from the other.
678
+ *
679
+ * Fields are ordered identity → resulting state → provenance → join keys. The two
680
+ * parties are from and to. Note that the message family has not moved to those
681
+ * names yet — message.received still calls the same two parties inbound_number and
682
+ * outbound_number. Nothing here restates the envelope: which signal occurred is
683
+ * the envelope's event, and when it was emitted is its timestamp. Retries carry
684
+ * the same X-Webhook-Event-ID header, which is what to deduplicate on.
548
685
  */
549
686
  export interface ContactEventPayload {
550
687
  /**
551
688
  * 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.
689
+ * own record. Same meaning as opt_out on the contact resource. On contact.help and
690
+ * contact.custom_keyword this reports the contact's existing state, which neither
691
+ * changes.
554
692
  *
555
693
  * Two signals from the same contact can arrive out of order, because each one is
556
694
  * queued on its own rather than against the contact. Compare the envelope's
@@ -574,6 +712,17 @@ export interface ContactEventPayload {
574
712
  */
575
713
  account_id?: string;
576
714
 
715
+ /**
716
+ * The RCS agent the signal reached, when it reached one.
717
+ *
718
+ * Omitted entirely on channels that have no agent, rather than sent as null — an
719
+ * SMS or WhatsApp payload does not carry this key at all. On RCS it is the
720
+ * counterpart to To: a contact reaches an agent rather than a number, so exactly
721
+ * one of the two is populated and never both. If you run more than one agent, this
722
+ * is what tells you which of them the contact acted on.
723
+ */
724
+ agent_id?: string | null;
725
+
577
726
  /**
578
727
  * The channel the signal arrived on, for example sms or whatsapp.
579
728
  */
@@ -581,11 +730,18 @@ export interface ContactEventPayload {
581
730
 
582
731
  /**
583
732
  * 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.
733
+ * or contact.custom_keyword from a number you have not messaged before — the
734
+ * contact is created if it does not exist yet, so this identifier is always
735
+ * resolvable against the contacts API.
586
736
  */
587
737
  contact_id?: string;
588
738
 
739
+ /**
740
+ * The contact's number, in E.164 format with the leading + — who raised the
741
+ * signal. The same party message.received publishes as inbound_number.
742
+ */
743
+ from?: string;
744
+
589
745
  /**
590
746
  * The inbound message that carried the signal, matching message_id on the
591
747
  * corresponding message.received event so the two can be joined.
@@ -599,10 +755,19 @@ export interface ContactEventPayload {
599
755
  message_id?: string | null;
600
756
 
601
757
  /**
602
- * The contact's number in E.164 format. Same value as phone_number on the contact
603
- * resource.
758
+ * The auto-reply template whose keyword the contact matched, joinable against the
759
+ * templates API.
760
+ *
761
+ * This is what identifies which signal arrived on contact.custom_keyword: every
762
+ * custom template reports the same event name, so the event alone cannot tell your
763
+ * booking keyword from your opening-hours one. One template holds as many keywords
764
+ * as you configured, so this is steadier to switch on than text.
765
+ *
766
+ * Populated on the compliance sub-types too, where it names the template that
767
+ * replied. Sent as null when no template was involved — a network-reported opt-out
768
+ * matches no keyword. The field is always present, so read it and check for null.
604
769
  */
605
- phone_number?: string;
770
+ template_id?: string | null;
606
771
 
607
772
  /**
608
773
  * The text the contact sent, for example STOP or UNSUBSCRIBE. Sent as null when
@@ -610,6 +775,22 @@ export interface ContactEventPayload {
610
775
  * check for null rather than checking whether the key exists.
611
776
  */
612
777
  text?: string | null;
778
+
779
+ /**
780
+ * The number of yours that received the signal, in E.164 format with the leading
781
+ * +. Tells a multi-number account which of its senders the contact acted on, which
782
+ * nothing else on this payload answers.
783
+ *
784
+ * This is your number, not the contact's. That is the opposite of what to means on
785
+ * POST /v3/messages, where it is the list of recipients you are sending to. Reply
786
+ * to From, not to this field, or the message goes back to yourself.
787
+ *
788
+ * Sent as null when the signal did not arrive at a number of yours — an RCS signal
789
+ * terminates at an agent rather than a number, and a provider-reported opt-out may
790
+ * name no receiving number at all. The field is always present, so read it and
791
+ * check for null rather than checking whether the key exists.
792
+ */
793
+ to?: string | null;
613
794
  }
614
795
 
615
796
  /**
@@ -695,10 +876,24 @@ export interface InboundMessageEventPayload {
695
876
  account_id?: string;
696
877
 
697
878
  /**
698
- * The channel the message arrived on, for example sms or whatsapp.
879
+ * The channel the message arrived on, for example sms or mms.
699
880
  */
700
881
  channel?: string;
701
882
 
883
+ /**
884
+ * Attachments the contact sent, present only on channels that carry them (mms
885
+ * today) and omitted entirely otherwise.
886
+ *
887
+ * Each url points at the carrier's own copy of the file — sent.dm records where
888
+ * the attachment is, not the attachment itself. The link is unauthenticated and
889
+ * expires on the carrier's schedule, which differs between them: assume days, not
890
+ * months. Download what you need on receipt; re-reading the message through GET
891
+ * /v3/messages/{id} returns the same stored link, not a fresh one, so once it
892
+ * lapses the entry remains with whatever the carrier declared about the file but
893
+ * the file is no longer reachable.
894
+ */
895
+ media?: Array<InboundMessageEventPayload.Media> | null;
896
+
702
897
  /**
703
898
  * The inbound message.
704
899
  */
@@ -723,6 +918,41 @@ export interface InboundMessageEventPayload {
723
918
  updated_at?: string;
724
919
  }
725
920
 
921
+ export namespace InboundMessageEventPayload {
922
+ /**
923
+ * One attachment on an inbound message.
924
+ */
925
+ export interface Media {
926
+ /**
927
+ * SHA-256 of the file as the carrier declared it, when it declares one. Verify
928
+ * what you download against this — sent.dm never reads the bytes, so it is the
929
+ * only integrity signal available.
930
+ */
931
+ hash_sha256?: string | null;
932
+
933
+ /**
934
+ * Content type as the carrier reported it, for example image/jpeg.
935
+ */
936
+ mime_type?: string | null;
937
+
938
+ /**
939
+ * Size in bytes as the carrier declared it. Absent when it declared none.
940
+ */
941
+ size_bytes?: number | null;
942
+
943
+ /**
944
+ * Where the carrier hosts the attachment.
945
+ *
946
+ * This link expires and is not authenticated. sent.dm relays it rather than
947
+ * copying the file, so how long it stays fetchable is the carrier's decision and
948
+ * differs between them — assume days, not months. Anyone holding the URL can fetch
949
+ * it until it lapses. Copy the file on receipt if you need it to outlive that
950
+ * window; do not store this URL as a permanent reference.
951
+ */
952
+ url?: string | null;
953
+ }
954
+ }
955
+
726
956
  /**
727
957
  * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
728
958
  * this shape and varies only in Payload.
@@ -808,6 +1038,35 @@ export interface MessageEventPayload {
808
1038
  */
809
1039
  outbound_number?: string;
810
1040
 
1041
+ /**
1042
+ * A human-readable sentence for ReasonCode, for example "The recipient is not
1043
+ * registered on this channel". Omitted whenever reason_code is.
1044
+ */
1045
+ reason?: string | null;
1046
+
1047
+ /**
1048
+ * Why the message reached this status, as a stable platform code such as
1049
+ * DELIVERY_007 or BUSINESS_003. Present on message.failed, message.filtered and
1050
+ * message.blocked; omitted on every status that needs no explanation. Switch on
1051
+ * this rather than on Reason: the code is stable, the wording may be improved. It
1052
+ * is the platform's classification of the outcome and never a carrier or vendor
1053
+ * code.
1054
+ */
1055
+ reason_code?: string | null;
1056
+
1057
+ /**
1058
+ * message.scheduled only: why the message is held, either because you scheduled it
1059
+ * or because the recipient is inside a protected quiet-hours window. Omitted on
1060
+ * every other event.
1061
+ */
1062
+ schedule_reason?: string | null;
1063
+
1064
+ /**
1065
+ * message.scheduled only: when the held message will be released for delivery, in
1066
+ * UTC (yyyy-MM-ddTHH:mm:ssZ). Omitted on every other event.
1067
+ */
1068
+ scheduled_at?: string | null;
1069
+
811
1070
  /**
812
1071
  * The template the message was sent from, when it was sent from one.
813
1072
  */
@@ -1104,11 +1363,31 @@ export interface WebhookListEventsResponse {
1104
1363
 
1105
1364
  /**
1106
1365
  * 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.
1110
- */
1111
- event_data?: MessageEvent | InboundMessageEvent | TemplateEvent | ChannelEvent | ContactEvent;
1366
+ * the six webhook envelopes:
1367
+ *
1368
+ * message — an outbound message changed status. message with event:
1369
+ * message.received — someone replied to you. templates — a template was approved,
1370
+ * rejected, paused or similar. channel — one of your markets moved in provisioning
1371
+ * or compliance. contact — a consent signal: opt-in, opt-out or help. link — a
1372
+ * tracked short link was clicked or a hosted file downloaded, or one expired or
1373
+ * was revoked.
1374
+ *
1375
+ * Read field and event to tell which, the same way your endpoint does. The two
1376
+ * message envelopes are the reason that is two fields and not one: they share a
1377
+ * field and differ by event.
1378
+ *
1379
+ * Treat the list as open. It has grown twice — channel and then link — and a
1380
+ * handler that rejects an envelope it does not recognise will break on the next
1381
+ * addition rather than ignore it.
1382
+ */
1383
+ event_data?:
1384
+ | MessageEvent
1385
+ | InboundMessageEvent
1386
+ | TemplateEvent
1387
+ | ChannelEvent
1388
+ | ContactEvent
1389
+ | WebhookListEventsResponse.SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload
1390
+ | WebhookListEventsResponse.SentDmServicesCommonServicesWebhooksContractsWebhookEventOfCallWebhookPayload;
1112
1391
 
1113
1392
  event_type?: string;
1114
1393
 
@@ -1121,6 +1400,336 @@ export interface WebhookListEventsResponse {
1121
1400
  response_body?: string | null;
1122
1401
  }
1123
1402
 
1403
+ export namespace WebhookListEventsResponse {
1404
+ /**
1405
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
1406
+ * this shape and varies only in Payload.
1407
+ */
1408
+ export interface SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload {
1409
+ /**
1410
+ * The specific event within the family, for example message.delivered,
1411
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
1412
+ * treat it as optional.
1413
+ */
1414
+ event?: string | null;
1415
+
1416
+ /**
1417
+ * The event family, for example message, templates or contact. Route on this
1418
+ * first, then on event for the specific change.
1419
+ */
1420
+ field?: string;
1421
+
1422
+ /**
1423
+ * Body of a link event: something happened to a tracked link Sent published on the
1424
+ * customer's behalf. A link points either at a URL the customer supplied or at a
1425
+ * file Sent hosts for them; LinkKind says which. Delivered when an eligible
1426
+ * request is served, or when a published link reaches the end of its life.
1427
+ *
1428
+ * A click is a request, not a read receipt. link.clicked means the redirect was
1429
+ * served; link.downloaded means bytes went out. Neither proves a person saw
1430
+ * anything — messaging providers and link scanners fetch URLs on their own, which
1431
+ * is what TrafficClass exists to tell apart. Filter on it before reporting a
1432
+ * click-through rate; treat likely_human as a hint, never as delivery
1433
+ * confirmation.
1434
+ *
1435
+ * RecordId identifies the link; the X-Webhook-Event-ID header identifies the
1436
+ * delivery. One link is hit many times, so those are the two keys a subscriber
1437
+ * needs: group by the first, deduplicate on the second — exactly as on every other
1438
+ * family. The payload carries no event identifier of its own, for the same reason
1439
+ * none of the others do.
1440
+ *
1441
+ * Nothing here identifies the visitor. No IP address and no visitor token crosses
1442
+ * this boundary. Country, Device and Browser are coarse buckets derived at the
1443
+ * edge and are absent whenever the request did not supply enough to derive them.
1444
+ */
1445
+ payload?: SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload.Payload | null;
1446
+
1447
+ /**
1448
+ * The event-specific body.
1449
+ */
1450
+ request_id?: string | null;
1451
+
1452
+ /**
1453
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
1454
+ * time, not the time the underlying change happened. Use the timestamp inside the
1455
+ * payload for the latter.
1456
+ */
1457
+ timestamp?: string;
1458
+ }
1459
+
1460
+ export namespace SentDmServicesCommonServicesWebhooksContractsWebhookEventOfLinkWebhookPayload {
1461
+ /**
1462
+ * Body of a link event: something happened to a tracked link Sent published on the
1463
+ * customer's behalf. A link points either at a URL the customer supplied or at a
1464
+ * file Sent hosts for them; LinkKind says which. Delivered when an eligible
1465
+ * request is served, or when a published link reaches the end of its life.
1466
+ *
1467
+ * A click is a request, not a read receipt. link.clicked means the redirect was
1468
+ * served; link.downloaded means bytes went out. Neither proves a person saw
1469
+ * anything — messaging providers and link scanners fetch URLs on their own, which
1470
+ * is what TrafficClass exists to tell apart. Filter on it before reporting a
1471
+ * click-through rate; treat likely_human as a hint, never as delivery
1472
+ * confirmation.
1473
+ *
1474
+ * RecordId identifies the link; the X-Webhook-Event-ID header identifies the
1475
+ * delivery. One link is hit many times, so those are the two keys a subscriber
1476
+ * needs: group by the first, deduplicate on the second — exactly as on every other
1477
+ * family. The payload carries no event identifier of its own, for the same reason
1478
+ * none of the others do.
1479
+ *
1480
+ * Nothing here identifies the visitor. No IP address and no visitor token crosses
1481
+ * this boundary. Country, Device and Browser are coarse buckets derived at the
1482
+ * edge and are absent whenever the request did not supply enough to derive them.
1483
+ */
1484
+ export interface Payload {
1485
+ /**
1486
+ * The link's public identifier — the eight-character code in the short URL, for
1487
+ * example A78B2BU0. Unique across both kinds, and never reused, so it is the
1488
+ * stable key to group one link's events by.
1489
+ */
1490
+ record_id: string;
1491
+
1492
+ /**
1493
+ * Where the request appeared to come from, as an ISO 3166-1 alpha-2 code. Named
1494
+ * separately from the country on a channel event, which is a destination market
1495
+ * the customer registered for — this one is a property of a single visitor and is
1496
+ * absent when the edge could not resolve it.
1497
+ */
1498
+ access_country?: string | null;
1499
+
1500
+ /**
1501
+ * How the request was served, when the edge recorded it. Free text describing the
1502
+ * outcome — show it to a human rather than branching on it.
1503
+ */
1504
+ access_outcome?: string | null;
1505
+
1506
+ /**
1507
+ * The requesting browser family, for example chrome or safari, or unknown. Derived
1508
+ * from the user agent.
1509
+ */
1510
+ browser?: string | null;
1511
+
1512
+ /**
1513
+ * How many bytes were served, for a file access. A ranged request reports the
1514
+ * bytes in that range, not the size of the file, so several accesses of one file
1515
+ * can each report a part.
1516
+ */
1517
+ bytes_served?: number | null;
1518
+
1519
+ /**
1520
+ * The channel the message carrying this link went out on: sms, whatsapp, or rcs.
1521
+ */
1522
+ channel?: string | null;
1523
+
1524
+ /**
1525
+ * The organization the link belongs to. Always the parent account, never a sender
1526
+ * profile — read SenderProfileId for that.
1527
+ *
1528
+ * This family publishes the owner as an explicit pair rather than the single
1529
+ * account_id the other families use. The pair says which organization and which
1530
+ * profile without the subscriber deriving either, which is the trade: one more key
1531
+ * against not having to know that account_id silently becomes the profile when one
1532
+ * exists.
1533
+ */
1534
+ customer_id?: string;
1535
+
1536
+ /**
1537
+ * The requesting device class: mobile, tablet, desktop or unknown. Derived from
1538
+ * the user agent.
1539
+ */
1540
+ device?: string | null;
1541
+
1542
+ /**
1543
+ * What the link points at: url for a destination the customer supplied, file for
1544
+ * media Sent hosts. Always present, and implied by the event — link.clicked is
1545
+ * always url and link.downloaded always file — but published as its own field so a
1546
+ * subscriber can branch on the kind without parsing the event name, the same
1547
+ * separation the channel family keeps between its event and its status.
1548
+ */
1549
+ link_kind?: string;
1550
+
1551
+ /**
1552
+ * The message the link was published in.
1553
+ *
1554
+ * The event can arrive before the message is readable through GET /v3/messages: a
1555
+ * provider may fetch a link within milliseconds of the send, and nothing here
1556
+ * waits for the message row. Retry the read rather than treating an unknown id as
1557
+ * an error.
1558
+ */
1559
+ message_id?: string | null;
1560
+
1561
+ /**
1562
+ * When the access or lifecycle change actually happened, in UTC
1563
+ * (yyyy-MM-ddTHH:mm:ssZ). The envelope's timestamp is when Sent emitted the event;
1564
+ * this is when the thing occurred, and the two differ by the ingest delay.
1565
+ */
1566
+ occurred_at?: string;
1567
+
1568
+ /**
1569
+ * The caller-supplied label tying this link back to a position in the message, for
1570
+ * example body:0 for the first link in the body. Present when the link was created
1571
+ * with one.
1572
+ */
1573
+ reference_key?: string | null;
1574
+
1575
+ /**
1576
+ * The host of the page that linked here, when the request supplied one. The host
1577
+ * only — never a full referring URL.
1578
+ */
1579
+ referrer_host?: string | null;
1580
+
1581
+ /**
1582
+ * The HTTP method of the request that was served, for an access event. Omitted on
1583
+ * link.expired and link.revoked, which describe no request.
1584
+ */
1585
+ request_method?: string | null;
1586
+
1587
+ /**
1588
+ * The sender profile that owns the link, or null when the organization owns it
1589
+ * directly. Always on the wire so a handler reads one shape rather than branching
1590
+ * on whether the key arrived.
1591
+ *
1592
+ * sender_profile_id, not profile_id: the API already publishes
1593
+ * messaging_profile_id and sending_phone_number_profile_id for provider-side
1594
+ * profiles, which are a different thing entirely. The unqualified name would read
1595
+ * as one of those.
1596
+ */
1597
+ sender_profile_id?: string | null;
1598
+
1599
+ /**
1600
+ * The HTTP status Sent answered the request with: 302 for a link, 200 or 206 for a
1601
+ * file. Omitted on lifecycle events.
1602
+ */
1603
+ status_code?: number | null;
1604
+
1605
+ /**
1606
+ * A coarse guess at what made the request: likely_human, provider (a messaging
1607
+ * platform prefetching the link), bot, or unknown. Derived from the user agent, so
1608
+ * it is a hint for filtering noise rather than a fact to bill or report on.
1609
+ */
1610
+ traffic_class?: string | null;
1611
+ }
1612
+ }
1613
+
1614
+ /**
1615
+ * The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
1616
+ * this shape and varies only in Payload.
1617
+ */
1618
+ export interface SentDmServicesCommonServicesWebhooksContractsWebhookEventOfCallWebhookPayload {
1619
+ /**
1620
+ * The specific event within the family, for example message.delivered,
1621
+ * message.received or contact.opt_out. Absent on events that have no subtype, so
1622
+ * treat it as optional.
1623
+ */
1624
+ event?: string | null;
1625
+
1626
+ /**
1627
+ * The event family, for example message, templates or contact. Route on this
1628
+ * first, then on event for the specific change.
1629
+ */
1630
+ field?: string;
1631
+
1632
+ /**
1633
+ * Body of a call.initiated, call.answered, call.completed, call.failed or
1634
+ * call.recording_ready event. Which of them occurred is the envelope's event.
1635
+ *
1636
+ * Shaped like the message, inbound, template and channel payloads: account_id
1637
+ * names the account the event is about, channel names the channel, and updated_at
1638
+ * is when the change happened on the call, in the same yyyy-MM-ddTHH:mm:ssZ form.
1639
+ * duration_seconds and price are added on call.completed, reason on call.failed
1640
+ * and recording_id on call.recording_ready; each is omitted rather than sent as
1641
+ * null when it does not apply.
1642
+ *
1643
+ * Casing is snake_case because these ride the same webhook stream customers
1644
+ * already parse message_id from; the question/answer contract is a separate
1645
+ * surface and stays camelCase. Nothing here is provider-shaped: no provider call
1646
+ * id, no namespaced identity.
1647
+ */
1648
+ payload?: SentDmServicesCommonServicesWebhooksContractsWebhookEventOfCallWebhookPayload.Payload | null;
1649
+
1650
+ /**
1651
+ * The event-specific body.
1652
+ */
1653
+ request_id?: string | null;
1654
+
1655
+ /**
1656
+ * When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
1657
+ * time, not the time the underlying change happened. Use the timestamp inside the
1658
+ * payload for the latter.
1659
+ */
1660
+ timestamp?: string;
1661
+ }
1662
+
1663
+ export namespace SentDmServicesCommonServicesWebhooksContractsWebhookEventOfCallWebhookPayload {
1664
+ /**
1665
+ * Body of a call.initiated, call.answered, call.completed, call.failed or
1666
+ * call.recording_ready event. Which of them occurred is the envelope's event.
1667
+ *
1668
+ * Shaped like the message, inbound, template and channel payloads: account_id
1669
+ * names the account the event is about, channel names the channel, and updated_at
1670
+ * is when the change happened on the call, in the same yyyy-MM-ddTHH:mm:ssZ form.
1671
+ * duration_seconds and price are added on call.completed, reason on call.failed
1672
+ * and recording_id on call.recording_ready; each is omitted rather than sent as
1673
+ * null when it does not apply.
1674
+ *
1675
+ * Casing is snake_case because these ride the same webhook stream customers
1676
+ * already parse message_id from; the question/answer contract is a separate
1677
+ * surface and stays camelCase. Nothing here is provider-shaped: no provider call
1678
+ * id, no namespaced identity.
1679
+ */
1680
+ export interface Payload {
1681
+ /**
1682
+ * Sent's call id, the same one the customer saw on the first question.
1683
+ */
1684
+ call_id: string;
1685
+
1686
+ /**
1687
+ * The account the call belongs to: the key's own customer, or the sender profile
1688
+ * it acted as.
1689
+ */
1690
+ account_id?: string;
1691
+
1692
+ /**
1693
+ * Always voice.
1694
+ */
1695
+ channel?: string;
1696
+
1697
+ /**
1698
+ * How long the call lasted. Only on call.completed.
1699
+ */
1700
+ duration_seconds?: number | null;
1701
+
1702
+ /**
1703
+ * The customer number that owns the call, in E.164 format.
1704
+ */
1705
+ number?: string;
1706
+
1707
+ /**
1708
+ * What the call was charged. Only on call.completed, and omitted there until
1709
+ * billing has recorded the charge.
1710
+ */
1711
+ price?: number | null;
1712
+
1713
+ /**
1714
+ * The machine-readable reason the call did not complete. Only on call.failed, and
1715
+ * omitted when no reason was recorded.
1716
+ */
1717
+ reason?: string | null;
1718
+
1719
+ /**
1720
+ * The recording that became available, the same id GET /v3/calls/{id}/recordings
1721
+ * lists it under. Only on call.recording_ready, which is sent once per recording.
1722
+ */
1723
+ recording_id?: string | null;
1724
+
1725
+ /**
1726
+ * When the change happened on the call, as opposed to when the event was emitted.
1727
+ */
1728
+ updated_at?: string;
1729
+ }
1730
+ }
1731
+ }
1732
+
1124
1733
  /**
1125
1734
  * Standard API response envelope for all v3 endpoints
1126
1735
  */
@@ -1223,6 +1832,13 @@ export interface WebhookCreateParams {
1223
1832
  */
1224
1833
  sandbox?: boolean;
1225
1834
 
1835
+ /**
1836
+ * Body param: Request-only: the events an organization webhook's sender profile
1837
+ * clones receive, one clone per existing and future profile. Responses never
1838
+ * return it.
1839
+ */
1840
+ sender_profile?: WebhookCreateParams.SenderProfile | null;
1841
+
1226
1842
  /**
1227
1843
  * Body param
1228
1844
  */
@@ -1243,6 +1859,18 @@ export interface WebhookCreateParams {
1243
1859
  'x-profile-id'?: string;
1244
1860
  }
1245
1861
 
1862
+ export namespace WebhookCreateParams {
1863
+ /**
1864
+ * Request-only: the events an organization webhook's sender profile clones
1865
+ * receive, one clone per existing and future profile. Responses never return it.
1866
+ */
1867
+ export interface SenderProfile {
1868
+ event_filters?: { [key: string]: Array<string> } | null;
1869
+
1870
+ event_types?: Array<string>;
1871
+ }
1872
+ }
1873
+
1246
1874
  export interface WebhookRetrieveParams {
1247
1875
  /**
1248
1876
  * Profile UUID to scope the request to a child profile. Only organization API keys
@@ -1283,6 +1911,13 @@ export interface WebhookUpdateParams {
1283
1911
  */
1284
1912
  sandbox?: boolean;
1285
1913
 
1914
+ /**
1915
+ * Body param: Request-only: the events an organization webhook's sender profile
1916
+ * clones receive, one clone per existing and future profile. Responses never
1917
+ * return it.
1918
+ */
1919
+ sender_profile?: WebhookUpdateParams.SenderProfile | null;
1920
+
1286
1921
  /**
1287
1922
  * Body param
1288
1923
  */
@@ -1303,6 +1938,18 @@ export interface WebhookUpdateParams {
1303
1938
  'x-profile-id'?: string;
1304
1939
  }
1305
1940
 
1941
+ export namespace WebhookUpdateParams {
1942
+ /**
1943
+ * Request-only: the events an organization webhook's sender profile clones
1944
+ * receive, one clone per existing and future profile. Responses never return it.
1945
+ */
1946
+ export interface SenderProfile {
1947
+ event_filters?: { [key: string]: Array<string> } | null;
1948
+
1949
+ event_types?: Array<string>;
1950
+ }
1951
+ }
1952
+
1306
1953
  export interface WebhookListParams extends WebhooksPageParams {
1307
1954
  /**
1308
1955
  * Query param