retransmit.dev 0.5.0 → 0.6.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/README.md CHANGED
@@ -229,6 +229,47 @@ const { data } = await retransmit.sms.get("sms_xxxxxxxxxxxx");
229
229
  console.log(data?.status); // "sent" | "delivered" | "undelivered" | ...
230
230
  ```
231
231
 
232
+ ### Sender IDs
233
+
234
+ `from` is the name shown on the handset instead of a phone number. Approval is
235
+ per country, so request it first in the dashboard under **SMS > Sender IDs**.
236
+ The request asks for the name and the countries you send to. Most countries
237
+ accept the name as it is; where the carriers require a registration, the form
238
+ adds what that filing needs (what you send, a sample message, your legal
239
+ entity). Retransmit files it for you, and there is no AWS or carrier account to
240
+ set up.
241
+
242
+ Sending with a name that is not approved for the destination country fails with
243
+ `sender_not_allowed`. Leave `from` out to use your approved sender for that
244
+ country, or the provider default when you have none.
245
+
246
+ The United States, Canada, and Mexico do not accept alphanumeric sender IDs.
247
+
248
+ ### Choosing a carrier
249
+
250
+ You do not have to work out which carrier fits a number. Leave `provider` out
251
+ and Retransmit routes by destination country and price.
252
+
253
+ Pass it to pin the send to one carrier. `sns` (AWS End User Messaging) is the
254
+ one that reaches every destination; `mtn` and `orange` only cover the countries
255
+ Retransmit has that carrier in:
256
+
257
+ ```ts
258
+ await retransmit.sms.send({
259
+ to: "+237670000000",
260
+ text: "Your verification code is 482913",
261
+ provider: "sns", // "sns" | "mtn" | "orange"
262
+ });
263
+ ```
264
+
265
+ The value is the carrier, not one of its country operations, so it keeps
266
+ working as more countries are added. A pinned send never falls back: if that
267
+ carrier cannot deliver to the destination, the request fails with `no_route`.
268
+
269
+ `get` returns both. `requested_provider` is what you asked for, `provider` is
270
+ the country operation that carried the message (`mtn_cm`, `orange_cm`,
271
+ `aws_sns`), and is null until the message is routed.
272
+
232
273
  ## Email batches
233
274
 
234
275
  Send up to 10,000 emails in one request:
package/dist/index.cjs CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  EMAIL_STATUSES: () => EMAIL_STATUSES,
25
25
  Emails: () => Emails,
26
26
  Retransmit: () => Retransmit,
27
+ SMS_PROVIDERS: () => SMS_PROVIDERS,
27
28
  SMS_STATUSES: () => SMS_STATUSES,
28
29
  Sms: () => Sms,
29
30
  WHATSAPP_STATUSES: () => WHATSAPP_STATUSES,
@@ -159,7 +160,8 @@ var Sms = class {
159
160
  return this.client.request("POST", "/v1/sms", {
160
161
  from: options.from,
161
162
  to: options.to,
162
- text: options.text
163
+ text: options.text,
164
+ provider: options.provider
163
165
  });
164
166
  }
165
167
  /** Retrieves an SMS with its current status and event history. */
@@ -199,7 +201,7 @@ var Whatsapp = class {
199
201
 
200
202
  // src/retransmit.ts
201
203
  var DEFAULT_BASE_URL = "https://api.retransmit.dev";
202
- var USER_AGENT = "retransmit.dev-node/0.5.0";
204
+ var USER_AGENT = "retransmit.dev-node/0.6.0";
203
205
  function readEnv(name) {
204
206
  return typeof process !== "undefined" ? process.env?.[name] : void 0;
205
207
  }
@@ -300,6 +302,7 @@ var SMS_STATUSES = [
300
302
  "rejected",
301
303
  "failed"
302
304
  ];
305
+ var SMS_PROVIDERS = ["sns", "mtn", "orange"];
303
306
  var WHATSAPP_STATUSES = ["queued", "sent", "delivered", "read", "failed"];
304
307
  // Annotate the CommonJS export names for ESM import in node:
305
308
  0 && (module.exports = {
@@ -307,6 +310,7 @@ var WHATSAPP_STATUSES = ["queued", "sent", "delivered", "read", "failed"];
307
310
  EMAIL_STATUSES,
308
311
  Emails,
309
312
  Retransmit,
313
+ SMS_PROVIDERS,
310
314
  SMS_STATUSES,
311
315
  Sms,
312
316
  WHATSAPP_STATUSES,
package/dist/index.d.cts CHANGED
@@ -200,16 +200,38 @@ interface ListEmailTagsResponse {
200
200
  }
201
201
  declare const SMS_STATUSES: readonly ["queued", "sent", "delivered", "undelivered", "expired", "rejected", "failed"];
202
202
  type SmsStatus = (typeof SMS_STATUSES)[number];
203
+ /**
204
+ * Carriers a send can be pinned to. Carrier-level, not per-country: `mtn`
205
+ * covers every MTN network Retransmit integrates with. `sns` (AWS End User
206
+ * Messaging) is first because it is the one that reaches every destination.
207
+ */
208
+ declare const SMS_PROVIDERS: readonly ["sns", "mtn", "orange"];
209
+ type SmsProvider = (typeof SMS_PROVIDERS)[number];
203
210
  interface SendSmsOptions {
204
211
  /**
205
212
  * Sender id shown on the recipient's device (up to 11 characters:
206
- * letters, digits, space, - and _). Defaults to the sender configured for
207
- * the routed provider.
213
+ * letters, digits, space, - and _).
214
+ *
215
+ * Approval is per country, so this must be a name your organization has had
216
+ * approved for the destination; request it in the dashboard under
217
+ * SMS > Sender IDs, which asks for the name and the countries, and for
218
+ * registration details only where the carriers require a filing. Sending
219
+ * with an unapproved name fails with `sender_not_allowed`. Leave it out to
220
+ * use your approved sender for that country, or the provider default when
221
+ * you have none.
208
222
  */
209
223
  from?: string;
210
224
  /** One recipient or up to 50, in international format (`+237670000000`). All must share one country. */
211
225
  to: string | string[];
212
226
  text: string;
227
+ /**
228
+ * Pins the send to one carrier. Leave it out to let Retransmit route by
229
+ * destination country and price. `sns` covers every destination; `mtn` and
230
+ * `orange` only the countries Retransmit has that carrier in. A pinned send
231
+ * never falls back to another carrier: it fails with `no_route` when that
232
+ * one cannot deliver.
233
+ */
234
+ provider?: SmsProvider;
213
235
  }
214
236
  interface SendSmsResponse {
215
237
  id: string;
@@ -231,7 +253,13 @@ interface GetSmsResponse {
231
253
  text: string;
232
254
  country: string | null;
233
255
  segments: number;
234
- /** Upstream provider that carried the message, e.g. `mtn_cm`. */
256
+ /** Carrier the send was pinned to, null when routing chose freely. */
257
+ requested_provider: SmsProvider | null;
258
+ /**
259
+ * Country operation that carried the message, e.g. `mtn_cm`, `orange_cm`
260
+ * or `aws_sns`. More specific than `requested_provider`, and null until
261
+ * the message is routed.
262
+ */
235
263
  provider: string | null;
236
264
  status: SmsStatus;
237
265
  error: string | null;
@@ -404,4 +432,4 @@ declare class Retransmit {
404
432
  request<T>(method: "GET" | "POST", path: string, body?: unknown, query?: Record<string, string | number | string[] | undefined>, options?: RequestOptions): Promise<Result<T>>;
405
433
  }
406
434
 
407
- export { type Attachment, Batch, EMAIL_STATUSES, type EmailAttachment, type EmailAttachmentWithDownload, type EmailEvent, type EmailStatus, type EmailSummary, type EmailTag, type EmailTagCount, Emails, type GetBatchResponse, type GetEmailResponse, type GetSmsResponse, type GetWhatsappResponse, type ListEmailAttachmentsResponse, type ListEmailTagsResponse, type ListEmailsOptions, type ListEmailsResponse, type RequestOptions, type Result, Retransmit, type RetransmitError, type RetransmitOptions, SMS_STATUSES, type SendBatchResponse, type SendEmailOptions, type SendEmailResponse, type SendSmsOptions, type SendSmsResponse, type SendWhatsappOptions, type SendWhatsappResponse, Sms, type SmsEvent, type SmsStatus, WHATSAPP_STATUSES, Whatsapp, type WhatsappDocument, type WhatsappEvent, type WhatsappMedia, type WhatsappMessageType, type WhatsappStatus, type WhatsappTemplate };
435
+ export { type Attachment, Batch, EMAIL_STATUSES, type EmailAttachment, type EmailAttachmentWithDownload, type EmailEvent, type EmailStatus, type EmailSummary, type EmailTag, type EmailTagCount, Emails, type GetBatchResponse, type GetEmailResponse, type GetSmsResponse, type GetWhatsappResponse, type ListEmailAttachmentsResponse, type ListEmailTagsResponse, type ListEmailsOptions, type ListEmailsResponse, type RequestOptions, type Result, Retransmit, type RetransmitError, type RetransmitOptions, SMS_PROVIDERS, SMS_STATUSES, type SendBatchResponse, type SendEmailOptions, type SendEmailResponse, type SendSmsOptions, type SendSmsResponse, type SendWhatsappOptions, type SendWhatsappResponse, Sms, type SmsEvent, type SmsProvider, type SmsStatus, WHATSAPP_STATUSES, Whatsapp, type WhatsappDocument, type WhatsappEvent, type WhatsappMedia, type WhatsappMessageType, type WhatsappStatus, type WhatsappTemplate };
package/dist/index.d.ts CHANGED
@@ -200,16 +200,38 @@ interface ListEmailTagsResponse {
200
200
  }
201
201
  declare const SMS_STATUSES: readonly ["queued", "sent", "delivered", "undelivered", "expired", "rejected", "failed"];
202
202
  type SmsStatus = (typeof SMS_STATUSES)[number];
203
+ /**
204
+ * Carriers a send can be pinned to. Carrier-level, not per-country: `mtn`
205
+ * covers every MTN network Retransmit integrates with. `sns` (AWS End User
206
+ * Messaging) is first because it is the one that reaches every destination.
207
+ */
208
+ declare const SMS_PROVIDERS: readonly ["sns", "mtn", "orange"];
209
+ type SmsProvider = (typeof SMS_PROVIDERS)[number];
203
210
  interface SendSmsOptions {
204
211
  /**
205
212
  * Sender id shown on the recipient's device (up to 11 characters:
206
- * letters, digits, space, - and _). Defaults to the sender configured for
207
- * the routed provider.
213
+ * letters, digits, space, - and _).
214
+ *
215
+ * Approval is per country, so this must be a name your organization has had
216
+ * approved for the destination; request it in the dashboard under
217
+ * SMS > Sender IDs, which asks for the name and the countries, and for
218
+ * registration details only where the carriers require a filing. Sending
219
+ * with an unapproved name fails with `sender_not_allowed`. Leave it out to
220
+ * use your approved sender for that country, or the provider default when
221
+ * you have none.
208
222
  */
209
223
  from?: string;
210
224
  /** One recipient or up to 50, in international format (`+237670000000`). All must share one country. */
211
225
  to: string | string[];
212
226
  text: string;
227
+ /**
228
+ * Pins the send to one carrier. Leave it out to let Retransmit route by
229
+ * destination country and price. `sns` covers every destination; `mtn` and
230
+ * `orange` only the countries Retransmit has that carrier in. A pinned send
231
+ * never falls back to another carrier: it fails with `no_route` when that
232
+ * one cannot deliver.
233
+ */
234
+ provider?: SmsProvider;
213
235
  }
214
236
  interface SendSmsResponse {
215
237
  id: string;
@@ -231,7 +253,13 @@ interface GetSmsResponse {
231
253
  text: string;
232
254
  country: string | null;
233
255
  segments: number;
234
- /** Upstream provider that carried the message, e.g. `mtn_cm`. */
256
+ /** Carrier the send was pinned to, null when routing chose freely. */
257
+ requested_provider: SmsProvider | null;
258
+ /**
259
+ * Country operation that carried the message, e.g. `mtn_cm`, `orange_cm`
260
+ * or `aws_sns`. More specific than `requested_provider`, and null until
261
+ * the message is routed.
262
+ */
235
263
  provider: string | null;
236
264
  status: SmsStatus;
237
265
  error: string | null;
@@ -404,4 +432,4 @@ declare class Retransmit {
404
432
  request<T>(method: "GET" | "POST", path: string, body?: unknown, query?: Record<string, string | number | string[] | undefined>, options?: RequestOptions): Promise<Result<T>>;
405
433
  }
406
434
 
407
- export { type Attachment, Batch, EMAIL_STATUSES, type EmailAttachment, type EmailAttachmentWithDownload, type EmailEvent, type EmailStatus, type EmailSummary, type EmailTag, type EmailTagCount, Emails, type GetBatchResponse, type GetEmailResponse, type GetSmsResponse, type GetWhatsappResponse, type ListEmailAttachmentsResponse, type ListEmailTagsResponse, type ListEmailsOptions, type ListEmailsResponse, type RequestOptions, type Result, Retransmit, type RetransmitError, type RetransmitOptions, SMS_STATUSES, type SendBatchResponse, type SendEmailOptions, type SendEmailResponse, type SendSmsOptions, type SendSmsResponse, type SendWhatsappOptions, type SendWhatsappResponse, Sms, type SmsEvent, type SmsStatus, WHATSAPP_STATUSES, Whatsapp, type WhatsappDocument, type WhatsappEvent, type WhatsappMedia, type WhatsappMessageType, type WhatsappStatus, type WhatsappTemplate };
435
+ export { type Attachment, Batch, EMAIL_STATUSES, type EmailAttachment, type EmailAttachmentWithDownload, type EmailEvent, type EmailStatus, type EmailSummary, type EmailTag, type EmailTagCount, Emails, type GetBatchResponse, type GetEmailResponse, type GetSmsResponse, type GetWhatsappResponse, type ListEmailAttachmentsResponse, type ListEmailTagsResponse, type ListEmailsOptions, type ListEmailsResponse, type RequestOptions, type Result, Retransmit, type RetransmitError, type RetransmitOptions, SMS_PROVIDERS, SMS_STATUSES, type SendBatchResponse, type SendEmailOptions, type SendEmailResponse, type SendSmsOptions, type SendSmsResponse, type SendWhatsappOptions, type SendWhatsappResponse, Sms, type SmsEvent, type SmsProvider, type SmsStatus, WHATSAPP_STATUSES, Whatsapp, type WhatsappDocument, type WhatsappEvent, type WhatsappMedia, type WhatsappMessageType, type WhatsappStatus, type WhatsappTemplate };
package/dist/index.js CHANGED
@@ -126,7 +126,8 @@ var Sms = class {
126
126
  return this.client.request("POST", "/v1/sms", {
127
127
  from: options.from,
128
128
  to: options.to,
129
- text: options.text
129
+ text: options.text,
130
+ provider: options.provider
130
131
  });
131
132
  }
132
133
  /** Retrieves an SMS with its current status and event history. */
@@ -166,7 +167,7 @@ var Whatsapp = class {
166
167
 
167
168
  // src/retransmit.ts
168
169
  var DEFAULT_BASE_URL = "https://api.retransmit.dev";
169
- var USER_AGENT = "retransmit.dev-node/0.5.0";
170
+ var USER_AGENT = "retransmit.dev-node/0.6.0";
170
171
  function readEnv(name) {
171
172
  return typeof process !== "undefined" ? process.env?.[name] : void 0;
172
173
  }
@@ -267,12 +268,14 @@ var SMS_STATUSES = [
267
268
  "rejected",
268
269
  "failed"
269
270
  ];
271
+ var SMS_PROVIDERS = ["sns", "mtn", "orange"];
270
272
  var WHATSAPP_STATUSES = ["queued", "sent", "delivered", "read", "failed"];
271
273
  export {
272
274
  Batch,
273
275
  EMAIL_STATUSES,
274
276
  Emails,
275
277
  Retransmit,
278
+ SMS_PROVIDERS,
276
279
  SMS_STATUSES,
277
280
  Sms,
278
281
  WHATSAPP_STATUSES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retransmit.dev",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Node.js SDK for the Retransmit email, SMS and WhatsApp APIs",
5
5
  "keywords": [
6
6
  "email",