@sendly/node 3.0.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -26,6 +26,10 @@ interface SendlyConfig {
26
26
  */
27
27
  maxRetries?: number;
28
28
  }
29
+ /**
30
+ * Message type for compliance classification
31
+ */
32
+ type MessageType = "marketing" | "transactional";
29
33
  /**
30
34
  * Request payload for sending an SMS message
31
35
  */
@@ -44,6 +48,12 @@ interface SendMessageRequest {
44
48
  * For US/Canada: Your verified toll-free number
45
49
  */
46
50
  from?: string;
51
+ /**
52
+ * Message type for compliance (default: "marketing")
53
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
54
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
55
+ */
56
+ messageType?: MessageType;
47
57
  }
48
58
  /**
49
59
  * Message status values
@@ -171,7 +181,7 @@ interface ScheduleMessageRequest {
171
181
  */
172
182
  text: string;
173
183
  /**
174
- * When to send the message (ISO 8601 format, must be > 1 minute in future)
184
+ * When to send the message (ISO 8601 format, must be 5 min - 5 days in future)
175
185
  */
176
186
  scheduledAt: string;
177
187
  /**
@@ -179,6 +189,12 @@ interface ScheduleMessageRequest {
179
189
  * For US/Canada: This is ignored - toll-free number pool is used
180
190
  */
181
191
  from?: string;
192
+ /**
193
+ * Message type for compliance (default: "marketing")
194
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
195
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
196
+ */
197
+ messageType?: MessageType;
182
198
  }
183
199
  /**
184
200
  * Scheduled message status values
@@ -312,6 +328,12 @@ interface BatchMessageRequest {
312
328
  * For US/Canada destinations: This is ignored - toll-free number pool is used
313
329
  */
314
330
  from?: string;
331
+ /**
332
+ * Message type for compliance (default: "marketing")
333
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
334
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
335
+ */
336
+ messageType?: MessageType;
315
337
  }
316
338
  /**
317
339
  * Result for a single message in a batch
@@ -510,6 +532,13 @@ declare const ALL_SUPPORTED_COUNTRIES: string[];
510
532
  * Webhook event types
511
533
  */
512
534
  type WebhookEventType = "message.sent" | "message.delivered" | "message.failed" | "message.bounced" | "message.queued";
535
+ /**
536
+ * Webhook mode - filters which events are delivered
537
+ * - "all": Receives all events (sandbox + production)
538
+ * - "test": Only sandbox/test events (livemode: false)
539
+ * - "live": Only production events (livemode: true) - requires verification
540
+ */
541
+ type WebhookMode = "all" | "test" | "live";
513
542
  /**
514
543
  * Circuit breaker state for webhook delivery
515
544
  */
@@ -530,6 +559,8 @@ interface Webhook {
530
559
  events: WebhookEventType[];
531
560
  /** Optional description */
532
561
  description?: string;
562
+ /** Event mode filter */
563
+ mode: WebhookMode;
533
564
  /** Whether the webhook is active */
534
565
  isActive: boolean;
535
566
  /** Number of consecutive failures */
@@ -574,6 +605,8 @@ interface CreateWebhookOptions {
574
605
  events: WebhookEventType[];
575
606
  /** Optional description */
576
607
  description?: string;
608
+ /** Event mode filter (defaults to "all") */
609
+ mode?: WebhookMode;
577
610
  /** Custom metadata */
578
611
  metadata?: Record<string, unknown>;
579
612
  }
@@ -587,6 +620,8 @@ interface UpdateWebhookOptions {
587
620
  events?: WebhookEventType[];
588
621
  /** New description */
589
622
  description?: string;
623
+ /** Event mode filter */
624
+ mode?: WebhookMode;
590
625
  /** Enable/disable webhook */
591
626
  isActive?: boolean;
592
627
  /** Custom metadata */
@@ -1909,4 +1944,4 @@ declare class Webhooks {
1909
1944
  */
1910
1945
  type WebhookMessageData = WebhookMessageObject;
1911
1946
 
1912
- export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CircuitState, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type Message, type MessageListResponse, type MessageStatus, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, TimeoutError, type UpdateWebhookOptions, ValidationError, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
1947
+ export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CircuitState, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, TimeoutError, type UpdateWebhookOptions, ValidationError, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -26,6 +26,10 @@ interface SendlyConfig {
26
26
  */
27
27
  maxRetries?: number;
28
28
  }
29
+ /**
30
+ * Message type for compliance classification
31
+ */
32
+ type MessageType = "marketing" | "transactional";
29
33
  /**
30
34
  * Request payload for sending an SMS message
31
35
  */
@@ -44,6 +48,12 @@ interface SendMessageRequest {
44
48
  * For US/Canada: Your verified toll-free number
45
49
  */
46
50
  from?: string;
51
+ /**
52
+ * Message type for compliance (default: "marketing")
53
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
54
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
55
+ */
56
+ messageType?: MessageType;
47
57
  }
48
58
  /**
49
59
  * Message status values
@@ -171,7 +181,7 @@ interface ScheduleMessageRequest {
171
181
  */
172
182
  text: string;
173
183
  /**
174
- * When to send the message (ISO 8601 format, must be > 1 minute in future)
184
+ * When to send the message (ISO 8601 format, must be 5 min - 5 days in future)
175
185
  */
176
186
  scheduledAt: string;
177
187
  /**
@@ -179,6 +189,12 @@ interface ScheduleMessageRequest {
179
189
  * For US/Canada: This is ignored - toll-free number pool is used
180
190
  */
181
191
  from?: string;
192
+ /**
193
+ * Message type for compliance (default: "marketing")
194
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
195
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
196
+ */
197
+ messageType?: MessageType;
182
198
  }
183
199
  /**
184
200
  * Scheduled message status values
@@ -312,6 +328,12 @@ interface BatchMessageRequest {
312
328
  * For US/Canada destinations: This is ignored - toll-free number pool is used
313
329
  */
314
330
  from?: string;
331
+ /**
332
+ * Message type for compliance (default: "marketing")
333
+ * - "marketing": Promotional content, subject to quiet hours (8am-9pm recipient time)
334
+ * - "transactional": OTPs, confirmations, alerts - bypasses quiet hours (24/7)
335
+ */
336
+ messageType?: MessageType;
315
337
  }
316
338
  /**
317
339
  * Result for a single message in a batch
@@ -510,6 +532,13 @@ declare const ALL_SUPPORTED_COUNTRIES: string[];
510
532
  * Webhook event types
511
533
  */
512
534
  type WebhookEventType = "message.sent" | "message.delivered" | "message.failed" | "message.bounced" | "message.queued";
535
+ /**
536
+ * Webhook mode - filters which events are delivered
537
+ * - "all": Receives all events (sandbox + production)
538
+ * - "test": Only sandbox/test events (livemode: false)
539
+ * - "live": Only production events (livemode: true) - requires verification
540
+ */
541
+ type WebhookMode = "all" | "test" | "live";
513
542
  /**
514
543
  * Circuit breaker state for webhook delivery
515
544
  */
@@ -530,6 +559,8 @@ interface Webhook {
530
559
  events: WebhookEventType[];
531
560
  /** Optional description */
532
561
  description?: string;
562
+ /** Event mode filter */
563
+ mode: WebhookMode;
533
564
  /** Whether the webhook is active */
534
565
  isActive: boolean;
535
566
  /** Number of consecutive failures */
@@ -574,6 +605,8 @@ interface CreateWebhookOptions {
574
605
  events: WebhookEventType[];
575
606
  /** Optional description */
576
607
  description?: string;
608
+ /** Event mode filter (defaults to "all") */
609
+ mode?: WebhookMode;
577
610
  /** Custom metadata */
578
611
  metadata?: Record<string, unknown>;
579
612
  }
@@ -587,6 +620,8 @@ interface UpdateWebhookOptions {
587
620
  events?: WebhookEventType[];
588
621
  /** New description */
589
622
  description?: string;
623
+ /** Event mode filter */
624
+ mode?: WebhookMode;
590
625
  /** Enable/disable webhook */
591
626
  isActive?: boolean;
592
627
  /** Custom metadata */
@@ -1909,4 +1944,4 @@ declare class Webhooks {
1909
1944
  */
1910
1945
  type WebhookMessageData = WebhookMessageObject;
1911
1946
 
1912
- export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CircuitState, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type Message, type MessageListResponse, type MessageStatus, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, TimeoutError, type UpdateWebhookOptions, ValidationError, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
1947
+ export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CircuitState, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, TimeoutError, type UpdateWebhookOptions, ValidationError, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -781,12 +781,16 @@ var MessagesResource = class {
781
781
  }
782
782
  const scheduledTime = new Date(request.scheduledAt);
783
783
  const now = /* @__PURE__ */ new Date();
784
- const oneMinuteFromNow = new Date(now.getTime() + 60 * 1e3);
784
+ const fiveMinutesFromNow = new Date(now.getTime() + 5 * 60 * 1e3);
785
+ const fiveDaysFromNow = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1e3);
785
786
  if (isNaN(scheduledTime.getTime())) {
786
787
  throw new Error("Invalid scheduledAt format. Use ISO 8601 format.");
787
788
  }
788
- if (scheduledTime <= oneMinuteFromNow) {
789
- throw new Error("scheduledAt must be at least 1 minute in the future.");
789
+ if (scheduledTime <= fiveMinutesFromNow) {
790
+ throw new Error("scheduledAt must be at least 5 minutes in the future.");
791
+ }
792
+ if (scheduledTime > fiveDaysFromNow) {
793
+ throw new Error("scheduledAt must be within 5 days.");
790
794
  }
791
795
  const scheduled = await this.http.request({
792
796
  method: "POST",
@@ -1041,6 +1045,7 @@ var WebhooksResource = class {
1041
1045
  url: options.url,
1042
1046
  events: options.events,
1043
1047
  ...options.description && { description: options.description },
1048
+ ...options.mode && { mode: options.mode },
1044
1049
  ...options.metadata && { metadata: options.metadata }
1045
1050
  }
1046
1051
  });
@@ -1131,6 +1136,7 @@ var WebhooksResource = class {
1131
1136
  description: options.description
1132
1137
  },
1133
1138
  ...options.isActive !== void 0 && { is_active: options.isActive },
1139
+ ...options.mode !== void 0 && { mode: options.mode },
1134
1140
  ...options.metadata !== void 0 && { metadata: options.metadata }
1135
1141
  }
1136
1142
  });
package/dist/index.mjs CHANGED
@@ -721,12 +721,16 @@ var MessagesResource = class {
721
721
  }
722
722
  const scheduledTime = new Date(request.scheduledAt);
723
723
  const now = /* @__PURE__ */ new Date();
724
- const oneMinuteFromNow = new Date(now.getTime() + 60 * 1e3);
724
+ const fiveMinutesFromNow = new Date(now.getTime() + 5 * 60 * 1e3);
725
+ const fiveDaysFromNow = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1e3);
725
726
  if (isNaN(scheduledTime.getTime())) {
726
727
  throw new Error("Invalid scheduledAt format. Use ISO 8601 format.");
727
728
  }
728
- if (scheduledTime <= oneMinuteFromNow) {
729
- throw new Error("scheduledAt must be at least 1 minute in the future.");
729
+ if (scheduledTime <= fiveMinutesFromNow) {
730
+ throw new Error("scheduledAt must be at least 5 minutes in the future.");
731
+ }
732
+ if (scheduledTime > fiveDaysFromNow) {
733
+ throw new Error("scheduledAt must be within 5 days.");
730
734
  }
731
735
  const scheduled = await this.http.request({
732
736
  method: "POST",
@@ -981,6 +985,7 @@ var WebhooksResource = class {
981
985
  url: options.url,
982
986
  events: options.events,
983
987
  ...options.description && { description: options.description },
988
+ ...options.mode && { mode: options.mode },
984
989
  ...options.metadata && { metadata: options.metadata }
985
990
  }
986
991
  });
@@ -1071,6 +1076,7 @@ var WebhooksResource = class {
1071
1076
  description: options.description
1072
1077
  },
1073
1078
  ...options.isActive !== void 0 && { is_active: options.isActive },
1079
+ ...options.mode !== void 0 && { mode: options.mode },
1074
1080
  ...options.metadata !== void 0 && { metadata: options.metadata }
1075
1081
  }
1076
1082
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendly/node",
3
- "version": "3.0.0",
3
+ "version": "3.4.0",
4
4
  "description": "Official Sendly Node.js SDK for SMS messaging",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",