@trycourier/courier 6.6.1-alpha0 → 6.7.0-alpha2

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 (196) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +11 -11
  3. package/client.d.mts +23 -14
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +23 -14
  6. package/client.d.ts.map +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +2 -2
  9. package/client.mjs.map +1 -1
  10. package/internal/to-file.d.mts +1 -1
  11. package/internal/to-file.d.ts +1 -1
  12. package/internal/to-file.js +1 -1
  13. package/internal/to-file.mjs +1 -1
  14. package/internal/tslib.js +6 -6
  15. package/package.json +1 -1
  16. package/resources/audiences.d.mts +27 -46
  17. package/resources/audiences.d.mts.map +1 -1
  18. package/resources/audiences.d.ts +27 -46
  19. package/resources/audiences.d.ts.map +1 -1
  20. package/resources/audit-events.d.mts +3 -7
  21. package/resources/audit-events.d.mts.map +1 -1
  22. package/resources/audit-events.d.ts +3 -7
  23. package/resources/audit-events.d.ts.map +1 -1
  24. package/resources/auth.d.mts +2 -2
  25. package/resources/auth.d.mts.map +1 -1
  26. package/resources/auth.d.ts +2 -2
  27. package/resources/auth.d.ts.map +1 -1
  28. package/resources/automations/automations.d.mts +2 -253
  29. package/resources/automations/automations.d.mts.map +1 -1
  30. package/resources/automations/automations.d.ts +2 -253
  31. package/resources/automations/automations.d.ts.map +1 -1
  32. package/resources/automations/automations.js +0 -42
  33. package/resources/automations/automations.js.map +1 -1
  34. package/resources/automations/automations.mjs +0 -42
  35. package/resources/automations/automations.mjs.map +1 -1
  36. package/resources/automations/index.d.mts +2 -2
  37. package/resources/automations/index.d.mts.map +1 -1
  38. package/resources/automations/index.d.ts +2 -2
  39. package/resources/automations/index.d.ts.map +1 -1
  40. package/resources/automations/index.js.map +1 -1
  41. package/resources/automations/index.mjs +1 -1
  42. package/resources/automations/index.mjs.map +1 -1
  43. package/resources/automations/invoke.d.mts +124 -9
  44. package/resources/automations/invoke.d.mts.map +1 -1
  45. package/resources/automations/invoke.d.ts +124 -9
  46. package/resources/automations/invoke.d.ts.map +1 -1
  47. package/resources/automations/invoke.js +45 -0
  48. package/resources/automations/invoke.js.map +1 -1
  49. package/resources/automations/invoke.mjs +45 -0
  50. package/resources/automations/invoke.mjs.map +1 -1
  51. package/resources/brands.d.mts +74 -50
  52. package/resources/brands.d.mts.map +1 -1
  53. package/resources/brands.d.ts +74 -50
  54. package/resources/brands.d.ts.map +1 -1
  55. package/resources/brands.js.map +1 -1
  56. package/resources/brands.mjs.map +1 -1
  57. package/resources/bulk.d.mts +38 -89
  58. package/resources/bulk.d.mts.map +1 -1
  59. package/resources/bulk.d.ts +38 -89
  60. package/resources/bulk.d.ts.map +1 -1
  61. package/resources/inbound.d.mts +1 -1
  62. package/resources/inbound.d.ts +1 -1
  63. package/resources/index.d.mts +8 -7
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +8 -7
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js +2 -0
  68. package/resources/index.js.map +1 -1
  69. package/resources/index.mjs +2 -1
  70. package/resources/index.mjs.map +1 -1
  71. package/resources/lists/index.d.mts +2 -2
  72. package/resources/lists/index.d.mts.map +1 -1
  73. package/resources/lists/index.d.ts +2 -2
  74. package/resources/lists/index.d.ts.map +1 -1
  75. package/resources/lists/index.js.map +1 -1
  76. package/resources/lists/index.mjs +1 -1
  77. package/resources/lists/index.mjs.map +1 -1
  78. package/resources/lists/lists.d.mts +9 -7
  79. package/resources/lists/lists.d.mts.map +1 -1
  80. package/resources/lists/lists.d.ts +9 -7
  81. package/resources/lists/lists.d.ts.map +1 -1
  82. package/resources/lists/lists.js +7 -2
  83. package/resources/lists/lists.js.map +1 -1
  84. package/resources/lists/lists.mjs +7 -2
  85. package/resources/lists/lists.mjs.map +1 -1
  86. package/resources/lists/subscriptions.d.mts +9 -34
  87. package/resources/lists/subscriptions.d.mts.map +1 -1
  88. package/resources/lists/subscriptions.d.ts +9 -34
  89. package/resources/lists/subscriptions.d.ts.map +1 -1
  90. package/resources/messages.d.mts +6 -6
  91. package/resources/messages.d.mts.map +1 -1
  92. package/resources/messages.d.ts +6 -6
  93. package/resources/messages.d.ts.map +1 -1
  94. package/resources/messages.js +1 -1
  95. package/resources/messages.js.map +1 -1
  96. package/resources/messages.mjs +1 -1
  97. package/resources/messages.mjs.map +1 -1
  98. package/resources/notifications/index.d.mts +1 -1
  99. package/resources/notifications/index.d.mts.map +1 -1
  100. package/resources/notifications/index.d.ts +1 -1
  101. package/resources/notifications/index.d.ts.map +1 -1
  102. package/resources/notifications/index.js.map +1 -1
  103. package/resources/notifications/index.mjs.map +1 -1
  104. package/resources/notifications/notifications.d.mts +3 -8
  105. package/resources/notifications/notifications.d.mts.map +1 -1
  106. package/resources/notifications/notifications.d.ts +3 -8
  107. package/resources/notifications/notifications.d.ts.map +1 -1
  108. package/resources/notifications/notifications.js.map +1 -1
  109. package/resources/notifications/notifications.mjs.map +1 -1
  110. package/resources/send.d.mts +245 -701
  111. package/resources/send.d.mts.map +1 -1
  112. package/resources/send.d.ts +245 -701
  113. package/resources/send.d.ts.map +1 -1
  114. package/resources/send.js +12 -1
  115. package/resources/send.js.map +1 -1
  116. package/resources/send.mjs +12 -1
  117. package/resources/send.mjs.map +1 -1
  118. package/resources/shared.d.mts +42 -0
  119. package/resources/shared.d.mts.map +1 -0
  120. package/resources/shared.d.ts +42 -0
  121. package/resources/shared.d.ts.map +1 -0
  122. package/resources/shared.js +4 -0
  123. package/resources/shared.js.map +1 -0
  124. package/resources/shared.mjs +3 -0
  125. package/resources/shared.mjs.map +1 -0
  126. package/resources/tenants/index.d.mts +1 -0
  127. package/resources/tenants/index.d.mts.map +1 -1
  128. package/resources/tenants/index.d.ts +1 -0
  129. package/resources/tenants/index.d.ts.map +1 -1
  130. package/resources/tenants/index.js +3 -1
  131. package/resources/tenants/index.js.map +1 -1
  132. package/resources/tenants/index.mjs +1 -0
  133. package/resources/tenants/index.mjs.map +1 -1
  134. package/resources/tenants/templates.d.mts +122 -0
  135. package/resources/tenants/templates.d.mts.map +1 -0
  136. package/resources/tenants/templates.d.ts +122 -0
  137. package/resources/tenants/templates.d.ts.map +1 -0
  138. package/resources/tenants/templates.js +38 -0
  139. package/resources/tenants/templates.js.map +1 -0
  140. package/resources/tenants/templates.mjs +34 -0
  141. package/resources/tenants/templates.mjs.map +1 -0
  142. package/resources/tenants/tenants.d.mts +4 -0
  143. package/resources/tenants/tenants.d.mts.map +1 -1
  144. package/resources/tenants/tenants.d.ts +4 -0
  145. package/resources/tenants/tenants.d.ts.map +1 -1
  146. package/resources/tenants/tenants.js +4 -0
  147. package/resources/tenants/tenants.js.map +1 -1
  148. package/resources/tenants/tenants.mjs +4 -0
  149. package/resources/tenants/tenants.mjs.map +1 -1
  150. package/resources/users/index.d.mts +1 -1
  151. package/resources/users/index.d.mts.map +1 -1
  152. package/resources/users/index.d.ts +1 -1
  153. package/resources/users/index.d.ts.map +1 -1
  154. package/resources/users/tokens.d.mts +22 -23
  155. package/resources/users/tokens.d.mts.map +1 -1
  156. package/resources/users/tokens.d.ts +22 -23
  157. package/resources/users/tokens.d.ts.map +1 -1
  158. package/resources/users/tokens.js +14 -15
  159. package/resources/users/tokens.js.map +1 -1
  160. package/resources/users/tokens.mjs +14 -15
  161. package/resources/users/tokens.mjs.map +1 -1
  162. package/resources/users/users.d.mts +2 -2
  163. package/resources/users/users.d.mts.map +1 -1
  164. package/resources/users/users.d.ts +2 -2
  165. package/resources/users/users.d.ts.map +1 -1
  166. package/src/client.ts +48 -38
  167. package/src/internal/to-file.ts +1 -1
  168. package/src/resources/audiences.ts +43 -82
  169. package/src/resources/audit-events.ts +5 -11
  170. package/src/resources/auth.ts +2 -16
  171. package/src/resources/automations/automations.ts +4 -340
  172. package/src/resources/automations/index.ts +3 -8
  173. package/src/resources/automations/invoke.ts +163 -13
  174. package/src/resources/brands.ts +117 -51
  175. package/src/resources/bulk.ts +31 -104
  176. package/src/resources/inbound.ts +1 -1
  177. package/src/resources/index.ts +17 -19
  178. package/src/resources/lists/index.ts +9 -1
  179. package/src/resources/lists/lists.ts +15 -5
  180. package/src/resources/lists/subscriptions.ts +12 -45
  181. package/src/resources/messages.ts +8 -5
  182. package/src/resources/notifications/index.ts +0 -2
  183. package/src/resources/notifications/notifications.ts +2 -12
  184. package/src/resources/send.ts +249 -853
  185. package/src/resources/shared.ts +61 -0
  186. package/src/resources/tenants/index.ts +8 -0
  187. package/src/resources/tenants/templates.ts +165 -0
  188. package/src/resources/tenants/tenants.ts +21 -0
  189. package/src/resources/users/index.ts +2 -2
  190. package/src/resources/users/tokens.ts +33 -34
  191. package/src/resources/users/users.ts +4 -4
  192. package/src/version.ts +1 -1
  193. package/version.d.mts +1 -1
  194. package/version.d.ts +1 -1
  195. package/version.js +1 -1
  196. package/version.mjs +1 -1
@@ -1,484 +1,45 @@
1
1
  import { APIResource } from "../core/resource.js";
2
2
  import * as SendAPI from "./send.js";
3
3
  import * as BulkAPI from "./bulk.js";
4
+ import * as Shared from "./shared.js";
5
+ import * as TemplatesAPI from "./tenants/templates.js";
4
6
  import { APIPromise } from "../core/api-promise.js";
5
7
  import { RequestOptions } from "../internal/request-options.js";
6
8
  export declare class Send extends APIResource {
7
9
  /**
8
10
  * Use the send API to send a message to one or more recipients.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const response = await client.send.message({
15
+ * message: {
16
+ * to: { user_id: 'example_user' },
17
+ * template: 'template_id',
18
+ * data: { name: 'Example Name' },
19
+ * },
20
+ * });
21
+ * ```
9
22
  */
10
- sendMessage(body: SendSendMessageParams, options?: RequestOptions): APIPromise<SendSendMessageResponse>;
11
- }
12
- export interface BaseMessage {
13
- brand_id?: string | null;
14
- /**
15
- * "Define run-time configuration for one or more channels. If you don't specify
16
- * channels, the default configuration for each channel will be used. Valid
17
- * ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."
18
- */
19
- channels?: {
20
- [key: string]: BaseMessage.Channels;
21
- } | null;
22
- /**
23
- * Context to load with this recipient. Will override any context set on
24
- * message.context.
25
- */
26
- context?: MessageContext | null;
27
- /**
28
- * An arbitrary object that includes any data you want to pass to the message. The
29
- * data will populate the corresponding template or elements variables.
30
- */
31
- data?: {
32
- [key: string]: unknown;
33
- } | null;
34
- /**
35
- * Defines the time to wait before delivering the message. You can specify one of
36
- * the following options. Duration with the number of milliseconds to delay. Until
37
- * with an ISO 8601 timestamp that specifies when it should be delivered. Until
38
- * with an OpenStreetMap opening_hours-like format that specifies the
39
- * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window)
40
- * (e.g., 'Mo-Fr 08:00-18:00pm')
41
- */
42
- delay?: BaseMessage.Delay | null;
43
- /**
44
- * "Expiry allows you to set an absolute or relative time in which a message
45
- * expires. Note: This is only valid for the Courier Inbox channel as of
46
- * 12-08-2022."
47
- */
48
- expiry?: BaseMessage.Expiry | null;
49
- /**
50
- * Metadata such as utm tracking attached with the notification through this
51
- * channel.
52
- */
53
- metadata?: BaseMessage.Metadata | null;
54
- preferences?: BaseMessage.Preferences | null;
55
- /**
56
- * An object whose keys are valid provider identifiers which map to an object.
57
- */
58
- providers?: {
59
- [key: string]: BaseMessage.Providers;
60
- } | null;
61
- /**
62
- * Allows you to customize which channel(s) Courier will potentially deliver the
63
- * message. If no routing key is specified, Courier will use the default routing
64
- * configuration or routing defined by the template.
65
- */
66
- routing?: BaseMessage.Routing | null;
67
- /**
68
- * Time in ms to attempt the channel before failing over to the next available
69
- * channel.
70
- */
71
- timeout?: BaseMessage.Timeout | null;
72
- }
73
- export declare namespace BaseMessage {
74
- interface Channels {
75
- /**
76
- * Id of the brand that should be used for rendering the message. If not specified,
77
- * the brand configured as default brand will be used.
78
- */
79
- brand_id?: string | null;
80
- /**
81
- * A JavaScript conditional expression to determine if the message should be sent
82
- * through the channel. Has access to the data and profile object. For example,
83
- * `data.name === profile.name`
84
- */
85
- if?: string | null;
86
- metadata?: Channels.Metadata | null;
87
- /**
88
- * Channel specific overrides.
89
- */
90
- override?: {
91
- [key: string]: unknown;
92
- } | null;
93
- /**
94
- * A list of providers enabled for this channel. Courier will select one provider
95
- * to send through unless routing_method is set to all.
96
- */
97
- providers?: Array<string> | null;
98
- /**
99
- * The method for selecting the providers to send the message with. Single will
100
- * send to one of the available providers for this channel, all will send the
101
- * message through all channels. Defaults to `single`.
102
- */
103
- routing_method?: SendAPI.RoutingMethod | null;
104
- timeouts?: Channels.Timeouts | null;
105
- }
106
- namespace Channels {
107
- interface Metadata {
108
- utm?: SendAPI.Utm | null;
109
- }
110
- interface Timeouts {
111
- channel?: number | null;
112
- provider?: number | null;
113
- }
114
- }
115
- /**
116
- * Defines the time to wait before delivering the message. You can specify one of
117
- * the following options. Duration with the number of milliseconds to delay. Until
118
- * with an ISO 8601 timestamp that specifies when it should be delivered. Until
119
- * with an OpenStreetMap opening_hours-like format that specifies the
120
- * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window)
121
- * (e.g., 'Mo-Fr 08:00-18:00pm')
122
- */
123
- interface Delay {
124
- /**
125
- * The duration of the delay in milliseconds.
126
- */
127
- duration?: number | null;
128
- /**
129
- * An ISO 8601 timestamp that specifies when it should be delivered or an
130
- * OpenStreetMap opening_hours-like format that specifies the
131
- * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window)
132
- * (e.g., 'Mo-Fr 08:00-18:00pm')
133
- */
134
- until?: string | null;
135
- }
136
- /**
137
- * "Expiry allows you to set an absolute or relative time in which a message
138
- * expires. Note: This is only valid for the Courier Inbox channel as of
139
- * 12-08-2022."
140
- */
141
- interface Expiry {
142
- /**
143
- * A duration in the form of milliseconds or an ISO8601 Duration format (i.e.
144
- * P1DT4H).
145
- */
146
- expires_in: string | number;
147
- /**
148
- * An epoch timestamp or ISO8601 timestamp with timezone
149
- * `(YYYY-MM-DDThh:mm:ss.sTZD)` that describes the time in which a message expires.
150
- */
151
- expires_at?: string | null;
152
- }
153
- /**
154
- * Metadata such as utm tracking attached with the notification through this
155
- * channel.
156
- */
157
- interface Metadata {
158
- /**
159
- * An arbitrary string to tracks the event that generated this request (e.g.
160
- * 'signup').
161
- */
162
- event?: string | null;
163
- /**
164
- * An array of up to 9 tags you wish to associate with this request (and
165
- * corresponding messages) for later analysis. Individual tags cannot be more than
166
- * 30 characters in length.
167
- */
168
- tags?: Array<string> | null;
169
- /**
170
- * A unique ID used to correlate this request to processing on your servers. Note:
171
- * Courier does not verify the uniqueness of this ID.
172
- */
173
- trace_id?: string | null;
174
- /**
175
- * Identify the campaign that refers traffic to a specific website, and attributes
176
- * the browser's website session.
177
- */
178
- utm?: SendAPI.Utm | null;
179
- }
180
- interface Preferences {
181
- /**
182
- * The ID of the subscription topic you want to apply to the message. If this is a
183
- * templated message, it will override the subscription topic if already associated
184
- */
185
- subscription_topic_id: string;
186
- }
187
- interface Providers {
188
- /**
189
- * A JavaScript conditional expression to determine if the message should be sent
190
- * through the channel. Has access to the data and profile object. For example,
191
- * `data.name === profile.name`
192
- */
193
- if?: string | null;
194
- metadata?: Providers.Metadata | null;
195
- /**
196
- * Provider specific overrides.
197
- */
198
- override?: {
199
- [key: string]: unknown;
200
- } | null;
201
- timeouts?: number | null;
202
- }
203
- namespace Providers {
204
- interface Metadata {
205
- utm?: SendAPI.Utm | null;
206
- }
207
- }
208
- /**
209
- * Allows you to customize which channel(s) Courier will potentially deliver the
210
- * message. If no routing key is specified, Courier will use the default routing
211
- * configuration or routing defined by the template.
212
- */
213
- interface Routing {
214
- /**
215
- * A list of channels or providers to send the message through. Can also
216
- * recursively define sub-routing methods, which can be useful for defining
217
- * advanced push notification delivery strategies.
218
- */
219
- channels: Array<Routing.RoutingStrategyChannel | Routing.RoutingStrategyProvider | string>;
220
- method: SendAPI.RoutingMethod;
221
- }
222
- namespace Routing {
223
- interface RoutingStrategyChannel {
224
- channel: string;
225
- config?: {
226
- [key: string]: unknown;
227
- } | null;
228
- if?: string | null;
229
- method?: SendAPI.RoutingMethod | null;
230
- providers?: {
231
- [key: string]: RoutingStrategyChannel.Providers;
232
- } | null;
233
- }
234
- namespace RoutingStrategyChannel {
235
- interface Providers {
236
- /**
237
- * A JavaScript conditional expression to determine if the message should be sent
238
- * through the channel. Has access to the data and profile object. For example,
239
- * `data.name === profile.name`
240
- */
241
- if?: string | null;
242
- metadata?: Providers.Metadata | null;
243
- /**
244
- * Provider specific overrides.
245
- */
246
- override?: {
247
- [key: string]: unknown;
248
- } | null;
249
- timeouts?: number | null;
250
- }
251
- namespace Providers {
252
- interface Metadata {
253
- utm?: SendAPI.Utm | null;
254
- }
255
- }
256
- }
257
- interface RoutingStrategyProvider {
258
- metadata: RoutingStrategyProvider.Metadata;
259
- name: string;
260
- config?: {
261
- [key: string]: unknown;
262
- } | null;
263
- if?: string | null;
264
- }
265
- namespace RoutingStrategyProvider {
266
- interface Metadata {
267
- utm?: SendAPI.Utm | null;
268
- }
269
- }
270
- }
271
- /**
272
- * Time in ms to attempt the channel before failing over to the next available
273
- * channel.
274
- */
275
- interface Timeout {
276
- channel?: {
277
- [key: string]: number;
278
- } | null;
279
- criteria?: 'no-escalation' | 'delivered' | 'viewed' | 'engaged' | null;
280
- escalation?: number | null;
281
- message?: number | null;
282
- provider?: {
283
- [key: string]: number;
284
- } | null;
285
- }
286
- }
287
- export interface BaseMessageSendTo {
288
- /**
289
- * The recipient or a list of recipients of the message
290
- */
291
- to?: BaseMessageSendTo.AudienceRecipient | BaseMessageSendTo.UnionMember1 | BaseMessageSendTo.UnionMember2 | BulkAPI.UserRecipient | BaseMessageSendTo.SlackRecipient | BaseMessageSendTo.MsTeamsRecipient | {
292
- [key: string]: unknown;
293
- } | BaseMessageSendTo.PagerdutyRecipient | BaseMessageSendTo.WebhookRecipient | Array<Recipient> | null;
294
- }
295
- export declare namespace BaseMessageSendTo {
296
- interface AudienceRecipient {
297
- /**
298
- * A unique identifier associated with an Audience. A message will be sent to each
299
- * user in the audience.
300
- */
301
- audience_id: string;
302
- data?: {
303
- [key: string]: unknown;
304
- } | null;
305
- filters?: Array<AudienceRecipient.Filter> | null;
306
- }
307
- namespace AudienceRecipient {
308
- interface Filter {
309
- /**
310
- * Send to users only if they are member of the account
311
- */
312
- operator: 'MEMBER_OF';
313
- path: 'account_id';
314
- value: string;
315
- }
316
- }
317
- interface UnionMember1 {
318
- data?: {
319
- [key: string]: unknown;
320
- } | null;
321
- filters?: Array<UnionMember1.Filter> | null;
322
- list_id?: string | null;
323
- }
324
- namespace UnionMember1 {
325
- interface Filter {
326
- /**
327
- * Send to users only if they are member of the account
328
- */
329
- operator: 'MEMBER_OF';
330
- path: 'account_id';
331
- value: string;
332
- }
333
- }
334
- interface UnionMember2 {
335
- data?: {
336
- [key: string]: unknown;
337
- } | null;
338
- list_pattern?: string | null;
339
- }
340
- interface SlackRecipient {
341
- slack: SlackRecipient.SendToSlackChannel | SlackRecipient.SendToSlackEmail | SlackRecipient.SendToSlackUserID;
342
- }
343
- namespace SlackRecipient {
344
- interface SendToSlackChannel extends SendAPI.SlackBaseProperties {
345
- channel: string;
346
- }
347
- interface SendToSlackEmail extends SendAPI.SlackBaseProperties {
348
- email: string;
349
- }
350
- interface SendToSlackUserID extends SendAPI.SlackBaseProperties {
351
- user_id: string;
352
- }
353
- }
354
- interface MsTeamsRecipient {
355
- ms_teams: MsTeamsRecipient.SendToMsTeamsUserID | MsTeamsRecipient.SendToMsTeamsEmail | MsTeamsRecipient.SendToMsTeamsChannelID | MsTeamsRecipient.SendToMsTeamsConversationID | MsTeamsRecipient.SendToMsTeamsChannelName;
356
- }
357
- namespace MsTeamsRecipient {
358
- interface SendToMsTeamsUserID extends SendAPI.MsTeamsBaseProperties {
359
- user_id: string;
360
- }
361
- interface SendToMsTeamsEmail extends SendAPI.MsTeamsBaseProperties {
362
- email: string;
363
- }
364
- interface SendToMsTeamsChannelID extends SendAPI.MsTeamsBaseProperties {
365
- channel_id: string;
366
- }
367
- interface SendToMsTeamsConversationID extends SendAPI.MsTeamsBaseProperties {
368
- conversation_id: string;
369
- }
370
- interface SendToMsTeamsChannelName extends SendAPI.MsTeamsBaseProperties {
371
- channel_name: string;
372
- team_id: string;
373
- }
374
- }
375
- interface PagerdutyRecipient {
376
- pagerduty: PagerdutyRecipient.Pagerduty;
377
- }
378
- namespace PagerdutyRecipient {
379
- interface Pagerduty {
380
- event_action?: string | null;
381
- routing_key?: string | null;
382
- severity?: string | null;
383
- source?: string | null;
384
- }
385
- }
386
- interface WebhookRecipient {
387
- webhook: WebhookRecipient.Webhook;
388
- }
389
- namespace WebhookRecipient {
390
- interface Webhook {
391
- /**
392
- * The URL to send the webhook request to.
393
- */
394
- url: string;
395
- /**
396
- * Authentication configuration for the webhook request.
397
- */
398
- authentication?: Webhook.Authentication | null;
399
- /**
400
- * Custom headers to include in the webhook request.
401
- */
402
- headers?: {
403
- [key: string]: string;
404
- } | null;
405
- /**
406
- * The HTTP method to use for the webhook request. Defaults to POST if not
407
- * specified.
408
- */
409
- method?: 'POST' | 'PUT' | null;
410
- /**
411
- * Specifies what profile information is included in the request payload. Defaults
412
- * to 'limited' if not specified.
413
- */
414
- profile?: 'limited' | 'expanded' | null;
415
- }
416
- namespace Webhook {
417
- /**
418
- * Authentication configuration for the webhook request.
419
- */
420
- interface Authentication {
421
- /**
422
- * The authentication mode to use. Defaults to 'none' if not specified.
423
- */
424
- mode: 'none' | 'basic' | 'bearer';
425
- /**
426
- * Token for bearer authentication.
427
- */
428
- token?: string | null;
429
- /**
430
- * Password for basic authentication.
431
- */
432
- password?: string | null;
433
- /**
434
- * Username for basic authentication.
435
- */
436
- username?: string | null;
437
- }
438
- }
439
- }
23
+ message(body: SendMessageParams, options?: RequestOptions): APIPromise<SendMessageResponse>;
440
24
  }
441
25
  /**
442
- * Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks.
26
+ * The channel element allows a notification to be customized based on which
27
+ * channel it is sent through. For example, you may want to display a detailed
28
+ * message when the notification is sent through email, and a more concise message
29
+ * in a push notification. Channel elements are only valid as top-level elements;
30
+ * you cannot nest channel elements. If there is a channel element specified at the
31
+ * top-level of the document, all sibling elements must be channel elements. Note:
32
+ * As an alternative, most elements support a `channel` property. Which allows you
33
+ * to selectively display an individual element on a per channel basis. See the
34
+ * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/)
35
+ * for more details.
443
36
  */
444
- export type Content = Content.ElementalContent | Content.ElementalContentSugar;
445
- export declare namespace Content {
446
- interface ElementalContent {
447
- elements: Array<SendAPI.ElementalNode>;
448
- /**
449
- * For example, "2022-01-01"
450
- */
451
- version: string;
452
- brand?: unknown;
453
- }
454
- /**
455
- * Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks.
456
- */
457
- interface ElementalContentSugar {
458
- /**
459
- * The text content displayed in the notification.
460
- */
461
- body: string;
462
- /**
463
- * The title to be displayed by supported channels i.e. push, email (as subject)
464
- */
465
- title: string;
466
- }
467
- }
468
- export interface ElementalChannelNode {
37
+ export interface ElementalChannelNode extends Shared.ElementalBaseNode {
469
38
  /**
470
39
  * The channel the contents of this element should be applied to. Can be `email`,
471
40
  * `push`, `direct_message`, `sms` or a provider such as slack
472
41
  */
473
42
  channel: string;
474
- channels?: Array<string> | null;
475
- /**
476
- * An array of elements to apply to the channel. If `raw` has not been specified,
477
- * `elements` is `required`.
478
- */
479
- elements?: Array<ElementalNode> | null;
480
- if?: string | null;
481
- loop?: string | null;
482
43
  /**
483
44
  * Raw data to apply to the channel. If `elements` has not been specified, `raw` is
484
45
  * `required`.
@@ -486,17 +47,6 @@ export interface ElementalChannelNode {
486
47
  raw?: {
487
48
  [key: string]: unknown;
488
49
  } | null;
489
- ref?: string | null;
490
- }
491
- export interface ElementalGroupNode {
492
- /**
493
- * Sub elements to render.
494
- */
495
- elements: Array<ElementalNode>;
496
- channels?: Array<string> | null;
497
- if?: string | null;
498
- loop?: string | null;
499
- ref?: string | null;
500
50
  }
501
51
  /**
502
52
  * The channel element allows a notification to be customized based on which
@@ -510,20 +60,12 @@ export interface ElementalGroupNode {
510
60
  * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/)
511
61
  * for more details.
512
62
  */
513
- export type ElementalNode = ElementalNode.UnionMember0 | ElementalNode.UnionMember1 | ElementalNode.UnionMember2 | ElementalNode.UnionMember3 | ElementalNode.UnionMember4 | ElementalNode.UnionMember5 | ElementalNode.UnionMember6 | ElementalNode.UnionMember7;
63
+ export type ElementalNode = ElementalNode.UnionMember0 | ElementalNode.UnionMember1 | ElementalNode.UnionMember2 | ElementalNode.UnionMember3 | ElementalNode.UnionMember4 | ElementalNode.UnionMember5 | ElementalNode.UnionMember6;
514
64
  export declare namespace ElementalNode {
515
- interface UnionMember0 {
516
- channels?: Array<string> | null;
517
- if?: string | null;
518
- loop?: string | null;
519
- ref?: string | null;
65
+ interface UnionMember0 extends Shared.ElementalBaseNode {
520
66
  type?: 'text';
521
67
  }
522
- interface UnionMember1 {
523
- channels?: Array<string> | null;
524
- if?: string | null;
525
- loop?: string | null;
526
- ref?: string | null;
68
+ interface UnionMember1 extends Shared.ElementalBaseNode {
527
69
  type?: 'meta';
528
70
  }
529
71
  /**
@@ -541,270 +83,272 @@ export declare namespace ElementalNode {
541
83
  interface UnionMember2 extends SendAPI.ElementalChannelNode {
542
84
  type?: 'channel';
543
85
  }
544
- interface UnionMember3 {
545
- channels?: Array<string> | null;
546
- if?: string | null;
547
- loop?: string | null;
548
- ref?: string | null;
86
+ interface UnionMember3 extends Shared.ElementalBaseNode {
549
87
  type?: 'image';
550
88
  }
551
89
  interface UnionMember4 {
552
- channels?: Array<string> | null;
553
- if?: string | null;
554
- loop?: string | null;
555
- ref?: string | null;
90
+ /**
91
+ * A unique id used to identify the action when it is executed.
92
+ */
93
+ action_id?: string | null;
94
+ /**
95
+ * The alignment of the action button. Defaults to "center".
96
+ */
97
+ align?: Shared.Alignment | null;
98
+ /**
99
+ * The background color of the action button.
100
+ */
101
+ background_color?: string | null;
102
+ /**
103
+ * The text content of the action shown to the user.
104
+ */
105
+ content?: string;
106
+ /**
107
+ * The target URL of the action.
108
+ */
109
+ href?: string;
110
+ /**
111
+ * Region specific content. See
112
+ * [locales docs](https://www.courier.com/docs/platform/content/elemental/locales/)
113
+ * for more details.
114
+ */
115
+ locales?: {
116
+ [key: string]: UnionMember4.Locales;
117
+ } | null;
118
+ /**
119
+ * Defaults to `button`.
120
+ */
121
+ style?: 'button' | 'link' | null;
556
122
  type?: 'action';
557
123
  }
558
- interface UnionMember5 {
559
- channels?: Array<string> | null;
560
- if?: string | null;
561
- loop?: string | null;
562
- ref?: string | null;
563
- type?: 'divider';
124
+ namespace UnionMember4 {
125
+ interface Locales {
126
+ content: string;
127
+ }
564
128
  }
565
- /**
566
- * Allows you to group elements together. This can be useful when used in
567
- * combination with "if" or "loop". See
568
- * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/)
569
- * for more details.
570
- */
571
- interface UnionMember6 extends SendAPI.ElementalGroupNode {
572
- type?: 'group';
129
+ interface UnionMember5 extends Shared.ElementalBaseNode {
130
+ type?: 'divider';
573
131
  }
574
- interface UnionMember7 {
575
- channels?: Array<string> | null;
576
- if?: string | null;
577
- loop?: string | null;
578
- ref?: string | null;
132
+ interface UnionMember6 extends Shared.ElementalBaseNode {
579
133
  type?: 'quote';
580
134
  }
581
135
  }
582
- /**
583
- * Describes the content of the message in a way that will work for email, push,
584
- * chat, or any channel.
585
- */
586
- export type Message = Message.ContentMessage | Message.TemplateMessage;
587
- export declare namespace Message {
136
+ export interface MessageContext {
588
137
  /**
589
- * Describes the content of the message in a way that will work for email, push,
590
- * chat, or any channel.
138
+ * Tenant id used to load brand/default preferences/context.
591
139
  */
592
- interface ContentMessage extends SendAPI.BaseMessage, SendAPI.BaseMessageSendTo {
593
- /**
594
- * Describes the content of the message in a way that will work for email, push,
595
- * chat, or any channel. Either this or template must be specified.
596
- */
597
- content: SendAPI.Content;
598
- }
140
+ tenant_id?: string | null;
141
+ }
142
+ export interface Recipient {
599
143
  /**
600
- * A template for a type of message that can be sent more than once. For example,
601
- * you might create an "Appointment Reminder" Notification or “Reset Password”
602
- * Notifications.
144
+ * Use `tenant_id` instead.
603
145
  */
604
- interface TemplateMessage extends SendAPI.BaseMessage, SendAPI.BaseMessageSendTo {
605
- /**
606
- * The id of the notification template to be rendered and sent to the recipient(s).
607
- * This field or the content field must be supplied.
608
- */
609
- template: string;
146
+ account_id?: string | null;
147
+ /**
148
+ * Context such as tenant_id to send the notification with.
149
+ */
150
+ context?: MessageContext | null;
151
+ data?: {
152
+ [key: string]: unknown;
153
+ } | null;
154
+ email?: string | null;
155
+ /**
156
+ * The user's preferred ISO 639-1 language code.
157
+ */
158
+ locale?: string | null;
159
+ phone_number?: string | null;
160
+ preferences?: Recipient.Preferences | null;
161
+ /**
162
+ * Tenant id. Will load brand, default preferences and base context data.
163
+ */
164
+ tenant_id?: string | null;
165
+ user_id?: string | null;
166
+ }
167
+ export declare namespace Recipient {
168
+ interface Preferences {
169
+ notifications: {
170
+ [key: string]: Shared.Preference;
171
+ };
172
+ categories?: {
173
+ [key: string]: Shared.Preference;
174
+ } | null;
175
+ templateId?: string | null;
610
176
  }
611
177
  }
612
- export interface MessageContext {
178
+ export interface Utm {
179
+ campaign?: string | null;
180
+ content?: string | null;
181
+ medium?: string | null;
182
+ source?: string | null;
183
+ term?: string | null;
184
+ }
185
+ export interface SendMessageResponse {
613
186
  /**
614
- * An id of a tenant, see
615
- * [tenants api docs](https://www.courier.com/docs/reference/tenants/). Will load
616
- * brand, default preferences and any other base context data associated with this
617
- * tenant.
187
+ * A successful call to `POST /send` returns a `202` status code along with a
188
+ * `requestId` in the response body. For single-recipient requests, the `requestId`
189
+ * is the derived message_id. For multiple recipients, Courier assigns a unique
190
+ * message_id to each derived message.
618
191
  */
619
- tenant_id?: string | null;
192
+ requestId: string;
620
193
  }
621
- export interface MsTeamsBaseProperties {
622
- service_url: string;
623
- tenant_id: string;
194
+ export interface SendMessageParams {
195
+ /**
196
+ * The message property has the following primary top-level properties. They define
197
+ * the destination and content of the message.
198
+ */
199
+ message: SendMessageParams.Message;
624
200
  }
625
- export type Recipient = Recipient.AudienceRecipient | Recipient.UnionMember1 | Recipient.UnionMember2 | BulkAPI.UserRecipient | Recipient.SlackRecipient | Recipient.MsTeamsRecipient | {
626
- [key: string]: unknown;
627
- } | Recipient.PagerdutyRecipient | Recipient.WebhookRecipient;
628
- export declare namespace Recipient {
629
- interface AudienceRecipient {
201
+ export declare namespace SendMessageParams {
202
+ /**
203
+ * The message property has the following primary top-level properties. They define
204
+ * the destination and content of the message.
205
+ */
206
+ interface Message {
207
+ brand_id?: string | null;
630
208
  /**
631
- * A unique identifier associated with an Audience. A message will be sent to each
632
- * user in the audience.
209
+ * Define run-time configuration for channels. Valid ChannelId's: email, sms, push,
210
+ * inbox, direct_message, banner, webhook.
633
211
  */
634
- audience_id: string;
212
+ channels?: {
213
+ [key: string]: Message.Channels;
214
+ } | null;
215
+ /**
216
+ * Describes content that will work for email, inbox, push, chat, or any channel
217
+ * id.
218
+ */
219
+ content?: Shared.ElementalContentSugar | TemplatesAPI.ElementalContent;
220
+ context?: SendAPI.MessageContext | null;
635
221
  data?: {
636
222
  [key: string]: unknown;
637
223
  } | null;
638
- filters?: Array<AudienceRecipient.Filter> | null;
224
+ delay?: Message.Delay | null;
225
+ expiry?: Message.Expiry | null;
226
+ metadata?: Message.Metadata | null;
227
+ preferences?: Message.Preferences | null;
228
+ providers?: {
229
+ [key: string]: Message.Providers;
230
+ } | null;
231
+ /**
232
+ * Customize which channels/providers Courier may deliver the message through.
233
+ */
234
+ routing?: Message.Routing | null;
235
+ timeout?: Message.Timeout | null;
236
+ /**
237
+ * The recipient or a list of recipients of the message
238
+ */
239
+ to?: BulkAPI.UserRecipient | Array<SendAPI.Recipient> | null;
639
240
  }
640
- namespace AudienceRecipient {
641
- interface Filter {
241
+ namespace Message {
242
+ interface Channels {
642
243
  /**
643
- * Send to users only if they are member of the account
244
+ * Brand id used for rendering.
644
245
  */
645
- operator: 'MEMBER_OF';
646
- path: 'account_id';
647
- value: string;
648
- }
649
- }
650
- interface UnionMember1 {
651
- data?: {
652
- [key: string]: unknown;
653
- } | null;
654
- filters?: Array<UnionMember1.Filter> | null;
655
- list_id?: string | null;
656
- }
657
- namespace UnionMember1 {
658
- interface Filter {
246
+ brand_id?: string | null;
659
247
  /**
660
- * Send to users only if they are member of the account
248
+ * JS conditional with access to data/profile.
661
249
  */
662
- operator: 'MEMBER_OF';
663
- path: 'account_id';
664
- value: string;
665
- }
666
- }
667
- interface UnionMember2 {
668
- data?: {
669
- [key: string]: unknown;
670
- } | null;
671
- list_pattern?: string | null;
672
- }
673
- interface SlackRecipient {
674
- slack: SlackRecipient.SendToSlackChannel | SlackRecipient.SendToSlackEmail | SlackRecipient.SendToSlackUserID;
675
- }
676
- namespace SlackRecipient {
677
- interface SendToSlackChannel extends SendAPI.SlackBaseProperties {
678
- channel: string;
679
- }
680
- interface SendToSlackEmail extends SendAPI.SlackBaseProperties {
681
- email: string;
682
- }
683
- interface SendToSlackUserID extends SendAPI.SlackBaseProperties {
684
- user_id: string;
685
- }
686
- }
687
- interface MsTeamsRecipient {
688
- ms_teams: MsTeamsRecipient.SendToMsTeamsUserID | MsTeamsRecipient.SendToMsTeamsEmail | MsTeamsRecipient.SendToMsTeamsChannelID | MsTeamsRecipient.SendToMsTeamsConversationID | MsTeamsRecipient.SendToMsTeamsChannelName;
689
- }
690
- namespace MsTeamsRecipient {
691
- interface SendToMsTeamsUserID extends SendAPI.MsTeamsBaseProperties {
692
- user_id: string;
693
- }
694
- interface SendToMsTeamsEmail extends SendAPI.MsTeamsBaseProperties {
695
- email: string;
696
- }
697
- interface SendToMsTeamsChannelID extends SendAPI.MsTeamsBaseProperties {
698
- channel_id: string;
699
- }
700
- interface SendToMsTeamsConversationID extends SendAPI.MsTeamsBaseProperties {
701
- conversation_id: string;
702
- }
703
- interface SendToMsTeamsChannelName extends SendAPI.MsTeamsBaseProperties {
704
- channel_name: string;
705
- team_id: string;
250
+ if?: string | null;
251
+ metadata?: Channels.Metadata | null;
252
+ /**
253
+ * Channel specific overrides.
254
+ */
255
+ override?: {
256
+ [key: string]: unknown;
257
+ } | null;
258
+ /**
259
+ * Providers enabled for this channel.
260
+ */
261
+ providers?: Array<string> | null;
262
+ /**
263
+ * Defaults to `single`.
264
+ */
265
+ routing_method?: 'all' | 'single' | null;
266
+ timeouts?: Channels.Timeouts | null;
706
267
  }
707
- }
708
- interface PagerdutyRecipient {
709
- pagerduty: PagerdutyRecipient.Pagerduty;
710
- }
711
- namespace PagerdutyRecipient {
712
- interface Pagerduty {
713
- event_action?: string | null;
714
- routing_key?: string | null;
715
- severity?: string | null;
716
- source?: string | null;
268
+ namespace Channels {
269
+ interface Metadata {
270
+ utm?: SendAPI.Utm | null;
271
+ }
272
+ interface Timeouts {
273
+ channel?: number | null;
274
+ provider?: number | null;
275
+ }
717
276
  }
718
- }
719
- interface WebhookRecipient {
720
- webhook: WebhookRecipient.Webhook;
721
- }
722
- namespace WebhookRecipient {
723
- interface Webhook {
277
+ interface Delay {
724
278
  /**
725
- * The URL to send the webhook request to.
279
+ * The duration of the delay in milliseconds.
726
280
  */
727
- url: string;
281
+ duration?: number | null;
728
282
  /**
729
- * Authentication configuration for the webhook request.
283
+ * ISO 8601 timestamp or opening_hours-like format.
730
284
  */
731
- authentication?: Webhook.Authentication | null;
285
+ until?: string | null;
286
+ }
287
+ interface Expiry {
732
288
  /**
733
- * Custom headers to include in the webhook request.
289
+ * Duration in ms or ISO8601 duration (e.g. P1DT4H).
734
290
  */
735
- headers?: {
736
- [key: string]: string;
737
- } | null;
291
+ expires_in: string | number;
738
292
  /**
739
- * The HTTP method to use for the webhook request. Defaults to POST if not
740
- * specified.
293
+ * Epoch or ISO8601 timestamp with timezone.
741
294
  */
742
- method?: 'POST' | 'PUT' | null;
295
+ expires_at?: string | null;
296
+ }
297
+ interface Metadata {
298
+ event?: string | null;
299
+ tags?: Array<string> | null;
300
+ trace_id?: string | null;
301
+ utm?: SendAPI.Utm | null;
302
+ }
303
+ interface Preferences {
743
304
  /**
744
- * Specifies what profile information is included in the request payload. Defaults
745
- * to 'limited' if not specified.
305
+ * The subscription topic to apply to the message.
746
306
  */
747
- profile?: 'limited' | 'expanded' | null;
307
+ subscription_topic_id: string;
748
308
  }
749
- namespace Webhook {
309
+ interface Providers {
310
+ /**
311
+ * JS conditional with access to data/profile.
312
+ */
313
+ if?: string | null;
314
+ metadata?: Providers.Metadata | null;
750
315
  /**
751
- * Authentication configuration for the webhook request.
316
+ * Provider-specific overrides.
752
317
  */
753
- interface Authentication {
754
- /**
755
- * The authentication mode to use. Defaults to 'none' if not specified.
756
- */
757
- mode: 'none' | 'basic' | 'bearer';
758
- /**
759
- * Token for bearer authentication.
760
- */
761
- token?: string | null;
762
- /**
763
- * Password for basic authentication.
764
- */
765
- password?: string | null;
766
- /**
767
- * Username for basic authentication.
768
- */
769
- username?: string | null;
318
+ override?: {
319
+ [key: string]: unknown;
320
+ } | null;
321
+ timeouts?: number | null;
322
+ }
323
+ namespace Providers {
324
+ interface Metadata {
325
+ utm?: SendAPI.Utm | null;
770
326
  }
771
327
  }
328
+ /**
329
+ * Customize which channels/providers Courier may deliver the message through.
330
+ */
331
+ interface Routing {
332
+ /**
333
+ * A list of channels or providers (or nested routing rules).
334
+ */
335
+ channels: Array<Shared.MessageRoutingChannel>;
336
+ method: 'all' | 'single';
337
+ }
338
+ interface Timeout {
339
+ channel?: {
340
+ [key: string]: number;
341
+ } | null;
342
+ criteria?: 'no-escalation' | 'delivered' | 'viewed' | 'engaged' | null;
343
+ escalation?: number | null;
344
+ message?: number | null;
345
+ provider?: {
346
+ [key: string]: number;
347
+ } | null;
348
+ }
772
349
  }
773
350
  }
774
- export type RoutingMethod = 'all' | 'single';
775
- export interface SlackBaseProperties {
776
- access_token: string;
777
- }
778
- export interface Utm {
779
- campaign?: string | null;
780
- content?: string | null;
781
- medium?: string | null;
782
- source?: string | null;
783
- term?: string | null;
784
- }
785
- export interface SendSendMessageResponse {
786
- /**
787
- * A successful call to `POST /send` returns a `202` status code along with a
788
- * `requestId` in the response body.
789
- *
790
- * For send requests that have a single recipient, the `requestId` is assigned to
791
- * the derived message as its message_id. Therefore the `requestId` can be supplied
792
- * to the Message's API for single recipient messages.
793
- *
794
- * For send requests that have multiple recipients (accounts, audiences, lists,
795
- * etc.), Courier assigns a unique id to each derived message as its `message_id`.
796
- * Therefore the `requestId` cannot be supplied to the Message's API for
797
- * single-recipient messages.
798
- */
799
- requestId: string;
800
- }
801
- export interface SendSendMessageParams {
802
- /**
803
- * Defines the message to be delivered
804
- */
805
- message: Message;
806
- }
807
351
  export declare namespace Send {
808
- export { type BaseMessage as BaseMessage, type BaseMessageSendTo as BaseMessageSendTo, type Content as Content, type ElementalChannelNode as ElementalChannelNode, type ElementalGroupNode as ElementalGroupNode, type ElementalNode as ElementalNode, type Message as Message, type MessageContext as MessageContext, type MsTeamsBaseProperties as MsTeamsBaseProperties, type Recipient as Recipient, type RoutingMethod as RoutingMethod, type SlackBaseProperties as SlackBaseProperties, type Utm as Utm, type SendSendMessageResponse as SendSendMessageResponse, type SendSendMessageParams as SendSendMessageParams, };
352
+ export { type ElementalChannelNode as ElementalChannelNode, type ElementalNode as ElementalNode, type MessageContext as MessageContext, type Recipient as Recipient, type Utm as Utm, type SendMessageResponse as SendMessageResponse, type SendMessageParams as SendMessageParams, };
809
353
  }
810
354
  //# sourceMappingURL=send.d.ts.map