@trycourier/courier 9.1.0 → 9.3.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 (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.d.mts +4 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +4 -4
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/resources/index.d.mts +2 -2
  10. package/resources/index.d.mts.map +1 -1
  11. package/resources/index.d.ts +2 -2
  12. package/resources/index.d.ts.map +1 -1
  13. package/resources/index.js.map +1 -1
  14. package/resources/index.mjs.map +1 -1
  15. package/resources/journeys/index.d.mts +1 -1
  16. package/resources/journeys/index.d.mts.map +1 -1
  17. package/resources/journeys/index.d.ts +1 -1
  18. package/resources/journeys/index.d.ts.map +1 -1
  19. package/resources/journeys/index.js.map +1 -1
  20. package/resources/journeys/index.mjs.map +1 -1
  21. package/resources/journeys/journeys.d.mts +114 -1
  22. package/resources/journeys/journeys.d.mts.map +1 -1
  23. package/resources/journeys/journeys.d.ts +114 -1
  24. package/resources/journeys/journeys.d.ts.map +1 -1
  25. package/resources/journeys/journeys.js.map +1 -1
  26. package/resources/journeys/journeys.mjs.map +1 -1
  27. package/resources/notifications/index.d.mts +1 -1
  28. package/resources/notifications/index.d.mts.map +1 -1
  29. package/resources/notifications/index.d.ts +1 -1
  30. package/resources/notifications/index.d.ts.map +1 -1
  31. package/resources/notifications/index.js.map +1 -1
  32. package/resources/notifications/index.mjs.map +1 -1
  33. package/resources/notifications/notifications.d.mts +133 -1
  34. package/resources/notifications/notifications.d.mts.map +1 -1
  35. package/resources/notifications/notifications.d.ts +133 -1
  36. package/resources/notifications/notifications.d.ts.map +1 -1
  37. package/resources/notifications/notifications.js +31 -0
  38. package/resources/notifications/notifications.js.map +1 -1
  39. package/resources/notifications/notifications.mjs +31 -0
  40. package/resources/notifications/notifications.mjs.map +1 -1
  41. package/resources/shared.d.mts +45 -10
  42. package/resources/shared.d.mts.map +1 -1
  43. package/resources/shared.d.ts +45 -10
  44. package/resources/shared.d.ts.map +1 -1
  45. package/src/client.ts +14 -0
  46. package/src/resources/index.ts +7 -0
  47. package/src/resources/journeys/index.ts +5 -0
  48. package/src/resources/journeys/journeys.ts +137 -0
  49. package/src/resources/notifications/index.ts +2 -0
  50. package/src/resources/notifications/notifications.ts +160 -0
  51. package/src/resources/shared.ts +47 -12
  52. package/src/version.ts +1 -1
  53. package/version.d.mts +1 -1
  54. package/version.d.ts +1 -1
  55. package/version.js +1 -1
  56. package/version.mjs +1 -1
@@ -1073,6 +1073,11 @@ export namespace JourneySendNode {
1073
1073
 
1074
1074
  template?: string;
1075
1075
 
1076
+ /**
1077
+ * Recipient override for this send. Provide exactly one of `email_override`,
1078
+ * `phone_number_override`, `user_id_override`, `slack`, or `ms_teams` — not a
1079
+ * combination.
1080
+ */
1076
1081
  to?: Message.To;
1077
1082
  }
1078
1083
 
@@ -1104,16 +1109,143 @@ export namespace JourneySendNode {
1104
1109
  timezone?: string;
1105
1110
  }
1106
1111
 
1112
+ /**
1113
+ * Recipient override for this send. Provide exactly one of `email_override`,
1114
+ * `phone_number_override`, `user_id_override`, `slack`, or `ms_teams` — not a
1115
+ * combination.
1116
+ */
1107
1117
  export interface To {
1108
1118
  email_override?: string;
1109
1119
 
1120
+ /**
1121
+ * Send to a Microsoft Teams address directly, bypassing the recipient's stored
1122
+ * profile. Requires exactly one target: `channel_id`, `channel_name` (with
1123
+ * `team_id`), `user_id`, or `email`. `channel_name`, `user_id`, and `email` also
1124
+ * need at least one of `service_url` or `tenant_id` — if you provide both, they
1125
+ * must agree. `channel_id` doesn't require tenant context to publish, but provide
1126
+ * `service_url` or `tenant_id` anyway: sends without either have failed at
1127
+ * delivery in testing. `conversation_id` and `reply_to_activity_id`, available on
1128
+ * the send API's `MsTeams` profile, aren't supported here yet.
1129
+ */
1130
+ ms_teams?: JourneysAPI.JourneySendNodeToMsTeams;
1131
+
1110
1132
  phone_number_override?: string;
1111
1133
 
1134
+ /**
1135
+ * Send to a Slack address directly, bypassing the recipient's stored profile.
1136
+ * Requires exactly one of `channel`, `user_id`, or `email`.
1137
+ */
1138
+ slack?: JourneysAPI.JourneySendNodeToSlack;
1139
+
1112
1140
  user_id_override?: string;
1113
1141
  }
1114
1142
  }
1115
1143
  }
1116
1144
 
1145
+ /**
1146
+ * Send to a Microsoft Teams address directly, bypassing the recipient's stored
1147
+ * profile. Requires exactly one target: `channel_id`, `channel_name` (with
1148
+ * `team_id`), `user_id`, or `email`. `channel_name`, `user_id`, and `email` also
1149
+ * need at least one of `service_url` or `tenant_id` — if you provide both, they
1150
+ * must agree. `channel_id` doesn't require tenant context to publish, but provide
1151
+ * `service_url` or `tenant_id` anyway: sends without either have failed at
1152
+ * delivery in testing. `conversation_id` and `reply_to_activity_id`, available on
1153
+ * the send API's `MsTeams` profile, aren't supported here yet.
1154
+ */
1155
+ export interface JourneySendNodeToMsTeams {
1156
+ /**
1157
+ * Bot Framework channel ID to send to.
1158
+ */
1159
+ channel_id?: string;
1160
+
1161
+ /**
1162
+ * Teams channel name to send to. Requires `team_id`.
1163
+ */
1164
+ channel_name?: string;
1165
+
1166
+ /**
1167
+ * Email address of the Teams user to send to.
1168
+ */
1169
+ email?: string;
1170
+
1171
+ /**
1172
+ * The regional Bot Framework host for this conversation, e.g.
1173
+ * `https://smba.trafficmanager.net/amer`. A path segment naming the Microsoft
1174
+ * tenant may follow it and is used to derive `tenant_id` when it is not supplied
1175
+ * directly.
1176
+ */
1177
+ service_url?: string;
1178
+
1179
+ /**
1180
+ * Microsoft Teams team ID. Required alongside `channel_name`.
1181
+ */
1182
+ team_id?: string;
1183
+
1184
+ /**
1185
+ * The Microsoft (Azure AD) tenant this send targets or authenticates against.
1186
+ * Unrelated to `message.context.tenant_id`, which is the Courier customer's own
1187
+ * multi-tenant context.
1188
+ */
1189
+ tenant_id?: string;
1190
+
1191
+ /**
1192
+ * Microsoft Teams user ID to send to.
1193
+ */
1194
+ user_id?: string;
1195
+ }
1196
+
1197
+ /**
1198
+ * Send to a Slack address directly, bypassing the recipient's stored profile.
1199
+ * Requires exactly one of `channel`, `user_id`, or `email`.
1200
+ */
1201
+ export type JourneySendNodeToSlack =
1202
+ | JourneySendNodeToSlackChannel
1203
+ | JourneySendNodeToSlackUserID
1204
+ | JourneySendNodeToSlackEmail;
1205
+
1206
+ export interface JourneySendNodeToSlackChannel {
1207
+ /**
1208
+ * Slack channel to send to, by name or ID.
1209
+ */
1210
+ channel: string;
1211
+
1212
+ /**
1213
+ * A runtime reference to a Slack access token, such as `{{data.slack_token}}`.
1214
+ * Literal values are rejected — they'd be stored permanently with no way to rotate
1215
+ * them. Omit to use the token on the recipient's stored Slack profile.
1216
+ */
1217
+ access_token?: string;
1218
+ }
1219
+
1220
+ export interface JourneySendNodeToSlackEmail {
1221
+ /**
1222
+ * Email address of the Slack user to send to, resolved via the workspace
1223
+ * directory.
1224
+ */
1225
+ email: string;
1226
+
1227
+ /**
1228
+ * A runtime reference to a Slack access token, such as `{{data.slack_token}}`.
1229
+ * Literal values are rejected — they'd be stored permanently with no way to rotate
1230
+ * them. Omit to use the token on the recipient's stored Slack profile.
1231
+ */
1232
+ access_token?: string;
1233
+ }
1234
+
1235
+ export interface JourneySendNodeToSlackUserID {
1236
+ /**
1237
+ * Slack user ID to send to.
1238
+ */
1239
+ user_id: string;
1240
+
1241
+ /**
1242
+ * A runtime reference to a Slack access token, such as `{{data.slack_token}}`.
1243
+ * Literal values are rejected — they'd be stored permanently with no way to rotate
1244
+ * them. Omit to use the token on the recipient's stored Slack profile.
1245
+ */
1246
+ access_token?: string;
1247
+ }
1248
+
1117
1249
  /**
1118
1250
  * Lifecycle state of a journey.
1119
1251
  */
@@ -1674,6 +1806,11 @@ export declare namespace Journeys {
1674
1806
  type JourneyRunStepsResponse as JourneyRunStepsResponse,
1675
1807
  type JourneySegmentTriggerNode as JourneySegmentTriggerNode,
1676
1808
  type JourneySendNode as JourneySendNode,
1809
+ type JourneySendNodeToMsTeams as JourneySendNodeToMsTeams,
1810
+ type JourneySendNodeToSlack as JourneySendNodeToSlack,
1811
+ type JourneySendNodeToSlackChannel as JourneySendNodeToSlackChannel,
1812
+ type JourneySendNodeToSlackEmail as JourneySendNodeToSlackEmail,
1813
+ type JourneySendNodeToSlackUserID as JourneySendNodeToSlackUserID,
1677
1814
  type JourneyState as JourneyState,
1678
1815
  type JourneyTemplateCreateRequest as JourneyTemplateCreateRequest,
1679
1816
  type JourneyTemplateGetResponse as JourneyTemplateGetResponse,
@@ -19,6 +19,7 @@ export {
19
19
  type NotificationElementPutRequest,
20
20
  type NotificationGetContent,
21
21
  type NotificationLocalePutRequest,
22
+ type NotificationMetricsResponse,
22
23
  type NotificationTemplateAlias,
23
24
  type NotificationTemplateCreateRequest,
24
25
  type NotificationTemplatePayload,
@@ -35,6 +36,7 @@ export {
35
36
  type NotificationCreateParams,
36
37
  type NotificationRetrieveParams,
37
38
  type NotificationListParams,
39
+ type NotificationGetMetricsParams,
38
40
  type NotificationListVersionsParams,
39
41
  type NotificationPublishParams,
40
42
  type NotificationPutContentParams,
@@ -124,6 +124,42 @@ export class Notifications extends APIResource {
124
124
  });
125
125
  }
126
126
 
127
+ /**
128
+ * Fetch the delivery funnel for one Notification Template as a time series — sent,
129
+ * delivered, opened, clicked, errors, and undeliverable — broken out per provider
130
+ * and channel inside each bucket. Sum the entries in a bucket for its totals;
131
+ * there is no bucket-level total.
132
+ *
133
+ * Choose the window absolutely with `start` and `end`, or relatively with
134
+ * `lookback` (an ISO 8601 duration). `start` and `end` take precedence when both
135
+ * are supplied, and a request carrying neither defaults to `lookback=P30D`. The
136
+ * window is snapped outwards onto the `granularity` grid so every bucket it
137
+ * overlaps is returned whole, and the snapped boundaries come back as `start` and
138
+ * `end` — align a chart on those rather than on what was requested. Every boundary
139
+ * is UTC; there is no timezone support.
140
+ *
141
+ * Every bucket in the window is returned, including the quiet ones, whose `data`
142
+ * array is empty, so a series is directly plottable with no gap filling
143
+ * client-side. An unknown template id returns `200` with an all-empty series
144
+ * rather than `404`, and messages sent without a Notification Template never
145
+ * appear here.
146
+ *
147
+ * Available in the US region only.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const notificationMetricsResponse =
152
+ * await client.notifications.getMetrics('x');
153
+ * ```
154
+ */
155
+ getMetrics(
156
+ id: string,
157
+ query: NotificationGetMetricsParams | null | undefined = {},
158
+ options?: RequestOptions,
159
+ ): APIPromise<NotificationMetricsResponse> {
160
+ return this._client.get(path`/notifications/${id}/metrics`, { query, ...options });
161
+ }
162
+
127
163
  /**
128
164
  * Returns a notification template's published versions, most recent first, for
129
165
  * comparison or rollback. Paged.
@@ -546,6 +582,96 @@ export namespace NotificationLocalePutRequest {
546
582
  }
547
583
  }
548
584
 
585
+ export interface NotificationMetricsResponse {
586
+ /**
587
+ * End of the window actually queried, ceiled onto the granularity grid.
588
+ * Second-precision UTC.
589
+ */
590
+ end: string;
591
+
592
+ /**
593
+ * Bucket size the series was built at.
594
+ */
595
+ granularity: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH';
596
+
597
+ /**
598
+ * The template the series describes, echoed from the request.
599
+ */
600
+ notificationId: string;
601
+
602
+ /**
603
+ * One entry per bucket between `start` and `end`, oldest first, including buckets
604
+ * with no activity.
605
+ */
606
+ series: Array<NotificationMetricsResponse.Series>;
607
+
608
+ /**
609
+ * Inclusive start of the window actually queried, floored onto the granularity
610
+ * grid. Second-precision UTC.
611
+ */
612
+ start: string;
613
+ }
614
+
615
+ export namespace NotificationMetricsResponse {
616
+ export interface Series {
617
+ /**
618
+ * One entry per provider and channel that handled a message in this bucket. Empty
619
+ * when nothing was sent.
620
+ */
621
+ data: Array<Series.Data>;
622
+
623
+ /**
624
+ * Start of the bucket, second-precision UTC.
625
+ */
626
+ period: string;
627
+ }
628
+
629
+ export namespace Series {
630
+ export interface Data {
631
+ /**
632
+ * Channel the provider delivered on, e.g. `email`.
633
+ */
634
+ channel: string;
635
+
636
+ /**
637
+ * Messages with at least one tracked link click.
638
+ */
639
+ clicked: number;
640
+
641
+ /**
642
+ * Messages the provider confirmed as delivered.
643
+ */
644
+ delivered: number;
645
+
646
+ /**
647
+ * Messages the provider rejected or failed on, including ones a later provider
648
+ * then delivered.
649
+ */
650
+ errors: number;
651
+
652
+ /**
653
+ * Messages opened at least once. Always `0` on channels with no open tracking.
654
+ */
655
+ opened: number;
656
+
657
+ /**
658
+ * Provider that handled the messages, e.g. `sendgrid`.
659
+ */
660
+ provider: string;
661
+
662
+ /**
663
+ * Messages handed to the provider.
664
+ */
665
+ sent: number;
666
+
667
+ /**
668
+ * Messages Courier could not deliver on any provider for the channel.
669
+ */
670
+ undeliverable: number;
671
+ }
672
+ }
673
+ }
674
+
549
675
  /**
550
676
  * A template's send-time alias as returned by a read, omitted entirely when it has
551
677
  * none. Usually a single string; an array for a template that resolves from
@@ -916,6 +1042,38 @@ export interface NotificationListParams {
916
1042
  notes?: boolean | null;
917
1043
  }
918
1044
 
1045
+ export interface NotificationGetMetricsParams {
1046
+ /**
1047
+ * The end of the window, as an ISO 8601 timestamp with an offset. Must be supplied
1048
+ * together with `start`. An `end` in the future is accepted and not clamped — the
1049
+ * trailing buckets come back empty.
1050
+ */
1051
+ end?: string;
1052
+
1053
+ /**
1054
+ * The size of each bucket in the series. Defaults to `DAY`. `WEEK` buckets start
1055
+ * on Sunday. A fine granularity caps the window it can cover: `HOUR` spans at most
1056
+ * 7 days and `DAY` at most 90 days, and a wider window returns `400` — request a
1057
+ * coarser granularity instead. `WEEK` and `MONTH` are uncapped, subject to the
1058
+ * 1000-bucket limit on a single response.
1059
+ */
1060
+ granularity?: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH';
1061
+
1062
+ /**
1063
+ * The length of the window, counted back from now, as an ISO 8601 duration
1064
+ * (`P30D`, `P12W`, `PT12H`). Defaults to `P30D`, and is ignored when `start` and
1065
+ * `end` are supplied. A malformed or non-positive duration returns `400`.
1066
+ */
1067
+ lookback?: string;
1068
+
1069
+ /**
1070
+ * The inclusive start of the window, as an ISO 8601 timestamp with an offset
1071
+ * (`2026-04-01T00:00:00Z`). Must be supplied together with `end` and be earlier
1072
+ * than it; either one alone returns `400`.
1073
+ */
1074
+ start?: string;
1075
+ }
1076
+
919
1077
  export interface NotificationListVersionsParams {
920
1078
  /**
921
1079
  * Opaque pagination cursor from a previous response. Omit for the first page.
@@ -1088,6 +1246,7 @@ export declare namespace Notifications {
1088
1246
  type NotificationElementPutRequest as NotificationElementPutRequest,
1089
1247
  type NotificationGetContent as NotificationGetContent,
1090
1248
  type NotificationLocalePutRequest as NotificationLocalePutRequest,
1249
+ type NotificationMetricsResponse as NotificationMetricsResponse,
1091
1250
  type NotificationTemplateAlias as NotificationTemplateAlias,
1092
1251
  type NotificationTemplateCreateRequest as NotificationTemplateCreateRequest,
1093
1252
  type NotificationTemplatePayload as NotificationTemplatePayload,
@@ -1104,6 +1263,7 @@ export declare namespace Notifications {
1104
1263
  type NotificationCreateParams as NotificationCreateParams,
1105
1264
  type NotificationRetrieveParams as NotificationRetrieveParams,
1106
1265
  type NotificationListParams as NotificationListParams,
1266
+ type NotificationGetMetricsParams as NotificationGetMetricsParams,
1107
1267
  type NotificationListVersionsParams as NotificationListVersionsParams,
1108
1268
  type NotificationPublishParams as NotificationPublishParams,
1109
1269
  type NotificationPutContentParams as NotificationPutContentParams,
@@ -383,6 +383,10 @@ export interface Metadata {
383
383
  utm?: Utm | null;
384
384
  }
385
385
 
386
+ /**
387
+ * Provide at least one of `tenant_id` or `service_url`. If you provide both, they
388
+ * must agree.
389
+ */
386
390
  export type MsTeams =
387
391
  | SendToMsTeamsUserID
388
392
  | SendToMsTeamsEmail
@@ -390,16 +394,26 @@ export type MsTeams =
390
394
  | SendToMsTeamsConversationID
391
395
  | SendToMsTeamsChannelName;
392
396
 
397
+ /**
398
+ * Tenant context shared by every MS Teams send variant. Provide at least one of
399
+ * `tenant_id` or `service_url`. If you provide both, they must agree — a
400
+ * `service_url` pointing at a different Microsoft tenant than `tenant_id` is
401
+ * rejected.
402
+ */
393
403
  export interface MsTeamsBaseProperties {
394
- service_url: string;
404
+ service_url?: string;
395
405
 
396
- tenant_id: string;
406
+ tenant_id?: string;
397
407
  }
398
408
 
399
409
  /**
400
410
  * Send via Microsoft Teams
401
411
  */
402
412
  export interface MsTeamsRecipient {
413
+ /**
414
+ * Provide at least one of `tenant_id` or `service_url`. If you provide both, they
415
+ * must agree.
416
+ */
403
417
  ms_teams: MsTeams;
404
418
  }
405
419
 
@@ -474,22 +488,31 @@ export interface SendToChannel {
474
488
  channel_id: string;
475
489
  }
476
490
 
491
+ /**
492
+ * Sends directly to a Microsoft Teams channel by its Bot Framework ID. Still
493
+ * provide at least one of `tenant_id` or `service_url` — sends without either have
494
+ * failed Bot Framework authentication in testing.
495
+ */
477
496
  export interface SendToMsTeamsChannelID {
478
497
  channel_id: string;
479
498
 
480
- service_url: string;
499
+ service_url?: string;
481
500
 
482
- tenant_id: string;
501
+ tenant_id?: string;
483
502
  }
484
503
 
504
+ /**
505
+ * `team_id` is required alongside `channel_name`. Also provide at least one of
506
+ * `tenant_id` or `service_url`; if you provide both, they must agree.
507
+ */
485
508
  export interface SendToMsTeamsChannelName {
486
509
  channel_name: string;
487
510
 
488
- service_url: string;
489
-
490
511
  team_id: string;
491
512
 
492
- tenant_id: string;
513
+ service_url?: string;
514
+
515
+ tenant_id?: string;
493
516
  }
494
517
 
495
518
  export interface SendToMsTeamsConversationID {
@@ -500,20 +523,28 @@ export interface SendToMsTeamsConversationID {
500
523
  tenant_id: string;
501
524
  }
502
525
 
526
+ /**
527
+ * Provide at least one of `tenant_id` or `service_url`. If you provide both, they
528
+ * must agree.
529
+ */
503
530
  export interface SendToMsTeamsEmail {
504
531
  email: string;
505
532
 
506
- service_url: string;
533
+ service_url?: string;
507
534
 
508
- tenant_id: string;
535
+ tenant_id?: string;
509
536
  }
510
537
 
538
+ /**
539
+ * Provide at least one of `tenant_id` or `service_url`. If you provide both, they
540
+ * must agree.
541
+ */
511
542
  export interface SendToMsTeamsUserID {
512
- service_url: string;
543
+ user_id: string;
513
544
 
514
- tenant_id: string;
545
+ service_url?: string;
515
546
 
516
- user_id: string;
547
+ tenant_id?: string;
517
548
  }
518
549
 
519
550
  export interface SendToSlackChannel {
@@ -613,6 +644,10 @@ export interface UserProfile {
613
644
 
614
645
  middle_name?: string | null;
615
646
 
647
+ /**
648
+ * Provide at least one of `tenant_id` or `service_url`. If you provide both, they
649
+ * must agree.
650
+ */
616
651
  ms_teams?: MsTeams | null;
617
652
 
618
653
  name?: string | null;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '9.1.0'; // x-release-please-version
1
+ export const VERSION = '9.3.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "9.1.0";
1
+ export declare const VERSION = "9.3.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "9.1.0";
1
+ export declare const VERSION = "9.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '9.1.0'; // x-release-please-version
4
+ exports.VERSION = '9.3.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '9.1.0'; // x-release-please-version
1
+ export const VERSION = '9.3.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map