@sendly/node 3.1.0 → 3.5.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/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
@@ -418,7 +440,7 @@ interface BatchListResponse {
418
440
  /**
419
441
  * Error codes returned by the Sendly API
420
442
  */
421
- type SendlyErrorCode = "invalid_request" | "unauthorized" | "invalid_auth_format" | "invalid_key_format" | "invalid_api_key" | "key_revoked" | "key_expired" | "insufficient_permissions" | "insufficient_credits" | "unsupported_destination" | "not_found" | "rate_limit_exceeded" | "internal_error";
443
+ type SendlyErrorCode = "invalid_request" | "unauthorized" | "invalid_auth_format" | "invalid_key_format" | "invalid_api_key" | "api_key_required" | "key_revoked" | "key_expired" | "insufficient_permissions" | "insufficient_credits" | "unsupported_destination" | "not_found" | "rate_limit_exceeded" | "internal_error";
422
444
  /**
423
445
  * Error response from the Sendly API
424
446
  */
@@ -1922,4 +1944,4 @@ declare class Webhooks {
1922
1944
  */
1923
1945
  type WebhookMessageData = WebhookMessageObject;
1924
1946
 
1925
- 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
@@ -418,7 +440,7 @@ interface BatchListResponse {
418
440
  /**
419
441
  * Error codes returned by the Sendly API
420
442
  */
421
- type SendlyErrorCode = "invalid_request" | "unauthorized" | "invalid_auth_format" | "invalid_key_format" | "invalid_api_key" | "key_revoked" | "key_expired" | "insufficient_permissions" | "insufficient_credits" | "unsupported_destination" | "not_found" | "rate_limit_exceeded" | "internal_error";
443
+ type SendlyErrorCode = "invalid_request" | "unauthorized" | "invalid_auth_format" | "invalid_key_format" | "invalid_api_key" | "api_key_required" | "key_revoked" | "key_expired" | "insufficient_permissions" | "insufficient_credits" | "unsupported_destination" | "not_found" | "rate_limit_exceeded" | "internal_error";
422
444
  /**
423
445
  * Error response from the Sendly API
424
446
  */
@@ -1922,4 +1944,4 @@ declare class Webhooks {
1922
1944
  */
1923
1945
  type WebhookMessageData = WebhookMessageObject;
1924
1946
 
1925
- 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
@@ -93,6 +93,7 @@ var SendlyError = class _SendlyError extends Error {
93
93
  case "invalid_auth_format":
94
94
  case "invalid_key_format":
95
95
  case "invalid_api_key":
96
+ case "api_key_required":
96
97
  case "key_revoked":
97
98
  case "key_expired":
98
99
  case "insufficient_permissions":
@@ -781,12 +782,16 @@ var MessagesResource = class {
781
782
  }
782
783
  const scheduledTime = new Date(request.scheduledAt);
783
784
  const now = /* @__PURE__ */ new Date();
784
- const oneMinuteFromNow = new Date(now.getTime() + 60 * 1e3);
785
+ const fiveMinutesFromNow = new Date(now.getTime() + 5 * 60 * 1e3);
786
+ const fiveDaysFromNow = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1e3);
785
787
  if (isNaN(scheduledTime.getTime())) {
786
788
  throw new Error("Invalid scheduledAt format. Use ISO 8601 format.");
787
789
  }
788
- if (scheduledTime <= oneMinuteFromNow) {
789
- throw new Error("scheduledAt must be at least 1 minute in the future.");
790
+ if (scheduledTime <= fiveMinutesFromNow) {
791
+ throw new Error("scheduledAt must be at least 5 minutes in the future.");
792
+ }
793
+ if (scheduledTime > fiveDaysFromNow) {
794
+ throw new Error("scheduledAt must be within 5 days.");
790
795
  }
791
796
  const scheduled = await this.http.request({
792
797
  method: "POST",
package/dist/index.mjs CHANGED
@@ -33,6 +33,7 @@ var SendlyError = class _SendlyError extends Error {
33
33
  case "invalid_auth_format":
34
34
  case "invalid_key_format":
35
35
  case "invalid_api_key":
36
+ case "api_key_required":
36
37
  case "key_revoked":
37
38
  case "key_expired":
38
39
  case "insufficient_permissions":
@@ -721,12 +722,16 @@ var MessagesResource = class {
721
722
  }
722
723
  const scheduledTime = new Date(request.scheduledAt);
723
724
  const now = /* @__PURE__ */ new Date();
724
- const oneMinuteFromNow = new Date(now.getTime() + 60 * 1e3);
725
+ const fiveMinutesFromNow = new Date(now.getTime() + 5 * 60 * 1e3);
726
+ const fiveDaysFromNow = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1e3);
725
727
  if (isNaN(scheduledTime.getTime())) {
726
728
  throw new Error("Invalid scheduledAt format. Use ISO 8601 format.");
727
729
  }
728
- if (scheduledTime <= oneMinuteFromNow) {
729
- throw new Error("scheduledAt must be at least 1 minute in the future.");
730
+ if (scheduledTime <= fiveMinutesFromNow) {
731
+ throw new Error("scheduledAt must be at least 5 minutes in the future.");
732
+ }
733
+ if (scheduledTime > fiveDaysFromNow) {
734
+ throw new Error("scheduledAt must be within 5 days.");
730
735
  }
731
736
  const scheduled = await this.http.request({
732
737
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendly/node",
3
- "version": "3.1.0",
3
+ "version": "3.5.2",
4
4
  "description": "Official Sendly Node.js SDK for SMS messaging",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",