mailchannels-sdk 0.7.0 β 0.7.2
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.
- package/README.md +1 -0
- package/dist/mailchannels.d.mts +97 -51
- package/dist/mailchannels.d.ts +97 -51
- package/dist/mailchannels.mjs +58 -23
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ Already implemented features are marked with a checkmark. Please open an issue i
|
|
|
77
77
|
|
|
78
78
|
- π§ Emails
|
|
79
79
|
- β
[Send an Email](https://docs.mailchannels.net/email-api/api-reference/send-an-email)
|
|
80
|
+
- β
[Send an Email Asynchronously](https://docs.mailchannels.net/email-api/api-reference/send-an-email-asynchronously)
|
|
80
81
|
- β
[DKIM, SPF & Domain Lockdown Check](https://docs.mailchannels.net/email-api/api-reference/dkim-spf-domain-lockdown-check)
|
|
81
82
|
- β
[Create DKIM Key Pair](https://docs.mailchannels.net/email-api/api-reference/create-dkim-key-pair)
|
|
82
83
|
- β
[Retrieve DKIM Keys](https://docs.mailchannels.net/email-api/api-reference/retrieve-dkim-keys)
|
package/dist/mailchannels.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ interface SuccessResponse {
|
|
|
28
28
|
error: ErrorResponse | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
type DataResponse<T> = {
|
|
31
|
+
type DataResponse$1<T> = {
|
|
32
32
|
/**
|
|
33
33
|
* The response data.
|
|
34
34
|
*/
|
|
@@ -54,7 +54,7 @@ interface EmailsSendRecipient {
|
|
|
54
54
|
*/
|
|
55
55
|
email: string;
|
|
56
56
|
/**
|
|
57
|
-
* The name of the recipient.
|
|
57
|
+
* The name of the recipient. Display name in raw text, e.g. John Doe, εΌ δΈ.
|
|
58
58
|
*/
|
|
59
59
|
name?: string;
|
|
60
60
|
}
|
|
@@ -147,6 +147,16 @@ interface EmailsSendOptionsBase {
|
|
|
147
147
|
*/
|
|
148
148
|
selector: string;
|
|
149
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* 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.
|
|
152
|
+
* @example
|
|
153
|
+
* { email: 'email@example.com', name: 'Example' }
|
|
154
|
+
* @example
|
|
155
|
+
* 'email@example.com'
|
|
156
|
+
* @example
|
|
157
|
+
* 'Name <email@example.com>'
|
|
158
|
+
*/
|
|
159
|
+
envelopeFrom?: EmailsSendRecipient | string;
|
|
150
160
|
/**
|
|
151
161
|
* The sender of the email. Can be a string or an object with email and name properties.
|
|
152
162
|
* @example
|
|
@@ -185,6 +195,11 @@ interface EmailsSendOptionsBase {
|
|
|
185
195
|
to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
|
|
186
196
|
/**
|
|
187
197
|
* 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.
|
|
198
|
+
*
|
|
199
|
+
* Only links (`<a>` tags) meeting all of the following conditions are processed for click tracking:
|
|
200
|
+
* - The URL is non-empty.
|
|
201
|
+
* - The URL starts with `http` or `https`.
|
|
202
|
+
* - The link does not have a `clicktracking` attribute set to `off`.
|
|
188
203
|
*/
|
|
189
204
|
tracking?: EmailsSendTracking;
|
|
190
205
|
/**
|
|
@@ -252,35 +267,46 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
|
|
|
252
267
|
}
|
|
253
268
|
);
|
|
254
269
|
|
|
255
|
-
type EmailsSendResponse = SuccessResponse & DataResponse<{
|
|
270
|
+
type EmailsSendResponse = SuccessResponse & DataResponse$1<{
|
|
256
271
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
272
|
+
* Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
|
|
273
|
+
*/
|
|
259
274
|
rendered?: string[];
|
|
260
275
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
276
|
+
* 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.
|
|
277
|
+
*/
|
|
263
278
|
requestId?: string;
|
|
264
279
|
results?: {
|
|
265
280
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
281
|
+
* The index of the personalization in the request. Starts at 0.
|
|
282
|
+
*/
|
|
268
283
|
index?: number;
|
|
269
284
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
285
|
+
* 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.
|
|
286
|
+
*/
|
|
272
287
|
messageId: string;
|
|
273
288
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
289
|
+
* A human-readable explanation of the status.
|
|
290
|
+
*/
|
|
276
291
|
reason?: string;
|
|
277
292
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
293
|
+
* The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
|
|
294
|
+
*/
|
|
280
295
|
status: "sent" | "failed";
|
|
281
296
|
}[];
|
|
282
297
|
}>;
|
|
283
298
|
|
|
299
|
+
type EmailsSendAsyncResponse = DataResponse<{
|
|
300
|
+
/**
|
|
301
|
+
* ISO 8601 timestamp when the request was queued for processing.
|
|
302
|
+
*/
|
|
303
|
+
queuedAt: string[];
|
|
304
|
+
/**
|
|
305
|
+
* Unique identifier for tracking this async request. Will be included in all webhook events for this request.
|
|
306
|
+
*/
|
|
307
|
+
requestId: string;
|
|
308
|
+
}>;
|
|
309
|
+
|
|
284
310
|
interface EmailsCreateDkimKeyOptions {
|
|
285
311
|
/**
|
|
286
312
|
* Algorithm used for the new key pair Currently, only RSA is supported.
|
|
@@ -348,7 +374,7 @@ interface EmailsDkimKey {
|
|
|
348
374
|
statusModifiedAt?: string;
|
|
349
375
|
}
|
|
350
376
|
|
|
351
|
-
type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
|
|
377
|
+
type EmailsCreateDkimKeyResponse = DataResponse$1<EmailsDkimKey>;
|
|
352
378
|
|
|
353
379
|
interface EmailsCheckDomainDkim {
|
|
354
380
|
/**
|
|
@@ -388,7 +414,7 @@ interface EmailsCheckDomainOptions {
|
|
|
388
414
|
|
|
389
415
|
type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
|
|
390
416
|
|
|
391
|
-
type EmailsCheckDomainResponse = DataResponse<{
|
|
417
|
+
type EmailsCheckDomainResponse = DataResponse$1<{
|
|
392
418
|
dkim: {
|
|
393
419
|
domain: string;
|
|
394
420
|
/**
|
|
@@ -470,7 +496,7 @@ interface EmailsGetDkimKeysOptions {
|
|
|
470
496
|
|
|
471
497
|
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
472
498
|
|
|
473
|
-
type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
499
|
+
type EmailsGetDkimKeysResponse = DataResponse$1<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
474
500
|
|
|
475
501
|
interface EmailsUpdateDkimKeyOptions {
|
|
476
502
|
/**
|
|
@@ -495,7 +521,7 @@ interface EmailsRotateDkimKeyOptions {
|
|
|
495
521
|
};
|
|
496
522
|
}
|
|
497
523
|
|
|
498
|
-
type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
524
|
+
type EmailsRotateDkimKeyResponse = DataResponse$1<{
|
|
499
525
|
new: EmailsDkimKey;
|
|
500
526
|
rotated: EmailsDkimKey;
|
|
501
527
|
}>;
|
|
@@ -503,14 +529,15 @@ type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
|
503
529
|
declare class Emails {
|
|
504
530
|
protected mailchannels: MailChannelsClient;
|
|
505
531
|
constructor(mailchannels: MailChannelsClient);
|
|
532
|
+
private _sendEmail;
|
|
506
533
|
/**
|
|
507
|
-
*
|
|
534
|
+
* Sends an email message to one or more recipients.
|
|
508
535
|
* @param options - The email options to send.
|
|
509
536
|
* @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`.
|
|
510
537
|
* @example
|
|
511
538
|
* ```ts
|
|
512
539
|
* const mailchannels = new MailChannels('your-api-key')
|
|
513
|
-
* const { success, data } = await mailchannels.emails.send({
|
|
540
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
514
541
|
* to: 'to@example.com',
|
|
515
542
|
* from: 'from@example.com',
|
|
516
543
|
* subject: 'Test',
|
|
@@ -519,13 +546,32 @@ declare class Emails {
|
|
|
519
546
|
* ```
|
|
520
547
|
*/
|
|
521
548
|
send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
|
|
549
|
+
/**
|
|
550
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
551
|
+
*
|
|
552
|
+
* 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.
|
|
553
|
+
*
|
|
554
|
+
* 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.
|
|
555
|
+
* @param options - The email options to send.
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
559
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
560
|
+
* to: 'to@example.com',
|
|
561
|
+
* from: 'from@example.com',
|
|
562
|
+
* subject: 'Test',
|
|
563
|
+
* html: 'Test'
|
|
564
|
+
* })
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
|
|
522
568
|
/**
|
|
523
569
|
* 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.
|
|
524
570
|
* @param options - The domain options to check.
|
|
525
571
|
* @example
|
|
526
572
|
* ```ts
|
|
527
573
|
* const mailchannels = new MailChannels('your-api-key')
|
|
528
|
-
* const {
|
|
574
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
529
575
|
* dkim: [{
|
|
530
576
|
* domain: 'example.com',
|
|
531
577
|
* privateKey: 'your-private-key',
|
|
@@ -595,13 +641,13 @@ declare class Emails {
|
|
|
595
641
|
rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
|
|
596
642
|
}
|
|
597
643
|
|
|
598
|
-
type WebhooksListResponse = DataResponse<string[]>;
|
|
644
|
+
type WebhooksListResponse = DataResponse$1<string[]>;
|
|
599
645
|
|
|
600
|
-
type WebhooksSigningKeyResponse = DataResponse<{
|
|
646
|
+
type WebhooksSigningKeyResponse = DataResponse$1<{
|
|
601
647
|
key: string;
|
|
602
648
|
}>;
|
|
603
649
|
|
|
604
|
-
type WebhooksValidateResponse = DataResponse<{
|
|
650
|
+
type WebhooksValidateResponse = DataResponse$1<{
|
|
605
651
|
/**
|
|
606
652
|
* Indicates whether all webhook validations passed.
|
|
607
653
|
*/
|
|
@@ -702,7 +748,7 @@ interface SubAccountsAccount {
|
|
|
702
748
|
handle: string;
|
|
703
749
|
}
|
|
704
750
|
|
|
705
|
-
type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
|
|
751
|
+
type SubAccountsCreateResponse = DataResponse$1<SubAccountsAccount>;
|
|
706
752
|
|
|
707
753
|
interface SubAccountsListOptions {
|
|
708
754
|
/**
|
|
@@ -717,7 +763,7 @@ interface SubAccountsListOptions {
|
|
|
717
763
|
offset?: number;
|
|
718
764
|
}
|
|
719
765
|
|
|
720
|
-
type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
|
|
766
|
+
type SubAccountsListResponse = DataResponse$1<SubAccountsAccount[]>;
|
|
721
767
|
|
|
722
768
|
interface SubAccountsApiKey {
|
|
723
769
|
/**
|
|
@@ -730,7 +776,7 @@ interface SubAccountsApiKey {
|
|
|
730
776
|
value: string;
|
|
731
777
|
}
|
|
732
778
|
|
|
733
|
-
type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
|
|
779
|
+
type SubAccountsCreateApiKeyResponse = DataResponse$1<SubAccountsApiKey>;
|
|
734
780
|
|
|
735
781
|
interface SubAccountsListApiKeyOptions {
|
|
736
782
|
/**
|
|
@@ -745,7 +791,7 @@ interface SubAccountsListApiKeyOptions {
|
|
|
745
791
|
offset?: number;
|
|
746
792
|
}
|
|
747
793
|
|
|
748
|
-
type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
|
|
794
|
+
type SubAccountsListApiKeyResponse = DataResponse$1<SubAccountsApiKey[]>;
|
|
749
795
|
|
|
750
796
|
interface SubAccountsSmtpPassword {
|
|
751
797
|
/**
|
|
@@ -762,15 +808,15 @@ interface SubAccountsSmtpPassword {
|
|
|
762
808
|
value: string;
|
|
763
809
|
}
|
|
764
810
|
|
|
765
|
-
type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
|
|
811
|
+
type SubAccountsCreateSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword>;
|
|
766
812
|
|
|
767
|
-
type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
|
|
813
|
+
type SubAccountsListSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword[]>;
|
|
768
814
|
|
|
769
815
|
interface SubAccountsLimit {
|
|
770
816
|
sends: number;
|
|
771
817
|
}
|
|
772
818
|
|
|
773
|
-
type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
|
|
819
|
+
type SubAccountsLimitResponse = DataResponse$1<SubAccountsLimit>;
|
|
774
820
|
|
|
775
821
|
interface SubAccountsUsage {
|
|
776
822
|
/**
|
|
@@ -789,7 +835,7 @@ interface SubAccountsUsage {
|
|
|
789
835
|
total: number;
|
|
790
836
|
}
|
|
791
837
|
|
|
792
|
-
type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
|
|
838
|
+
type SubAccountsUsageResponse = DataResponse$1<SubAccountsUsage>;
|
|
793
839
|
|
|
794
840
|
declare class SubAccounts {
|
|
795
841
|
protected mailchannels: MailChannelsClient;
|
|
@@ -970,7 +1016,7 @@ interface MetricsEngagement {
|
|
|
970
1016
|
startTime: string;
|
|
971
1017
|
}
|
|
972
1018
|
|
|
973
|
-
type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
|
|
1019
|
+
type MetricsEngagementResponse = DataResponse$1<MetricsEngagement>;
|
|
974
1020
|
|
|
975
1021
|
interface MetricsPerformance {
|
|
976
1022
|
/**
|
|
@@ -1003,7 +1049,7 @@ interface MetricsPerformance {
|
|
|
1003
1049
|
startTime: string;
|
|
1004
1050
|
}
|
|
1005
1051
|
|
|
1006
|
-
type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
|
|
1052
|
+
type MetricsPerformanceResponse = DataResponse$1<MetricsPerformance>;
|
|
1007
1053
|
|
|
1008
1054
|
interface MetricsRecipientBehaviour {
|
|
1009
1055
|
/**
|
|
@@ -1031,7 +1077,7 @@ interface MetricsRecipientBehaviour {
|
|
|
1031
1077
|
unsubscribed: number;
|
|
1032
1078
|
}
|
|
1033
1079
|
|
|
1034
|
-
type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
|
|
1080
|
+
type MetricsRecipientBehaviourResponse = DataResponse$1<MetricsRecipientBehaviour>;
|
|
1035
1081
|
|
|
1036
1082
|
interface MetricsVolume {
|
|
1037
1083
|
/**
|
|
@@ -1064,9 +1110,9 @@ interface MetricsVolume {
|
|
|
1064
1110
|
startTime: string;
|
|
1065
1111
|
}
|
|
1066
1112
|
|
|
1067
|
-
type MetricsVolumeResponse = DataResponse<MetricsVolume>;
|
|
1113
|
+
type MetricsVolumeResponse = DataResponse$1<MetricsVolume>;
|
|
1068
1114
|
|
|
1069
|
-
type MetricsUsageResponse = DataResponse<{
|
|
1115
|
+
type MetricsUsageResponse = DataResponse$1<{
|
|
1070
1116
|
/**
|
|
1071
1117
|
* The end date of the current billing period (ISO 8601 format).
|
|
1072
1118
|
* @example "2025-04-11"
|
|
@@ -1134,7 +1180,7 @@ interface MetricsSenders {
|
|
|
1134
1180
|
total: number;
|
|
1135
1181
|
}
|
|
1136
1182
|
|
|
1137
|
-
type MetricsSendersResponse = DataResponse<MetricsSenders>;
|
|
1183
|
+
type MetricsSendersResponse = DataResponse$1<MetricsSenders>;
|
|
1138
1184
|
|
|
1139
1185
|
interface MetricsBucket {
|
|
1140
1186
|
/**
|
|
@@ -1305,7 +1351,7 @@ interface SuppressionsListEntry {
|
|
|
1305
1351
|
types: SuppressionsTypes[];
|
|
1306
1352
|
}
|
|
1307
1353
|
|
|
1308
|
-
type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
|
|
1354
|
+
type SuppressionsListResponse = DataResponse$1<SuppressionsListEntry[]>;
|
|
1309
1355
|
|
|
1310
1356
|
declare class Suppressions {
|
|
1311
1357
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1363,9 +1409,9 @@ interface ListEntry {
|
|
|
1363
1409
|
type: "domain" | "email_address" | "ip_address";
|
|
1364
1410
|
}
|
|
1365
1411
|
|
|
1366
|
-
type ListEntryResponse = DataResponse<ListEntry>;
|
|
1412
|
+
type ListEntryResponse = DataResponse$1<ListEntry>;
|
|
1367
1413
|
|
|
1368
|
-
type ListEntriesResponse = DataResponse<ListEntry[]>;
|
|
1414
|
+
type ListEntriesResponse = DataResponse$1<ListEntry[]>;
|
|
1369
1415
|
|
|
1370
1416
|
interface DomainsData {
|
|
1371
1417
|
/**
|
|
@@ -1441,9 +1487,9 @@ interface DomainsProvisionOptions {
|
|
|
1441
1487
|
|
|
1442
1488
|
type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
|
|
1443
1489
|
|
|
1444
|
-
type DomainsProvisionResponse = DataResponse<DomainsData>;
|
|
1490
|
+
type DomainsProvisionResponse = DataResponse$1<DomainsData>;
|
|
1445
1491
|
|
|
1446
|
-
type DomainsBulkProvisionResponse = DataResponse<{
|
|
1492
|
+
type DomainsBulkProvisionResponse = DataResponse$1<{
|
|
1447
1493
|
/**
|
|
1448
1494
|
* Domains that were successfully provisioned or updated.
|
|
1449
1495
|
*/
|
|
@@ -1485,7 +1531,7 @@ interface DomainsListOptions {
|
|
|
1485
1531
|
offset?: number;
|
|
1486
1532
|
}
|
|
1487
1533
|
|
|
1488
|
-
type DomainsListResponse = DataResponse<{
|
|
1534
|
+
type DomainsListResponse = DataResponse$1<{
|
|
1489
1535
|
/**
|
|
1490
1536
|
* A list of domains.
|
|
1491
1537
|
*/
|
|
@@ -1503,7 +1549,7 @@ interface DomainsCreateLoginLink {
|
|
|
1503
1549
|
link: string;
|
|
1504
1550
|
}
|
|
1505
1551
|
|
|
1506
|
-
type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
|
|
1552
|
+
type DomainsCreateLoginLinkResponse = DataResponse$1<DomainsCreateLoginLink>;
|
|
1507
1553
|
|
|
1508
1554
|
interface DomainsListDownstreamAddressesOptions {
|
|
1509
1555
|
/**
|
|
@@ -1537,7 +1583,7 @@ interface DomainsDownstreamAddress {
|
|
|
1537
1583
|
weight: number;
|
|
1538
1584
|
}
|
|
1539
1585
|
|
|
1540
|
-
type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
|
|
1586
|
+
type DomainsListDownstreamAddressesResponse = DataResponse$1<DomainsDownstreamAddress[]>;
|
|
1541
1587
|
|
|
1542
1588
|
interface DomainsBulkCreateLoginLinkResult {
|
|
1543
1589
|
/**
|
|
@@ -1560,7 +1606,7 @@ interface DomainsBulkCreateLoginLinks {
|
|
|
1560
1606
|
errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
|
|
1561
1607
|
}
|
|
1562
1608
|
|
|
1563
|
-
type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
|
|
1609
|
+
type DomainsBulkCreateLoginLinksResponse = DataResponse$1<DomainsBulkCreateLoginLinks>;
|
|
1564
1610
|
|
|
1565
1611
|
declare class Domains {
|
|
1566
1612
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1784,7 +1830,7 @@ interface UsersCreateOptions {
|
|
|
1784
1830
|
};
|
|
1785
1831
|
}
|
|
1786
1832
|
|
|
1787
|
-
type UsersCreateResponse = DataResponse<{
|
|
1833
|
+
type UsersCreateResponse = DataResponse$1<{
|
|
1788
1834
|
email: string;
|
|
1789
1835
|
roles: string[];
|
|
1790
1836
|
filter?: boolean;
|
|
@@ -1852,7 +1898,7 @@ declare class Users {
|
|
|
1852
1898
|
deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
|
|
1853
1899
|
}
|
|
1854
1900
|
|
|
1855
|
-
type ServiceSubscriptionsResponse = DataResponse<{
|
|
1901
|
+
type ServiceSubscriptionsResponse = DataResponse$1<{
|
|
1856
1902
|
active: boolean;
|
|
1857
1903
|
activeAccountsCount: number;
|
|
1858
1904
|
handle: string;
|
|
@@ -1940,4 +1986,4 @@ declare class MailChannels extends MailChannelsClient {
|
|
|
1940
1986
|
}
|
|
1941
1987
|
|
|
1942
1988
|
export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
|
|
1943
|
-
export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, 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, Optional, 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 };
|
|
1989
|
+
export type { DataResponse$1 as DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, 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, Optional, 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 };
|
package/dist/mailchannels.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ interface SuccessResponse {
|
|
|
28
28
|
error: ErrorResponse | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
type DataResponse<T> = {
|
|
31
|
+
type DataResponse$1<T> = {
|
|
32
32
|
/**
|
|
33
33
|
* The response data.
|
|
34
34
|
*/
|
|
@@ -54,7 +54,7 @@ interface EmailsSendRecipient {
|
|
|
54
54
|
*/
|
|
55
55
|
email: string;
|
|
56
56
|
/**
|
|
57
|
-
* The name of the recipient.
|
|
57
|
+
* The name of the recipient. Display name in raw text, e.g. John Doe, εΌ δΈ.
|
|
58
58
|
*/
|
|
59
59
|
name?: string;
|
|
60
60
|
}
|
|
@@ -147,6 +147,16 @@ interface EmailsSendOptionsBase {
|
|
|
147
147
|
*/
|
|
148
148
|
selector: string;
|
|
149
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* 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.
|
|
152
|
+
* @example
|
|
153
|
+
* { email: 'email@example.com', name: 'Example' }
|
|
154
|
+
* @example
|
|
155
|
+
* 'email@example.com'
|
|
156
|
+
* @example
|
|
157
|
+
* 'Name <email@example.com>'
|
|
158
|
+
*/
|
|
159
|
+
envelopeFrom?: EmailsSendRecipient | string;
|
|
150
160
|
/**
|
|
151
161
|
* The sender of the email. Can be a string or an object with email and name properties.
|
|
152
162
|
* @example
|
|
@@ -185,6 +195,11 @@ interface EmailsSendOptionsBase {
|
|
|
185
195
|
to: EmailsSendRecipient[] | EmailsSendRecipient | string[] | string;
|
|
186
196
|
/**
|
|
187
197
|
* 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.
|
|
198
|
+
*
|
|
199
|
+
* Only links (`<a>` tags) meeting all of the following conditions are processed for click tracking:
|
|
200
|
+
* - The URL is non-empty.
|
|
201
|
+
* - The URL starts with `http` or `https`.
|
|
202
|
+
* - The link does not have a `clicktracking` attribute set to `off`.
|
|
188
203
|
*/
|
|
189
204
|
tracking?: EmailsSendTracking;
|
|
190
205
|
/**
|
|
@@ -252,35 +267,46 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
|
|
|
252
267
|
}
|
|
253
268
|
);
|
|
254
269
|
|
|
255
|
-
type EmailsSendResponse = SuccessResponse & DataResponse<{
|
|
270
|
+
type EmailsSendResponse = SuccessResponse & DataResponse$1<{
|
|
256
271
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
272
|
+
* Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
|
|
273
|
+
*/
|
|
259
274
|
rendered?: string[];
|
|
260
275
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
276
|
+
* 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.
|
|
277
|
+
*/
|
|
263
278
|
requestId?: string;
|
|
264
279
|
results?: {
|
|
265
280
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
281
|
+
* The index of the personalization in the request. Starts at 0.
|
|
282
|
+
*/
|
|
268
283
|
index?: number;
|
|
269
284
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
285
|
+
* 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.
|
|
286
|
+
*/
|
|
272
287
|
messageId: string;
|
|
273
288
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
289
|
+
* A human-readable explanation of the status.
|
|
290
|
+
*/
|
|
276
291
|
reason?: string;
|
|
277
292
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
293
|
+
* The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
|
|
294
|
+
*/
|
|
280
295
|
status: "sent" | "failed";
|
|
281
296
|
}[];
|
|
282
297
|
}>;
|
|
283
298
|
|
|
299
|
+
type EmailsSendAsyncResponse = DataResponse<{
|
|
300
|
+
/**
|
|
301
|
+
* ISO 8601 timestamp when the request was queued for processing.
|
|
302
|
+
*/
|
|
303
|
+
queuedAt: string[];
|
|
304
|
+
/**
|
|
305
|
+
* Unique identifier for tracking this async request. Will be included in all webhook events for this request.
|
|
306
|
+
*/
|
|
307
|
+
requestId: string;
|
|
308
|
+
}>;
|
|
309
|
+
|
|
284
310
|
interface EmailsCreateDkimKeyOptions {
|
|
285
311
|
/**
|
|
286
312
|
* Algorithm used for the new key pair Currently, only RSA is supported.
|
|
@@ -348,7 +374,7 @@ interface EmailsDkimKey {
|
|
|
348
374
|
statusModifiedAt?: string;
|
|
349
375
|
}
|
|
350
376
|
|
|
351
|
-
type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
|
|
377
|
+
type EmailsCreateDkimKeyResponse = DataResponse$1<EmailsDkimKey>;
|
|
352
378
|
|
|
353
379
|
interface EmailsCheckDomainDkim {
|
|
354
380
|
/**
|
|
@@ -388,7 +414,7 @@ interface EmailsCheckDomainOptions {
|
|
|
388
414
|
|
|
389
415
|
type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
|
|
390
416
|
|
|
391
|
-
type EmailsCheckDomainResponse = DataResponse<{
|
|
417
|
+
type EmailsCheckDomainResponse = DataResponse$1<{
|
|
392
418
|
dkim: {
|
|
393
419
|
domain: string;
|
|
394
420
|
/**
|
|
@@ -470,7 +496,7 @@ interface EmailsGetDkimKeysOptions {
|
|
|
470
496
|
|
|
471
497
|
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
472
498
|
|
|
473
|
-
type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
499
|
+
type EmailsGetDkimKeysResponse = DataResponse$1<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
474
500
|
|
|
475
501
|
interface EmailsUpdateDkimKeyOptions {
|
|
476
502
|
/**
|
|
@@ -495,7 +521,7 @@ interface EmailsRotateDkimKeyOptions {
|
|
|
495
521
|
};
|
|
496
522
|
}
|
|
497
523
|
|
|
498
|
-
type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
524
|
+
type EmailsRotateDkimKeyResponse = DataResponse$1<{
|
|
499
525
|
new: EmailsDkimKey;
|
|
500
526
|
rotated: EmailsDkimKey;
|
|
501
527
|
}>;
|
|
@@ -503,14 +529,15 @@ type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
|
503
529
|
declare class Emails {
|
|
504
530
|
protected mailchannels: MailChannelsClient;
|
|
505
531
|
constructor(mailchannels: MailChannelsClient);
|
|
532
|
+
private _sendEmail;
|
|
506
533
|
/**
|
|
507
|
-
*
|
|
534
|
+
* Sends an email message to one or more recipients.
|
|
508
535
|
* @param options - The email options to send.
|
|
509
536
|
* @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`.
|
|
510
537
|
* @example
|
|
511
538
|
* ```ts
|
|
512
539
|
* const mailchannels = new MailChannels('your-api-key')
|
|
513
|
-
* const { success, data } = await mailchannels.emails.send({
|
|
540
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
514
541
|
* to: 'to@example.com',
|
|
515
542
|
* from: 'from@example.com',
|
|
516
543
|
* subject: 'Test',
|
|
@@ -519,13 +546,32 @@ declare class Emails {
|
|
|
519
546
|
* ```
|
|
520
547
|
*/
|
|
521
548
|
send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
|
|
549
|
+
/**
|
|
550
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
551
|
+
*
|
|
552
|
+
* 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.
|
|
553
|
+
*
|
|
554
|
+
* 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.
|
|
555
|
+
* @param options - The email options to send.
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
559
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
560
|
+
* to: 'to@example.com',
|
|
561
|
+
* from: 'from@example.com',
|
|
562
|
+
* subject: 'Test',
|
|
563
|
+
* html: 'Test'
|
|
564
|
+
* })
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
|
|
522
568
|
/**
|
|
523
569
|
* 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.
|
|
524
570
|
* @param options - The domain options to check.
|
|
525
571
|
* @example
|
|
526
572
|
* ```ts
|
|
527
573
|
* const mailchannels = new MailChannels('your-api-key')
|
|
528
|
-
* const {
|
|
574
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
529
575
|
* dkim: [{
|
|
530
576
|
* domain: 'example.com',
|
|
531
577
|
* privateKey: 'your-private-key',
|
|
@@ -595,13 +641,13 @@ declare class Emails {
|
|
|
595
641
|
rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
|
|
596
642
|
}
|
|
597
643
|
|
|
598
|
-
type WebhooksListResponse = DataResponse<string[]>;
|
|
644
|
+
type WebhooksListResponse = DataResponse$1<string[]>;
|
|
599
645
|
|
|
600
|
-
type WebhooksSigningKeyResponse = DataResponse<{
|
|
646
|
+
type WebhooksSigningKeyResponse = DataResponse$1<{
|
|
601
647
|
key: string;
|
|
602
648
|
}>;
|
|
603
649
|
|
|
604
|
-
type WebhooksValidateResponse = DataResponse<{
|
|
650
|
+
type WebhooksValidateResponse = DataResponse$1<{
|
|
605
651
|
/**
|
|
606
652
|
* Indicates whether all webhook validations passed.
|
|
607
653
|
*/
|
|
@@ -702,7 +748,7 @@ interface SubAccountsAccount {
|
|
|
702
748
|
handle: string;
|
|
703
749
|
}
|
|
704
750
|
|
|
705
|
-
type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
|
|
751
|
+
type SubAccountsCreateResponse = DataResponse$1<SubAccountsAccount>;
|
|
706
752
|
|
|
707
753
|
interface SubAccountsListOptions {
|
|
708
754
|
/**
|
|
@@ -717,7 +763,7 @@ interface SubAccountsListOptions {
|
|
|
717
763
|
offset?: number;
|
|
718
764
|
}
|
|
719
765
|
|
|
720
|
-
type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
|
|
766
|
+
type SubAccountsListResponse = DataResponse$1<SubAccountsAccount[]>;
|
|
721
767
|
|
|
722
768
|
interface SubAccountsApiKey {
|
|
723
769
|
/**
|
|
@@ -730,7 +776,7 @@ interface SubAccountsApiKey {
|
|
|
730
776
|
value: string;
|
|
731
777
|
}
|
|
732
778
|
|
|
733
|
-
type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
|
|
779
|
+
type SubAccountsCreateApiKeyResponse = DataResponse$1<SubAccountsApiKey>;
|
|
734
780
|
|
|
735
781
|
interface SubAccountsListApiKeyOptions {
|
|
736
782
|
/**
|
|
@@ -745,7 +791,7 @@ interface SubAccountsListApiKeyOptions {
|
|
|
745
791
|
offset?: number;
|
|
746
792
|
}
|
|
747
793
|
|
|
748
|
-
type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
|
|
794
|
+
type SubAccountsListApiKeyResponse = DataResponse$1<SubAccountsApiKey[]>;
|
|
749
795
|
|
|
750
796
|
interface SubAccountsSmtpPassword {
|
|
751
797
|
/**
|
|
@@ -762,15 +808,15 @@ interface SubAccountsSmtpPassword {
|
|
|
762
808
|
value: string;
|
|
763
809
|
}
|
|
764
810
|
|
|
765
|
-
type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
|
|
811
|
+
type SubAccountsCreateSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword>;
|
|
766
812
|
|
|
767
|
-
type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
|
|
813
|
+
type SubAccountsListSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword[]>;
|
|
768
814
|
|
|
769
815
|
interface SubAccountsLimit {
|
|
770
816
|
sends: number;
|
|
771
817
|
}
|
|
772
818
|
|
|
773
|
-
type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
|
|
819
|
+
type SubAccountsLimitResponse = DataResponse$1<SubAccountsLimit>;
|
|
774
820
|
|
|
775
821
|
interface SubAccountsUsage {
|
|
776
822
|
/**
|
|
@@ -789,7 +835,7 @@ interface SubAccountsUsage {
|
|
|
789
835
|
total: number;
|
|
790
836
|
}
|
|
791
837
|
|
|
792
|
-
type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
|
|
838
|
+
type SubAccountsUsageResponse = DataResponse$1<SubAccountsUsage>;
|
|
793
839
|
|
|
794
840
|
declare class SubAccounts {
|
|
795
841
|
protected mailchannels: MailChannelsClient;
|
|
@@ -970,7 +1016,7 @@ interface MetricsEngagement {
|
|
|
970
1016
|
startTime: string;
|
|
971
1017
|
}
|
|
972
1018
|
|
|
973
|
-
type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
|
|
1019
|
+
type MetricsEngagementResponse = DataResponse$1<MetricsEngagement>;
|
|
974
1020
|
|
|
975
1021
|
interface MetricsPerformance {
|
|
976
1022
|
/**
|
|
@@ -1003,7 +1049,7 @@ interface MetricsPerformance {
|
|
|
1003
1049
|
startTime: string;
|
|
1004
1050
|
}
|
|
1005
1051
|
|
|
1006
|
-
type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
|
|
1052
|
+
type MetricsPerformanceResponse = DataResponse$1<MetricsPerformance>;
|
|
1007
1053
|
|
|
1008
1054
|
interface MetricsRecipientBehaviour {
|
|
1009
1055
|
/**
|
|
@@ -1031,7 +1077,7 @@ interface MetricsRecipientBehaviour {
|
|
|
1031
1077
|
unsubscribed: number;
|
|
1032
1078
|
}
|
|
1033
1079
|
|
|
1034
|
-
type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
|
|
1080
|
+
type MetricsRecipientBehaviourResponse = DataResponse$1<MetricsRecipientBehaviour>;
|
|
1035
1081
|
|
|
1036
1082
|
interface MetricsVolume {
|
|
1037
1083
|
/**
|
|
@@ -1064,9 +1110,9 @@ interface MetricsVolume {
|
|
|
1064
1110
|
startTime: string;
|
|
1065
1111
|
}
|
|
1066
1112
|
|
|
1067
|
-
type MetricsVolumeResponse = DataResponse<MetricsVolume>;
|
|
1113
|
+
type MetricsVolumeResponse = DataResponse$1<MetricsVolume>;
|
|
1068
1114
|
|
|
1069
|
-
type MetricsUsageResponse = DataResponse<{
|
|
1115
|
+
type MetricsUsageResponse = DataResponse$1<{
|
|
1070
1116
|
/**
|
|
1071
1117
|
* The end date of the current billing period (ISO 8601 format).
|
|
1072
1118
|
* @example "2025-04-11"
|
|
@@ -1134,7 +1180,7 @@ interface MetricsSenders {
|
|
|
1134
1180
|
total: number;
|
|
1135
1181
|
}
|
|
1136
1182
|
|
|
1137
|
-
type MetricsSendersResponse = DataResponse<MetricsSenders>;
|
|
1183
|
+
type MetricsSendersResponse = DataResponse$1<MetricsSenders>;
|
|
1138
1184
|
|
|
1139
1185
|
interface MetricsBucket {
|
|
1140
1186
|
/**
|
|
@@ -1305,7 +1351,7 @@ interface SuppressionsListEntry {
|
|
|
1305
1351
|
types: SuppressionsTypes[];
|
|
1306
1352
|
}
|
|
1307
1353
|
|
|
1308
|
-
type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
|
|
1354
|
+
type SuppressionsListResponse = DataResponse$1<SuppressionsListEntry[]>;
|
|
1309
1355
|
|
|
1310
1356
|
declare class Suppressions {
|
|
1311
1357
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1363,9 +1409,9 @@ interface ListEntry {
|
|
|
1363
1409
|
type: "domain" | "email_address" | "ip_address";
|
|
1364
1410
|
}
|
|
1365
1411
|
|
|
1366
|
-
type ListEntryResponse = DataResponse<ListEntry>;
|
|
1412
|
+
type ListEntryResponse = DataResponse$1<ListEntry>;
|
|
1367
1413
|
|
|
1368
|
-
type ListEntriesResponse = DataResponse<ListEntry[]>;
|
|
1414
|
+
type ListEntriesResponse = DataResponse$1<ListEntry[]>;
|
|
1369
1415
|
|
|
1370
1416
|
interface DomainsData {
|
|
1371
1417
|
/**
|
|
@@ -1441,9 +1487,9 @@ interface DomainsProvisionOptions {
|
|
|
1441
1487
|
|
|
1442
1488
|
type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
|
|
1443
1489
|
|
|
1444
|
-
type DomainsProvisionResponse = DataResponse<DomainsData>;
|
|
1490
|
+
type DomainsProvisionResponse = DataResponse$1<DomainsData>;
|
|
1445
1491
|
|
|
1446
|
-
type DomainsBulkProvisionResponse = DataResponse<{
|
|
1492
|
+
type DomainsBulkProvisionResponse = DataResponse$1<{
|
|
1447
1493
|
/**
|
|
1448
1494
|
* Domains that were successfully provisioned or updated.
|
|
1449
1495
|
*/
|
|
@@ -1485,7 +1531,7 @@ interface DomainsListOptions {
|
|
|
1485
1531
|
offset?: number;
|
|
1486
1532
|
}
|
|
1487
1533
|
|
|
1488
|
-
type DomainsListResponse = DataResponse<{
|
|
1534
|
+
type DomainsListResponse = DataResponse$1<{
|
|
1489
1535
|
/**
|
|
1490
1536
|
* A list of domains.
|
|
1491
1537
|
*/
|
|
@@ -1503,7 +1549,7 @@ interface DomainsCreateLoginLink {
|
|
|
1503
1549
|
link: string;
|
|
1504
1550
|
}
|
|
1505
1551
|
|
|
1506
|
-
type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
|
|
1552
|
+
type DomainsCreateLoginLinkResponse = DataResponse$1<DomainsCreateLoginLink>;
|
|
1507
1553
|
|
|
1508
1554
|
interface DomainsListDownstreamAddressesOptions {
|
|
1509
1555
|
/**
|
|
@@ -1537,7 +1583,7 @@ interface DomainsDownstreamAddress {
|
|
|
1537
1583
|
weight: number;
|
|
1538
1584
|
}
|
|
1539
1585
|
|
|
1540
|
-
type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
|
|
1586
|
+
type DomainsListDownstreamAddressesResponse = DataResponse$1<DomainsDownstreamAddress[]>;
|
|
1541
1587
|
|
|
1542
1588
|
interface DomainsBulkCreateLoginLinkResult {
|
|
1543
1589
|
/**
|
|
@@ -1560,7 +1606,7 @@ interface DomainsBulkCreateLoginLinks {
|
|
|
1560
1606
|
errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
|
|
1561
1607
|
}
|
|
1562
1608
|
|
|
1563
|
-
type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
|
|
1609
|
+
type DomainsBulkCreateLoginLinksResponse = DataResponse$1<DomainsBulkCreateLoginLinks>;
|
|
1564
1610
|
|
|
1565
1611
|
declare class Domains {
|
|
1566
1612
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1784,7 +1830,7 @@ interface UsersCreateOptions {
|
|
|
1784
1830
|
};
|
|
1785
1831
|
}
|
|
1786
1832
|
|
|
1787
|
-
type UsersCreateResponse = DataResponse<{
|
|
1833
|
+
type UsersCreateResponse = DataResponse$1<{
|
|
1788
1834
|
email: string;
|
|
1789
1835
|
roles: string[];
|
|
1790
1836
|
filter?: boolean;
|
|
@@ -1852,7 +1898,7 @@ declare class Users {
|
|
|
1852
1898
|
deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
|
|
1853
1899
|
}
|
|
1854
1900
|
|
|
1855
|
-
type ServiceSubscriptionsResponse = DataResponse<{
|
|
1901
|
+
type ServiceSubscriptionsResponse = DataResponse$1<{
|
|
1856
1902
|
active: boolean;
|
|
1857
1903
|
activeAccountsCount: number;
|
|
1858
1904
|
handle: string;
|
|
@@ -1940,4 +1986,4 @@ declare class MailChannels extends MailChannelsClient {
|
|
|
1940
1986
|
}
|
|
1941
1987
|
|
|
1942
1988
|
export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
|
|
1943
|
-
export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, 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, Optional, 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 };
|
|
1989
|
+
export type { DataResponse$1 as DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, 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, Optional, 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 };
|
package/dist/mailchannels.mjs
CHANGED
|
@@ -148,22 +148,7 @@ class Emails {
|
|
|
148
148
|
constructor(mailchannels) {
|
|
149
149
|
this.mailchannels = mailchannels;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
* Send an email using MailChannels Email API.
|
|
153
|
-
* @param options - The email options to send.
|
|
154
|
-
* @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`.
|
|
155
|
-
* @example
|
|
156
|
-
* ```ts
|
|
157
|
-
* const mailchannels = new MailChannels('your-api-key')
|
|
158
|
-
* const { success, data } = await mailchannels.emails.send({
|
|
159
|
-
* to: 'to@example.com',
|
|
160
|
-
* from: 'from@example.com',
|
|
161
|
-
* subject: 'Test',
|
|
162
|
-
* html: 'Test'
|
|
163
|
-
* })
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
async send(options, dryRun = false) {
|
|
151
|
+
async _sendEmail(options, flags) {
|
|
167
152
|
let error = null;
|
|
168
153
|
const { cc, bcc, from, to, html, text, mustaches, dkim } = options;
|
|
169
154
|
const parsedFrom = parseRecipient(from);
|
|
@@ -198,6 +183,7 @@ class Emails {
|
|
|
198
183
|
}],
|
|
199
184
|
headers: options.headers,
|
|
200
185
|
reply_to: parseRecipient(options.replyTo),
|
|
186
|
+
envelope_from: parseRecipient(options.envelopeFrom),
|
|
201
187
|
from: parsedFrom,
|
|
202
188
|
subject: options.subject,
|
|
203
189
|
content,
|
|
@@ -207,8 +193,9 @@ class Emails {
|
|
|
207
193
|
} : void 0,
|
|
208
194
|
transactional: options.transactional
|
|
209
195
|
};
|
|
210
|
-
const
|
|
211
|
-
|
|
196
|
+
const endpoint = flags.async ? "/tx/v1/send-async" : "/tx/v1/send";
|
|
197
|
+
const response = await this.mailchannels.post(endpoint, {
|
|
198
|
+
query: { "dry-run": flags.dryRun },
|
|
212
199
|
body: payload,
|
|
213
200
|
onResponseError: async ({ response: response2 }) => {
|
|
214
201
|
error = getStatusError(response2, {
|
|
@@ -218,14 +205,23 @@ class Emails {
|
|
|
218
205
|
});
|
|
219
206
|
}
|
|
220
207
|
}).catch((e) => {
|
|
221
|
-
error ||= getResultError(e, "Failed to send email.");
|
|
208
|
+
error ||= getResultError(e, flags.async ? "Failed to queue email." : "Failed to send email.");
|
|
222
209
|
return null;
|
|
223
210
|
});
|
|
224
211
|
if (!response) return { success: false, data: null, error };
|
|
212
|
+
if (flags.async) {
|
|
213
|
+
const asyncResponse = response;
|
|
214
|
+
const data2 = clean({
|
|
215
|
+
queuedAt: asyncResponse.queued_at,
|
|
216
|
+
requestId: asyncResponse.request_id
|
|
217
|
+
});
|
|
218
|
+
return { data: data2, error: null };
|
|
219
|
+
}
|
|
220
|
+
const syncResponse = response;
|
|
225
221
|
const data = clean({
|
|
226
|
-
rendered:
|
|
227
|
-
requestId:
|
|
228
|
-
results:
|
|
222
|
+
rendered: syncResponse.data,
|
|
223
|
+
requestId: syncResponse.request_id,
|
|
224
|
+
results: syncResponse.results?.map((result) => ({
|
|
229
225
|
index: result.index,
|
|
230
226
|
messageId: result.message_id,
|
|
231
227
|
reason: result.reason,
|
|
@@ -234,13 +230,52 @@ class Emails {
|
|
|
234
230
|
});
|
|
235
231
|
return { success: !!data, data, error: null };
|
|
236
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Sends an email message to one or more recipients.
|
|
235
|
+
* @param options - The email options to send.
|
|
236
|
+
* @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`.
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
240
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
241
|
+
* to: 'to@example.com',
|
|
242
|
+
* from: 'from@example.com',
|
|
243
|
+
* subject: 'Test',
|
|
244
|
+
* html: 'Test'
|
|
245
|
+
* })
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
async send(options, dryRun = false) {
|
|
249
|
+
return this._sendEmail(options, { dryRun });
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
253
|
+
*
|
|
254
|
+
* 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.
|
|
255
|
+
*
|
|
256
|
+
* 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.
|
|
257
|
+
* @param options - The email options to send.
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
261
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
262
|
+
* to: 'to@example.com',
|
|
263
|
+
* from: 'from@example.com',
|
|
264
|
+
* subject: 'Test',
|
|
265
|
+
* html: 'Test'
|
|
266
|
+
* })
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
async sendAsync(options) {
|
|
270
|
+
return this._sendEmail(options, { async: true });
|
|
271
|
+
}
|
|
237
272
|
/**
|
|
238
273
|
* 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.
|
|
239
274
|
* @param options - The domain options to check.
|
|
240
275
|
* @example
|
|
241
276
|
* ```ts
|
|
242
277
|
* const mailchannels = new MailChannels('your-api-key')
|
|
243
|
-
* const {
|
|
278
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
244
279
|
* dkim: [{
|
|
245
280
|
* domain: 'example.com',
|
|
246
281
|
* privateKey: 'your-private-key',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailchannels-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Node.js SDK to integrate MailChannels API into your JavaScript or TypeScript server-side applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"ofetch": "^2.0.0-alpha.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@eslint/compat": "^2.0.
|
|
41
|
-
"@stylistic/eslint-plugin": "^5.
|
|
40
|
+
"@eslint/compat": "^2.0.1",
|
|
41
|
+
"@stylistic/eslint-plugin": "^5.7.1",
|
|
42
42
|
"@types/markdown-it": "^14.1.2",
|
|
43
|
-
"@types/node": "^25.0.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
45
|
-
"@typescript-eslint/parser": "^8.
|
|
46
|
-
"@vitest/coverage-v8": "^4.0.
|
|
43
|
+
"@types/node": "^25.0.10",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
45
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
46
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
47
47
|
"changelogen": "^0.6.2",
|
|
48
48
|
"eslint": "^9.39.2",
|
|
49
49
|
"eslint-plugin-import-x": "^4.16.1",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"scule": "^1.3.0",
|
|
52
52
|
"typescript": "^5.9.3",
|
|
53
53
|
"unbuild": "^3.6.1",
|
|
54
|
-
"vitepress": "^
|
|
55
|
-
"vitepress-plugin-group-icons": "^1.
|
|
56
|
-
"vitepress-plugin-llms": "^1.
|
|
57
|
-
"vitest": "^4.0.
|
|
54
|
+
"vitepress": "^v2.0.0-alpha.15",
|
|
55
|
+
"vitepress-plugin-group-icons": "^1.7.1",
|
|
56
|
+
"vitepress-plugin-llms": "^1.10.0",
|
|
57
|
+
"vitest": "^4.0.18"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "unbuild",
|