mailchannels-sdk 0.7.0 → 0.7.1
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 +81 -50
- package/dist/mailchannels.d.ts +81 -50
- package/dist/mailchannels.mjs +57 -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
|
*/
|
|
@@ -252,35 +252,46 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
|
|
|
252
252
|
}
|
|
253
253
|
);
|
|
254
254
|
|
|
255
|
-
type EmailsSendResponse = SuccessResponse & DataResponse<{
|
|
255
|
+
type EmailsSendResponse = SuccessResponse & DataResponse$1<{
|
|
256
256
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
* Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
|
|
258
|
+
*/
|
|
259
259
|
rendered?: string[];
|
|
260
260
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
* 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.
|
|
262
|
+
*/
|
|
263
263
|
requestId?: string;
|
|
264
264
|
results?: {
|
|
265
265
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
* The index of the personalization in the request. Starts at 0.
|
|
267
|
+
*/
|
|
268
268
|
index?: number;
|
|
269
269
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
* 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.
|
|
271
|
+
*/
|
|
272
272
|
messageId: string;
|
|
273
273
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
* A human-readable explanation of the status.
|
|
275
|
+
*/
|
|
276
276
|
reason?: string;
|
|
277
277
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
* The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
|
|
279
|
+
*/
|
|
280
280
|
status: "sent" | "failed";
|
|
281
281
|
}[];
|
|
282
282
|
}>;
|
|
283
283
|
|
|
284
|
+
type EmailsSendAsyncResponse = DataResponse<{
|
|
285
|
+
/**
|
|
286
|
+
* ISO 8601 timestamp when the request was queued for processing.
|
|
287
|
+
*/
|
|
288
|
+
queuedAt: string[];
|
|
289
|
+
/**
|
|
290
|
+
* Unique identifier for tracking this async request. Will be included in all webhook events for this request.
|
|
291
|
+
*/
|
|
292
|
+
requestId: string;
|
|
293
|
+
}>;
|
|
294
|
+
|
|
284
295
|
interface EmailsCreateDkimKeyOptions {
|
|
285
296
|
/**
|
|
286
297
|
* Algorithm used for the new key pair Currently, only RSA is supported.
|
|
@@ -348,7 +359,7 @@ interface EmailsDkimKey {
|
|
|
348
359
|
statusModifiedAt?: string;
|
|
349
360
|
}
|
|
350
361
|
|
|
351
|
-
type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
|
|
362
|
+
type EmailsCreateDkimKeyResponse = DataResponse$1<EmailsDkimKey>;
|
|
352
363
|
|
|
353
364
|
interface EmailsCheckDomainDkim {
|
|
354
365
|
/**
|
|
@@ -388,7 +399,7 @@ interface EmailsCheckDomainOptions {
|
|
|
388
399
|
|
|
389
400
|
type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
|
|
390
401
|
|
|
391
|
-
type EmailsCheckDomainResponse = DataResponse<{
|
|
402
|
+
type EmailsCheckDomainResponse = DataResponse$1<{
|
|
392
403
|
dkim: {
|
|
393
404
|
domain: string;
|
|
394
405
|
/**
|
|
@@ -470,7 +481,7 @@ interface EmailsGetDkimKeysOptions {
|
|
|
470
481
|
|
|
471
482
|
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
472
483
|
|
|
473
|
-
type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
484
|
+
type EmailsGetDkimKeysResponse = DataResponse$1<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
474
485
|
|
|
475
486
|
interface EmailsUpdateDkimKeyOptions {
|
|
476
487
|
/**
|
|
@@ -495,7 +506,7 @@ interface EmailsRotateDkimKeyOptions {
|
|
|
495
506
|
};
|
|
496
507
|
}
|
|
497
508
|
|
|
498
|
-
type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
509
|
+
type EmailsRotateDkimKeyResponse = DataResponse$1<{
|
|
499
510
|
new: EmailsDkimKey;
|
|
500
511
|
rotated: EmailsDkimKey;
|
|
501
512
|
}>;
|
|
@@ -503,14 +514,15 @@ type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
|
503
514
|
declare class Emails {
|
|
504
515
|
protected mailchannels: MailChannelsClient;
|
|
505
516
|
constructor(mailchannels: MailChannelsClient);
|
|
517
|
+
private _sendEmail;
|
|
506
518
|
/**
|
|
507
|
-
*
|
|
519
|
+
* Sends an email message to one or more recipients.
|
|
508
520
|
* @param options - The email options to send.
|
|
509
521
|
* @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
522
|
* @example
|
|
511
523
|
* ```ts
|
|
512
524
|
* const mailchannels = new MailChannels('your-api-key')
|
|
513
|
-
* const { success, data } = await mailchannels.emails.send({
|
|
525
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
514
526
|
* to: 'to@example.com',
|
|
515
527
|
* from: 'from@example.com',
|
|
516
528
|
* subject: 'Test',
|
|
@@ -519,13 +531,32 @@ declare class Emails {
|
|
|
519
531
|
* ```
|
|
520
532
|
*/
|
|
521
533
|
send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
|
|
534
|
+
/**
|
|
535
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
536
|
+
*
|
|
537
|
+
* 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.
|
|
538
|
+
*
|
|
539
|
+
* 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.
|
|
540
|
+
* @param options - The email options to send.
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
544
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
545
|
+
* to: 'to@example.com',
|
|
546
|
+
* from: 'from@example.com',
|
|
547
|
+
* subject: 'Test',
|
|
548
|
+
* html: 'Test'
|
|
549
|
+
* })
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
|
|
522
553
|
/**
|
|
523
554
|
* 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
555
|
* @param options - The domain options to check.
|
|
525
556
|
* @example
|
|
526
557
|
* ```ts
|
|
527
558
|
* const mailchannels = new MailChannels('your-api-key')
|
|
528
|
-
* const {
|
|
559
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
529
560
|
* dkim: [{
|
|
530
561
|
* domain: 'example.com',
|
|
531
562
|
* privateKey: 'your-private-key',
|
|
@@ -595,13 +626,13 @@ declare class Emails {
|
|
|
595
626
|
rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
|
|
596
627
|
}
|
|
597
628
|
|
|
598
|
-
type WebhooksListResponse = DataResponse<string[]>;
|
|
629
|
+
type WebhooksListResponse = DataResponse$1<string[]>;
|
|
599
630
|
|
|
600
|
-
type WebhooksSigningKeyResponse = DataResponse<{
|
|
631
|
+
type WebhooksSigningKeyResponse = DataResponse$1<{
|
|
601
632
|
key: string;
|
|
602
633
|
}>;
|
|
603
634
|
|
|
604
|
-
type WebhooksValidateResponse = DataResponse<{
|
|
635
|
+
type WebhooksValidateResponse = DataResponse$1<{
|
|
605
636
|
/**
|
|
606
637
|
* Indicates whether all webhook validations passed.
|
|
607
638
|
*/
|
|
@@ -702,7 +733,7 @@ interface SubAccountsAccount {
|
|
|
702
733
|
handle: string;
|
|
703
734
|
}
|
|
704
735
|
|
|
705
|
-
type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
|
|
736
|
+
type SubAccountsCreateResponse = DataResponse$1<SubAccountsAccount>;
|
|
706
737
|
|
|
707
738
|
interface SubAccountsListOptions {
|
|
708
739
|
/**
|
|
@@ -717,7 +748,7 @@ interface SubAccountsListOptions {
|
|
|
717
748
|
offset?: number;
|
|
718
749
|
}
|
|
719
750
|
|
|
720
|
-
type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
|
|
751
|
+
type SubAccountsListResponse = DataResponse$1<SubAccountsAccount[]>;
|
|
721
752
|
|
|
722
753
|
interface SubAccountsApiKey {
|
|
723
754
|
/**
|
|
@@ -730,7 +761,7 @@ interface SubAccountsApiKey {
|
|
|
730
761
|
value: string;
|
|
731
762
|
}
|
|
732
763
|
|
|
733
|
-
type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
|
|
764
|
+
type SubAccountsCreateApiKeyResponse = DataResponse$1<SubAccountsApiKey>;
|
|
734
765
|
|
|
735
766
|
interface SubAccountsListApiKeyOptions {
|
|
736
767
|
/**
|
|
@@ -745,7 +776,7 @@ interface SubAccountsListApiKeyOptions {
|
|
|
745
776
|
offset?: number;
|
|
746
777
|
}
|
|
747
778
|
|
|
748
|
-
type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
|
|
779
|
+
type SubAccountsListApiKeyResponse = DataResponse$1<SubAccountsApiKey[]>;
|
|
749
780
|
|
|
750
781
|
interface SubAccountsSmtpPassword {
|
|
751
782
|
/**
|
|
@@ -762,15 +793,15 @@ interface SubAccountsSmtpPassword {
|
|
|
762
793
|
value: string;
|
|
763
794
|
}
|
|
764
795
|
|
|
765
|
-
type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
|
|
796
|
+
type SubAccountsCreateSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword>;
|
|
766
797
|
|
|
767
|
-
type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
|
|
798
|
+
type SubAccountsListSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword[]>;
|
|
768
799
|
|
|
769
800
|
interface SubAccountsLimit {
|
|
770
801
|
sends: number;
|
|
771
802
|
}
|
|
772
803
|
|
|
773
|
-
type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
|
|
804
|
+
type SubAccountsLimitResponse = DataResponse$1<SubAccountsLimit>;
|
|
774
805
|
|
|
775
806
|
interface SubAccountsUsage {
|
|
776
807
|
/**
|
|
@@ -789,7 +820,7 @@ interface SubAccountsUsage {
|
|
|
789
820
|
total: number;
|
|
790
821
|
}
|
|
791
822
|
|
|
792
|
-
type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
|
|
823
|
+
type SubAccountsUsageResponse = DataResponse$1<SubAccountsUsage>;
|
|
793
824
|
|
|
794
825
|
declare class SubAccounts {
|
|
795
826
|
protected mailchannels: MailChannelsClient;
|
|
@@ -970,7 +1001,7 @@ interface MetricsEngagement {
|
|
|
970
1001
|
startTime: string;
|
|
971
1002
|
}
|
|
972
1003
|
|
|
973
|
-
type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
|
|
1004
|
+
type MetricsEngagementResponse = DataResponse$1<MetricsEngagement>;
|
|
974
1005
|
|
|
975
1006
|
interface MetricsPerformance {
|
|
976
1007
|
/**
|
|
@@ -1003,7 +1034,7 @@ interface MetricsPerformance {
|
|
|
1003
1034
|
startTime: string;
|
|
1004
1035
|
}
|
|
1005
1036
|
|
|
1006
|
-
type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
|
|
1037
|
+
type MetricsPerformanceResponse = DataResponse$1<MetricsPerformance>;
|
|
1007
1038
|
|
|
1008
1039
|
interface MetricsRecipientBehaviour {
|
|
1009
1040
|
/**
|
|
@@ -1031,7 +1062,7 @@ interface MetricsRecipientBehaviour {
|
|
|
1031
1062
|
unsubscribed: number;
|
|
1032
1063
|
}
|
|
1033
1064
|
|
|
1034
|
-
type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
|
|
1065
|
+
type MetricsRecipientBehaviourResponse = DataResponse$1<MetricsRecipientBehaviour>;
|
|
1035
1066
|
|
|
1036
1067
|
interface MetricsVolume {
|
|
1037
1068
|
/**
|
|
@@ -1064,9 +1095,9 @@ interface MetricsVolume {
|
|
|
1064
1095
|
startTime: string;
|
|
1065
1096
|
}
|
|
1066
1097
|
|
|
1067
|
-
type MetricsVolumeResponse = DataResponse<MetricsVolume>;
|
|
1098
|
+
type MetricsVolumeResponse = DataResponse$1<MetricsVolume>;
|
|
1068
1099
|
|
|
1069
|
-
type MetricsUsageResponse = DataResponse<{
|
|
1100
|
+
type MetricsUsageResponse = DataResponse$1<{
|
|
1070
1101
|
/**
|
|
1071
1102
|
* The end date of the current billing period (ISO 8601 format).
|
|
1072
1103
|
* @example "2025-04-11"
|
|
@@ -1134,7 +1165,7 @@ interface MetricsSenders {
|
|
|
1134
1165
|
total: number;
|
|
1135
1166
|
}
|
|
1136
1167
|
|
|
1137
|
-
type MetricsSendersResponse = DataResponse<MetricsSenders>;
|
|
1168
|
+
type MetricsSendersResponse = DataResponse$1<MetricsSenders>;
|
|
1138
1169
|
|
|
1139
1170
|
interface MetricsBucket {
|
|
1140
1171
|
/**
|
|
@@ -1305,7 +1336,7 @@ interface SuppressionsListEntry {
|
|
|
1305
1336
|
types: SuppressionsTypes[];
|
|
1306
1337
|
}
|
|
1307
1338
|
|
|
1308
|
-
type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
|
|
1339
|
+
type SuppressionsListResponse = DataResponse$1<SuppressionsListEntry[]>;
|
|
1309
1340
|
|
|
1310
1341
|
declare class Suppressions {
|
|
1311
1342
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1363,9 +1394,9 @@ interface ListEntry {
|
|
|
1363
1394
|
type: "domain" | "email_address" | "ip_address";
|
|
1364
1395
|
}
|
|
1365
1396
|
|
|
1366
|
-
type ListEntryResponse = DataResponse<ListEntry>;
|
|
1397
|
+
type ListEntryResponse = DataResponse$1<ListEntry>;
|
|
1367
1398
|
|
|
1368
|
-
type ListEntriesResponse = DataResponse<ListEntry[]>;
|
|
1399
|
+
type ListEntriesResponse = DataResponse$1<ListEntry[]>;
|
|
1369
1400
|
|
|
1370
1401
|
interface DomainsData {
|
|
1371
1402
|
/**
|
|
@@ -1441,9 +1472,9 @@ interface DomainsProvisionOptions {
|
|
|
1441
1472
|
|
|
1442
1473
|
type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
|
|
1443
1474
|
|
|
1444
|
-
type DomainsProvisionResponse = DataResponse<DomainsData>;
|
|
1475
|
+
type DomainsProvisionResponse = DataResponse$1<DomainsData>;
|
|
1445
1476
|
|
|
1446
|
-
type DomainsBulkProvisionResponse = DataResponse<{
|
|
1477
|
+
type DomainsBulkProvisionResponse = DataResponse$1<{
|
|
1447
1478
|
/**
|
|
1448
1479
|
* Domains that were successfully provisioned or updated.
|
|
1449
1480
|
*/
|
|
@@ -1485,7 +1516,7 @@ interface DomainsListOptions {
|
|
|
1485
1516
|
offset?: number;
|
|
1486
1517
|
}
|
|
1487
1518
|
|
|
1488
|
-
type DomainsListResponse = DataResponse<{
|
|
1519
|
+
type DomainsListResponse = DataResponse$1<{
|
|
1489
1520
|
/**
|
|
1490
1521
|
* A list of domains.
|
|
1491
1522
|
*/
|
|
@@ -1503,7 +1534,7 @@ interface DomainsCreateLoginLink {
|
|
|
1503
1534
|
link: string;
|
|
1504
1535
|
}
|
|
1505
1536
|
|
|
1506
|
-
type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
|
|
1537
|
+
type DomainsCreateLoginLinkResponse = DataResponse$1<DomainsCreateLoginLink>;
|
|
1507
1538
|
|
|
1508
1539
|
interface DomainsListDownstreamAddressesOptions {
|
|
1509
1540
|
/**
|
|
@@ -1537,7 +1568,7 @@ interface DomainsDownstreamAddress {
|
|
|
1537
1568
|
weight: number;
|
|
1538
1569
|
}
|
|
1539
1570
|
|
|
1540
|
-
type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
|
|
1571
|
+
type DomainsListDownstreamAddressesResponse = DataResponse$1<DomainsDownstreamAddress[]>;
|
|
1541
1572
|
|
|
1542
1573
|
interface DomainsBulkCreateLoginLinkResult {
|
|
1543
1574
|
/**
|
|
@@ -1560,7 +1591,7 @@ interface DomainsBulkCreateLoginLinks {
|
|
|
1560
1591
|
errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
|
|
1561
1592
|
}
|
|
1562
1593
|
|
|
1563
|
-
type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
|
|
1594
|
+
type DomainsBulkCreateLoginLinksResponse = DataResponse$1<DomainsBulkCreateLoginLinks>;
|
|
1564
1595
|
|
|
1565
1596
|
declare class Domains {
|
|
1566
1597
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1784,7 +1815,7 @@ interface UsersCreateOptions {
|
|
|
1784
1815
|
};
|
|
1785
1816
|
}
|
|
1786
1817
|
|
|
1787
|
-
type UsersCreateResponse = DataResponse<{
|
|
1818
|
+
type UsersCreateResponse = DataResponse$1<{
|
|
1788
1819
|
email: string;
|
|
1789
1820
|
roles: string[];
|
|
1790
1821
|
filter?: boolean;
|
|
@@ -1852,7 +1883,7 @@ declare class Users {
|
|
|
1852
1883
|
deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
|
|
1853
1884
|
}
|
|
1854
1885
|
|
|
1855
|
-
type ServiceSubscriptionsResponse = DataResponse<{
|
|
1886
|
+
type ServiceSubscriptionsResponse = DataResponse$1<{
|
|
1856
1887
|
active: boolean;
|
|
1857
1888
|
activeAccountsCount: number;
|
|
1858
1889
|
handle: string;
|
|
@@ -1940,4 +1971,4 @@ declare class MailChannels extends MailChannelsClient {
|
|
|
1940
1971
|
}
|
|
1941
1972
|
|
|
1942
1973
|
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 };
|
|
1974
|
+
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
|
*/
|
|
@@ -252,35 +252,46 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
|
|
|
252
252
|
}
|
|
253
253
|
);
|
|
254
254
|
|
|
255
|
-
type EmailsSendResponse = SuccessResponse & DataResponse<{
|
|
255
|
+
type EmailsSendResponse = SuccessResponse & DataResponse$1<{
|
|
256
256
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
* Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
|
|
258
|
+
*/
|
|
259
259
|
rendered?: string[];
|
|
260
260
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
* 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.
|
|
262
|
+
*/
|
|
263
263
|
requestId?: string;
|
|
264
264
|
results?: {
|
|
265
265
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
* The index of the personalization in the request. Starts at 0.
|
|
267
|
+
*/
|
|
268
268
|
index?: number;
|
|
269
269
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
* 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.
|
|
271
|
+
*/
|
|
272
272
|
messageId: string;
|
|
273
273
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
* A human-readable explanation of the status.
|
|
275
|
+
*/
|
|
276
276
|
reason?: string;
|
|
277
277
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
* The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
|
|
279
|
+
*/
|
|
280
280
|
status: "sent" | "failed";
|
|
281
281
|
}[];
|
|
282
282
|
}>;
|
|
283
283
|
|
|
284
|
+
type EmailsSendAsyncResponse = DataResponse<{
|
|
285
|
+
/**
|
|
286
|
+
* ISO 8601 timestamp when the request was queued for processing.
|
|
287
|
+
*/
|
|
288
|
+
queuedAt: string[];
|
|
289
|
+
/**
|
|
290
|
+
* Unique identifier for tracking this async request. Will be included in all webhook events for this request.
|
|
291
|
+
*/
|
|
292
|
+
requestId: string;
|
|
293
|
+
}>;
|
|
294
|
+
|
|
284
295
|
interface EmailsCreateDkimKeyOptions {
|
|
285
296
|
/**
|
|
286
297
|
* Algorithm used for the new key pair Currently, only RSA is supported.
|
|
@@ -348,7 +359,7 @@ interface EmailsDkimKey {
|
|
|
348
359
|
statusModifiedAt?: string;
|
|
349
360
|
}
|
|
350
361
|
|
|
351
|
-
type EmailsCreateDkimKeyResponse = DataResponse<EmailsDkimKey>;
|
|
362
|
+
type EmailsCreateDkimKeyResponse = DataResponse$1<EmailsDkimKey>;
|
|
352
363
|
|
|
353
364
|
interface EmailsCheckDomainDkim {
|
|
354
365
|
/**
|
|
@@ -388,7 +399,7 @@ interface EmailsCheckDomainOptions {
|
|
|
388
399
|
|
|
389
400
|
type EmailsCheckDomainVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown";
|
|
390
401
|
|
|
391
|
-
type EmailsCheckDomainResponse = DataResponse<{
|
|
402
|
+
type EmailsCheckDomainResponse = DataResponse$1<{
|
|
392
403
|
dkim: {
|
|
393
404
|
domain: string;
|
|
394
405
|
/**
|
|
@@ -470,7 +481,7 @@ interface EmailsGetDkimKeysOptions {
|
|
|
470
481
|
|
|
471
482
|
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
472
483
|
|
|
473
|
-
type EmailsGetDkimKeysResponse = DataResponse<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
484
|
+
type EmailsGetDkimKeysResponse = DataResponse$1<Optional<EmailsDkimKey, "dnsRecords">[]>;
|
|
474
485
|
|
|
475
486
|
interface EmailsUpdateDkimKeyOptions {
|
|
476
487
|
/**
|
|
@@ -495,7 +506,7 @@ interface EmailsRotateDkimKeyOptions {
|
|
|
495
506
|
};
|
|
496
507
|
}
|
|
497
508
|
|
|
498
|
-
type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
509
|
+
type EmailsRotateDkimKeyResponse = DataResponse$1<{
|
|
499
510
|
new: EmailsDkimKey;
|
|
500
511
|
rotated: EmailsDkimKey;
|
|
501
512
|
}>;
|
|
@@ -503,14 +514,15 @@ type EmailsRotateDkimKeyResponse = DataResponse<{
|
|
|
503
514
|
declare class Emails {
|
|
504
515
|
protected mailchannels: MailChannelsClient;
|
|
505
516
|
constructor(mailchannels: MailChannelsClient);
|
|
517
|
+
private _sendEmail;
|
|
506
518
|
/**
|
|
507
|
-
*
|
|
519
|
+
* Sends an email message to one or more recipients.
|
|
508
520
|
* @param options - The email options to send.
|
|
509
521
|
* @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
522
|
* @example
|
|
511
523
|
* ```ts
|
|
512
524
|
* const mailchannels = new MailChannels('your-api-key')
|
|
513
|
-
* const { success, data } = await mailchannels.emails.send({
|
|
525
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
514
526
|
* to: 'to@example.com',
|
|
515
527
|
* from: 'from@example.com',
|
|
516
528
|
* subject: 'Test',
|
|
@@ -519,13 +531,32 @@ declare class Emails {
|
|
|
519
531
|
* ```
|
|
520
532
|
*/
|
|
521
533
|
send(options: EmailsSendOptions, dryRun?: boolean): Promise<EmailsSendResponse>;
|
|
534
|
+
/**
|
|
535
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
536
|
+
*
|
|
537
|
+
* 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.
|
|
538
|
+
*
|
|
539
|
+
* 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.
|
|
540
|
+
* @param options - The email options to send.
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
544
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
545
|
+
* to: 'to@example.com',
|
|
546
|
+
* from: 'from@example.com',
|
|
547
|
+
* subject: 'Test',
|
|
548
|
+
* html: 'Test'
|
|
549
|
+
* })
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
sendAsync(options: EmailsSendOptions): Promise<EmailsSendAsyncResponse>;
|
|
522
553
|
/**
|
|
523
554
|
* 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
555
|
* @param options - The domain options to check.
|
|
525
556
|
* @example
|
|
526
557
|
* ```ts
|
|
527
558
|
* const mailchannels = new MailChannels('your-api-key')
|
|
528
|
-
* const {
|
|
559
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
529
560
|
* dkim: [{
|
|
530
561
|
* domain: 'example.com',
|
|
531
562
|
* privateKey: 'your-private-key',
|
|
@@ -595,13 +626,13 @@ declare class Emails {
|
|
|
595
626
|
rotateDkimKey(domain: string, selector: string, options: EmailsRotateDkimKeyOptions): Promise<EmailsRotateDkimKeyResponse>;
|
|
596
627
|
}
|
|
597
628
|
|
|
598
|
-
type WebhooksListResponse = DataResponse<string[]>;
|
|
629
|
+
type WebhooksListResponse = DataResponse$1<string[]>;
|
|
599
630
|
|
|
600
|
-
type WebhooksSigningKeyResponse = DataResponse<{
|
|
631
|
+
type WebhooksSigningKeyResponse = DataResponse$1<{
|
|
601
632
|
key: string;
|
|
602
633
|
}>;
|
|
603
634
|
|
|
604
|
-
type WebhooksValidateResponse = DataResponse<{
|
|
635
|
+
type WebhooksValidateResponse = DataResponse$1<{
|
|
605
636
|
/**
|
|
606
637
|
* Indicates whether all webhook validations passed.
|
|
607
638
|
*/
|
|
@@ -702,7 +733,7 @@ interface SubAccountsAccount {
|
|
|
702
733
|
handle: string;
|
|
703
734
|
}
|
|
704
735
|
|
|
705
|
-
type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;
|
|
736
|
+
type SubAccountsCreateResponse = DataResponse$1<SubAccountsAccount>;
|
|
706
737
|
|
|
707
738
|
interface SubAccountsListOptions {
|
|
708
739
|
/**
|
|
@@ -717,7 +748,7 @@ interface SubAccountsListOptions {
|
|
|
717
748
|
offset?: number;
|
|
718
749
|
}
|
|
719
750
|
|
|
720
|
-
type SubAccountsListResponse = DataResponse<SubAccountsAccount[]>;
|
|
751
|
+
type SubAccountsListResponse = DataResponse$1<SubAccountsAccount[]>;
|
|
721
752
|
|
|
722
753
|
interface SubAccountsApiKey {
|
|
723
754
|
/**
|
|
@@ -730,7 +761,7 @@ interface SubAccountsApiKey {
|
|
|
730
761
|
value: string;
|
|
731
762
|
}
|
|
732
763
|
|
|
733
|
-
type SubAccountsCreateApiKeyResponse = DataResponse<SubAccountsApiKey>;
|
|
764
|
+
type SubAccountsCreateApiKeyResponse = DataResponse$1<SubAccountsApiKey>;
|
|
734
765
|
|
|
735
766
|
interface SubAccountsListApiKeyOptions {
|
|
736
767
|
/**
|
|
@@ -745,7 +776,7 @@ interface SubAccountsListApiKeyOptions {
|
|
|
745
776
|
offset?: number;
|
|
746
777
|
}
|
|
747
778
|
|
|
748
|
-
type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;
|
|
779
|
+
type SubAccountsListApiKeyResponse = DataResponse$1<SubAccountsApiKey[]>;
|
|
749
780
|
|
|
750
781
|
interface SubAccountsSmtpPassword {
|
|
751
782
|
/**
|
|
@@ -762,15 +793,15 @@ interface SubAccountsSmtpPassword {
|
|
|
762
793
|
value: string;
|
|
763
794
|
}
|
|
764
795
|
|
|
765
|
-
type SubAccountsCreateSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword>;
|
|
796
|
+
type SubAccountsCreateSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword>;
|
|
766
797
|
|
|
767
|
-
type SubAccountsListSmtpPasswordResponse = DataResponse<SubAccountsSmtpPassword[]>;
|
|
798
|
+
type SubAccountsListSmtpPasswordResponse = DataResponse$1<SubAccountsSmtpPassword[]>;
|
|
768
799
|
|
|
769
800
|
interface SubAccountsLimit {
|
|
770
801
|
sends: number;
|
|
771
802
|
}
|
|
772
803
|
|
|
773
|
-
type SubAccountsLimitResponse = DataResponse<SubAccountsLimit>;
|
|
804
|
+
type SubAccountsLimitResponse = DataResponse$1<SubAccountsLimit>;
|
|
774
805
|
|
|
775
806
|
interface SubAccountsUsage {
|
|
776
807
|
/**
|
|
@@ -789,7 +820,7 @@ interface SubAccountsUsage {
|
|
|
789
820
|
total: number;
|
|
790
821
|
}
|
|
791
822
|
|
|
792
|
-
type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;
|
|
823
|
+
type SubAccountsUsageResponse = DataResponse$1<SubAccountsUsage>;
|
|
793
824
|
|
|
794
825
|
declare class SubAccounts {
|
|
795
826
|
protected mailchannels: MailChannelsClient;
|
|
@@ -970,7 +1001,7 @@ interface MetricsEngagement {
|
|
|
970
1001
|
startTime: string;
|
|
971
1002
|
}
|
|
972
1003
|
|
|
973
|
-
type MetricsEngagementResponse = DataResponse<MetricsEngagement>;
|
|
1004
|
+
type MetricsEngagementResponse = DataResponse$1<MetricsEngagement>;
|
|
974
1005
|
|
|
975
1006
|
interface MetricsPerformance {
|
|
976
1007
|
/**
|
|
@@ -1003,7 +1034,7 @@ interface MetricsPerformance {
|
|
|
1003
1034
|
startTime: string;
|
|
1004
1035
|
}
|
|
1005
1036
|
|
|
1006
|
-
type MetricsPerformanceResponse = DataResponse<MetricsPerformance>;
|
|
1037
|
+
type MetricsPerformanceResponse = DataResponse$1<MetricsPerformance>;
|
|
1007
1038
|
|
|
1008
1039
|
interface MetricsRecipientBehaviour {
|
|
1009
1040
|
/**
|
|
@@ -1031,7 +1062,7 @@ interface MetricsRecipientBehaviour {
|
|
|
1031
1062
|
unsubscribed: number;
|
|
1032
1063
|
}
|
|
1033
1064
|
|
|
1034
|
-
type MetricsRecipientBehaviourResponse = DataResponse<MetricsRecipientBehaviour>;
|
|
1065
|
+
type MetricsRecipientBehaviourResponse = DataResponse$1<MetricsRecipientBehaviour>;
|
|
1035
1066
|
|
|
1036
1067
|
interface MetricsVolume {
|
|
1037
1068
|
/**
|
|
@@ -1064,9 +1095,9 @@ interface MetricsVolume {
|
|
|
1064
1095
|
startTime: string;
|
|
1065
1096
|
}
|
|
1066
1097
|
|
|
1067
|
-
type MetricsVolumeResponse = DataResponse<MetricsVolume>;
|
|
1098
|
+
type MetricsVolumeResponse = DataResponse$1<MetricsVolume>;
|
|
1068
1099
|
|
|
1069
|
-
type MetricsUsageResponse = DataResponse<{
|
|
1100
|
+
type MetricsUsageResponse = DataResponse$1<{
|
|
1070
1101
|
/**
|
|
1071
1102
|
* The end date of the current billing period (ISO 8601 format).
|
|
1072
1103
|
* @example "2025-04-11"
|
|
@@ -1134,7 +1165,7 @@ interface MetricsSenders {
|
|
|
1134
1165
|
total: number;
|
|
1135
1166
|
}
|
|
1136
1167
|
|
|
1137
|
-
type MetricsSendersResponse = DataResponse<MetricsSenders>;
|
|
1168
|
+
type MetricsSendersResponse = DataResponse$1<MetricsSenders>;
|
|
1138
1169
|
|
|
1139
1170
|
interface MetricsBucket {
|
|
1140
1171
|
/**
|
|
@@ -1305,7 +1336,7 @@ interface SuppressionsListEntry {
|
|
|
1305
1336
|
types: SuppressionsTypes[];
|
|
1306
1337
|
}
|
|
1307
1338
|
|
|
1308
|
-
type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;
|
|
1339
|
+
type SuppressionsListResponse = DataResponse$1<SuppressionsListEntry[]>;
|
|
1309
1340
|
|
|
1310
1341
|
declare class Suppressions {
|
|
1311
1342
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1363,9 +1394,9 @@ interface ListEntry {
|
|
|
1363
1394
|
type: "domain" | "email_address" | "ip_address";
|
|
1364
1395
|
}
|
|
1365
1396
|
|
|
1366
|
-
type ListEntryResponse = DataResponse<ListEntry>;
|
|
1397
|
+
type ListEntryResponse = DataResponse$1<ListEntry>;
|
|
1367
1398
|
|
|
1368
|
-
type ListEntriesResponse = DataResponse<ListEntry[]>;
|
|
1399
|
+
type ListEntriesResponse = DataResponse$1<ListEntry[]>;
|
|
1369
1400
|
|
|
1370
1401
|
interface DomainsData {
|
|
1371
1402
|
/**
|
|
@@ -1441,9 +1472,9 @@ interface DomainsProvisionOptions {
|
|
|
1441
1472
|
|
|
1442
1473
|
type DomainsBulkProvisionOptions = DomainsProvisionOptions & Pick<DomainsData, "subscriptionHandle">;
|
|
1443
1474
|
|
|
1444
|
-
type DomainsProvisionResponse = DataResponse<DomainsData>;
|
|
1475
|
+
type DomainsProvisionResponse = DataResponse$1<DomainsData>;
|
|
1445
1476
|
|
|
1446
|
-
type DomainsBulkProvisionResponse = DataResponse<{
|
|
1477
|
+
type DomainsBulkProvisionResponse = DataResponse$1<{
|
|
1447
1478
|
/**
|
|
1448
1479
|
* Domains that were successfully provisioned or updated.
|
|
1449
1480
|
*/
|
|
@@ -1485,7 +1516,7 @@ interface DomainsListOptions {
|
|
|
1485
1516
|
offset?: number;
|
|
1486
1517
|
}
|
|
1487
1518
|
|
|
1488
|
-
type DomainsListResponse = DataResponse<{
|
|
1519
|
+
type DomainsListResponse = DataResponse$1<{
|
|
1489
1520
|
/**
|
|
1490
1521
|
* A list of domains.
|
|
1491
1522
|
*/
|
|
@@ -1503,7 +1534,7 @@ interface DomainsCreateLoginLink {
|
|
|
1503
1534
|
link: string;
|
|
1504
1535
|
}
|
|
1505
1536
|
|
|
1506
|
-
type DomainsCreateLoginLinkResponse = DataResponse<DomainsCreateLoginLink>;
|
|
1537
|
+
type DomainsCreateLoginLinkResponse = DataResponse$1<DomainsCreateLoginLink>;
|
|
1507
1538
|
|
|
1508
1539
|
interface DomainsListDownstreamAddressesOptions {
|
|
1509
1540
|
/**
|
|
@@ -1537,7 +1568,7 @@ interface DomainsDownstreamAddress {
|
|
|
1537
1568
|
weight: number;
|
|
1538
1569
|
}
|
|
1539
1570
|
|
|
1540
|
-
type DomainsListDownstreamAddressesResponse = DataResponse<DomainsDownstreamAddress[]>;
|
|
1571
|
+
type DomainsListDownstreamAddressesResponse = DataResponse$1<DomainsDownstreamAddress[]>;
|
|
1541
1572
|
|
|
1542
1573
|
interface DomainsBulkCreateLoginLinkResult {
|
|
1543
1574
|
/**
|
|
@@ -1560,7 +1591,7 @@ interface DomainsBulkCreateLoginLinks {
|
|
|
1560
1591
|
errors: Omit<DomainsBulkCreateLoginLinkResult, "loginLink">[];
|
|
1561
1592
|
}
|
|
1562
1593
|
|
|
1563
|
-
type DomainsBulkCreateLoginLinksResponse = DataResponse<DomainsBulkCreateLoginLinks>;
|
|
1594
|
+
type DomainsBulkCreateLoginLinksResponse = DataResponse$1<DomainsBulkCreateLoginLinks>;
|
|
1564
1595
|
|
|
1565
1596
|
declare class Domains {
|
|
1566
1597
|
protected mailchannels: MailChannelsClient;
|
|
@@ -1784,7 +1815,7 @@ interface UsersCreateOptions {
|
|
|
1784
1815
|
};
|
|
1785
1816
|
}
|
|
1786
1817
|
|
|
1787
|
-
type UsersCreateResponse = DataResponse<{
|
|
1818
|
+
type UsersCreateResponse = DataResponse$1<{
|
|
1788
1819
|
email: string;
|
|
1789
1820
|
roles: string[];
|
|
1790
1821
|
filter?: boolean;
|
|
@@ -1852,7 +1883,7 @@ declare class Users {
|
|
|
1852
1883
|
deleteListEntry(email: string, options: ListEntryOptions): Promise<SuccessResponse>;
|
|
1853
1884
|
}
|
|
1854
1885
|
|
|
1855
|
-
type ServiceSubscriptionsResponse = DataResponse<{
|
|
1886
|
+
type ServiceSubscriptionsResponse = DataResponse$1<{
|
|
1856
1887
|
active: boolean;
|
|
1857
1888
|
activeAccountsCount: number;
|
|
1858
1889
|
handle: string;
|
|
@@ -1940,4 +1971,4 @@ declare class MailChannels extends MailChannelsClient {
|
|
|
1940
1971
|
}
|
|
1941
1972
|
|
|
1942
1973
|
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 };
|
|
1974
|
+
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);
|
|
@@ -207,8 +192,9 @@ class Emails {
|
|
|
207
192
|
} : void 0,
|
|
208
193
|
transactional: options.transactional
|
|
209
194
|
};
|
|
210
|
-
const
|
|
211
|
-
|
|
195
|
+
const endpoint = flags.async ? "/tx/v1/send-async" : "/tx/v1/send";
|
|
196
|
+
const response = await this.mailchannels.post(endpoint, {
|
|
197
|
+
query: { "dry-run": flags.dryRun },
|
|
212
198
|
body: payload,
|
|
213
199
|
onResponseError: async ({ response: response2 }) => {
|
|
214
200
|
error = getStatusError(response2, {
|
|
@@ -218,14 +204,23 @@ class Emails {
|
|
|
218
204
|
});
|
|
219
205
|
}
|
|
220
206
|
}).catch((e) => {
|
|
221
|
-
error ||= getResultError(e, "Failed to send email.");
|
|
207
|
+
error ||= getResultError(e, flags.async ? "Failed to queue email." : "Failed to send email.");
|
|
222
208
|
return null;
|
|
223
209
|
});
|
|
224
210
|
if (!response) return { success: false, data: null, error };
|
|
211
|
+
if (flags.async) {
|
|
212
|
+
const asyncResponse = response;
|
|
213
|
+
const data2 = clean({
|
|
214
|
+
queuedAt: asyncResponse.queued_at,
|
|
215
|
+
requestId: asyncResponse.request_id
|
|
216
|
+
});
|
|
217
|
+
return { data: data2, error: null };
|
|
218
|
+
}
|
|
219
|
+
const syncResponse = response;
|
|
225
220
|
const data = clean({
|
|
226
|
-
rendered:
|
|
227
|
-
requestId:
|
|
228
|
-
results:
|
|
221
|
+
rendered: syncResponse.data,
|
|
222
|
+
requestId: syncResponse.request_id,
|
|
223
|
+
results: syncResponse.results?.map((result) => ({
|
|
229
224
|
index: result.index,
|
|
230
225
|
messageId: result.message_id,
|
|
231
226
|
reason: result.reason,
|
|
@@ -234,13 +229,52 @@ class Emails {
|
|
|
234
229
|
});
|
|
235
230
|
return { success: !!data, data, error: null };
|
|
236
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Sends an email message to one or more recipients.
|
|
234
|
+
* @param options - The email options to send.
|
|
235
|
+
* @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`.
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
239
|
+
* const { success, data, error } = await mailchannels.emails.send({
|
|
240
|
+
* to: 'to@example.com',
|
|
241
|
+
* from: 'from@example.com',
|
|
242
|
+
* subject: 'Test',
|
|
243
|
+
* html: 'Test'
|
|
244
|
+
* })
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
async send(options, dryRun = false) {
|
|
248
|
+
return this._sendEmail(options, { dryRun });
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Queues an email message for asynchronous processing and returns immediately with a request ID.
|
|
252
|
+
*
|
|
253
|
+
* 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.
|
|
254
|
+
*
|
|
255
|
+
* 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.
|
|
256
|
+
* @param options - The email options to send.
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* const mailchannels = new MailChannels('your-api-key')
|
|
260
|
+
* const { data, error } = await mailchannels.emails.sendAsync({
|
|
261
|
+
* to: 'to@example.com',
|
|
262
|
+
* from: 'from@example.com',
|
|
263
|
+
* subject: 'Test',
|
|
264
|
+
* html: 'Test'
|
|
265
|
+
* })
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
async sendAsync(options) {
|
|
269
|
+
return this._sendEmail(options, { async: true });
|
|
270
|
+
}
|
|
237
271
|
/**
|
|
238
272
|
* 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
273
|
* @param options - The domain options to check.
|
|
240
274
|
* @example
|
|
241
275
|
* ```ts
|
|
242
276
|
* const mailchannels = new MailChannels('your-api-key')
|
|
243
|
-
* const {
|
|
277
|
+
* const { data, error } = await mailchannels.emails.checkDomain({
|
|
244
278
|
* dkim: [{
|
|
245
279
|
* domain: 'example.com',
|
|
246
280
|
* 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.1",
|
|
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.0",
|
|
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.9",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
45
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
46
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
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.17"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "unbuild",
|