mailchannels-sdk 0.7.3 → 0.7.5

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.
@@ -1,1934 +1,2101 @@
1
- import { FetchOptions } from 'ofetch';
1
+ import { FetchOptions } from "ofetch";
2
2
 
3
+ //#region src/client.d.ts
3
4
  declare class MailChannelsClient {
4
- #private;
5
- private static BASE_URL;
6
- constructor(key: string);
7
- protected _fetch<T>(path: string, options?: FetchOptions<"json">): Promise<T>;
8
- post<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
9
- get<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
10
- delete<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
11
- put<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
12
- patch<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
5
+ #private;
6
+ private static BASE_URL;
7
+ constructor(key: string);
8
+ protected _fetch<T>(path: string, options?: FetchOptions<"json">): Promise<T>;
9
+ post<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
10
+ get<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
11
+ delete<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
12
+ put<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
13
+ patch<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
13
14
  }
14
-
15
+ //#endregion
16
+ //#region src/types/responses.d.ts
15
17
  interface ErrorResponse {
16
- message: string;
17
- statusCode: number | null;
18
+ message: string;
19
+ statusCode: number | null;
18
20
  }
19
21
  interface SuccessResponse {
20
- /**
21
- * Whether the operation was successful.
22
- */
23
- success: boolean;
24
- /**
25
- * Error information if the operation failed.
26
- */
27
- error: ErrorResponse | null;
22
+ /**
23
+ * Whether the operation was successful.
24
+ */
25
+ success: boolean;
26
+ /**
27
+ * Error information if the operation failed.
28
+ */
29
+ error: ErrorResponse | null;
28
30
  }
29
31
  type DataResponse<T> = {
30
- /**
31
- * The response data.
32
- */
33
- data: T;
34
- /**
35
- * Error information if the operation failed.
36
- */
37
- error: null;
32
+ /**
33
+ * The response data.
34
+ */
35
+ data: T;
36
+ /**
37
+ * Error information if the operation failed.
38
+ */
39
+ error: null;
38
40
  } | {
39
- /**
40
- * The response data.
41
- */
42
- data: null;
43
- /**
44
- * Error information if the operation failed.
45
- */
46
- error: ErrorResponse;
41
+ /**
42
+ * The response data.
43
+ */
44
+ data: null;
45
+ /**
46
+ * Error information if the operation failed.
47
+ */
48
+ error: ErrorResponse;
47
49
  };
48
-
50
+ //#endregion
51
+ //#region src/types/emails/send.d.ts
49
52
  interface EmailsSendRecipient {
50
- /**
51
- * The email address of the recipient.
52
- */
53
- email: string;
54
- /**
55
- * The name of the recipient. Display name in raw text, e.g. John Doe, 张三.
56
- */
57
- name?: string;
53
+ /**
54
+ * The email address of the recipient.
55
+ */
56
+ email: string;
57
+ /**
58
+ * The name of the recipient. Display name in raw text, e.g. John Doe, 张三.
59
+ */
60
+ name?: string;
58
61
  }
59
62
  interface EmailsSendAttachment {
60
- /**
61
- * The attachment data, encoded in base64.
62
- */
63
- content: string;
64
- /**
65
- * The name of the attachment file.
66
- */
67
- filename: string;
68
- /**
69
- * The MIME type of the attachment.
70
- */
71
- type: string;
63
+ /**
64
+ * The attachment data, encoded in base64.
65
+ */
66
+ content: string;
67
+ /**
68
+ * The name of the attachment file.
69
+ */
70
+ filename: string;
71
+ /**
72
+ * The MIME type of the attachment.
73
+ */
74
+ type: string;
72
75
  }
73
76
  interface EmailsSendTracking {
74
- /**
75
- * Track when a recipient clicks a link in your email.
76
- * @default false
77
- */
78
- click?: boolean;
79
- /**
80
- * Track when a recipient opens your email. Please note that some email clients may not support open tracking.
81
- * @default false
82
- */
83
- open?: boolean;
77
+ /**
78
+ * Track when a recipient clicks a link in your email.
79
+ * @default false
80
+ */
81
+ click?: boolean;
82
+ /**
83
+ * Track when a recipient opens your email. Please note that some email clients may not support open tracking.
84
+ * @default false
85
+ */
86
+ open?: boolean;
84
87
  }
85
88
  interface EmailsSendOptionsBase {
89
+ /**
90
+ * An array of attachments to be sent with the email.
91
+ */
92
+ attachments?: EmailsSendAttachment[];
93
+ /**
94
+ * The campaign identifier. If specified, this ID will be included in all relevant webhooks. It can be up to 48 UTF-8 characters long and must not contain spaces.
95
+ */
96
+ campaignId?: string;
97
+ /**
98
+ * The BCC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
99
+ * @example
100
+ * [
101
+ * { email: 'email1@example.com', name: 'Example1' },
102
+ * { email: 'email2@example.com', name: 'Example2' }
103
+ * ]
104
+ * @example
105
+ * { email: 'email@example.com', name: 'Example' }
106
+ * @example
107
+ * ['email1@example.com', 'email2@example.com']
108
+ * @example
109
+ * 'email@example.com'
110
+ * @example
111
+ * 'Name <email@example.com>'
112
+ */
113
+ bcc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
114
+ /**
115
+ * The CC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
116
+ * @example
117
+ * [
118
+ * { email: 'email1@example.com', name: 'Example1' },
119
+ * { email: 'email2@example.com', name: 'Example2' }
120
+ * ]
121
+ * @example
122
+ * { email: 'email@example.com', name: 'Example' }
123
+ * @example
124
+ * ['email1@example.com', 'email2@example.com']
125
+ * @example
126
+ * 'email@example.com'
127
+ * @example
128
+ * 'Name <email@example.com>'
129
+ */
130
+ cc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
131
+ /**
132
+ * The DKIM settings for the email.
133
+ */
134
+ dkim?: {
86
135
  /**
87
- * An array of attachments to be sent with the email.
88
- */
89
- attachments?: EmailsSendAttachment[];
90
- /**
91
- * The campaign identifier. If specified, this ID will be included in all relevant webhooks. It can be up to 48 UTF-8 characters long and must not contain spaces.
92
- */
93
- campaignId?: string;
94
- /**
95
- * The BCC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
96
- * @example
97
- * [
98
- * { email: 'email1@example.com', name: 'Example1' },
99
- * { email: 'email2@example.com', name: 'Example2' }
100
- * ]
101
- * @example
102
- * { email: 'email@example.com', name: 'Example' }
103
- * @example
104
- * ['email1@example.com', 'email2@example.com']
105
- * @example
106
- * 'email@example.com'
107
- * @example
108
- * 'Name <email@example.com>'
109
- */
110
- bcc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
111
- /**
112
- * The CC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties.
113
- * @example
114
- * [
115
- * { email: 'email1@example.com', name: 'Example1' },
116
- * { email: 'email2@example.com', name: 'Example2' }
117
- * ]
118
- * @example
119
- * { email: 'email@example.com', name: 'Example' }
120
- * @example
121
- * ['email1@example.com', 'email2@example.com']
122
- * @example
123
- * 'email@example.com'
124
- * @example
125
- * 'Name <email@example.com>'
126
- */
127
- cc?: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
128
- /**
129
- * The DKIM settings for the email.
130
- */
131
- dkim?: {
132
- /**
133
- * Domain used for DKIM signing.
134
- */
135
- domain: string;
136
- /**
137
- * DKIM private key encoded in Base64.
138
- */
139
- privateKey?: string;
140
- /**
141
- * DKIM selector in the domain DNS records.
142
- */
143
- selector: string;
144
- };
145
- /**
146
- * Optional envelope sender address. If not set, the envelope sender defaults to the `from.email` field. Can be overridden per-personalization. Only the email portion is used; the name field is ignored.
147
- * @example
148
- * { email: 'email@example.com', name: 'Example' }
149
- * @example
150
- * 'email@example.com'
151
- * @example
152
- * 'Name <email@example.com>'
153
- */
154
- envelopeFrom?: EmailsSendRecipient | string;
155
- /**
156
- * The sender of the email. Can be a string or an object with email and name properties.
157
- * @example
158
- * { email: 'email@example.com', name: 'Example' }
159
- * @example
160
- * 'email@example.com'
161
- * @example
162
- * 'Name <email@example.com>'
163
- */
164
- from: EmailsSendRecipient | string;
165
- /**
166
- * An object containing key-value pairs, where both keys (header names) and values must be strings. These pairs represent custom headers to be substituted.
167
- *
168
- * Please note the following restrictions and behavior:
169
- * - **Reserved headers**: The following headers cannot be modified: `Authentication-Results`, `BCC`, `CC`, `Content-Transfer-Encoding`, `Content-Type`, `DKIM-Signature`, `From`, `Message-ID`, `Received`, `Reply-To`, `Subject`, `To`.
170
- * - **Header precedence**: If a header is defined in both the personalizations object and the root headers, the value from personalizations will be used.
171
- * - **Case sensitivity**: Headers are treated as case-insensitive. If multiple headers differ only by case, only one will be used, with no guarantee of which one.
172
- */
173
- headers?: Record<string, string>;
174
- /**
175
- * The recipient of the email. Can be an array of email addresses or an array of objects with `email` and `name` properties or a single email address string or an object with `email` and `name` properties.
176
- * @example
177
- * [
178
- * { email: 'email1@example.com', name: 'Example1' },
179
- * { email: 'email2@example.com', name: 'Example2' },
180
- * ]
181
- * @example
182
- * { email: 'email@example.com', name: 'Example' }
183
- * @example
184
- * ['email1@example.com', 'email2@example.com']
185
- * @example
186
- * 'email@example.com'
187
- * @example
188
- * 'Name <email@example.com>'
189
- */
190
- to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
191
- /**
192
- * Adjust open and click tracking for the message. Please note that enabling tracking for your messages requires a subscription that supports open and click tracking.
193
- *
194
- * Only links (`<a>` tags) meeting all of the following conditions are processed for click tracking:
195
- * - The URL is non-empty.
196
- * - The URL starts with `http` or `https`.
197
- * - The link does not have a `clicktracking` attribute set to `off`.
198
- */
199
- tracking?: EmailsSendTracking;
200
- /**
201
- * A single `replyTo` recipient object, or a single email address.
202
- * @example
203
- * { email: 'email@example.com', name: 'Example' }
204
- * @example
205
- * 'email@example.com'
206
- * @example
207
- * 'Name <email@example.com>'
208
- */
209
- replyTo?: EmailsSendRecipient | string;
210
- /**
211
- * The subject of the email.
136
+ * Domain used for DKIM signing.
212
137
  */
213
- subject: string;
138
+ domain: string;
214
139
  /**
215
- * Data to be used if the email is a mustache template, key-value pairs of variables to set for template rendering. Keys must be strings.
216
- *
217
- * the values can be one of the following types:
218
- * - string
219
- * - number
220
- * - boolean
221
- * - list, whose values are all of permitted types
222
- * - map, whose keys must be strings, and whose values are all of permitted types
140
+ * DKIM private key encoded in Base64.
223
141
  */
224
- mustaches?: Record<string, unknown>;
142
+ privateKey?: string;
225
143
  /**
226
- * Mark these messages as transactional or non-transactional. In order for a message to be marked as non-transactional, it must have exactly one recipient per personalization, and it must be DKIM signed. 400 Bad Request will be returned if there are more than one recipient in any personalization for non-transactional messages. If a message is marked as non-transactional, it changes the sending process as follows:
227
- *
228
- * List-Unsubscribe headers will be added.
229
- * @default true
144
+ * DKIM selector in the domain DNS records.
230
145
  */
231
- transactional?: boolean;
146
+ selector: string;
147
+ };
148
+ /**
149
+ * Optional envelope sender address. If not set, the envelope sender defaults to the `from.email` field. Can be overridden per-personalization. Only the email portion is used; the name field is ignored.
150
+ * @example
151
+ * { email: 'email@example.com', name: 'Example' }
152
+ * @example
153
+ * 'email@example.com'
154
+ * @example
155
+ * 'Name <email@example.com>'
156
+ */
157
+ envelopeFrom?: EmailsSendRecipient | string;
158
+ /**
159
+ * The sender of the email. Can be a string or an object with email and name properties.
160
+ * @example
161
+ * { email: 'email@example.com', name: 'Example' }
162
+ * @example
163
+ * 'email@example.com'
164
+ * @example
165
+ * 'Name <email@example.com>'
166
+ */
167
+ from: EmailsSendRecipient | string;
168
+ /**
169
+ * An object containing key-value pairs, where both keys (header names) and values must be strings. These pairs represent custom headers to be substituted.
170
+ *
171
+ * Please note the following restrictions and behavior:
172
+ * - **Reserved headers**: The following headers cannot be modified: `Authentication-Results`, `BCC`, `CC`, `Content-Transfer-Encoding`, `Content-Type`, `DKIM-Signature`, `From`, `Message-ID`, `Received`, `Reply-To`, `Subject`, `To`.
173
+ * - **Header precedence**: If a header is defined in both the personalizations object and the root headers, the value from personalizations will be used.
174
+ * - **Case sensitivity**: Headers are treated as case-insensitive. If multiple headers differ only by case, only one will be used, with no guarantee of which one.
175
+ */
176
+ headers?: Record<string, string>;
177
+ /**
178
+ * The recipient of the email. Can be an array of email addresses or an array of objects with `email` and `name` properties or a single email address string or an object with `email` and `name` properties.
179
+ * @example
180
+ * [
181
+ * { email: 'email1@example.com', name: 'Example1' },
182
+ * { email: 'email2@example.com', name: 'Example2' },
183
+ * ]
184
+ * @example
185
+ * { email: 'email@example.com', name: 'Example' }
186
+ * @example
187
+ * ['email1@example.com', 'email2@example.com']
188
+ * @example
189
+ * 'email@example.com'
190
+ * @example
191
+ * 'Name <email@example.com>'
192
+ */
193
+ to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
194
+ /**
195
+ * Adjust open and click tracking for the message. Please note that enabling tracking for your messages requires a subscription that supports open and click tracking.
196
+ *
197
+ * Only links (`<a>` tags) meeting all of the following conditions are processed for click tracking:
198
+ * - The URL is non-empty.
199
+ * - The URL starts with `http` or `https`.
200
+ * - The link does not have a `clicktracking` attribute set to `off`.
201
+ */
202
+ tracking?: EmailsSendTracking;
203
+ /**
204
+ * A single `replyTo` recipient object, or a single email address.
205
+ * @example
206
+ * { email: 'email@example.com', name: 'Example' }
207
+ * @example
208
+ * 'email@example.com'
209
+ * @example
210
+ * 'Name <email@example.com>'
211
+ */
212
+ replyTo?: EmailsSendRecipient | string;
213
+ /**
214
+ * The subject of the email.
215
+ */
216
+ subject: string;
217
+ /**
218
+ * Data to be used if the email is a mustache template, key-value pairs of variables to set for template rendering. Keys must be strings.
219
+ *
220
+ * the values can be one of the following types:
221
+ * - string
222
+ * - number
223
+ * - boolean
224
+ * - list, whose values are all of permitted types
225
+ * - map, whose keys must be strings, and whose values are all of permitted types
226
+ */
227
+ mustaches?: Record<string, unknown>;
228
+ /**
229
+ * Mark these messages as transactional or non-transactional. In order for a message to be marked as non-transactional, it must have exactly one recipient per personalization, and it must be DKIM signed. 400 Bad Request will be returned if there are more than one recipient in any personalization for non-transactional messages. If a message is marked as non-transactional, it changes the sending process as follows:
230
+ *
231
+ * List-Unsubscribe headers will be added.
232
+ * @default true
233
+ */
234
+ transactional?: boolean;
232
235
  }
233
236
  type EmailsSendOptions = EmailsSendOptionsBase & ({
234
- /**
235
- * The HTML content of the email.
236
- * @example
237
- * '<p>Hello World</p>'
238
- */
239
- html: string;
240
- /**
241
- * The plain text content of the email (optional when html is provided).
242
- * @example
243
- * 'Hello World'
244
- */
245
- text?: string;
237
+ /**
238
+ * The HTML content of the email.
239
+ * @example
240
+ * '<p>Hello World</p>'
241
+ */
242
+ html: string;
243
+ /**
244
+ * The plain text content of the email (optional when html is provided).
245
+ * @example
246
+ * 'Hello World'
247
+ */
248
+ text?: string;
246
249
  } | {
247
- /**
248
- * The HTML content of the email (optional when text is provided).
249
- * @example
250
- * '<p>Hello World</p>'
251
- */
252
- html?: string;
253
- /**
254
- * The plain text content of the email.
255
- * @example
256
- * 'Hello World'
257
- */
258
- text: string;
250
+ /**
251
+ * The HTML content of the email (optional when text is provided).
252
+ * @example
253
+ * '<p>Hello World</p>'
254
+ */
255
+ html?: string;
256
+ /**
257
+ * The plain text content of the email.
258
+ * @example
259
+ * 'Hello World'
260
+ */
261
+ text: string;
259
262
  });
260
263
  type EmailsSendResponse = SuccessResponse & DataResponse<{
264
+ /**
265
+ * Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
266
+ */
267
+ rendered?: string[];
268
+ /**
269
+ * The Request ID is a unique identifier generated by the service to track the HTTP request. It will also be included in all webhooks for reference.
270
+ */
271
+ requestId?: string;
272
+ results?: {
261
273
  /**
262
- * Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
274
+ * The index of the personalization in the request. Starts at 0.
263
275
  */
264
- rendered?: string[];
276
+ index?: number;
265
277
  /**
266
- * The Request ID is a unique identifier generated by the service to track the HTTP request. It will also be included in all webhooks for reference.
278
+ * The Message ID is a unique identifier generated by the service. Each personalization has a distinct Message ID, which is also used in the `Message-Id` header and included in webhooks.
267
279
  */
268
- requestId?: string;
269
- results?: {
270
- /**
271
- * The index of the personalization in the request. Starts at 0.
272
- */
273
- index?: number;
274
- /**
275
- * The Message ID is a unique identifier generated by the service. Each personalization has a distinct Message ID, which is also used in the `Message-Id` header and included in webhooks.
276
- */
277
- messageId: string;
278
- /**
279
- * A human-readable explanation of the status.
280
- */
281
- reason?: string;
282
- /**
283
- * The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
284
- */
285
- status: "sent" | "failed";
286
- }[];
287
- }>;
288
-
289
- type EmailsSendAsyncResponse = DataResponse<{
280
+ messageId: string;
290
281
  /**
291
- * ISO 8601 timestamp when the request was queued for processing.
282
+ * A human-readable explanation of the status.
292
283
  */
293
- queuedAt: string;
284
+ reason?: string;
294
285
  /**
295
- * Unique identifier for tracking this async request. Will be included in all webhook events for this request.
286
+ * The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
296
287
  */
297
- requestId: string;
288
+ status: "sent" | "failed";
289
+ }[];
298
290
  }>;
299
-
291
+ //#endregion
292
+ //#region src/types/emails/send-async.d.ts
293
+ type EmailsSendAsyncResponse = DataResponse<{
294
+ /**
295
+ * ISO 8601 timestamp when the request was queued for processing.
296
+ */
297
+ queuedAt: string;
298
+ /**
299
+ * Unique identifier for tracking this async request. Will be included in all webhook events for this request.
300
+ */
301
+ requestId: string;
302
+ }>;
303
+ //#endregion
304
+ //#region src/types/emails/create-dkim-key.d.ts
300
305
  interface EmailsCreateDkimKeyOptions {
301
- /**
302
- * Algorithm used for the new key pair Currently, only RSA is supported.
303
- * @default "rsa"
304
- */
305
- algorithm?: "rsa";
306
- /**
307
- * Key length in bits. For RSA, must be a multiple of 1024. Common values: 1024 or 2048.
308
- * @default 2048
309
- */
310
- length?: 1024 | 2048 | 3072 | 4096;
311
- /**
312
- * Selector for the new key pair. Must be a maximum of 63 characters.
313
- */
314
- selector: string;
306
+ /**
307
+ * Algorithm used for the new key pair Currently, only RSA is supported.
308
+ * @default "rsa"
309
+ */
310
+ algorithm?: "rsa";
311
+ /**
312
+ * Key length in bits. For RSA, must be a multiple of 1024. Common values: 1024 or 2048.
313
+ * @default 2048
314
+ */
315
+ length?: 1024 | 2048 | 3072 | 4096;
316
+ /**
317
+ * Selector for the new key pair. Must be a maximum of 63 characters.
318
+ */
319
+ selector: string;
315
320
  }
316
321
  type EmailsDkimKeyStatus = "active" | "retired" | "revoked" | "rotated";
317
322
  interface EmailsDkimKey {
318
- /**
319
- * Algorithm used for the key pair.
320
- */
321
- algorithm: string;
322
- /**
323
- * Timestamp when the key pair was created.
324
- */
325
- createdAt?: string;
326
- /**
327
- * Suggested DNS records for the DKIM key.
328
- */
329
- dnsRecords: {
330
- name: string;
331
- type: string;
332
- value: string;
333
- }[];
334
- /**
335
- * Domain associated with the key pair.
336
- */
337
- domain: string;
338
- /**
339
- * UTC timestamp after which you can no longer use the rotated key for signing.
340
- */
341
- gracePeriodExpiresAt?: string;
342
- /**
343
- * Key length in bits.
344
- */
345
- length: 1024 | 2048 | 3072 | 4096;
346
- publicKey: string;
347
- /**
348
- * UTC timestamp when a rotated key pair is retired.
349
- */
350
- retiresAt?: string;
351
- /**
352
- * Selector assigned to the key pair.
353
- */
354
- selector: string;
355
- /**
356
- * Status of the key.
357
- */
358
- status: EmailsDkimKeyStatus;
359
- /**
360
- * Timestamp when the key was last modified.
361
- */
362
- statusModifiedAt?: string;
323
+ /**
324
+ * Algorithm used for the key pair.
325
+ */
326
+ algorithm: string;
327
+ /**
328
+ * Timestamp when the key pair was created.
329
+ */
330
+ createdAt?: string;
331
+ /**
332
+ * Suggested DNS records for the DKIM key.
333
+ */
334
+ dnsRecords: {
335
+ name: string;
336
+ type: string;
337
+ value: string;
338
+ }[];
339
+ /**
340
+ * Domain associated with the key pair.
341
+ */
342
+ domain: string;
343
+ /**
344
+ * UTC timestamp after which you can no longer use the rotated key for signing.
345
+ */
346
+ gracePeriodExpiresAt?: string;
347
+ /**
348
+ * Key length in bits.
349
+ */
350
+ length: 1024 | 2048 | 3072 | 4096;
351
+ publicKey: string;
352
+ /**
353
+ * UTC timestamp when a rotated key pair is retired.
354
+ */
355
+ retiresAt?: string;
356
+ /**
357
+ * Selector assigned to the key pair.
358
+ */
359
+ selector: string;
360
+ /**
361
+ * Status of the key.
362
+ */
363
+ status: EmailsDkimKeyStatus;
364
+ /**
365
+ * Timestamp when the key was last modified.
366
+ */
367
+ statusModifiedAt?: string;
363
368
  }
364
369
  type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
365
-
370
+ //#endregion
371
+ //#region src/types/emails/check-domain.d.ts
366
372
  interface EmailsCheckDomainDkim {
367
- /**
368
- * Domain used for DKIM signing.
369
- */
370
- domain?: string;
371
- /**
372
- * DKIM private key encoded in Base64.
373
- */
374
- privateKey?: string;
375
- /**
376
- * DKIM selector in the domain DNS records.
377
- */
378
- selector?: string;
373
+ /**
374
+ * Domain used for DKIM signing.
375
+ */
376
+ domain?: string;
377
+ /**
378
+ * DKIM private key encoded in Base64.
379
+ */
380
+ privateKey?: string;
381
+ /**
382
+ * DKIM selector in the domain DNS records.
383
+ */
384
+ selector?: string;
379
385
  }
380
386
  interface EmailsCheckDomainOptions {
381
- /**
382
- * Each item may include DKIM `domain`, `selector` and `privateKey`. Up to 10 items are allowed. The absence or presence of these fields affects how DKIM settings are validated:
383
- * 1. If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key.
384
- * 2. If `domain` and `selector` are present, use the stored private key for the given domain and selector.
385
- * 3. If only `domain` is present, use all stored keys for the given domain.
386
- * 4. If none are present, use all stored keys for the `domain` provided in the domain field of the request.
387
- * 5. If `privateKey` is present, `selector` must be present.
388
- * 6. If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request.
389
- */
390
- dkim?: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
391
- /**
392
- * Domain used for sending emails. If `dkim` settings are not provided, or `dkim` settings are provided with no `domain`, the stored dkim settings for this domain will be used.
393
- */
394
- domain: string;
395
- /**
396
- * Used exclusively for [Domain Lockdown](https://support.mailchannels.com/hc/en-us/articles/16918954360845-Secure-your-domain-name-against-spoofing-with-Domain-Lockdown) verification. If you're not using senderid to associate your domain with your account, you can disregard this field. The corresponding value is included in the `X-MailChannels-SenderId` header of emails sent via MailChannels.
397
- */
398
- senderId?: string;
387
+ /**
388
+ * Each item may include DKIM `domain`, `selector` and `privateKey`. Up to 10 items are allowed. The absence or presence of these fields affects how DKIM settings are validated:
389
+ * 1. If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key.
390
+ * 2. If `domain` and `selector` are present, use the stored private key for the given domain and selector.
391
+ * 3. If only `domain` is present, use all stored keys for the given domain.
392
+ * 4. If none are present, use all stored keys for the `domain` provided in the domain field of the request.
393
+ * 5. If `privateKey` is present, `selector` must be present.
394
+ * 6. If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request.
395
+ */
396
+ dkim?: EmailsCheckDomainDkim[] | EmailsCheckDomainDkim;
397
+ /**
398
+ * Domain used for sending emails. If `dkim` settings are not provided, or `dkim` settings are provided with no `domain`, the stored dkim settings for this domain will be used.
399
+ */
400
+ domain: string;
401
+ /**
402
+ * Used exclusively for [Domain Lockdown](https://support.mailchannels.com/hc/en-us/articles/16918954360845-Secure-your-domain-name-against-spoofing-with-Domain-Lockdown) verification. If you're not using senderid to associate your domain with your account, you can disregard this field. The corresponding value is included in the `X-MailChannels-SenderId` header of emails sent via MailChannels.
403
+ */
404
+ senderId?: string;
399
405
  }
400
406
  type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
401
407
  type EmailsCheckDomainResponse = DataResponse<{
402
- dkim: {
403
- domain: string;
404
- /**
405
- * The human readable status of the DKIM key used for verification.
406
- */
407
- keyStatus?: EmailsDkimKey["status"] | "provided";
408
- selector: string;
409
- /**
410
- * A human-readable explanation of DKIM check.
411
- */
412
- reason?: string;
413
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
414
- }[];
415
- domainLockdown: {
416
- /**
417
- * A human-readable explanation of Domain Lockdown check.
418
- */
419
- reason?: string;
420
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
421
- };
408
+ dkim: {
409
+ domain: string;
422
410
  /**
423
- * These results are here to help avoid [SDNF](https://support.mailchannels.com/hc/en-us/articles/203155500-550-5-2-1-SDNF-Sender-Domain-Not-Found) (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain.
411
+ * The human readable status of the DKIM key used for verification.
424
412
  */
425
- senderDomain: {
426
- a: {
427
- /**
428
- * A human-readable explanation of A record check.
429
- */
430
- reason?: string;
431
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
432
- };
433
- mx: {
434
- /**
435
- * A human-readable explanation of MX record check.
436
- */
437
- reason?: string;
438
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
439
- };
440
- /**
441
- * Overall verdict. Passed if either A or MX record check passed.
442
- */
443
- verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
413
+ keyStatus?: EmailsDkimKey["status"] | "provided";
414
+ selector: string;
415
+ /**
416
+ * A human-readable explanation of DKIM check.
417
+ */
418
+ reason?: string;
419
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
420
+ }[];
421
+ domainLockdown: {
422
+ /**
423
+ * A human-readable explanation of Domain Lockdown check.
424
+ */
425
+ reason?: string;
426
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
427
+ };
428
+ /**
429
+ * These results are here to help avoid [SDNF](https://support.mailchannels.com/hc/en-us/articles/203155500-550-5-2-1-SDNF-Sender-Domain-Not-Found) (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain.
430
+ */
431
+ senderDomain: {
432
+ a: {
433
+ /**
434
+ * A human-readable explanation of A record check.
435
+ */
436
+ reason?: string;
437
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
444
438
  };
445
- spf: {
446
- /**
447
- * A human-readable explanation of SPF check.
448
- */
449
- reason?: string;
450
- verdict: EmailsCheckDomainVerdict;
439
+ mx: {
440
+ /**
441
+ * A human-readable explanation of MX record check.
442
+ */
443
+ reason?: string;
444
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
451
445
  };
452
- references?: string[];
453
- }>;
454
-
455
- interface EmailsGetDkimKeysOptions {
456
446
  /**
457
- * Selector to filter keys by. Must be a maximum of 63 characters.
447
+ * Overall verdict. Passed if either A or MX record check passed.
458
448
  */
459
- selector?: string;
449
+ verdict: Extract<EmailsCheckDomainVerdict, "passed" | "failed">;
450
+ };
451
+ spf: {
460
452
  /**
461
- * Status to filter keys by.
453
+ * A human-readable explanation of SPF check.
462
454
  */
463
- status?: EmailsDkimKey["status"];
464
- /**
465
- * Number of keys to skip before returning results.
466
- * @default 0
467
- */
468
- offset?: number;
469
- /**
470
- * Maximum number of keys to return. Maximum is `100` and minimum is `1`.
471
- * @default 10
472
- */
473
- limit?: number;
474
- /**
475
- * If `true`, includes the suggested DKIM DNS record for each returned key.
476
- * @default false
477
- */
478
- includeDnsRecord?: boolean;
455
+ reason?: string;
456
+ verdict: EmailsCheckDomainVerdict;
457
+ };
458
+ references?: string[];
459
+ }>;
460
+ //#endregion
461
+ //#region src/types/emails/get-dkim-keys.d.ts
462
+ interface EmailsGetDkimKeysOptions {
463
+ /**
464
+ * Selector to filter keys by. Must be a maximum of 63 characters.
465
+ */
466
+ selector?: string;
467
+ /**
468
+ * Status to filter keys by.
469
+ */
470
+ status?: EmailsDkimKey["status"];
471
+ /**
472
+ * Number of keys to skip before returning results.
473
+ * @default 0
474
+ */
475
+ offset?: number;
476
+ /**
477
+ * Maximum number of keys to return. Maximum is `100` and minimum is `1`.
478
+ * @default 10
479
+ */
480
+ limit?: number;
481
+ /**
482
+ * If `true`, includes the suggested DKIM DNS record for each returned key.
483
+ * @default false
484
+ */
485
+ includeDnsRecord?: boolean;
479
486
  }
480
487
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
481
488
  type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
482
-
489
+ //#endregion
490
+ //#region src/types/emails/update-dkim-key.d.ts
483
491
  interface EmailsUpdateDkimKeyOptions {
492
+ /**
493
+ * Selector of the DKIM key pair to update. Must be a maximum of 63 characters.
494
+ */
495
+ selector: string;
496
+ /**
497
+ * New status of the DKIM key pair.
498
+ * - `revoked`: Indicates that the key is compromised and should not be used.
499
+ * - `retired`: Indicates that the key has been rotated and is no longer in use.
500
+ * - `rotated`: Indicates that the key is going through the rotation process. Only active key pairs can be updated to this status, and no new key pair is created. The rotated key can be used to sign emails for 3 days after the status update, and will automatically change to `retired` 2 weeks after update. For a smooth key transition, it is recommended to create and publish a new key pair before signing is disabled for the rotated key.
501
+ */
502
+ status: Exclude<EmailsDkimKey["status"], "active">;
503
+ }
504
+ //#endregion
505
+ //#region src/types/emails/rotate-dkim-key.d.ts
506
+ interface EmailsRotateDkimKeyOptions {
507
+ newKey: {
484
508
  /**
485
- * Selector of the DKIM key pair to update. Must be a maximum of 63 characters.
509
+ * Selector for the new key pair. Must be a maximum of 63 characters.
486
510
  */
487
511
  selector: string;
488
- /**
489
- * New status of the DKIM key pair.
490
- * - `revoked`: Indicates that the key is compromised and should not be used.
491
- * - `retired`: Indicates that the key has been rotated and is no longer in use.
492
- * - `rotated`: Indicates that the key is going through the rotation process. Only active key pairs can be updated to this status, and no new key pair is created. The rotated key can be used to sign emails for 3 days after the status update, and will automatically change to `retired` 2 weeks after update. For a smooth key transition, it is recommended to create and publish a new key pair before signing is disabled for the rotated key.
493
- */
494
- status: Exclude<EmailsDkimKey["status"], "active">;
495
- }
496
-
497
- interface EmailsRotateDkimKeyOptions {
498
- newKey: {
499
- /**
500
- * Selector for the new key pair. Must be a maximum of 63 characters.
501
- */
502
- selector: string;
503
- };
512
+ };
504
513
  }
505
514
  type EmailsRotateDkimKeyResponse = DataResponse<{
506
- new: EmailsDkimKey;
507
- rotated: EmailsDkimKey;
515
+ new: EmailsDkimKey;
516
+ rotated: EmailsDkimKey;
508
517
  }>;
509
-
518
+ //#endregion
519
+ //#region src/modules/emails.d.ts
510
520
  declare class Emails {
511
- protected mailchannels: MailChannelsClient;
512
- constructor(mailchannels: MailChannelsClient);
513
- private _sendEmail;
514
- /**
515
- * Sends an email message to one or more recipients.
516
- * @param options - The email options to send.
517
- * @param dryRun - When set to `true`, the message will not be sent. Instead, the fully rendered message will be returned in the `data` property of the response. The default value is `false`.
518
- * @example
519
- * ```ts
520
- * const mailchannels = new MailChannels('your-api-key')
521
- * const { success, data, error } = await mailchannels.emails.send({
522
- * to: 'to@example.com',
523
- * from: 'from@example.com',
524
- * subject: 'Test',
525
- * html: 'Test'
526
- * })
527
- * ```
528
- */
529
- send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
530
- /**
531
- * Queues an email message for asynchronous processing and returns immediately with a request ID.
532
- *
533
- * The email will be processed in the background, and you'll receive webhook events for all delivery status updates (e.g. `dropped`, `processed`, `delivered`, `hard-bounced`). These webhook events are identical to those sent for the synchronous /send endpoint.
534
- *
535
- * Use this endpoint when you need to send emails without waiting for processing to complete. This can improve your application's response time, especially when sending to multiple recipients.
536
- * @param options - The email options to send.
537
- * @example
538
- * ```ts
539
- * const mailchannels = new MailChannels('your-api-key')
540
- * const { data, error } = await mailchannels.emails.sendAsync({
541
- * to: 'to@example.com',
542
- * from: 'from@example.com',
543
- * subject: 'Test',
544
- * html: 'Test'
545
- * })
546
- * ```
547
- */
548
- sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
549
- /**
550
- * Validates a domain's email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This endpoint checks whether the domain is properly configured for secure email delivery.
551
- * @param options - The domain options to check.
552
- * @example
553
- * ```ts
554
- * const mailchannels = new MailChannels('your-api-key')
555
- * const { data, error } = await mailchannels.emails.checkDomain({
556
- * dkim: [{
557
- * domain: 'example.com',
558
- * privateKey: 'your-private-key',
559
- * selector: 'mailchannels'
560
- * }],
561
- * domain: 'example.com',
562
- * senderId: 'sender-id'
563
- * })
564
- * ```
565
- */
566
- checkDomain(options: EmailsCheckDomainOptions): Promise<EmailsCheckDomainResponse>;
567
- /**
568
- * Create a DKIM key pair for a specified domain and selector using the specified algorithm and key length, for the current customer.
569
- * @param domain - The domain to create the DKIM key for.
570
- * @param options - DKIM key creation options.
571
- * @example
572
- * ```ts
573
- * const mailchannels = new MailChannels('your-api-key')
574
- * const { data, error } = await mailchannels.emails.createDkimKey('example.com', {
575
- * selector: 'mailchannels'
576
- * })
577
- * ```
578
- */
579
- createDkimKey(domain: string, options: EmailsCreateDkimKeyOptions): Promise<EmailsCreateDkimKeyResponse>;
580
- /**
581
- * Search for DKIM keys by domain, with optional filters. If selector is provided, at most one key will be returned.
582
- * @param domain - The domain to search DKIM keys for.
583
- * @param options - The options to filter DKIM keys by.
584
- * @example
585
- * ```ts
586
- * const mailchannels = new MailChannels('your-api-key')
587
- * const { data, error } = await mailchannels.getDkimKeys('example.com', {
588
- * includeDnsRecord: true
589
- * })
590
- * ```
591
- */
592
- getDkimKeys(domain: string, options?: EmailsGetDkimKeysOptions): Promise<EmailsGetDkimKeysResponse>;
593
- /**
594
- * Update fields of an existing DKIM key pair for the specified domain and selector, for the current customer. Currently, only the `status` field can be updated.
595
- * @param domain - The domain the DKIM key belongs to.
596
- * @param options - The options to update the DKIM key.
597
- * @example
598
- * ```ts
599
- * const mailchannels = new MailChannels('your-api-key')
600
- * const { success, error } = await mailchannels.emails.updateDkimKey('example.com', {
601
- * selector: 'mailchannels',
602
- * status: 'retired'
603
- * })
604
- */
605
- updateDkimKey(domain: string, options: EmailsUpdateDkimKeyOptions): Promise<SuccessResponse>;
606
- /**
607
- * Rotate an active DKIM key pair. Mark the original key as `rotated`, and create a new key pair with the required new key selector, reusing the same algorithm and key length. The rotated key remains valid for signing for a 3-day grace period, and is automatically changed to `retired` 2 weeks after rotation. Publish the new key to its DNS TXT record before rotated key expires for signing as emails sent with an unpublished key will fail DKIM validation by receiving providers. After the grace period, only the new key is valid for signing if published.
608
- * @param domain - The domain the DKIM key belongs to.
609
- * @param selector - The selector of the DKIM key to rotate.
610
- * @param options - The options to rotate the DKIM key.
611
- * @param options.newKey.selector - The selector for the new key pair. Must be a maximum of 63 characters.
612
- * @example
613
- * ```ts
614
- * const mailchannels = new MailChannels('your-api-key')
615
- * const { data, error } = await mailchannels.emails.rotateDkimKey('example.com', 'mailchannels', {
616
- * newKey: {
617
- * selector: 'new-selector'
618
- * }
619
- * })
620
- * ```
621
- */
622
- rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
521
+ protected mailchannels: MailChannelsClient;
522
+ constructor(mailchannels: MailChannelsClient);
523
+ private _sendEmail;
524
+ /**
525
+ * Sends an email message to one or more recipients.
526
+ * @param options - The email options to send.
527
+ * @param dryRun - When set to `true`, the message will not be sent. Instead, the fully rendered message will be returned in the `data` property of the response. The default value is `false`.
528
+ * @example
529
+ * ```ts
530
+ * const mailchannels = new MailChannels('your-api-key')
531
+ * const { success, data, error } = await mailchannels.emails.send({
532
+ * to: 'to@example.com',
533
+ * from: 'from@example.com',
534
+ * subject: 'Test',
535
+ * html: 'Test'
536
+ * })
537
+ * ```
538
+ */
539
+ send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
540
+ /**
541
+ * Queues an email message for asynchronous processing and returns immediately with a request ID.
542
+ *
543
+ * The email will be processed in the background, and you'll receive webhook events for all delivery status updates (e.g. `dropped`, `processed`, `delivered`, `hard-bounced`). These webhook events are identical to those sent for the synchronous /send endpoint.
544
+ *
545
+ * Use this endpoint when you need to send emails without waiting for processing to complete. This can improve your application's response time, especially when sending to multiple recipients.
546
+ * @param options - The email options to send.
547
+ * @example
548
+ * ```ts
549
+ * const mailchannels = new MailChannels('your-api-key')
550
+ * const { data, error } = await mailchannels.emails.sendAsync({
551
+ * to: 'to@example.com',
552
+ * from: 'from@example.com',
553
+ * subject: 'Test',
554
+ * html: 'Test'
555
+ * })
556
+ * ```
557
+ */
558
+ sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
559
+ /**
560
+ * Validates a domain's email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This endpoint checks whether the domain is properly configured for secure email delivery.
561
+ * @param options - The domain options to check.
562
+ * @example
563
+ * ```ts
564
+ * const mailchannels = new MailChannels('your-api-key')
565
+ * const { data, error } = await mailchannels.emails.checkDomain({
566
+ * dkim: [{
567
+ * domain: 'example.com',
568
+ * privateKey: 'your-private-key',
569
+ * selector: 'mailchannels'
570
+ * }],
571
+ * domain: 'example.com',
572
+ * senderId: 'sender-id'
573
+ * })
574
+ * ```
575
+ */
576
+ checkDomain(options: EmailsCheckDomainOptions): Promise<EmailsCheckDomainResponse>;
577
+ /**
578
+ * Create a DKIM key pair for a specified domain and selector using the specified algorithm and key length, for the current customer.
579
+ * @param domain - The domain to create the DKIM key for.
580
+ * @param options - DKIM key creation options.
581
+ * @example
582
+ * ```ts
583
+ * const mailchannels = new MailChannels('your-api-key')
584
+ * const { data, error } = await mailchannels.emails.createDkimKey('example.com', {
585
+ * selector: 'mailchannels'
586
+ * })
587
+ * ```
588
+ */
589
+ createDkimKey(domain: string, options: EmailsCreateDkimKeyOptions): Promise<EmailsCreateDkimKeyResponse>;
590
+ /**
591
+ * Search for DKIM keys by domain, with optional filters. If selector is provided, at most one key will be returned.
592
+ * @param domain - The domain to search DKIM keys for.
593
+ * @param options - The options to filter DKIM keys by.
594
+ * @example
595
+ * ```ts
596
+ * const mailchannels = new MailChannels('your-api-key')
597
+ * const { data, error } = await mailchannels.getDkimKeys('example.com', {
598
+ * includeDnsRecord: true
599
+ * })
600
+ * ```
601
+ */
602
+ getDkimKeys(domain: string, options?: EmailsGetDkimKeysOptions): Promise<EmailsGetDkimKeysResponse>;
603
+ /**
604
+ * Update fields of an existing DKIM key pair for the specified domain and selector, for the current customer. Currently, only the `status` field can be updated.
605
+ * @param domain - The domain the DKIM key belongs to.
606
+ * @param options - The options to update the DKIM key.
607
+ * @example
608
+ * ```ts
609
+ * const mailchannels = new MailChannels('your-api-key')
610
+ * const { success, error } = await mailchannels.emails.updateDkimKey('example.com', {
611
+ * selector: 'mailchannels',
612
+ * status: 'retired'
613
+ * })
614
+ */
615
+ updateDkimKey(domain: string, options: EmailsUpdateDkimKeyOptions): Promise<SuccessResponse>;
616
+ /**
617
+ * Rotate an active DKIM key pair. Mark the original key as `rotated`, and create a new key pair with the required new key selector, reusing the same algorithm and key length. The rotated key remains valid for signing for a 3-day grace period, and is automatically changed to `retired` 2 weeks after rotation. Publish the new key to its DNS TXT record before rotated key expires for signing as emails sent with an unpublished key will fail DKIM validation by receiving providers. After the grace period, only the new key is valid for signing if published.
618
+ * @param domain - The domain the DKIM key belongs to.
619
+ * @param selector - The selector of the DKIM key to rotate.
620
+ * @param options - The options to rotate the DKIM key.
621
+ * @param options.newKey.selector - The selector for the new key pair. Must be a maximum of 63 characters.
622
+ * @example
623
+ * ```ts
624
+ * const mailchannels = new MailChannels('your-api-key')
625
+ * const { data, error } = await mailchannels.emails.rotateDkimKey('example.com', 'mailchannels', {
626
+ * newKey: {
627
+ * selector: 'new-selector'
628
+ * }
629
+ * })
630
+ * ```
631
+ */
632
+ rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
623
633
  }
624
-
634
+ //#endregion
635
+ //#region src/types/webhooks/list.d.ts
625
636
  type WebhooksListResponse = DataResponse<string[]>;
626
-
637
+ //#endregion
638
+ //#region src/types/webhooks/signing-key.d.ts
627
639
  type WebhooksSigningKeyResponse = DataResponse<{
628
- key: string;
640
+ /**
641
+ * The ID of the key.
642
+ */
643
+ id: string;
644
+ /**
645
+ * The public key used to verify webhook signatures.
646
+ */
647
+ key: string;
629
648
  }>;
630
-
649
+ //#endregion
650
+ //#region src/types/webhooks/validate.d.ts
631
651
  type WebhooksValidateResponse = DataResponse<{
632
- /**
633
- * Indicates whether all webhook validations passed.
634
- */
635
- allPassed: boolean;
636
- /**
637
- * Detailed results for each tested webhook, including whether it returned a 2xx status code, along with its response status code and body.
638
- */
639
- results: {
640
- /**
641
- * Indicates whether the webhook responded with a 2xx HTTP status code.
642
- */
643
- result: "passed" | "failed";
644
- /**
645
- * The webhook that was validated.
646
- */
647
- webhook: string;
648
- /**
649
- * The HTTP response returned by the webhook, including status code and response body. A null value indicates no response was received. Possible reasons include timeouts, connection failures, or other network-related issues.
650
- */
651
- response: {
652
- /**
653
- * Response body from webhook. Returns an error if unprocessable or too large.
654
- */
655
- body?: string;
656
- /**
657
- * HTTP status code returned by the webhook.
658
- */
659
- status: number;
660
- } | null;
661
- }[];
652
+ /**
653
+ * Indicates whether all webhook validations passed.
654
+ */
655
+ allPassed: boolean;
656
+ /**
657
+ * Detailed results for each tested webhook, including whether it returned a 2xx status code, along with its response status code and body.
658
+ */
659
+ results: {
660
+ /**
661
+ * Indicates whether the webhook responded with a 2xx HTTP status code.
662
+ */
663
+ result: "passed" | "failed";
664
+ /**
665
+ * The webhook that was validated.
666
+ */
667
+ webhook: string;
668
+ /**
669
+ * The HTTP response returned by the webhook, including status code and response body. A null value indicates no response was received. Possible reasons include timeouts, connection failures, or other network-related issues.
670
+ */
671
+ response: {
672
+ /**
673
+ * Response body from webhook. Returns an error if unprocessable or too large.
674
+ */
675
+ body?: string;
676
+ /**
677
+ * HTTP status code returned by the webhook.
678
+ */
679
+ status: number;
680
+ } | null;
681
+ }[];
662
682
  }>;
663
-
683
+ //#endregion
684
+ //#region src/types/webhooks/verify.d.ts
685
+ interface WebhooksVerifyOptions {
686
+ /**
687
+ * The raw body of the incoming webhook request as a string. This should be the exact payload received from the webhook, without any modifications or parsing, to ensure accurate signature verification.
688
+ */
689
+ payload: string;
690
+ /**
691
+ * The headers of the incoming webhook request as a record of key-value pairs. These headers should include `content-digest`, `signature`, and `signature-input` required for validating the authenticity of the webhook request.
692
+ */
693
+ headers: Record<string, string> | {
694
+ "content-digest": string;
695
+ "signature": string;
696
+ "signature-input": string;
697
+ };
698
+ /**
699
+ * The public key used to verify the webhook signature. If not provided, the SDK will attempt to retrieve the appropriate public key based on the `keyId` specified in the `signature-input` header.
700
+ */
701
+ publicKey?: string;
702
+ }
703
+ //#endregion
704
+ //#region src/modules/webhooks.d.ts
664
705
  declare class Webhooks {
665
- protected mailchannels: MailChannelsClient;
666
- constructor(mailchannels: MailChannelsClient);
667
- /**
668
- * Enrolls the customer to receive event notifications via webhooks.
669
- * @param endpoint - The URL to receive event notifications. Must be no longer than `8000` characters.
670
- * @example
671
- * ```ts
672
- * const mailchannels = new MailChannels('your-api-key')
673
- * const { success, error } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
674
- * ```
675
- */
676
- enroll(endpoint: string): Promise<SuccessResponse>;
677
- /**
678
- * Retrieves all registered webhook endpoints associated with the customer.
679
- * @example
680
- * ```ts
681
- * const mailchannels = new MailChannels('your-api-key')
682
- * const { data, error } = await mailchannels.webhooks.list()
683
- * ```
684
- */
685
- list(): Promise<WebhooksListResponse>;
686
- /**
687
- * Deletes all registered webhook endpoints for the customer.
688
- * @example
689
- * ```ts
690
- * const mailchannels = new MailChannels('your-api-key')
691
- * const { success, error } = await mailchannels.webhooks.delete()
692
- * ```
693
- */
694
- delete(): Promise<SuccessResponse>;
695
- /**
696
- * Retrieves the public key used to verify signatures on incoming webhook payloads.
697
- * @param id - The ID of the key.
698
- * @example
699
- * ```ts
700
- * const mailchannels = new MailChannels('your-api-key')
701
- * const { data, error } = await mailchannels.webhooks.getSigningKey('key-id')
702
- * ```
703
- */
704
- getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
705
- /**
706
- * Validates whether your enrolled webhook(s) respond with an HTTP `2xx` status code. Sends a test request to each webhook containing your customer handle, a hardcoded event type (`test`), a hardcoded sender email (`test@mailchannels.com`), a timestamp, a request ID (provided or generated), and an SMTP ID. The response includes the HTTP status code and body returned by each webhook.
707
- * @param requestId - Optional identifier in the webhook payload. If not provided, a value will be automatically generated. Must not exceed 28 characters.
708
- * @example
709
- * ```ts
710
- * const mailchannels = new MailChannels('your-api-key')
711
- * const { data, error } = await mailchannels.webhooks.validate('optional-request-id')
712
- * ```
713
- */
714
- validate(requestId?: string): Promise<WebhooksValidateResponse>;
706
+ protected mailchannels: MailChannelsClient;
707
+ constructor(mailchannels: MailChannelsClient);
708
+ /**
709
+ * Enrolls the customer to receive event notifications via webhooks.
710
+ * @param endpoint - The URL to receive event notifications. Must be no longer than `8000` characters.
711
+ * @example
712
+ * ```ts
713
+ * const mailchannels = new MailChannels('your-api-key')
714
+ * const { success, error } = mailchannels.webhooks.enroll('https://example.com/api/webhooks/mailchannels')
715
+ * ```
716
+ */
717
+ enroll(endpoint: string): Promise<SuccessResponse>;
718
+ /**
719
+ * Retrieves all registered webhook endpoints associated with the customer.
720
+ * @example
721
+ * ```ts
722
+ * const mailchannels = new MailChannels('your-api-key')
723
+ * const { data, error } = await mailchannels.webhooks.list()
724
+ * ```
725
+ */
726
+ list(): Promise<WebhooksListResponse>;
727
+ /**
728
+ * Deletes all registered webhook endpoints for the customer.
729
+ * @example
730
+ * ```ts
731
+ * const mailchannels = new MailChannels('your-api-key')
732
+ * const { success, error } = await mailchannels.webhooks.delete()
733
+ * ```
734
+ */
735
+ delete(): Promise<SuccessResponse>;
736
+ /**
737
+ * Retrieves the public key used to verify signatures on incoming webhook payloads.
738
+ * @param id - The ID of the key.
739
+ * @example
740
+ * ```ts
741
+ * const mailchannels = new MailChannels('your-api-key')
742
+ * const { data, error } = await mailchannels.webhooks.getSigningKey('key-id')
743
+ * ```
744
+ */
745
+ getSigningKey(id: string): Promise<WebhooksSigningKeyResponse>;
746
+ /**
747
+ * Validates whether your enrolled webhook(s) respond with an HTTP `2xx` status code. Sends a test request to each webhook containing your customer handle, a hardcoded event type (`test`), a hardcoded sender email (`test@mailchannels.com`), a timestamp, a request ID (provided or generated), and an SMTP ID. The response includes the HTTP status code and body returned by each webhook.
748
+ * @param requestId - Optional identifier in the webhook payload. If not provided, a value will be automatically generated. Must not exceed 28 characters.
749
+ * @example
750
+ * ```ts
751
+ * const mailchannels = new MailChannels('your-api-key')
752
+ * const { data, error } = await mailchannels.webhooks.validate('optional-request-id')
753
+ * ```
754
+ */
755
+ validate(requestId?: string): Promise<WebhooksValidateResponse>;
756
+ /**
757
+ * Verifies the authenticity of incoming webhook requests by validating their signatures using the provided options.
758
+ * @param options - The options for verifying the webhook.
759
+ * @example
760
+ * ```ts
761
+ * const isValid = await Webhooks.verify({ payload: rawBody, headers })
762
+ * ```
763
+ */
764
+ static verify(options: WebhooksVerifyOptions): Promise<boolean>;
765
+ /**
766
+ * Verifies the authenticity of incoming webhook requests by validating their signatures using the provided options.
767
+ * @param options - The options for verifying the webhook.
768
+ * @example
769
+ * ```ts
770
+ * const mailchannels = new MailChannels('your-api-key')
771
+ * const isValid = await mailchannels.webhooks.verify({ payload: rawBody, headers })
772
+ * ```
773
+ */
774
+ verify(options: WebhooksVerifyOptions): Promise<boolean>;
715
775
  }
716
-
776
+ //#endregion
777
+ //#region src/types/sub-accounts/create.d.ts
717
778
  interface SubAccountsAccount {
718
- /**
719
- * The name of the company associated with the sub-account.
720
- */
721
- companyName: string;
722
- /**
723
- * If the sub-account is enabled.
724
- */
725
- enabled: boolean;
726
- /**
727
- * The handle for the sub-account.
728
- */
729
- handle: string;
779
+ /**
780
+ * The name of the company associated with the sub-account.
781
+ */
782
+ companyName: string;
783
+ /**
784
+ * If the sub-account is enabled.
785
+ */
786
+ enabled: boolean;
787
+ /**
788
+ * The handle for the sub-account.
789
+ */
790
+ handle: string;
730
791
  }
731
792
  type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
732
-
793
+ //#endregion
794
+ //#region src/types/sub-accounts/list.d.ts
733
795
  interface SubAccountsListOptions {
734
- /**
735
- * Possible values are `1` to `1000`.
736
- * @default 1000
737
- */
738
- limit?: number;
739
- /**
740
- * The offset for pagination.
741
- * @default 0
742
- */
743
- offset?: number;
796
+ /**
797
+ * Possible values are `1` to `1000`.
798
+ * @default 1000
799
+ */
800
+ limit?: number;
801
+ /**
802
+ * The offset for pagination.
803
+ * @default 0
804
+ */
805
+ offset?: number;
744
806
  }
745
807
  type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
746
-
808
+ //#endregion
809
+ //#region src/types/sub-accounts/api-key.d.ts
747
810
  interface SubAccountsApiKey {
748
- /**
749
- * The API key ID for the sub-account.
750
- */
751
- id: number;
752
- /**
753
- * API key for the sub-account.
754
- */
755
- value: string;
811
+ /**
812
+ * The API key ID for the sub-account.
813
+ */
814
+ id: number;
815
+ /**
816
+ * API key for the sub-account.
817
+ */
818
+ value: string;
756
819
  }
757
820
  type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
758
821
  interface SubAccountsListApiKeyOptions {
759
- /**
760
- * The maximum number of API keys included in the response. Possible values are `1` to `1000`.
761
- * @default 100
762
- */
763
- limit?: number;
764
- /**
765
- * Offset into the list of API keys to return.
766
- * @default 0
767
- */
768
- offset?: number;
822
+ /**
823
+ * The maximum number of API keys included in the response. Possible values are `1` to `1000`.
824
+ * @default 100
825
+ */
826
+ limit?: number;
827
+ /**
828
+ * Offset into the list of API keys to return.
829
+ * @default 0
830
+ */
831
+ offset?: number;
769
832
  }
770
833
  type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
771
-
834
+ //#endregion
835
+ //#region src/types/sub-accounts/smtp-password.d.ts
772
836
  interface SubAccountsSmtpPassword {
773
- /**
774
- * Whether the SMTP password is enabled.
775
- */
776
- enabled: boolean;
777
- /**
778
- * The SMTP password ID for the sub-account.
779
- */
780
- id: number;
781
- /**
782
- * SMTP password for the sub-account.
783
- */
784
- value: string;
837
+ /**
838
+ * Whether the SMTP password is enabled.
839
+ */
840
+ enabled: boolean;
841
+ /**
842
+ * The SMTP password ID for the sub-account.
843
+ */
844
+ id: number;
845
+ /**
846
+ * SMTP password for the sub-account.
847
+ */
848
+ value: string;
785
849
  }
786
850
  type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
787
851
  type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
788
-
852
+ //#endregion
853
+ //#region src/types/sub-accounts/limit.d.ts
789
854
  interface SubAccountsLimit {
790
- sends: number;
855
+ sends: number;
791
856
  }
792
857
  type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
793
-
858
+ //#endregion
859
+ //#region src/types/sub-accounts/usage.d.ts
794
860
  interface SubAccountsUsage {
795
- /**
796
- * The end date of the current billing period (ISO 8601 format).
797
- * @example "2025-04-11"
798
- */
799
- endDate?: string;
800
- /**
801
- * The start date of the current billing period (ISO 8601 format).
802
- * @example "2025-03-12"
803
- */
804
- startDate?: string;
805
- /**
806
- * The total usage for the current billing period.
807
- */
808
- total: number;
861
+ /**
862
+ * The end date of the current billing period (ISO 8601 format).
863
+ * @example "2025-04-11"
864
+ */
865
+ endDate?: string;
866
+ /**
867
+ * The start date of the current billing period (ISO 8601 format).
868
+ * @example "2025-03-12"
869
+ */
870
+ startDate?: string;
871
+ /**
872
+ * The total usage for the current billing period.
873
+ */
874
+ total: number;
809
875
  }
810
876
  type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
811
-
877
+ //#endregion
878
+ //#region src/modules/sub-accounts.d.ts
812
879
  declare class SubAccounts {
813
- protected mailchannels: MailChannelsClient;
814
- private static readonly COMPANY_PATTERN;
815
- private static readonly HANDLE_PATTERN;
816
- constructor(mailchannels: MailChannelsClient);
817
- /**
818
- * Creates a new sub-account under the parent account. Each sub-account must have a unique handle composed solely of lowercase alphanumeric characters. If no handle is provided, a random handle will be generated. Note that Sub-accounts are only available to parent accounts on 100K and higher plans.
819
- * @param companyName - The name of the company associated with the sub-account. This name is used for display purposes only and does not affect the functionality of the sub-account. The length must be between 3 and 128 characters.
820
- * @param handle - A unique name for the sub-account to be created. The length must be between 3 and 128 characters, and it may contain only lowercase letters and numbers. If not provided, a random handle will be generated.
821
- * @example
822
- * ```ts
823
- * const mailchannels = new MailChannels('your-api-key')
824
- * const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
825
- * ```
826
- */
827
- create(companyName: string, handle?: string): Promise<SubAccountsCreateResponse>;
828
- /**
829
- * Retrieves all sub-accounts associated with the parent account. The response is paginated with a default limit of 1000 sub-accounts per page and an offset of 0.
830
- * @param options - The options to filter the list of sub-accounts.
831
- * @example
832
- * ```ts
833
- * const mailchannels = new MailChannels('your-api-key')
834
- * const { data, error } = await mailchannels.subAccounts.list()
835
- * ```
836
- */
837
- list(options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
838
- /**
839
- * Deletes the sub-account identified by its handle.
840
- * @param handle - Handle of sub-account to be deleted.
841
- * ```ts
842
- * const mailchannels = new MailChannels('your-api-key')
843
- * const { success, error } = await mailchannels.subAccounts.delete('validhandle123')
844
- * ```
845
- */
846
- delete(handle: string): Promise<SuccessResponse>;
847
- /**
848
- * Suspends the sub-account identified by its handle. This action disables the account, preventing it from sending any emails until it is reactivated.
849
- * @param handle - Handle of sub-account to be suspended.
850
- * @example
851
- * ```ts
852
- * const mailchannels = new MailChannels('your-api-key')
853
- * const { success, error } = await mailchannels.subAccounts.suspend('validhandle123')
854
- * ```
855
- */
856
- suspend(handle: string): Promise<SuccessResponse>;
857
- /**
858
- * Activates a suspended sub-account identified by its handle, restoring its ability to send emails.
859
- * @param handle - Handle of sub-account to be activated.
860
- * @example
861
- * ```ts
862
- * const mailchannels = new MailChannels('your-api-key')
863
- * const { success, error } = await mailchannels.subAccounts.activate('validhandle123')
864
- * ```
865
- */
866
- activate(handle: string): Promise<SuccessResponse>;
867
- /**
868
- * Creates a new API key for the specified sub-account.
869
- * @param handle - Handle of the sub-account to create API key for.
870
- * @example
871
- * ```ts
872
- * const mailchannels = new MailChannels('your-api-key')
873
- * const { data, error } = await mailchannels.subAccounts.createApiKey('validhandle123')
874
- * ```
875
- */
876
- createApiKey(handle: string): Promise<SubAccountsCreateApiKeyResponse>;
877
- /**
878
- * Retrieves details of all API keys associated with the specified sub-account. For security reasons, the full API key is not returned; only the key ID and a partially redacted version are provided.
879
- * @param handle - Handle of the sub-account to retrieve the API key for.
880
- * @param options - The options to filter the list of API keys.
881
- * @example
882
- * ```ts
883
- * const mailchannels = new MailChannels('your-api-key')
884
- * const { data, error } = await mailchannels.subAccounts.listApiKeys('validhandle123')
885
- * ```
886
- */
887
- listApiKeys(handle: string, options?: SubAccountsListApiKeyOptions): Promise<SubAccountsListApiKeyResponse>;
888
- /**
889
- * Deletes the API key identified by its ID for the specified sub-account.
890
- * @param handle - Handle of the sub-account for which the API key should be deleted.
891
- * @param id - The ID of the API key to delete.
892
- * @example
893
- * ```ts
894
- * const mailchannels = new MailChannels('your-api-key')
895
- * const { success, error } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
896
- * ```
897
- */
898
- deleteApiKey(handle: string, id: number): Promise<SuccessResponse>;
899
- /**
900
- * Creates a new SMTP password for the specified sub-account.
901
- * @param handle - Handle of the sub-account to create SMTP password for.
902
- * @example
903
- * ```ts
904
- * const mailchannels = new MailChannels('your-api-key')
905
- * const { data, error } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
906
- * ```
907
- */
908
- createSmtpPassword(handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
909
- /**
910
- * Retrieves details of all SMTP passwords associated with the specified sub-account. For security, the full SMTP password is not returned; only the password ID and a partially redacted version are provided.
911
- * @param handle - Handle of the sub-account to retrieve the SMTP password for.
912
- * @example
913
- * ```ts
914
- * const mailchannels = new MailChannels('your-api-key')
915
- * const { data, error } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
916
- * ```
917
- */
918
- listSmtpPasswords(handle: string): Promise<SubAccountsListSmtpPasswordResponse>;
919
- /**
920
- * Deletes the SMTP password identified by its ID for the specified sub-account.
921
- * @param handle - Handle of the sub-account for which the SMTP password should be deleted.
922
- * @param id - The ID of the SMTP password to delete.
923
- * @example
924
- * ```ts
925
- * const mailchannels = new MailChannels('your-api-key')
926
- * const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
927
- * ```
928
- */
929
- deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
930
- /**
931
- * Retrieves the limit of a specified sub-account. A value of `-1` indicates that the sub-account inherits the parent account's limit, allowing the sub-account to utilize any remaining capacity within the parent account's allocation.
932
- * @param handle - Handle of the sub-account to retrieve the limit for.
933
- * @example
934
- * ```ts
935
- * const mailchannels = new MailChannels('your-api-key')
936
- * const { data, error } = await mailchannels.subAccounts.getLimit('validhandle123')
937
- * ```
938
- */
939
- getLimit(handle: string): Promise<SubAccountsLimitResponse>;
940
- /**
941
- * Sets the limit for the specified sub-account.
942
- * @param handle - Handle of the sub-account to set limit for.
943
- * @param limit - The limits to set for the sub-account. The minimum allowed sends is `0`
944
- * @example
945
- * ```ts
946
- * const mailchannels = new MailChannels('your-api-key')
947
- * const { success, error } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
948
- * ```
949
- */
950
- setLimit(handle: string, limit: SubAccountsLimit): Promise<SuccessResponse>;
951
- /**
952
- * Deletes the limit for the specified sub-account. After a successful deletion, the specified sub-account will be limited to the parent account's limit.
953
- * @param handle - Handle of the sub-account to delete limit for.
954
- * @example
955
- * ```ts
956
- * const mailchannels = new MailChannels('your-api-key')
957
- * const { success, error } = await mailchannels.subAccounts.deleteLimit('validhandle123')
958
- * ```
959
- */
960
- deleteLimit(handle: string): Promise<SuccessResponse>;
961
- /**
962
- * Retrieves usage statistics for the specified sub-account during the current billing period.
963
- * @param handle - Handle of the sub-account to query usage stats for.
964
- * @example
965
- * ```ts
966
- * const mailchannels = new MailChannels('your-api-key')
967
- * const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123')
968
- * ```
969
- */
970
- getUsage(handle: string): Promise<SubAccountsUsageResponse>;
880
+ protected mailchannels: MailChannelsClient;
881
+ private static readonly COMPANY_PATTERN;
882
+ private static readonly HANDLE_PATTERN;
883
+ constructor(mailchannels: MailChannelsClient);
884
+ /**
885
+ * Creates a new sub-account under the parent account. Each sub-account must have a unique handle composed solely of lowercase alphanumeric characters. If no handle is provided, a random handle will be generated. Note that Sub-accounts are only available to parent accounts on 100K and higher plans.
886
+ * @param companyName - The name of the company associated with the sub-account. This name is used for display purposes only and does not affect the functionality of the sub-account. The length must be between 3 and 128 characters.
887
+ * @param handle - A unique name for the sub-account to be created. The length must be between 3 and 128 characters, and it may contain only lowercase letters and numbers. If not provided, a random handle will be generated.
888
+ * @example
889
+ * ```ts
890
+ * const mailchannels = new MailChannels('your-api-key')
891
+ * const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123')
892
+ * ```
893
+ */
894
+ create(companyName: string, handle?: string): Promise<SubAccountsCreateResponse>;
895
+ /**
896
+ * Retrieves all sub-accounts associated with the parent account. The response is paginated with a default limit of 1000 sub-accounts per page and an offset of 0.
897
+ * @param options - The options to filter the list of sub-accounts.
898
+ * @example
899
+ * ```ts
900
+ * const mailchannels = new MailChannels('your-api-key')
901
+ * const { data, error } = await mailchannels.subAccounts.list()
902
+ * ```
903
+ */
904
+ list(options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
905
+ /**
906
+ * Deletes the sub-account identified by its handle.
907
+ * @param handle - Handle of sub-account to be deleted.
908
+ * @example
909
+ * ```ts
910
+ * const mailchannels = new MailChannels('your-api-key')
911
+ * const { success, error } = await mailchannels.subAccounts.delete('validhandle123')
912
+ * ```
913
+ */
914
+ delete(handle: string): Promise<SuccessResponse>;
915
+ /**
916
+ * Suspends the sub-account identified by its handle. This action disables the account, preventing it from sending any emails until it is reactivated.
917
+ * @param handle - Handle of sub-account to be suspended.
918
+ * @example
919
+ * ```ts
920
+ * const mailchannels = new MailChannels('your-api-key')
921
+ * const { success, error } = await mailchannels.subAccounts.suspend('validhandle123')
922
+ * ```
923
+ */
924
+ suspend(handle: string): Promise<SuccessResponse>;
925
+ /**
926
+ * Activates a suspended sub-account identified by its handle, restoring its ability to send emails.
927
+ * @param handle - Handle of sub-account to be activated.
928
+ * @example
929
+ * ```ts
930
+ * const mailchannels = new MailChannels('your-api-key')
931
+ * const { success, error } = await mailchannels.subAccounts.activate('validhandle123')
932
+ * ```
933
+ */
934
+ activate(handle: string): Promise<SuccessResponse>;
935
+ /**
936
+ * Creates a new API key for the specified sub-account.
937
+ * @param handle - Handle of the sub-account to create API key for.
938
+ * @example
939
+ * ```ts
940
+ * const mailchannels = new MailChannels('your-api-key')
941
+ * const { data, error } = await mailchannels.subAccounts.createApiKey('validhandle123')
942
+ * ```
943
+ */
944
+ createApiKey(handle: string): Promise<SubAccountsCreateApiKeyResponse>;
945
+ /**
946
+ * Retrieves details of all API keys associated with the specified sub-account. For security reasons, the full API key is not returned; only the key ID and a partially redacted version are provided.
947
+ * @param handle - Handle of the sub-account to retrieve the API key for.
948
+ * @param options - The options to filter the list of API keys.
949
+ * @example
950
+ * ```ts
951
+ * const mailchannels = new MailChannels('your-api-key')
952
+ * const { data, error } = await mailchannels.subAccounts.listApiKeys('validhandle123')
953
+ * ```
954
+ */
955
+ listApiKeys(handle: string, options?: SubAccountsListApiKeyOptions): Promise<SubAccountsListApiKeyResponse>;
956
+ /**
957
+ * Deletes the API key identified by its ID for the specified sub-account.
958
+ * @param handle - Handle of the sub-account for which the API key should be deleted.
959
+ * @param id - The ID of the API key to delete.
960
+ * @example
961
+ * ```ts
962
+ * const mailchannels = new MailChannels('your-api-key')
963
+ * const { success, error } = await mailchannels.subAccounts.deleteApiKey('validhandle123', 1)
964
+ * ```
965
+ */
966
+ deleteApiKey(handle: string, id: number): Promise<SuccessResponse>;
967
+ /**
968
+ * Creates a new SMTP password for the specified sub-account.
969
+ * @param handle - Handle of the sub-account to create SMTP password for.
970
+ * @example
971
+ * ```ts
972
+ * const mailchannels = new MailChannels('your-api-key')
973
+ * const { data, error } = await mailchannels.subAccounts.createSmtpPassword('validhandle123')
974
+ * ```
975
+ */
976
+ createSmtpPassword(handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
977
+ /**
978
+ * Retrieves details of all SMTP passwords associated with the specified sub-account. For security, the full SMTP password is not returned; only the password ID and a partially redacted version are provided.
979
+ * @param handle - Handle of the sub-account to retrieve the SMTP password for.
980
+ * @example
981
+ * ```ts
982
+ * const mailchannels = new MailChannels('your-api-key')
983
+ * const { data, error } = await mailchannels.subAccounts.listSmtpPasswords('validhandle123')
984
+ * ```
985
+ */
986
+ listSmtpPasswords(handle: string): Promise<SubAccountsListSmtpPasswordResponse>;
987
+ /**
988
+ * Deletes the SMTP password identified by its ID for the specified sub-account.
989
+ * @param handle - Handle of the sub-account for which the SMTP password should be deleted.
990
+ * @param id - The ID of the SMTP password to delete.
991
+ * @example
992
+ * ```ts
993
+ * const mailchannels = new MailChannels('your-api-key')
994
+ * const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword('validhandle123', 1)
995
+ * ```
996
+ */
997
+ deleteSmtpPassword(handle: string, id: number): Promise<SuccessResponse>;
998
+ /**
999
+ * Retrieves the limit of a specified sub-account. A value of `-1` indicates that the sub-account inherits the parent account's limit, allowing the sub-account to utilize any remaining capacity within the parent account's allocation.
1000
+ * @param handle - Handle of the sub-account to retrieve the limit for.
1001
+ * @example
1002
+ * ```ts
1003
+ * const mailchannels = new MailChannels('your-api-key')
1004
+ * const { data, error } = await mailchannels.subAccounts.getLimit('validhandle123')
1005
+ * ```
1006
+ */
1007
+ getLimit(handle: string): Promise<SubAccountsLimitResponse>;
1008
+ /**
1009
+ * Sets the limit for the specified sub-account.
1010
+ * @param handle - Handle of the sub-account to set limit for.
1011
+ * @param limit - The limits to set for the sub-account. The minimum allowed sends is `0`
1012
+ * @example
1013
+ * ```ts
1014
+ * const mailchannels = new MailChannels('your-api-key')
1015
+ * const { success, error } = await mailchannels.subAccounts.setLimit('validhandle123', { sends: 1000 })
1016
+ * ```
1017
+ */
1018
+ setLimit(handle: string, limit: SubAccountsLimit): Promise<SuccessResponse>;
1019
+ /**
1020
+ * Deletes the limit for the specified sub-account. After a successful deletion, the specified sub-account will be limited to the parent account's limit.
1021
+ * @param handle - Handle of the sub-account to delete limit for.
1022
+ * @example
1023
+ * ```ts
1024
+ * const mailchannels = new MailChannels('your-api-key')
1025
+ * const { success, error } = await mailchannels.subAccounts.deleteLimit('validhandle123')
1026
+ * ```
1027
+ */
1028
+ deleteLimit(handle: string): Promise<SuccessResponse>;
1029
+ /**
1030
+ * Retrieves usage statistics for the specified sub-account during the current billing period.
1031
+ * @param handle - Handle of the sub-account to query usage stats for.
1032
+ * @example
1033
+ * ```ts
1034
+ * const mailchannels = new MailChannels('your-api-key')
1035
+ * const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123')
1036
+ * ```
1037
+ */
1038
+ getUsage(handle: string): Promise<SubAccountsUsageResponse>;
971
1039
  }
972
-
973
- interface MetricsEngagement {
974
- /**
975
- * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
976
- */
977
- buckets: {
978
- click: MetricsBucket[];
979
- clickTrackingDelivered: MetricsBucket[];
980
- open: MetricsBucket[];
981
- openTrackingDelivered: MetricsBucket[];
982
- };
983
- click: number;
984
- clickTrackingDelivered: number;
985
- endTime: string;
986
- open: number;
987
- openTrackingDelivered: number;
988
- startTime: string;
989
- }
990
- type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
991
-
992
- interface MetricsPerformance {
993
- /**
994
- * Count of messages bounced during the specified time range.
995
- */
996
- bounced: number;
997
- /**
998
- * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
999
- */
1000
- buckets: {
1001
- bounced: MetricsBucket[];
1002
- delivered: MetricsBucket[];
1003
- processed: MetricsBucket[];
1004
- };
1005
- /**
1006
- * Count of messages delivered during the specified time range.
1007
- */
1008
- delivered: number;
1009
- /**
1010
- * The end of the time range for retrieving message performance metrics (exclusive).
1011
- */
1012
- endTime: string;
1013
- /**
1014
- * Count of messages processed during the specified time range.
1015
- */
1016
- processed: number;
1017
- /**
1018
- * The beginning of the time range for retrieving message performance metrics (inclusive).
1019
- */
1020
- startTime: string;
1040
+ //#endregion
1041
+ //#region src/types/metrics/engagement.d.ts
1042
+ interface MetricsEngagement {
1043
+ /**
1044
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1045
+ */
1046
+ buckets: {
1047
+ click: MetricsBucket[];
1048
+ clickTrackingDelivered: MetricsBucket[];
1049
+ open: MetricsBucket[];
1050
+ openTrackingDelivered: MetricsBucket[];
1051
+ };
1052
+ click: number;
1053
+ clickTrackingDelivered: number;
1054
+ endTime: string;
1055
+ open: number;
1056
+ openTrackingDelivered: number;
1057
+ startTime: string;
1058
+ }
1059
+ type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
1060
+ //#endregion
1061
+ //#region src/types/metrics/performance.d.ts
1062
+ interface MetricsPerformance {
1063
+ /**
1064
+ * Count of messages bounced during the specified time range.
1065
+ */
1066
+ bounced: number;
1067
+ /**
1068
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1069
+ */
1070
+ buckets: {
1071
+ bounced: MetricsBucket[];
1072
+ delivered: MetricsBucket[];
1073
+ processed: MetricsBucket[];
1074
+ };
1075
+ /**
1076
+ * Count of messages delivered during the specified time range.
1077
+ */
1078
+ delivered: number;
1079
+ /**
1080
+ * The end of the time range for retrieving message performance metrics (exclusive).
1081
+ */
1082
+ endTime: string;
1083
+ /**
1084
+ * Count of messages processed during the specified time range.
1085
+ */
1086
+ processed: number;
1087
+ /**
1088
+ * The beginning of the time range for retrieving message performance metrics (inclusive).
1089
+ */
1090
+ startTime: string;
1021
1091
  }
1022
1092
  type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
1023
-
1093
+ //#endregion
1094
+ //#region src/types/metrics/recipient-behaviour.d.ts
1024
1095
  interface MetricsRecipientBehaviour {
1025
- /**
1026
- * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1027
- */
1028
- buckets: {
1029
- unsubscribeDelivered: MetricsBucket[];
1030
- unsubscribed: MetricsBucket[];
1031
- };
1032
- /**
1033
- * The end of the time range for retrieving recipient behaviour metrics (exclusive).
1034
- */
1035
- endTime: string;
1036
- /**
1037
- * The beginning of the time range for retrieving recipient behaviour metrics (inclusive).
1038
- */
1039
- startTime: string;
1040
- /**
1041
- * Count of recipients of delivered messages that include at least one of the unsubscribe link or unsubscribe headers. Since the unsubscribe feature requires exactly one recipient per message, this count also represents the total number of delivered messages.
1042
- */
1043
- unsubscribeDelivered: number;
1044
- /**
1045
- * Count of unsubscribed events by recipients.
1046
- */
1047
- unsubscribed: number;
1096
+ /**
1097
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1098
+ */
1099
+ buckets: {
1100
+ unsubscribeDelivered: MetricsBucket[];
1101
+ unsubscribed: MetricsBucket[];
1102
+ };
1103
+ /**
1104
+ * The end of the time range for retrieving recipient behaviour metrics (exclusive).
1105
+ */
1106
+ endTime: string;
1107
+ /**
1108
+ * The beginning of the time range for retrieving recipient behaviour metrics (inclusive).
1109
+ */
1110
+ startTime: string;
1111
+ /**
1112
+ * Count of recipients of delivered messages that include at least one of the unsubscribe link or unsubscribe headers. Since the unsubscribe feature requires exactly one recipient per message, this count also represents the total number of delivered messages.
1113
+ */
1114
+ unsubscribeDelivered: number;
1115
+ /**
1116
+ * Count of unsubscribed events by recipients.
1117
+ */
1118
+ unsubscribed: number;
1048
1119
  }
1049
1120
  type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
1050
-
1121
+ //#endregion
1122
+ //#region src/types/metrics/volume.d.ts
1051
1123
  interface MetricsVolume {
1052
- /**
1053
- * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1054
- */
1055
- buckets: {
1056
- delivered: MetricsBucket[];
1057
- dropped: MetricsBucket[];
1058
- processed: MetricsBucket[];
1059
- };
1060
- /**
1061
- * Count of messages delivered during the specified time range.
1062
- */
1063
- delivered: number;
1064
- /**
1065
- * Count of messages dropped during the specified time range.
1066
- */
1067
- dropped: number;
1068
- /**
1069
- * The end of the time range for retrieving message volume metrics (exclusive).
1070
- */
1071
- endTime: string;
1072
- /**
1073
- * Count of messages processed during the specified time range.
1074
- */
1075
- processed: number;
1076
- /**
1077
- * The beginning of the time range for retrieving message volume metrics (inclusive).
1078
- */
1079
- startTime: string;
1124
+ /**
1125
+ * A series of metrics aggregations bucketed by time interval (e.g. hour, day).
1126
+ */
1127
+ buckets: {
1128
+ delivered: MetricsBucket[];
1129
+ dropped: MetricsBucket[];
1130
+ processed: MetricsBucket[];
1131
+ };
1132
+ /**
1133
+ * Count of messages delivered during the specified time range.
1134
+ */
1135
+ delivered: number;
1136
+ /**
1137
+ * Count of messages dropped during the specified time range.
1138
+ */
1139
+ dropped: number;
1140
+ /**
1141
+ * The end of the time range for retrieving message volume metrics (exclusive).
1142
+ */
1143
+ endTime: string;
1144
+ /**
1145
+ * Count of messages processed during the specified time range.
1146
+ */
1147
+ processed: number;
1148
+ /**
1149
+ * The beginning of the time range for retrieving message volume metrics (inclusive).
1150
+ */
1151
+ startTime: string;
1080
1152
  }
1081
1153
  type MetricsVolumeResponse = DataResponse<MetricsVolume>;
1082
-
1154
+ //#endregion
1155
+ //#region src/types/metrics/usage.d.ts
1083
1156
  type MetricsUsageResponse = DataResponse<{
1084
- /**
1085
- * The end date of the current billing period (ISO 8601 format).
1086
- * @example "2025-04-11"
1087
- */
1088
- endDate: string;
1089
- /**
1090
- * The start date of the current billing period (ISO 8601 format).
1091
- * @example "2025-03-12"
1092
- */
1093
- startDate: string;
1094
- /**
1095
- * The total usage for the current billing period.
1096
- */
1097
- total: number;
1157
+ /**
1158
+ * The end date of the current billing period (ISO 8601 format).
1159
+ * @example "2025-04-11"
1160
+ */
1161
+ endDate: string;
1162
+ /**
1163
+ * The start date of the current billing period (ISO 8601 format).
1164
+ * @example "2025-03-12"
1165
+ */
1166
+ startDate: string;
1167
+ /**
1168
+ * The total usage for the current billing period.
1169
+ */
1170
+ total: number;
1098
1171
  }>;
1099
-
1172
+ //#endregion
1173
+ //#region src/types/metrics/senders.d.ts
1100
1174
  type MetricsSendersType = "sub-accounts" | "campaigns";
1101
1175
  interface MetricsSendersOptions {
1102
- /**
1103
- * The beginning of the time range for retrieving top senders metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
1104
- * @example "2025-11-02T03:13:35.761763554Z"
1105
- */
1106
- startTime?: string;
1107
- /**
1108
- * The end of the time range for retrieving top senders metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
1109
- * @example "2025-12-02T03:13:35.761763554Z"
1110
- */
1111
- endTime?: string;
1112
- /**
1113
- * The maximum number of senders to return. Possible values are 1 to 1000.
1114
- * @default 10
1115
- */
1116
- limit?: number;
1117
- /**
1118
- * The number of senders to skip before returning results.
1119
- * @default 0
1120
- */
1121
- offset?: number;
1122
- /**
1123
- * The order in which to sort the results, based on total messages (processed + dropped).
1124
- * @default "desc"
1125
- */
1126
- sortOrder?: "asc" | "desc";
1176
+ /**
1177
+ * The beginning of the time range for retrieving top senders metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
1178
+ * @example "2025-11-02T03:13:35.761763554Z"
1179
+ */
1180
+ startTime?: string;
1181
+ /**
1182
+ * The end of the time range for retrieving top senders metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
1183
+ * @example "2025-12-02T03:13:35.761763554Z"
1184
+ */
1185
+ endTime?: string;
1186
+ /**
1187
+ * The maximum number of senders to return. Possible values are 1 to 1000.
1188
+ * @default 10
1189
+ */
1190
+ limit?: number;
1191
+ /**
1192
+ * The number of senders to skip before returning results.
1193
+ * @default 0
1194
+ */
1195
+ offset?: number;
1196
+ /**
1197
+ * The order in which to sort the results, based on total messages (processed + dropped).
1198
+ * @default "desc"
1199
+ */
1200
+ sortOrder?: "asc" | "desc";
1127
1201
  }
1128
1202
  interface MetricsSenders {
1129
- endTime: string;
1130
- limit: number;
1131
- offset: number;
1132
- senders: {
1133
- bounced: number;
1134
- delivered: number;
1135
- dropped: number;
1136
- /**
1137
- * Maximum character length: 255
1138
- */
1139
- name: string;
1140
- processed: number;
1141
- }[];
1142
- startTime: string;
1203
+ endTime: string;
1204
+ limit: number;
1205
+ offset: number;
1206
+ senders: {
1207
+ bounced: number;
1208
+ delivered: number;
1209
+ dropped: number;
1143
1210
  /**
1144
- * The total number of senders in this category that sent messages in the given time range.
1211
+ * Maximum character length: 255
1145
1212
  */
1146
- total: number;
1213
+ name: string;
1214
+ processed: number;
1215
+ }[];
1216
+ startTime: string;
1217
+ /**
1218
+ * The total number of senders in this category that sent messages in the given time range.
1219
+ */
1220
+ total: number;
1147
1221
  }
1148
1222
  type MetricsSendersResponse = DataResponse<MetricsSenders>;
1149
-
1223
+ //#endregion
1224
+ //#region src/types/metrics/index.d.ts
1150
1225
  interface MetricsBucket {
1151
- /**
1152
- * The number of events or occurrences aggregated within this time period.
1153
- */
1154
- count: number;
1155
- /**
1156
- * The starting date and time of the time period this bucket represents.
1157
- */
1158
- periodStart: string;
1226
+ /**
1227
+ * The number of events or occurrences aggregated within this time period.
1228
+ */
1229
+ count: number;
1230
+ /**
1231
+ * The starting date and time of the time period this bucket represents.
1232
+ */
1233
+ periodStart: string;
1159
1234
  }
1160
1235
  interface MetricsOptions {
1161
- /**
1162
- * The beginning of the time range for retrieving message metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
1163
- * @example "2025-05-26"
1164
- */
1165
- startTime?: string;
1166
- /**
1167
- * The end of the time range for retrieving message metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
1168
- * @example "2025-05-31T15:16:17Z"
1169
- */
1170
- endTime?: string;
1171
- /**
1172
- * The ID of the campaign to filter metrics by. If not provided, metrics for all campaigns will be returned.
1173
- */
1174
- campaignId?: string;
1175
- /**
1176
- * The interval for aggregating metrics data.
1177
- * @default "day"
1178
- */
1179
- interval?: "hour" | "day" | "week" | "month";
1236
+ /**
1237
+ * The beginning of the time range for retrieving message metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to one month ago if not provided.
1238
+ * @example "2025-05-26"
1239
+ */
1240
+ startTime?: string;
1241
+ /**
1242
+ * The end of the time range for retrieving message metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. Defaults to the current time if not provided.
1243
+ * @example "2025-05-31T15:16:17Z"
1244
+ */
1245
+ endTime?: string;
1246
+ /**
1247
+ * The ID of the campaign to filter metrics by. If not provided, metrics for all campaigns will be returned.
1248
+ */
1249
+ campaignId?: string;
1250
+ /**
1251
+ * The interval for aggregating metrics data.
1252
+ * @default "day"
1253
+ */
1254
+ interval?: "hour" | "day" | "week" | "month";
1180
1255
  }
1181
-
1256
+ //#endregion
1257
+ //#region src/modules/metrics.d.ts
1182
1258
  declare class Metrics {
1183
- protected mailchannels: MailChannelsClient;
1184
- constructor(mailchannels: MailChannelsClient);
1185
- /**
1186
- * Retrieve engagement metrics for messages sent from your account, including counts of open and click events. Supports optional filters for time range, and campaign ID.
1187
- * @param options - Options to filter and customize the engagement metrics retrieval.
1188
- * @example
1189
- * ```ts
1190
- * const mailchannels = new MailChannels('your-api-key')
1191
- * const { data, error } = await mailchannels.metrics.engagement()
1192
- * ```
1193
- */
1194
- engagement(options?: MetricsOptions): Promise<MetricsEngagementResponse>;
1195
- /**
1196
- * Retrieve performance metrics for messages sent from your account, including counts of processed, delivered, hard-bounced events. Supports optional filters for time range, and campaign ID.
1197
- * @param options - Options to filter and customize the performance metrics retrieval.
1198
- * @example
1199
- * ```ts
1200
- * const mailchannels = new MailChannels('your-api-key')
1201
- * const { data, error } = await mailchannels.metrics.performance()
1202
- * ```
1203
- */
1204
- performance(options?: MetricsOptions): Promise<MetricsPerformanceResponse>;
1205
- /**
1206
- * Retrieve recipient behaviour metrics for messages sent from your account, including counts of unsubscribed events. Supports optional filters for time range, and campaign ID.
1207
- * @param options - Options to filter and customize the recipient behaviour metrics retrieval.
1208
- * @example
1209
- * ```ts
1210
- * const mailchannels = new MailChannels('your-api-key')
1211
- * const { data, error } = await mailchannels.metrics.recipientBehaviour()
1212
- * ```
1213
- */
1214
- recipientBehaviour(options?: MetricsOptions): Promise<MetricsRecipientBehaviourResponse>;
1215
- /**
1216
- * Retrieve volume metrics for messages sent from your account, including counts of processed, delivered and dropped events. Supports optional filters for time range and campaign ID.
1217
- * @param options - Options to filter and customize the volume metrics retrieval.
1218
- * @example
1219
- * ```ts
1220
- * const mailchannels = new MailChannels('your-api-key')
1221
- * const { data, error } = await mailchannels.metrics.volume()
1222
- * ```
1223
- */
1224
- volume(options?: MetricsOptions): Promise<MetricsVolumeResponse>;
1225
- /**
1226
- * Retrieves usage statistics during the current billing period.
1227
- * @example
1228
- * ```ts
1229
- * const mailchannels = new MailChannels('your-api-key')
1230
- * const { data, error } = await mailchannels.metrics.usage()
1231
- * ```
1232
- */
1233
- usage(): Promise<MetricsUsageResponse>;
1234
- /**
1235
- * Retrieves a list of senders, either sub-accounts or campaigns, with their associated message metrics. Sorted by total # of sent messages (processed + dropped). Supports optional filter for time range, and optional settings for limit, offset, and sort order. Note: senders without any messages in the given time range will not be included in the results. The default time range is from one month ago to now, and the default sort order is descending.
1236
- * @param type - The type of senders to retrieve metrics for. Can be either `sub-accounts` or `campaigns`.
1237
- * @param options - Optional filter options for time range, limit, offset, and sort order.
1238
- * @example
1239
- * ```ts
1240
- * const mailchannels = new MailChannels('your-api-key')
1241
- * const { data, error } = await mailchannels.metrics.senders('campaigns')
1242
- * ```
1243
- */
1244
- senders(type: MetricsSendersType, options?: MetricsSendersOptions): Promise<MetricsSendersResponse>;
1259
+ protected mailchannels: MailChannelsClient;
1260
+ constructor(mailchannels: MailChannelsClient);
1261
+ /**
1262
+ * Retrieve engagement metrics for messages sent from your account, including counts of open and click events. Supports optional filters for time range, and campaign ID.
1263
+ * @param options - Options to filter and customize the engagement metrics retrieval.
1264
+ * @example
1265
+ * ```ts
1266
+ * const mailchannels = new MailChannels('your-api-key')
1267
+ * const { data, error } = await mailchannels.metrics.engagement()
1268
+ * ```
1269
+ */
1270
+ engagement(options?: MetricsOptions): Promise<MetricsEngagementResponse>;
1271
+ /**
1272
+ * Retrieve performance metrics for messages sent from your account, including counts of processed, delivered, hard-bounced events. Supports optional filters for time range, and campaign ID.
1273
+ * @param options - Options to filter and customize the performance metrics retrieval.
1274
+ * @example
1275
+ * ```ts
1276
+ * const mailchannels = new MailChannels('your-api-key')
1277
+ * const { data, error } = await mailchannels.metrics.performance()
1278
+ * ```
1279
+ */
1280
+ performance(options?: MetricsOptions): Promise<MetricsPerformanceResponse>;
1281
+ /**
1282
+ * Retrieve recipient behaviour metrics for messages sent from your account, including counts of unsubscribed events. Supports optional filters for time range, and campaign ID.
1283
+ * @param options - Options to filter and customize the recipient behaviour metrics retrieval.
1284
+ * @example
1285
+ * ```ts
1286
+ * const mailchannels = new MailChannels('your-api-key')
1287
+ * const { data, error } = await mailchannels.metrics.recipientBehaviour()
1288
+ * ```
1289
+ */
1290
+ recipientBehaviour(options?: MetricsOptions): Promise<MetricsRecipientBehaviourResponse>;
1291
+ /**
1292
+ * Retrieve volume metrics for messages sent from your account, including counts of processed, delivered and dropped events. Supports optional filters for time range and campaign ID.
1293
+ * @param options - Options to filter and customize the volume metrics retrieval.
1294
+ * @example
1295
+ * ```ts
1296
+ * const mailchannels = new MailChannels('your-api-key')
1297
+ * const { data, error } = await mailchannels.metrics.volume()
1298
+ * ```
1299
+ */
1300
+ volume(options?: MetricsOptions): Promise<MetricsVolumeResponse>;
1301
+ /**
1302
+ * Retrieves usage statistics during the current billing period.
1303
+ * @example
1304
+ * ```ts
1305
+ * const mailchannels = new MailChannels('your-api-key')
1306
+ * const { data, error } = await mailchannels.metrics.usage()
1307
+ * ```
1308
+ */
1309
+ usage(): Promise<MetricsUsageResponse>;
1310
+ /**
1311
+ * Retrieves a list of senders, either sub-accounts or campaigns, with their associated message metrics. Sorted by total # of sent messages (processed + dropped). Supports optional filter for time range, and optional settings for limit, offset, and sort order. Note: senders without any messages in the given time range will not be included in the results. The default time range is from one month ago to now, and the default sort order is descending.
1312
+ * @param type - The type of senders to retrieve metrics for. Can be either `sub-accounts` or `campaigns`.
1313
+ * @param options - Optional filter options for time range, limit, offset, and sort order.
1314
+ * @example
1315
+ * ```ts
1316
+ * const mailchannels = new MailChannels('your-api-key')
1317
+ * const { data, error } = await mailchannels.metrics.senders('campaigns')
1318
+ * ```
1319
+ */
1320
+ senders(type: MetricsSendersType, options?: MetricsSendersOptions): Promise<MetricsSendersResponse>;
1245
1321
  }
1246
-
1322
+ //#endregion
1323
+ //#region src/types/suppressions/create.d.ts
1247
1324
  type SuppressionsTypes = "transactional" | "non-transactional";
1248
1325
  interface SuppressionsCreateOptions {
1326
+ /**
1327
+ * If true, the parent account creates suppression entries for all associated sub-accounts. This field is only applicable to parent accounts. Sub-accounts cannot create entries for other sub-accounts.
1328
+ * @default false
1329
+ */
1330
+ addToSubAccounts?: boolean;
1331
+ /**
1332
+ * The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed `1000`.
1333
+ */
1334
+ entries: {
1335
+ /**
1336
+ * Must be less than `1024` characters.
1337
+ */
1338
+ notes?: string;
1249
1339
  /**
1250
- * If true, the parent account creates suppression entries for all associated sub-accounts. This field is only applicable to parent accounts. Sub-accounts cannot create entries for other sub-accounts.
1251
- * @default false
1340
+ * The email address to suppress. Must be a valid email address format and less than `255` characters.
1252
1341
  */
1253
- addToSubAccounts?: boolean;
1342
+ recipient: string;
1254
1343
  /**
1255
- * The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed `1000`.
1344
+ * An array of types of suppression to apply to the recipient.
1345
+ * @default ["non-transactional"]
1256
1346
  */
1257
- entries: {
1258
- /**
1259
- * Must be less than `1024` characters.
1260
- */
1261
- notes?: string;
1262
- /**
1263
- * The email address to suppress. Must be a valid email address format and less than `255` characters.
1264
- */
1265
- recipient: string;
1266
- /**
1267
- * An array of types of suppression to apply to the recipient.
1268
- * @default ["non-transactional"]
1269
- */
1270
- types?: SuppressionsTypes[];
1271
- }[];
1347
+ types?: SuppressionsTypes[];
1348
+ }[];
1272
1349
  }
1273
-
1350
+ //#endregion
1351
+ //#region src/types/suppressions/list.d.ts
1274
1352
  type SuppressionsSource = "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all";
1275
1353
  interface SuppressionsListOptions {
1276
- /**
1277
- * The email address of the suppression entry to search for. If provided, the search will return the suppression entry associated with this recipient. If not provided, the search will return all suppression entries for the account.
1278
- */
1279
- recipient?: string;
1280
- /**
1281
- * The source of the suppression entries to filter by. If not provided, suppression entries from all sources will be returned.
1282
- */
1283
- source?: Exclude<SuppressionsSource, "all">;
1284
- /**
1285
- * The date and/or time before which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`.
1286
- */
1287
- createdBefore?: string;
1288
- /**
1289
- * The date and/or time after which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`.
1290
- */
1291
- createdAfter?: string;
1292
- /**
1293
- * The maximum number of suppression entries to return. Must be between `1` and `1000`.
1294
- * @default 1000
1295
- */
1296
- limit?: number;
1297
- /**
1298
- * The number of suppression entries to skip before returning results.
1299
- * @default 0
1300
- */
1301
- offset?: number;
1354
+ /**
1355
+ * The email address of the suppression entry to search for. If provided, the search will return the suppression entry associated with this recipient. If not provided, the search will return all suppression entries for the account.
1356
+ */
1357
+ recipient?: string;
1358
+ /**
1359
+ * The source of the suppression entries to filter by. If not provided, suppression entries from all sources will be returned.
1360
+ */
1361
+ source?: Exclude<SuppressionsSource, "all">;
1362
+ /**
1363
+ * The date and/or time before which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`.
1364
+ */
1365
+ createdBefore?: string;
1366
+ /**
1367
+ * The date and/or time after which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`.
1368
+ */
1369
+ createdAfter?: string;
1370
+ /**
1371
+ * The maximum number of suppression entries to return. Must be between `1` and `1000`.
1372
+ * @default 1000
1373
+ */
1374
+ limit?: number;
1375
+ /**
1376
+ * The number of suppression entries to skip before returning results.
1377
+ * @default 0
1378
+ */
1379
+ offset?: number;
1302
1380
  }
1303
1381
  interface SuppressionsListEntry {
1304
- createdAt: string;
1305
- notes?: string;
1306
- /**
1307
- * The email address that is suppressed.
1308
- */
1309
- recipient: string;
1310
- sender?: string;
1311
- source: SuppressionsSource;
1312
- types: SuppressionsTypes[];
1382
+ createdAt: string;
1383
+ notes?: string;
1384
+ /**
1385
+ * The email address that is suppressed.
1386
+ */
1387
+ recipient: string;
1388
+ sender?: string;
1389
+ source: SuppressionsSource;
1390
+ types: SuppressionsTypes[];
1313
1391
  }
1314
1392
  type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
1315
-
1393
+ //#endregion
1394
+ //#region src/modules/suppressions.d.ts
1316
1395
  declare class Suppressions {
1317
- protected mailchannels: MailChannelsClient;
1318
- constructor(mailchannels: MailChannelsClient);
1319
- /**
1320
- * Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If `types` is not provided, it defaults to `non-transactional`. The operation is atomic, meaning all entries are successfully added or none are added if an error occurs.
1321
- * @param options - The details of the suppression entries to create.
1322
- * @example
1323
- * ```ts
1324
- * const mailchannels = new MailChannels('your-api-key')
1325
- * const { success, error } = await mailchannels.suppressions.create({
1326
- * // ...
1327
- * });
1328
- */
1329
- create(options: SuppressionsCreateOptions): Promise<SuccessResponse>;
1330
- /**
1331
- * Deletes suppression entry associated with the account based on the specified recipient and source.
1332
- * @param recipient - The email address of the suppression entry to delete.
1333
- * @param source - The source of the suppression entry to be deleted. If source is not provided, it defaults to `api`. If source is set to `all`, all suppression entries related to the specified recipient will be deleted.
1334
- * @example
1335
- * ```ts
1336
- * const mailchannels = new MailChannels('your-api-key')
1337
- * const { success, error } = await mailchannels.suppressions.delete('name@example.com', 'api');
1338
- * ```
1339
- */
1340
- delete(recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
1341
- /**
1342
- * Retrieve suppression entries associated with the specified account. Supports filtering by recipient, source and creation date range. The response is paginated, with a default limit of `1000` entries per page and an offset of `0`.
1343
- * @example
1344
- * ```ts
1345
- * const mailchannels = new MailChannels('your-api-key')
1346
- * const { data, error } = await mailchannels.suppressions.list();
1347
- * ```
1348
- * @param options - Options to filter and customize the suppression entries retrieval.
1349
- */
1350
- list(options?: SuppressionsListOptions): Promise<SuppressionsListResponse>;
1396
+ protected mailchannels: MailChannelsClient;
1397
+ constructor(mailchannels: MailChannelsClient);
1398
+ /**
1399
+ * Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If `types` is not provided, it defaults to `non-transactional`. The operation is atomic, meaning all entries are successfully added or none are added if an error occurs.
1400
+ * @param options - The details of the suppression entries to create.
1401
+ * @example
1402
+ * ```ts
1403
+ * const mailchannels = new MailChannels('your-api-key')
1404
+ * const { success, error } = await mailchannels.suppressions.create({
1405
+ * // ...
1406
+ * });
1407
+ */
1408
+ create(options: SuppressionsCreateOptions): Promise<SuccessResponse>;
1409
+ /**
1410
+ * Deletes suppression entry associated with the account based on the specified recipient and source.
1411
+ * @param recipient - The email address of the suppression entry to delete.
1412
+ * @param source - The source of the suppression entry to be deleted. If source is not provided, it defaults to `api`. If source is set to `all`, all suppression entries related to the specified recipient will be deleted.
1413
+ * @example
1414
+ * ```ts
1415
+ * const mailchannels = new MailChannels('your-api-key')
1416
+ * const { success, error } = await mailchannels.suppressions.delete('name@example.com', 'api');
1417
+ * ```
1418
+ */
1419
+ delete(recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
1420
+ /**
1421
+ * Retrieve suppression entries associated with the specified account. Supports filtering by recipient, source and creation date range. The response is paginated, with a default limit of `1000` entries per page and an offset of `0`.
1422
+ * @param options - Options to filter and customize the suppression entries retrieval.
1423
+ * @example
1424
+ * ```ts
1425
+ * const mailchannels = new MailChannels('your-api-key')
1426
+ * const { data, error } = await mailchannels.suppressions.list();
1427
+ * ```
1428
+ */
1429
+ list(options?: SuppressionsListOptions): Promise<SuppressionsListResponse>;
1351
1430
  }
1352
-
1431
+ //#endregion
1432
+ //#region src/types/lists/entry.d.ts
1353
1433
  type ListNames = "blocklist" | "safelist" | "blacklist" | "whitelist";
1354
1434
  interface ListEntryOptions {
1355
- /**
1356
- * This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1357
- */
1358
- listName: ListNames;
1359
- /**
1360
- * This can be a domain, email address, or IP address. The type of the entry is automatically determined based on the value.
1361
- */
1362
- item: string;
1435
+ /**
1436
+ * This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1437
+ */
1438
+ listName: ListNames;
1439
+ /**
1440
+ * This can be a domain, email address, or IP address. The type of the entry is automatically determined based on the value.
1441
+ */
1442
+ item: string;
1363
1443
  }
1364
1444
  interface ListEntry {
1365
- action: Extract<ListNames, "blocklist" | "safelist">;
1366
- item: string;
1367
- type: "domain" | "email_address" | "ip_address";
1445
+ action: Extract<ListNames, "blocklist" | "safelist">;
1446
+ item: string;
1447
+ type: "domain" | "email_address" | "ip_address";
1368
1448
  }
1369
1449
  type ListEntryResponse = DataResponse<ListEntry>;
1370
1450
  type ListEntriesResponse = DataResponse<ListEntry[]>;
1371
-
1451
+ //#endregion
1452
+ //#region src/types/domains/provision.d.ts
1372
1453
  interface DomainsData {
1454
+ /**
1455
+ * The domain name.
1456
+ */
1457
+ domain: string;
1458
+ /**
1459
+ * The abuse policy settings for the domain. These settings determine how spam messages are handled.
1460
+ */
1461
+ settings?: Partial<{
1373
1462
  /**
1374
- * The domain name.
1463
+ * The abuse policy.
1375
1464
  */
1376
- domain: string;
1465
+ abusePolicy: "block" | "flag" | "quarantine";
1377
1466
  /**
1378
- * The abuse policy settings for the domain. These settings determine how spam messages are handled.
1467
+ * If `true`, this abuse policy overrides the recipient abuse policy.
1379
1468
  */
1380
- settings?: Partial<{
1381
- /**
1382
- * The abuse policy.
1383
- */
1384
- abusePolicy: "block" | "flag" | "quarantine";
1385
- /**
1386
- * If `true`, this abuse policy overrides the recipient abuse policy.
1387
- */
1388
- abusePolicyOverride: boolean;
1389
- /**
1390
- * The spam header name to use if the abuse policy is set to `flag`.
1391
- */
1392
- spamHeaderName: string;
1393
- /**
1394
- * The spam header value to use if the abuse policy is set to `flag`.
1395
- */
1396
- spamHeaderValue: string;
1397
- }>;
1469
+ abusePolicyOverride: boolean;
1398
1470
  /**
1399
- * A list of email addresses that are the domain admins for the domain.
1471
+ * The spam header name to use if the abuse policy is set to `flag`.
1400
1472
  */
1401
- admins?: string[] | null;
1473
+ spamHeaderName: string;
1402
1474
  /**
1403
- * The locations of mail servers to which messages will be delivered after filtering.
1475
+ * The spam header value to use if the abuse policy is set to `flag`.
1404
1476
  */
1405
- downstreamAddresses?: {
1406
- /**
1407
- * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1408
- */
1409
- priority: number;
1410
- /**
1411
- * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1412
- */
1413
- weight: number;
1414
- /**
1415
- * TCP port on which the downstream mail server is listening.
1416
- */
1417
- port: number;
1418
- /**
1419
- * The canonical hostname of the host providing the service, ending in a dot.
1420
- */
1421
- target: string;
1422
- }[] | null;
1477
+ spamHeaderValue: string;
1478
+ }>;
1479
+ /**
1480
+ * A list of email addresses that are the domain admins for the domain.
1481
+ */
1482
+ admins?: string[] | null;
1483
+ /**
1484
+ * The locations of mail servers to which messages will be delivered after filtering.
1485
+ */
1486
+ downstreamAddresses?: {
1423
1487
  /**
1424
- * A list of aliases for the domain. Mail is accepted for these domains and routed to the `downstreamAddresses` defined for the domain. Must be <= 255 characters.
1488
+ * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1425
1489
  */
1426
- aliases?: string[] | null;
1490
+ priority: number;
1427
1491
  /**
1428
- * The subscription `handle` that identifies the subscription that this domain should be provisioned against. Subscription handles can be retrieved from the `subscriptions` service method.
1492
+ * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1429
1493
  */
1430
- subscriptionHandle: string;
1431
- }
1432
- interface DomainsProvisionOptions extends DomainsData {
1494
+ weight: number;
1433
1495
  /**
1434
- * If present and set to true, the domain will be associated with the api-key that created it. This means that this api-key must be used for inbound-api actions involving this domain (for example adding safe/block list entries, etc).
1496
+ * TCP port on which the downstream mail server is listening.
1435
1497
  */
1436
- associateKey?: boolean;
1498
+ port: number;
1437
1499
  /**
1438
- * If present and set to true, the settings (domain settings, downstream addresses, aliases and admins) for the domain will be overwritten with the ones in the request if the domain already exists, unless a section is not included in the request or there is problem updating a setting in which case the previous settings are carried forward.
1500
+ * The canonical hostname of the host providing the service, ending in a dot.
1439
1501
  */
1440
- overwrite?: boolean;
1502
+ target: string;
1503
+ }[] | null;
1504
+ /**
1505
+ * A list of aliases for the domain. Mail is accepted for these domains and routed to the `downstreamAddresses` defined for the domain. Must be <= 255 characters.
1506
+ */
1507
+ aliases?: string[] | null;
1508
+ /**
1509
+ * The subscription `handle` that identifies the subscription that this domain should be provisioned against. Subscription handles can be retrieved from the `subscriptions` service method.
1510
+ */
1511
+ subscriptionHandle: string;
1512
+ }
1513
+ interface DomainsProvisionOptions extends DomainsData {
1514
+ /**
1515
+ * If present and set to true, the domain will be associated with the api-key that created it. This means that this api-key must be used for inbound-api actions involving this domain (for example adding safe/block list entries, etc).
1516
+ */
1517
+ associateKey?: boolean;
1518
+ /**
1519
+ * If present and set to true, the settings (domain settings, downstream addresses, aliases and admins) for the domain will be overwritten with the ones in the request if the domain already exists, unless a section is not included in the request or there is problem updating a setting in which case the previous settings are carried forward.
1520
+ */
1521
+ overwrite?: boolean;
1441
1522
  }
1442
1523
  type DomainsBulkProvisionOptions = Pick<DomainsProvisionOptions, "subscriptionHandle" | "associateKey" | "overwrite">;
1443
1524
  type DomainsProvisionResponse = DataResponse<DomainsData>;
1444
1525
  type DomainsBulkProvisionResponse = DataResponse<{
1526
+ /**
1527
+ * Domains that were successfully provisioned or updated.
1528
+ */
1529
+ successes: {
1445
1530
  /**
1446
- * Domains that were successfully provisioned or updated.
1531
+ * The provisioned domain data.
1447
1532
  */
1448
- successes: {
1449
- /**
1450
- * The provisioned domain data.
1451
- */
1452
- domain: DomainsData;
1453
- code: number;
1454
- comment?: string;
1455
- }[];
1533
+ domain: DomainsData;
1534
+ code: number;
1535
+ comment?: string;
1536
+ }[];
1537
+ /**
1538
+ * Domains that were not successfully provisioned.
1539
+ */
1540
+ errors: {
1456
1541
  /**
1457
- * Domains that were not successfully provisioned.
1542
+ * The failed to provision domain data.
1458
1543
  */
1459
- errors: {
1460
- /**
1461
- * The failed to provision domain data.
1462
- */
1463
- domain: DomainsData;
1464
- code: number;
1465
- comment?: string;
1466
- }[];
1544
+ domain: DomainsData;
1545
+ code: number;
1546
+ comment?: string;
1547
+ }[];
1467
1548
  }>;
1468
-
1549
+ //#endregion
1550
+ //#region src/types/domains/list.d.ts
1469
1551
  interface DomainsListOptions {
1470
- /**
1471
- * A list of domains to fetch. If this parameter is present, only domains whose name matches an item in this list are returned.
1472
- */
1473
- domains?: string[];
1474
- /**
1475
- * The maximum number of domains included in the response. Possible values are 1 to 5000.
1476
- * @default 10
1477
- */
1478
- limit?: number;
1479
- /**
1480
- * Offset into the list of domains to return.
1481
- * @default 0
1482
- */
1483
- offset?: number;
1552
+ /**
1553
+ * A list of domains to fetch. If this parameter is present, only domains whose name matches an item in this list are returned.
1554
+ */
1555
+ domains?: string[];
1556
+ /**
1557
+ * The maximum number of domains included in the response. Possible values are 1 to 5000.
1558
+ * @default 10
1559
+ */
1560
+ limit?: number;
1561
+ /**
1562
+ * Offset into the list of domains to return.
1563
+ * @default 0
1564
+ */
1565
+ offset?: number;
1484
1566
  }
1485
1567
  type DomainsListResponse = DataResponse<{
1486
- /**
1487
- * A list of domains.
1488
- */
1489
- domains: DomainsData[];
1490
- /**
1491
- * The total number of domains that are accessible with the given API key that match the list of domains in the 'domains' parameter. If there is no 'domains' parameter, this field is the total number of domains that are accessible with with this API key. A domain is accessible with a given API key if it is associated with that API key, or if it is not associated with any API key.
1492
- */
1493
- total: number;
1568
+ /**
1569
+ * A list of domains.
1570
+ */
1571
+ domains: DomainsData[];
1572
+ /**
1573
+ * The total number of domains that are accessible with the given API key that match the list of domains in the 'domains' parameter. If there is no 'domains' parameter, this field is the total number of domains that are accessible with with this API key. A domain is accessible with a given API key if it is associated with that API key, or if it is not associated with any API key.
1574
+ */
1575
+ total: number;
1494
1576
  }>;
1495
-
1577
+ //#endregion
1578
+ //#region src/types/domains/create-login-link.d.ts
1496
1579
  interface DomainsCreateLoginLink {
1497
- /**
1498
- * If a user browses to this URL, they will be automatically logged in as a domain admin.
1499
- */
1500
- link: string;
1580
+ /**
1581
+ * If a user browses to this URL, they will be automatically logged in as a domain admin.
1582
+ */
1583
+ link: string;
1501
1584
  }
1502
1585
  type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
1503
-
1586
+ //#endregion
1587
+ //#region src/types/domains/downstream-addresses.d.ts
1504
1588
  interface DomainsListDownstreamAddressesOptions {
1505
- /**
1506
- * The number of records to return.
1507
- * @default 10
1508
- */
1509
- limit?: number;
1510
- /**
1511
- * The offset into the records to return.
1512
- * @default 0
1513
- */
1514
- offset?: number;
1589
+ /**
1590
+ * The number of records to return.
1591
+ * @default 10
1592
+ */
1593
+ limit?: number;
1594
+ /**
1595
+ * The offset into the records to return.
1596
+ * @default 0
1597
+ */
1598
+ offset?: number;
1515
1599
  }
1516
1600
  interface DomainsDownstreamAddress {
1517
- /**
1518
- * TCP port on which the downstream mail server is listening.
1519
- */
1520
- port: number;
1521
- /**
1522
- * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1523
- */
1524
- priority: number;
1525
- /**
1526
- * The canonical hostname of the host providing the service, ending in a dot.
1527
- */
1528
- target: string;
1529
- /**
1530
- * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1531
- */
1532
- weight: number;
1601
+ /**
1602
+ * TCP port on which the downstream mail server is listening.
1603
+ */
1604
+ port: number;
1605
+ /**
1606
+ * The priority of the downstream address. Only addresses with the highest priority (the lowest numerical value) are selected.
1607
+ */
1608
+ priority: number;
1609
+ /**
1610
+ * The canonical hostname of the host providing the service, ending in a dot.
1611
+ */
1612
+ target: string;
1613
+ /**
1614
+ * Downstream addresses are selected in proportion to their weights. For example, if there are two downstream addresses, A with weight 40, and B with weight 10, then A is selected 80% of the time and B is selected 20% of the time.
1615
+ */
1616
+ weight: number;
1533
1617
  }
1534
1618
  type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
1535
-
1619
+ //#endregion
1620
+ //#region src/types/domains/bulk-create-login-links.d.ts
1536
1621
  interface DomainsBulkCreateLoginLinkResult {
1537
- /**
1538
- * The domain the request was for.
1539
- */
1540
- domain: string;
1541
- code: 200 | 400 | 401 | 403 | 404 | 500;
1542
- /**
1543
- * More information about the result of creating the login link.
1544
- */
1545
- comment?: string;
1546
- /**
1547
- * If a user browses to this URL, they will be automatically logged in as a domain admin.
1548
- */
1549
- loginLink: string;
1622
+ /**
1623
+ * The domain the request was for.
1624
+ */
1625
+ domain: string;
1626
+ code: 200 | 400 | 401 | 403 | 404 | 500;
1627
+ /**
1628
+ * More information about the result of creating the login link.
1629
+ */
1630
+ comment?: string;
1631
+ /**
1632
+ * If a user browses to this URL, they will be automatically logged in as a domain admin.
1633
+ */
1634
+ loginLink: string;
1550
1635
  }
1551
1636
  interface DomainsBulkCreateLoginLinks {
1552
- successes: DomainsBulkCreateLoginLinkResult[];
1553
- errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
1637
+ successes: DomainsBulkCreateLoginLinkResult[];
1638
+ errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
1554
1639
  }
1555
1640
  type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
1556
-
1641
+ //#endregion
1642
+ //#region src/modules/domains.d.ts
1557
1643
  declare class Domains {
1558
- protected mailchannels: MailChannelsClient;
1559
- constructor(mailchannels: MailChannelsClient);
1560
- /**
1561
- * Provision a single domain to use MailChannels Inbound.
1562
- * @param options - The provision options and domain data.
1563
- * @example
1564
- * ```ts
1565
- * const mailchannels = new MailChannels('your-api-key')
1566
- * const { data, error } = await mailchannels.domains.provision({
1567
- * domain: 'example.com',
1568
- * subscriptionHandle: 'your-subscription-handle'
1569
- * })
1570
- * ```
1571
- */
1572
- provision(options: DomainsProvisionOptions): Promise<DomainsProvisionResponse>;
1573
- /**
1574
- * Provision up to 1000 domains to use MailChannels Inbound.
1575
- * @param options - The options to provision the domains.
1576
- * @param domains - A list of domain data to provision.
1577
- * @example
1578
- * ```ts
1579
- * const mailchannels = new MailChannels('your-api-key')
1580
- * const { data, error } = await mailchannels.domains.bulkProvision({
1581
- * subscriptionHandle: 'your-subscription-handle'
1582
- * }, [
1583
- * {
1584
- * domain: 'example.com',
1585
- * admins: ['support@example.com']
1586
- * },
1587
- * {
1588
- * domain: 'example2.com'
1589
- * }
1590
- * ])
1591
- * ```
1592
- */
1593
- bulkProvision(options: DomainsBulkProvisionOptions, domains: Omit<DomainsData, "subscriptionHandle">[]): Promise<DomainsBulkProvisionResponse>;
1594
- /**
1595
- * Fetch a list of all domains associated with this API key.
1596
- * @param options - The options to filter the list of domains.
1597
- * @example
1598
- * ```ts
1599
- * const mailchannels = new MailChannels('your-api-key')
1600
- * const { data, error } = await mailchannels.domains.list()
1601
- * ```
1602
- */
1603
- list(options?: DomainsListOptions): Promise<DomainsListResponse>;
1604
- /**
1605
- * De-provision a domain to cease protecting it with MailChannels Inbound.
1606
- * @param domain - The domain name to be removed.
1607
- * @example
1608
- * ```ts
1609
- * const mailchannels = new MailChannels('your-api-key')
1610
- * const { success, error } = await mailchannels.domains.delete('example.com')
1611
- * ```
1612
- */
1613
- delete(domain: string): Promise<SuccessResponse>;
1614
- /**
1615
- * Add an entry to a domain blocklist or safelist.
1616
- * @param domain - The domain name.
1617
- * @param options - The options to add a list entry.
1618
- * @example
1619
- * ```ts
1620
- * const mailchannels = new MailChannels('your-api-key')
1621
- * const { data, error } = await mailchannels.domains.addListEntry('example.com', {
1622
- * listName: 'safelist',
1623
- * item: 'name@domain.com'
1624
- * })
1625
- * ```
1626
- */
1627
- addListEntry(domain: string, options: ListEntryOptions): Promise<ListEntryResponse>;
1628
- /**
1629
- * Get domain list entries.
1630
- * @param domain - The domain name.
1631
- * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1632
- * @example
1633
- * ```ts
1634
- * const mailchannels = new MailChannels('your-api-key')
1635
- * const { data, error } = await mailchannels.domains.listEntries('example.com', 'safelist')
1636
- * ```
1637
- */
1638
- listEntries(domain: string, listName: ListNames): Promise<ListEntriesResponse>;
1639
- /**
1640
- * Delete item from domain list.
1641
- * @param email - The domain name whose list will be modified.
1642
- * @param options - The options for the list entry to delete.
1643
- * @example
1644
- * ```ts
1645
- * const mailchannels = new MailChannels('your-api-key')
1646
- * const { success, error } = await mailchannels.domains.deleteListEntry('example.com', {
1647
- * listName: 'safelist',
1648
- * item: 'name@domain.com'
1649
- * })
1650
- * ```
1651
- */
1652
- deleteListEntry(domain: string, options: ListEntryOptions): Promise<SuccessResponse>;
1653
- /**
1654
- * Generate a link that allows a user to log in as a domain administrator.
1655
- * @param domain - The domain name.
1656
- * @example
1657
- * ```ts
1658
- * const mailchannels = new MailChannels('your-api-key')
1659
- * const { data, error } = await mailchannels.domains.createLoginLink('example.com')
1660
- * ```
1661
- */
1662
- createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
1663
- /**
1664
- * Sets the list of downstream addresses for the domain. This action deletes any existing downstream address for the domain before creating new ones. If the `records` parameter is an empty array, all downstream address records will be deleted.
1665
- * @param domain - The domain name.
1666
- * @param records - The list of records to set for the domain. A maximum of 10 records can be set.
1667
- * @example
1668
- * ```ts
1669
- * const mailchannels = new MailChannels('your-api-key')
1670
- * const { success, error } = await mailchannels.domains.setDownstreamAddress('example.com', [
1671
- * {
1672
- * port: 25,
1673
- * priority: 10,
1674
- * target: 'example.com.',
1675
- * weight: 10
1676
- * }
1677
- * ])
1678
- * ```
1679
- */
1680
- setDownstreamAddress(domain: string, records?: DomainsDownstreamAddress[]): Promise<SuccessResponse>;
1681
- /**
1682
- * Retrieve stored downstream addresses for the domain.
1683
- * @param domain - The domain name.
1684
- * @param options - The options to filter the list of downstream addresses.
1685
- * @example
1686
- * ```ts
1687
- * const mailchannels = new MailChannels('your-api-key')
1688
- * const { data, error } = await mailchannels.domains.listDownstreamAddresses('example.com')
1689
- * ```
1690
- */
1691
- listDownstreamAddresses(domain: string, options?: DomainsListDownstreamAddressesOptions): Promise<DomainsListDownstreamAddressesResponse>;
1692
- /**
1693
- * Update the API key that is associated with a domain.
1694
- * @param domain - The domain name.
1695
- * @param key - The new API key to associate with this domain.
1696
- * @example
1697
- * ```ts
1698
- * const mailchannels = new MailChannels('your-api-key')
1699
- * const { success, error } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1700
- * ```
1701
- */
1702
- updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
1703
- /**
1704
- * Generate a batch of links that allow a user to log in as a domain administrator to their different domains.
1705
- * @param domains - The list of domain names. Maximum of `1000` links per request.
1706
- * @example
1707
- * ```ts
1708
- * const mailchannels = new MailChannels('your-api-key')
1709
- * const { data, error } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1710
- * ```
1711
- */
1712
- bulkCreateLoginLinks(domains: string[]): Promise<DomainsBulkCreateLoginLinksResponse>;
1644
+ protected mailchannels: MailChannelsClient;
1645
+ constructor(mailchannels: MailChannelsClient);
1646
+ /**
1647
+ * Provision a single domain to use MailChannels Inbound.
1648
+ * @param options - The provision options and domain data.
1649
+ * @example
1650
+ * ```ts
1651
+ * const mailchannels = new MailChannels('your-api-key')
1652
+ * const { data, error } = await mailchannels.domains.provision({
1653
+ * domain: 'example.com',
1654
+ * subscriptionHandle: 'your-subscription-handle'
1655
+ * })
1656
+ * ```
1657
+ */
1658
+ provision(options: DomainsProvisionOptions): Promise<DomainsProvisionResponse>;
1659
+ /**
1660
+ * Provision up to 1000 domains to use MailChannels Inbound.
1661
+ * @param options - The options to provision the domains.
1662
+ * @param domains - A list of domain data to provision.
1663
+ * @example
1664
+ * ```ts
1665
+ * const mailchannels = new MailChannels('your-api-key')
1666
+ * const { data, error } = await mailchannels.domains.bulkProvision({
1667
+ * subscriptionHandle: 'your-subscription-handle'
1668
+ * }, [
1669
+ * {
1670
+ * domain: 'example.com',
1671
+ * admins: ['support@example.com']
1672
+ * },
1673
+ * {
1674
+ * domain: 'example2.com'
1675
+ * }
1676
+ * ])
1677
+ * ```
1678
+ */
1679
+ bulkProvision(options: DomainsBulkProvisionOptions, domains: Omit<DomainsData, "subscriptionHandle">[]): Promise<DomainsBulkProvisionResponse>;
1680
+ /**
1681
+ * Fetch a list of all domains associated with this API key.
1682
+ * @param options - The options to filter the list of domains.
1683
+ * @example
1684
+ * ```ts
1685
+ * const mailchannels = new MailChannels('your-api-key')
1686
+ * const { data, error } = await mailchannels.domains.list()
1687
+ * ```
1688
+ */
1689
+ list(options?: DomainsListOptions): Promise<DomainsListResponse>;
1690
+ /**
1691
+ * De-provision a domain to cease protecting it with MailChannels Inbound.
1692
+ * @param domain - The domain name to be removed.
1693
+ * @example
1694
+ * ```ts
1695
+ * const mailchannels = new MailChannels('your-api-key')
1696
+ * const { success, error } = await mailchannels.domains.delete('example.com')
1697
+ * ```
1698
+ */
1699
+ delete(domain: string): Promise<SuccessResponse>;
1700
+ /**
1701
+ * Add an entry to a domain blocklist or safelist.
1702
+ * @param domain - The domain name.
1703
+ * @param options - The options to add a list entry.
1704
+ * @example
1705
+ * ```ts
1706
+ * const mailchannels = new MailChannels('your-api-key')
1707
+ * const { data, error } = await mailchannels.domains.addListEntry('example.com', {
1708
+ * listName: 'safelist',
1709
+ * item: 'name@domain.com'
1710
+ * })
1711
+ * ```
1712
+ */
1713
+ addListEntry(domain: string, options: ListEntryOptions): Promise<ListEntryResponse>;
1714
+ /**
1715
+ * Get domain list entries.
1716
+ * @param domain - The domain name.
1717
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1718
+ * @example
1719
+ * ```ts
1720
+ * const mailchannels = new MailChannels('your-api-key')
1721
+ * const { data, error } = await mailchannels.domains.listEntries('example.com', 'safelist')
1722
+ * ```
1723
+ */
1724
+ listEntries(domain: string, listName: ListNames): Promise<ListEntriesResponse>;
1725
+ /**
1726
+ * Delete item from domain list.
1727
+ * @param email - The domain name whose list will be modified.
1728
+ * @param options - The options for the list entry to delete.
1729
+ * @example
1730
+ * ```ts
1731
+ * const mailchannels = new MailChannels('your-api-key')
1732
+ * const { success, error } = await mailchannels.domains.deleteListEntry('example.com', {
1733
+ * listName: 'safelist',
1734
+ * item: 'name@domain.com'
1735
+ * })
1736
+ * ```
1737
+ */
1738
+ deleteListEntry(domain: string, options: ListEntryOptions): Promise<SuccessResponse>;
1739
+ /**
1740
+ * Generate a link that allows a user to log in as a domain administrator.
1741
+ * @param domain - The domain name.
1742
+ * @example
1743
+ * ```ts
1744
+ * const mailchannels = new MailChannels('your-api-key')
1745
+ * const { data, error } = await mailchannels.domains.createLoginLink('example.com')
1746
+ * ```
1747
+ */
1748
+ createLoginLink(domain: string): Promise<DomainsCreateLoginLinkResponse>;
1749
+ /**
1750
+ * Sets the list of downstream addresses for the domain. This action deletes any existing downstream address for the domain before creating new ones. If the `records` parameter is an empty array, all downstream address records will be deleted.
1751
+ * @param domain - The domain name.
1752
+ * @param records - The list of records to set for the domain. A maximum of 10 records can be set.
1753
+ * @example
1754
+ * ```ts
1755
+ * const mailchannels = new MailChannels('your-api-key')
1756
+ * const { success, error } = await mailchannels.domains.setDownstreamAddress('example.com', [
1757
+ * {
1758
+ * port: 25,
1759
+ * priority: 10,
1760
+ * target: 'example.com.',
1761
+ * weight: 10
1762
+ * }
1763
+ * ])
1764
+ * ```
1765
+ */
1766
+ setDownstreamAddress(domain: string, records: DomainsDownstreamAddress[]): Promise<SuccessResponse>;
1767
+ /**
1768
+ * Retrieve stored downstream addresses for the domain.
1769
+ * @param domain - The domain name.
1770
+ * @param options - The options to filter the list of downstream addresses.
1771
+ * @example
1772
+ * ```ts
1773
+ * const mailchannels = new MailChannels('your-api-key')
1774
+ * const { data, error } = await mailchannels.domains.listDownstreamAddresses('example.com')
1775
+ * ```
1776
+ */
1777
+ listDownstreamAddresses(domain: string, options?: DomainsListDownstreamAddressesOptions): Promise<DomainsListDownstreamAddressesResponse>;
1778
+ /**
1779
+ * Update the API key that is associated with a domain.
1780
+ * @param domain - The domain name.
1781
+ * @param key - The new API key to associate with this domain.
1782
+ * @example
1783
+ * ```ts
1784
+ * const mailchannels = new MailChannels('your-api-key')
1785
+ * const { success, error } = await mailchannels.domains.updateApiKey('example.com', 'your-api-key')
1786
+ * ```
1787
+ */
1788
+ updateApiKey(domain: string, key: string): Promise<SuccessResponse>;
1789
+ /**
1790
+ * Generate a batch of links that allow a user to log in as a domain administrator to their different domains.
1791
+ * @param domains - The list of domain names. Maximum of `1000` links per request.
1792
+ * @example
1793
+ * ```ts
1794
+ * const mailchannels = new MailChannels('your-api-key')
1795
+ * const { data, error } = await mailchannels.domains.bulkCreateLoginLinks(['example.com', 'example2.com'])
1796
+ * ```
1797
+ */
1798
+ bulkCreateLoginLinks(domains: string[]): Promise<DomainsBulkCreateLoginLinksResponse>;
1713
1799
  }
1714
-
1800
+ //#endregion
1801
+ //#region src/modules/lists.d.ts
1715
1802
  declare class Lists {
1716
- protected mailchannels: MailChannelsClient;
1717
- constructor(mailchannels: MailChannelsClient);
1718
- /**
1719
- * Add item to account-level list
1720
- * @param options - The options for the list entry to add.
1721
- * @example
1722
- * ```ts
1723
- * const mailchannels = new MailChannels('your-api-key')
1724
- * const { data, error } = await mailchannels.lists.addListEntry({
1725
- * listName: 'safelist',
1726
- * item: 'name@domain.com'
1727
- * })
1728
- * ```
1729
- */
1730
- addListEntry(options: ListEntryOptions): Promise<ListEntryResponse>;
1731
- /**
1732
- * Get account-level list entries.
1733
- * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1734
- * @example
1735
- * ```ts
1736
- * const mailchannels = new MailChannels('your-api-key')
1737
- * const { data, error } = await mailchannels.lists.listEntries('safelist')
1738
- * ```
1739
- */
1740
- listEntries(listName: ListNames): Promise<ListEntriesResponse>;
1741
- /**
1742
- * Delete item from account-level list.
1743
- * @param options - The options for the list entry to delete.
1744
- * @example
1745
- * ```ts
1746
- * const mailchannels = new MailChannels('your-api-key')
1747
- * const { success, error } = await mailchannels.lists.deleteListEntry({
1748
- * listName: 'safelist',
1749
- * item: 'name@domain.com'
1750
- * })
1751
- * ```
1752
- */
1753
- deleteListEntry(options: ListEntryOptions): Promise<SuccessResponse>;
1803
+ protected mailchannels: MailChannelsClient;
1804
+ constructor(mailchannels: MailChannelsClient);
1805
+ /**
1806
+ * Add item to account-level list
1807
+ * @param options - The options for the list entry to add.
1808
+ * @example
1809
+ * ```ts
1810
+ * const mailchannels = new MailChannels('your-api-key')
1811
+ * const { data, error } = await mailchannels.lists.addListEntry({
1812
+ * listName: 'safelist',
1813
+ * item: 'name@domain.com'
1814
+ * })
1815
+ * ```
1816
+ */
1817
+ addListEntry(options: ListEntryOptions): Promise<ListEntryResponse>;
1818
+ /**
1819
+ * Get account-level list entries.
1820
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1821
+ * @example
1822
+ * ```ts
1823
+ * const mailchannels = new MailChannels('your-api-key')
1824
+ * const { data, error } = await mailchannels.lists.listEntries('safelist')
1825
+ * ```
1826
+ */
1827
+ listEntries(listName: ListNames): Promise<ListEntriesResponse>;
1828
+ /**
1829
+ * Delete item from account-level list.
1830
+ * @param options - The options for the list entry to delete.
1831
+ * @example
1832
+ * ```ts
1833
+ * const mailchannels = new MailChannels('your-api-key')
1834
+ * const { success, error } = await mailchannels.lists.deleteListEntry({
1835
+ * listName: 'safelist',
1836
+ * item: 'name@domain.com'
1837
+ * })
1838
+ * ```
1839
+ */
1840
+ deleteListEntry(options: ListEntryOptions): Promise<SuccessResponse>;
1754
1841
  }
1755
-
1842
+ //#endregion
1843
+ //#region src/types/users/create.d.ts
1756
1844
  interface UsersCreateOptions {
1757
- /**
1758
- * Flag to indicate if the user is a domain admin or a regular user.
1759
- * @default false
1760
- */
1761
- admin?: boolean;
1762
- /**
1763
- * Whether or not to filter mail for this recipient. There are three valid values.
1764
- * - `false` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, return an error.
1765
- * - `true` - Filtering policy will not be applied to messages intended for this recipient.
1766
- * - `compute` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, filtering policy will not be applied, and no error will be returned.
1767
- * @default 'compute'
1768
- */
1769
- filter?: boolean | "compute";
1770
- /**
1771
- * safelist and blocklist entries to be added.
1772
- */
1773
- listEntries?: {
1774
- blocklist?: string[];
1775
- safelist?: string[];
1776
- };
1845
+ /**
1846
+ * Flag to indicate if the user is a domain admin or a regular user.
1847
+ * @default false
1848
+ */
1849
+ admin?: boolean;
1850
+ /**
1851
+ * Whether or not to filter mail for this recipient. There are three valid values.
1852
+ * - `false` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, return an error.
1853
+ * - `true` - Filtering policy will not be applied to messages intended for this recipient.
1854
+ * - `compute` - Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, filtering policy will not be applied, and no error will be returned.
1855
+ * @default 'compute'
1856
+ */
1857
+ filter?: boolean | "compute";
1858
+ /**
1859
+ * safelist and blocklist entries to be added.
1860
+ */
1861
+ listEntries?: {
1862
+ blocklist?: string[];
1863
+ safelist?: string[];
1864
+ };
1777
1865
  }
1778
1866
  type UsersCreateResponse = DataResponse<{
1779
- email: string;
1780
- roles: string[];
1781
- filter?: boolean;
1782
- listEntries: {
1783
- item: string;
1784
- type: "domain" | "email_address" | "ip_address";
1785
- action: "safelist" | "blocklist";
1786
- }[];
1867
+ email: string;
1868
+ roles: string[];
1869
+ filter?: boolean;
1870
+ listEntries: {
1871
+ item: string;
1872
+ type: "domain" | "email_address" | "ip_address";
1873
+ action: "safelist" | "blocklist";
1874
+ }[];
1787
1875
  }>;
1788
-
1876
+ //#endregion
1877
+ //#region src/modules/users.d.ts
1789
1878
  declare class Users {
1790
- protected mailchannels: MailChannelsClient;
1791
- constructor(mailchannels: MailChannelsClient);
1792
- /**
1793
- * Create a recipient user.
1794
- * @param email - The email address of the user to create.
1795
- * @param options - The options for the user to create.
1796
- * @example
1797
- * ```ts
1798
- * const mailchannels = new MailChannels('your-api-key')
1799
- * const { data, error } = await mailchannels.users.create("name@example.com", {
1800
- * admin: true
1801
- * })
1802
- * ```
1803
- */
1804
- create(email: string, options?: UsersCreateOptions): Promise<UsersCreateResponse>;
1805
- /**
1806
- * Add item to recipient user list
1807
- * @param email - The email address of the recipient whose list will be modified.
1808
- * @param options - The options for the list entry to add.
1809
- * @example
1810
- * ```ts
1811
- * const mailchannels = new MailChannels('your-api-key')
1812
- * const { data, error } = await mailchannels.users.addListEntry('name@example.com', {
1813
- * listName: 'safelist',
1814
- * item: 'name@domain.com'
1815
- * })
1816
- * ```
1817
- */
1818
- addListEntry(email: string, options: ListEntryOptions): Promise<ListEntryResponse>;
1819
- /**
1820
- * Get recipient list entries.
1821
- * @param email - The email address of the recipient whose list will be fetched.
1822
- * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1823
- * @example
1824
- * ```ts
1825
- * const mailchannels = new MailChannels('your-api-key')
1826
- * const { data, error } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1827
- * ```
1828
- */
1829
- listEntries(email: string, listName: ListNames): Promise<ListEntriesResponse>;
1830
- /**
1831
- * Delete item from recipient list.
1832
- * @param email - The email address of the recipient whose list will be modified.
1833
- * @param options - The options for the list entry to delete.
1834
- * @example
1835
- * ```ts
1836
- * const mailchannels = new MailChannels('your-api-key')
1837
- * const { success, error } = await mailchannels.users.deleteListEntry('name@example.com', {
1838
- * listName: 'safelist',
1839
- * item: 'name@domain.com'
1840
- * })
1841
- * ```
1842
- */
1843
- deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1879
+ protected mailchannels: MailChannelsClient;
1880
+ constructor(mailchannels: MailChannelsClient);
1881
+ /**
1882
+ * Create a recipient user.
1883
+ * @param email - The email address of the user to create.
1884
+ * @param options - The options for the user to create.
1885
+ * @example
1886
+ * ```ts
1887
+ * const mailchannels = new MailChannels('your-api-key')
1888
+ * const { data, error } = await mailchannels.users.create("name@example.com", {
1889
+ * admin: true
1890
+ * })
1891
+ * ```
1892
+ */
1893
+ create(email: string, options?: UsersCreateOptions): Promise<UsersCreateResponse>;
1894
+ /**
1895
+ * Add item to recipient user list
1896
+ * @param email - The email address of the recipient whose list will be modified.
1897
+ * @param options - The options for the list entry to add.
1898
+ * @example
1899
+ * ```ts
1900
+ * const mailchannels = new MailChannels('your-api-key')
1901
+ * const { data, error } = await mailchannels.users.addListEntry('name@example.com', {
1902
+ * listName: 'safelist',
1903
+ * item: 'name@domain.com'
1904
+ * })
1905
+ * ```
1906
+ */
1907
+ addListEntry(email: string, options: ListEntryOptions): Promise<ListEntryResponse>;
1908
+ /**
1909
+ * Get recipient list entries.
1910
+ * @param email - The email address of the recipient whose list will be fetched.
1911
+ * @param listName - The name of the list to fetch. This can be a `blocklist`, `safelist`, `blacklist`, or `whitelist`.
1912
+ * @example
1913
+ * ```ts
1914
+ * const mailchannels = new MailChannels('your-api-key')
1915
+ * const { data, error } = await mailchannels.users.listEntries('name@example.com', 'safelist')
1916
+ * ```
1917
+ */
1918
+ listEntries(email: string, listName: ListNames): Promise<ListEntriesResponse>;
1919
+ /**
1920
+ * Delete item from recipient list.
1921
+ * @param email - The email address of the recipient whose list will be modified.
1922
+ * @param options - The options for the list entry to delete.
1923
+ * @example
1924
+ * ```ts
1925
+ * const mailchannels = new MailChannels('your-api-key')
1926
+ * const { success, error } = await mailchannels.users.deleteListEntry('name@example.com', {
1927
+ * listName: 'safelist',
1928
+ * item: 'name@domain.com'
1929
+ * })
1930
+ * ```
1931
+ */
1932
+ deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
1844
1933
  }
1845
-
1934
+ //#endregion
1935
+ //#region src/types/service/subscriptions.d.ts
1846
1936
  type ServiceSubscriptionsResponse = DataResponse<{
1847
- active: boolean;
1848
- activeAccountsCount: number;
1937
+ active: boolean;
1938
+ activeAccountsCount: number;
1939
+ handle: string;
1940
+ limits: {
1941
+ featureHandle: string;
1942
+ value: string;
1943
+ }[];
1944
+ plan: {
1849
1945
  handle: string;
1850
- limits: {
1851
- featureHandle: string;
1852
- value: string;
1853
- }[];
1854
- plan: {
1855
- handle: string;
1856
- name: string;
1857
- };
1946
+ name: string;
1947
+ };
1858
1948
  }[]>;
1859
-
1949
+ //#endregion
1950
+ //#region src/types/service/report.d.ts
1860
1951
  interface ServiceReportOptions {
1861
- /**
1862
- * The report type. It can be either `false_negative` or `false_positive`.
1863
- */
1864
- type: "false_negative" | "false_positive";
1865
- /**
1866
- * The full, unaltered message content in accordance with the RFC 2822 specifications without dot stuffing.
1867
- */
1868
- messageContent: string;
1869
- /**
1870
- * The SMTP envelope information.
1871
- */
1872
- smtpEnvelopeInformation?: {
1873
- ehlo: string;
1874
- mailFrom: string;
1875
- rcptTo: string;
1876
- };
1877
- /**
1878
- * The sending host information.
1879
- */
1880
- sendingHostInformation?: {
1881
- name: string;
1882
- };
1952
+ /**
1953
+ * The report type. It can be either `false_negative` or `false_positive`.
1954
+ */
1955
+ type: "false_negative" | "false_positive";
1956
+ /**
1957
+ * The full, unaltered message content in accordance with the RFC 2822 specifications without dot stuffing.
1958
+ */
1959
+ messageContent: string;
1960
+ /**
1961
+ * The SMTP envelope information.
1962
+ */
1963
+ smtpEnvelopeInformation?: {
1964
+ ehlo?: string;
1965
+ mailFrom?: string;
1966
+ rcptTo?: string;
1967
+ };
1968
+ /**
1969
+ * The sending host information.
1970
+ */
1971
+ sendingHostInformation?: {
1972
+ name?: string;
1973
+ };
1883
1974
  }
1884
-
1975
+ //#endregion
1976
+ //#region src/modules/service.d.ts
1885
1977
  declare class Service {
1886
- protected mailchannels: MailChannelsClient;
1887
- constructor(mailchannels: MailChannelsClient);
1888
- /**
1889
- * Retrieve the condition of the service
1890
- * @example
1891
- * ```ts
1892
- * const mailchannels = new MailChannels('your-api-key')
1893
- * const { success, error } = await mailchannels.service.status()
1894
- * ```
1895
- */
1896
- status(): Promise<SuccessResponse>;
1897
- /**
1898
- * Get a list of your subscriptions to MailChannels Inbound
1899
- * @example
1900
- * ```ts
1901
- * const mailchannels = new MailChannels('your-api-key')
1902
- * const { data, error } = await mailchannels.service.subscriptions()
1903
- * ```
1904
- */
1905
- subscriptions(): Promise<ServiceSubscriptionsResponse>;
1906
- /**
1907
- * Submit a false negative or false positive report.
1908
- * @param options - The report options
1909
- * @example
1910
- * ```ts
1911
- * const mailchannels = new MailChannels('your-api-key')
1912
- * const { success, error } = await mailchannels.service.report({
1913
- * // ...
1914
- * })
1915
- * ```
1916
- */
1917
- report(options: ServiceReportOptions): Promise<SuccessResponse>;
1978
+ protected mailchannels: MailChannelsClient;
1979
+ constructor(mailchannels: MailChannelsClient);
1980
+ /**
1981
+ * Retrieve the condition of the service
1982
+ * @example
1983
+ * ```ts
1984
+ * const mailchannels = new MailChannels('your-api-key')
1985
+ * const { success, error } = await mailchannels.service.status()
1986
+ * ```
1987
+ */
1988
+ status(): Promise<SuccessResponse>;
1989
+ /**
1990
+ * Get a list of your subscriptions to MailChannels Inbound
1991
+ * @example
1992
+ * ```ts
1993
+ * const mailchannels = new MailChannels('your-api-key')
1994
+ * const { data, error } = await mailchannels.service.subscriptions()
1995
+ * ```
1996
+ */
1997
+ subscriptions(): Promise<ServiceSubscriptionsResponse>;
1998
+ /**
1999
+ * Submit a false negative or false positive report.
2000
+ * @param options - The report options
2001
+ * @example
2002
+ * ```ts
2003
+ * const mailchannels = new MailChannels('your-api-key')
2004
+ * const { success, error } = await mailchannels.service.report({
2005
+ * // ...
2006
+ * })
2007
+ * ```
2008
+ */
2009
+ report(options: ServiceReportOptions): Promise<SuccessResponse>;
1918
2010
  }
1919
-
2011
+ //#endregion
2012
+ //#region src/types/webhooks/events.d.ts
2013
+ type WebhookEventType = "processed" | "delivered" | "open" | "click" | "hard-bounced" | "soft-bounced" | "dropped" | "complained" | "unsubscribed" | "test";
2014
+ interface WebhookEventBase<T extends WebhookEventType> {
2015
+ /**
2016
+ * The sender's email address
2017
+ */
2018
+ email?: string;
2019
+ /**
2020
+ * The MailChannels account ID that generated the webhook.
2021
+ * If the message was sent by a sub-account, this field contains the sub-account handle.
2022
+ */
2023
+ customer_handle: string;
2024
+ /**
2025
+ * The Unix timestamp (in seconds) when the event occurred; the timezone is always UTC
2026
+ */
2027
+ timestamp: number;
2028
+ /**
2029
+ * The Message-Id of the message that generated the event
2030
+ */
2031
+ smtp_id?: string;
2032
+ /**
2033
+ * The type of event that occurred
2034
+ */
2035
+ event: T;
2036
+ /**
2037
+ * A unique identifier generated to track the original HTTP request
2038
+ */
2039
+ request_id?: string;
2040
+ /**
2041
+ * The campaign identifier for the message that generated the event
2042
+ */
2043
+ campaign_id?: string;
2044
+ /**
2045
+ * The recipients of the message
2046
+ */
2047
+ recipients?: string[];
2048
+ }
2049
+ interface WebhookEventProcessed extends WebhookEventBase<"processed"> {}
2050
+ interface WebhookEventDelivered extends WebhookEventBase<"delivered"> {}
2051
+ interface WebhookEventWithTracking {
2052
+ /**
2053
+ * The User-Agent header given when the recipient opened the message
2054
+ */
2055
+ user_agent?: string;
2056
+ /**
2057
+ * The IP address of the host that made the HTTP request
2058
+ */
2059
+ ip?: string;
2060
+ }
2061
+ interface WebhookEventOpen extends WebhookEventBase<"open">, WebhookEventWithTracking {}
2062
+ interface WebhookEventClick extends WebhookEventBase<"click">, WebhookEventWithTracking {
2063
+ /**
2064
+ * The URL that was clicked by the recipient
2065
+ */
2066
+ url?: string;
2067
+ }
2068
+ interface WebhookEventWithStatus {
2069
+ /**
2070
+ * The SMTP status code that caused the bounce
2071
+ */
2072
+ status?: string;
2073
+ /**
2074
+ * A human-readable explanation of why the message hard-bounced
2075
+ */
2076
+ reason?: string;
2077
+ }
2078
+ interface WebhookEventHardBounced extends WebhookEventBase<"hard-bounced">, WebhookEventWithStatus {}
2079
+ interface WebhookEventSoftBounced extends WebhookEventBase<"soft-bounced">, WebhookEventWithStatus {}
2080
+ interface WebhookEventDropped extends WebhookEventBase<"dropped">, WebhookEventWithStatus {}
2081
+ interface WebhookEventComplained extends WebhookEventBase<"complained"> {}
2082
+ interface WebhookEventUnsubscribed extends WebhookEventBase<"unsubscribed"> {}
2083
+ interface WebhookEventTest extends Omit<WebhookEventBase<"test">, "recipients" | "campaign_id"> {}
2084
+ type WebhookEvent = WebhookEventProcessed | WebhookEventDelivered | WebhookEventOpen | WebhookEventClick | WebhookEventHardBounced | WebhookEventSoftBounced | WebhookEventDropped | WebhookEventComplained | WebhookEventUnsubscribed | WebhookEventTest;
2085
+ type WebhookEvents = WebhookEvent[];
2086
+ //#endregion
2087
+ //#region src/mailchannels.d.ts
1920
2088
  declare class MailChannels extends MailChannelsClient {
1921
- readonly emails: Emails;
1922
- readonly webhooks: Webhooks;
1923
- readonly subAccounts: SubAccounts;
1924
- readonly metrics: Metrics;
1925
- readonly suppressions: Suppressions;
1926
- readonly domains: Domains;
1927
- readonly lists: Lists;
1928
- readonly users: Users;
1929
- readonly service: Service;
1930
- constructor(key: string);
2089
+ readonly emails: Emails;
2090
+ readonly webhooks: Webhooks;
2091
+ readonly subAccounts: SubAccounts;
2092
+ readonly metrics: Metrics;
2093
+ readonly suppressions: Suppressions;
2094
+ readonly domains: Domains;
2095
+ readonly lists: Lists;
2096
+ readonly users: Users;
2097
+ readonly service: Service;
2098
+ constructor(key: string);
1931
2099
  }
1932
-
1933
- export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
1934
- export type { DataResponse, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };
2100
+ //#endregion
2101
+ export { DataResponse, Domains, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, Emails, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, Lists, MailChannels, MailChannelsClient, Metrics, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Service, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccounts, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, Suppressions, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, Users, UsersCreateOptions, UsersCreateResponse, WebhookEvent, WebhookEventClick, WebhookEventComplained, WebhookEventDelivered, WebhookEventDropped, WebhookEventHardBounced, WebhookEventOpen, WebhookEventProcessed, WebhookEventSoftBounced, WebhookEventTest, WebhookEventType, WebhookEventUnsubscribed, WebhookEvents, Webhooks, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse, WebhooksVerifyOptions };