telnyx 6.41.1 → 6.43.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.
Files changed (256) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +11 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +11 -0
  9. package/client.mjs.map +1 -1
  10. package/core/EventEmitter.d.mts +11 -0
  11. package/core/EventEmitter.d.mts.map +1 -1
  12. package/core/EventEmitter.d.ts +11 -0
  13. package/core/EventEmitter.d.ts.map +1 -1
  14. package/core/EventEmitter.js +15 -1
  15. package/core/EventEmitter.js.map +1 -1
  16. package/core/EventEmitter.mjs +13 -0
  17. package/core/EventEmitter.mjs.map +1 -1
  18. package/internal/types.d.mts +6 -6
  19. package/internal/types.d.mts.map +1 -1
  20. package/internal/types.d.ts +6 -6
  21. package/internal/types.d.ts.map +1 -1
  22. package/internal/utils/env.js +2 -2
  23. package/internal/utils/env.js.map +1 -1
  24. package/internal/utils/env.mjs +2 -2
  25. package/internal/utils/env.mjs.map +1 -1
  26. package/internal/ws-adapter-browser.d.mts +34 -0
  27. package/internal/ws-adapter-browser.d.mts.map +1 -0
  28. package/internal/ws-adapter-browser.d.ts +34 -0
  29. package/internal/ws-adapter-browser.d.ts.map +1 -0
  30. package/internal/ws-adapter-browser.js +88 -0
  31. package/internal/ws-adapter-browser.js.map +1 -0
  32. package/internal/ws-adapter-browser.mjs +84 -0
  33. package/internal/ws-adapter-browser.mjs.map +1 -0
  34. package/internal/ws-adapter-node.d.mts +27 -0
  35. package/internal/ws-adapter-node.d.mts.map +1 -0
  36. package/internal/ws-adapter-node.d.ts +27 -0
  37. package/internal/ws-adapter-node.d.ts.map +1 -0
  38. package/internal/ws-adapter-node.js +90 -0
  39. package/internal/ws-adapter-node.js.map +1 -0
  40. package/internal/ws-adapter-node.mjs +86 -0
  41. package/internal/ws-adapter-node.mjs.map +1 -0
  42. package/internal/ws-adapter.d.mts +24 -0
  43. package/internal/ws-adapter.d.mts.map +1 -0
  44. package/internal/ws-adapter.d.ts +24 -0
  45. package/internal/ws-adapter.d.ts.map +1 -0
  46. package/internal/ws-adapter.js +11 -0
  47. package/internal/ws-adapter.js.map +1 -0
  48. package/internal/ws-adapter.mjs +8 -0
  49. package/internal/ws-adapter.mjs.map +1 -0
  50. package/internal/ws.d.mts +80 -0
  51. package/internal/ws.d.mts.map +1 -0
  52. package/internal/ws.d.ts +80 -0
  53. package/internal/ws.d.ts.map +1 -0
  54. package/internal/ws.js +153 -0
  55. package/internal/ws.js.map +1 -0
  56. package/internal/ws.mjs +147 -0
  57. package/internal/ws.mjs.map +1 -0
  58. package/lib/text-to-speech-ws-base.d.mts +106 -0
  59. package/lib/text-to-speech-ws-base.d.mts.map +1 -0
  60. package/lib/text-to-speech-ws-base.d.ts +106 -0
  61. package/lib/text-to-speech-ws-base.d.ts.map +1 -0
  62. package/lib/text-to-speech-ws-base.js +475 -0
  63. package/lib/text-to-speech-ws-base.js.map +1 -0
  64. package/lib/text-to-speech-ws-base.mjs +471 -0
  65. package/lib/text-to-speech-ws-base.mjs.map +1 -0
  66. package/lib/text-to-speech-ws-internal.d.mts +71 -0
  67. package/lib/text-to-speech-ws-internal.d.mts.map +1 -0
  68. package/lib/text-to-speech-ws-internal.d.ts +71 -0
  69. package/lib/text-to-speech-ws-internal.d.ts.map +1 -0
  70. package/lib/text-to-speech-ws-internal.js +47 -0
  71. package/lib/text-to-speech-ws-internal.js.map +1 -0
  72. package/lib/text-to-speech-ws-internal.mjs +41 -0
  73. package/lib/text-to-speech-ws-internal.mjs.map +1 -0
  74. package/lib/text-to-speech-ws.d.mts +13 -0
  75. package/lib/text-to-speech-ws.d.mts.map +1 -0
  76. package/lib/text-to-speech-ws.d.ts +13 -0
  77. package/lib/text-to-speech-ws.d.ts.map +1 -0
  78. package/lib/text-to-speech-ws.js +30 -0
  79. package/lib/text-to-speech-ws.js.map +1 -0
  80. package/lib/text-to-speech-ws.mjs +25 -0
  81. package/lib/text-to-speech-ws.mjs.map +1 -0
  82. package/lib/webhooks.d.mts +6 -0
  83. package/lib/webhooks.d.mts.map +1 -1
  84. package/lib/webhooks.d.ts +6 -0
  85. package/lib/webhooks.d.ts.map +1 -1
  86. package/lib/webhooks.js +16 -0
  87. package/lib/webhooks.js.map +1 -1
  88. package/lib/webhooks.mjs +14 -0
  89. package/lib/webhooks.mjs.map +1 -1
  90. package/package.json +1 -1
  91. package/resources/ai/assistants/assistants.d.mts +938 -65
  92. package/resources/ai/assistants/assistants.d.mts.map +1 -1
  93. package/resources/ai/assistants/assistants.d.ts +938 -65
  94. package/resources/ai/assistants/assistants.d.ts.map +1 -1
  95. package/resources/ai/assistants/assistants.js +0 -1
  96. package/resources/ai/assistants/assistants.js.map +1 -1
  97. package/resources/ai/assistants/assistants.mjs +0 -1
  98. package/resources/ai/assistants/assistants.mjs.map +1 -1
  99. package/resources/ai/assistants/versions.d.mts +563 -25
  100. package/resources/ai/assistants/versions.d.mts.map +1 -1
  101. package/resources/ai/assistants/versions.d.ts +563 -25
  102. package/resources/ai/assistants/versions.d.ts.map +1 -1
  103. package/resources/ai/conversations/conversations.d.mts +2 -2
  104. package/resources/ai/conversations/conversations.d.mts.map +1 -1
  105. package/resources/ai/conversations/conversations.d.ts +2 -2
  106. package/resources/ai/conversations/conversations.d.ts.map +1 -1
  107. package/resources/ai/conversations/conversations.js.map +1 -1
  108. package/resources/ai/conversations/conversations.mjs +1 -1
  109. package/resources/ai/conversations/conversations.mjs.map +1 -1
  110. package/resources/ai/conversations/index.d.mts +1 -1
  111. package/resources/ai/conversations/index.d.mts.map +1 -1
  112. package/resources/ai/conversations/index.d.ts +1 -1
  113. package/resources/ai/conversations/index.d.ts.map +1 -1
  114. package/resources/ai/conversations/index.js.map +1 -1
  115. package/resources/ai/conversations/index.mjs +1 -1
  116. package/resources/ai/conversations/index.mjs.map +1 -1
  117. package/resources/ai/conversations/messages.d.mts +46 -48
  118. package/resources/ai/conversations/messages.d.mts.map +1 -1
  119. package/resources/ai/conversations/messages.d.ts +46 -48
  120. package/resources/ai/conversations/messages.d.ts.map +1 -1
  121. package/resources/ai/conversations/messages.js +9 -6
  122. package/resources/ai/conversations/messages.js.map +1 -1
  123. package/resources/ai/conversations/messages.mjs +9 -6
  124. package/resources/ai/conversations/messages.mjs.map +1 -1
  125. package/resources/calls/actions.d.mts +114 -6
  126. package/resources/calls/actions.d.mts.map +1 -1
  127. package/resources/calls/actions.d.ts +114 -6
  128. package/resources/calls/actions.d.ts.map +1 -1
  129. package/resources/calls/actions.js +4 -0
  130. package/resources/calls/actions.js.map +1 -1
  131. package/resources/calls/actions.mjs +4 -0
  132. package/resources/calls/actions.mjs.map +1 -1
  133. package/resources/calls/calls.d.mts +168 -8
  134. package/resources/calls/calls.d.mts.map +1 -1
  135. package/resources/calls/calls.d.ts +168 -8
  136. package/resources/calls/calls.d.ts.map +1 -1
  137. package/resources/calls/calls.js +4 -0
  138. package/resources/calls/calls.js.map +1 -1
  139. package/resources/calls/calls.mjs +4 -0
  140. package/resources/calls/calls.mjs.map +1 -1
  141. package/resources/index.d.mts +2 -3
  142. package/resources/index.d.mts.map +1 -1
  143. package/resources/index.d.ts +2 -3
  144. package/resources/index.d.ts.map +1 -1
  145. package/resources/index.js +2 -7
  146. package/resources/index.js.map +1 -1
  147. package/resources/index.mjs +1 -2
  148. package/resources/index.mjs.map +1 -1
  149. package/resources/messages/messages.d.mts +4 -0
  150. package/resources/messages/messages.d.mts.map +1 -1
  151. package/resources/messages/messages.d.ts +4 -0
  152. package/resources/messages/messages.d.ts.map +1 -1
  153. package/resources/messages/messages.js.map +1 -1
  154. package/resources/messages/messages.mjs.map +1 -1
  155. package/resources/session-analysis/session-analysis.d.mts +3 -13
  156. package/resources/session-analysis/session-analysis.d.mts.map +1 -1
  157. package/resources/session-analysis/session-analysis.d.ts +3 -13
  158. package/resources/session-analysis/session-analysis.d.ts.map +1 -1
  159. package/resources/session-analysis/session-analysis.js.map +1 -1
  160. package/resources/session-analysis/session-analysis.mjs.map +1 -1
  161. package/resources/texml/accounts/calls/calls.d.mts +45 -0
  162. package/resources/texml/accounts/calls/calls.d.mts.map +1 -1
  163. package/resources/texml/accounts/calls/calls.d.ts +45 -0
  164. package/resources/texml/accounts/calls/calls.d.ts.map +1 -1
  165. package/resources/texml/accounts/calls/calls.js.map +1 -1
  166. package/resources/texml/accounts/calls/calls.mjs.map +1 -1
  167. package/resources/text-to-speech/index.d.mts +2 -1
  168. package/resources/text-to-speech/index.d.mts.map +1 -1
  169. package/resources/text-to-speech/index.d.ts +2 -1
  170. package/resources/text-to-speech/index.d.ts.map +1 -1
  171. package/resources/text-to-speech/index.js.map +1 -1
  172. package/resources/text-to-speech/index.mjs.map +1 -1
  173. package/resources/text-to-speech/internal-base.d.mts +1 -48
  174. package/resources/text-to-speech/internal-base.d.mts.map +1 -1
  175. package/resources/text-to-speech/internal-base.d.ts +1 -48
  176. package/resources/text-to-speech/internal-base.d.ts.map +1 -1
  177. package/resources/text-to-speech/internal-base.js +5 -48
  178. package/resources/text-to-speech/internal-base.js.map +1 -1
  179. package/resources/text-to-speech/internal-base.mjs +1 -44
  180. package/resources/text-to-speech/internal-base.mjs.map +1 -1
  181. package/resources/text-to-speech/text-to-speech.d.mts +28 -3
  182. package/resources/text-to-speech/text-to-speech.d.mts.map +1 -1
  183. package/resources/text-to-speech/text-to-speech.d.ts +28 -3
  184. package/resources/text-to-speech/text-to-speech.d.ts.map +1 -1
  185. package/resources/text-to-speech/text-to-speech.js +1 -1
  186. package/resources/text-to-speech/text-to-speech.mjs +1 -1
  187. package/resources/text-to-speech/ws-base.d.mts +2 -0
  188. package/resources/text-to-speech/ws-base.d.mts.map +1 -0
  189. package/resources/text-to-speech/ws-base.d.ts +2 -0
  190. package/resources/text-to-speech/ws-base.d.ts.map +1 -0
  191. package/resources/text-to-speech/ws-base.js +7 -0
  192. package/resources/text-to-speech/ws-base.js.map +1 -0
  193. package/resources/text-to-speech/ws-base.mjs +3 -0
  194. package/resources/text-to-speech/ws-base.mjs.map +1 -0
  195. package/resources/text-to-speech/ws.d.mts +2 -41
  196. package/resources/text-to-speech/ws.d.mts.map +1 -1
  197. package/resources/text-to-speech/ws.d.ts +2 -41
  198. package/resources/text-to-speech/ws.d.ts.map +1 -1
  199. package/resources/text-to-speech/ws.js +2 -182
  200. package/resources/text-to-speech/ws.js.map +1 -1
  201. package/resources/text-to-speech/ws.mjs +1 -180
  202. package/resources/text-to-speech/ws.mjs.map +1 -1
  203. package/resources/verify-profiles.d.mts +97 -121
  204. package/resources/verify-profiles.d.mts.map +1 -1
  205. package/resources/verify-profiles.d.ts +97 -121
  206. package/resources/verify-profiles.d.ts.map +1 -1
  207. package/resources/webhooks.d.mts +642 -7
  208. package/resources/webhooks.d.mts.map +1 -1
  209. package/resources/webhooks.d.ts +642 -7
  210. package/resources/webhooks.d.ts.map +1 -1
  211. package/resources/webhooks.js +4 -10
  212. package/resources/webhooks.js.map +1 -1
  213. package/resources/webhooks.mjs +5 -11
  214. package/resources/webhooks.mjs.map +1 -1
  215. package/resources/whatsapp/phone-numbers/profile/profile.d.mts +5 -0
  216. package/resources/whatsapp/phone-numbers/profile/profile.d.mts.map +1 -1
  217. package/resources/whatsapp/phone-numbers/profile/profile.d.ts +5 -0
  218. package/resources/whatsapp/phone-numbers/profile/profile.d.ts.map +1 -1
  219. package/resources/whatsapp/phone-numbers/profile/profile.js.map +1 -1
  220. package/resources/whatsapp/phone-numbers/profile/profile.mjs.map +1 -1
  221. package/src/client.ts +22 -0
  222. package/src/core/EventEmitter.ts +16 -0
  223. package/src/internal/types.ts +6 -8
  224. package/src/internal/utils/env.ts +2 -2
  225. package/src/internal/ws-adapter-browser.ts +123 -0
  226. package/src/internal/ws-adapter-node.ts +105 -0
  227. package/src/internal/ws-adapter.ts +30 -0
  228. package/src/internal/ws.ts +193 -0
  229. package/src/lib/text-to-speech-ws-base.ts +618 -0
  230. package/src/lib/text-to-speech-ws-internal.ts +111 -0
  231. package/src/lib/text-to-speech-ws.ts +40 -0
  232. package/src/lib/webhooks.ts +27 -0
  233. package/src/resources/ai/assistants/assistants.ts +1065 -65
  234. package/src/resources/ai/assistants/versions.ts +639 -25
  235. package/src/resources/ai/conversations/conversations.ts +12 -2
  236. package/src/resources/ai/conversations/index.ts +6 -1
  237. package/src/resources/ai/conversations/messages.ts +67 -54
  238. package/src/resources/calls/actions.ts +184 -4
  239. package/src/resources/calls/calls.ts +191 -4
  240. package/src/resources/index.ts +6 -12
  241. package/src/resources/messages/messages.ts +5 -0
  242. package/src/resources/session-analysis/session-analysis.ts +3 -16
  243. package/src/resources/texml/accounts/calls/calls.ts +54 -0
  244. package/src/resources/text-to-speech/index.ts +2 -1
  245. package/src/resources/text-to-speech/internal-base.ts +6 -95
  246. package/src/resources/text-to-speech/text-to-speech.ts +33 -3
  247. package/src/resources/text-to-speech/ws-base.ts +7 -0
  248. package/src/resources/text-to-speech/ws.ts +2 -201
  249. package/src/resources/verify-profiles.ts +109 -142
  250. package/src/resources/webhooks.ts +886 -45
  251. package/src/resources/whatsapp/phone-numbers/profile/profile.ts +7 -0
  252. package/src/version.ts +1 -1
  253. package/version.d.mts +1 -1
  254. package/version.d.ts +1 -1
  255. package/version.js +1 -1
  256. package/version.mjs +1 -1
@@ -119,6 +119,7 @@ export class Calls extends APIResource {
119
119
  *
120
120
  * - `call.initiated`
121
121
  * - `call.answered` or `call.hangup`
122
+ * - `call.hold` and `call.unhold` if the call is held/unheld
122
123
  * - `call.machine.detection.ended` if `answering_machine_detection` was requested
123
124
  * - `call.machine.greeting.ended` if `answering_machine_detection` was requested
124
125
  * to detect the end of machine greeting
@@ -126,6 +127,9 @@ export class Calls extends APIResource {
126
127
  * `answering_machine_detection=premium` was requested
127
128
  * - `call.machine.premium.greeting.ended` if `answering_machine_detection=premium`
128
129
  * was requested and a beep was detected
130
+ * - `call.deepfake_detection.result` if `deepfake_detection` was enabled
131
+ * - `call.deepfake_detection.error` if `deepfake_detection` was enabled and an
132
+ * error occurred
129
133
  * - `streaming.started`, `streaming.stopped` or `streaming.failed` if `stream_url`
130
134
  * was set
131
135
  *
@@ -184,12 +188,12 @@ export interface CallAssistantRequest {
184
188
  /**
185
189
  * External LLM configuration for bringing your own LLM endpoint.
186
190
  */
187
- external_llm?: { [key: string]: unknown };
191
+ external_llm?: CallAssistantRequest.ExternalLlm;
188
192
 
189
193
  /**
190
194
  * Fallback LLM configuration used when the primary LLM provider is unavailable.
191
195
  */
192
- fallback_config?: { [key: string]: unknown };
196
+ fallback_config?: CallAssistantRequest.FallbackConfig;
193
197
 
194
198
  /**
195
199
  * Initial greeting text spoken when the assistant starts. Can be plain text for
@@ -256,6 +260,125 @@ export interface CallAssistantRequest {
256
260
  >;
257
261
  }
258
262
 
263
+ export namespace CallAssistantRequest {
264
+ /**
265
+ * External LLM configuration for bringing your own LLM endpoint.
266
+ */
267
+ export interface ExternalLlm {
268
+ /**
269
+ * Authentication method used when connecting to the external LLM endpoint.
270
+ */
271
+ authentication_method?: 'token' | 'certificate';
272
+
273
+ /**
274
+ * Base URL for the external LLM endpoint.
275
+ */
276
+ base_url?: string;
277
+
278
+ /**
279
+ * Integration secret identifier for the client certificate used with certificate
280
+ * authentication.
281
+ */
282
+ certificate_ref?: string;
283
+
284
+ /**
285
+ * When enabled, Telnyx forwards the assistant's dynamic variables to the external
286
+ * LLM endpoint. Defaults to false. The chat completion request includes a
287
+ * top-level `extra_metadata` object when dynamic variables are available. For
288
+ * example:
289
+ * `{"extra_metadata":{"customer_name":"Jane","account_id":"acct_789","telnyx_agent_target":"+13125550100","telnyx_end_user_target":"+13125550123"}}`.
290
+ */
291
+ forward_metadata?: boolean;
292
+
293
+ /**
294
+ * Integration secret identifier for the external LLM API key.
295
+ */
296
+ llm_api_key_ref?: string;
297
+
298
+ /**
299
+ * Model identifier to use with the external LLM endpoint.
300
+ */
301
+ model?: string;
302
+
303
+ /**
304
+ * URL used to retrieve an access token when certificate authentication is enabled.
305
+ */
306
+ token_retrieval_url?: string;
307
+
308
+ [k: string]: unknown;
309
+ }
310
+
311
+ /**
312
+ * Fallback LLM configuration used when the primary LLM provider is unavailable.
313
+ */
314
+ export interface FallbackConfig {
315
+ /**
316
+ * External LLM fallback configuration.
317
+ */
318
+ external_llm?: FallbackConfig.ExternalLlm;
319
+
320
+ /**
321
+ * Integration secret identifier for the fallback model API key.
322
+ */
323
+ llm_api_key_ref?: string;
324
+
325
+ /**
326
+ * Fallback Telnyx-hosted model to use when the primary LLM provider is
327
+ * unavailable.
328
+ */
329
+ model?: string;
330
+
331
+ [k: string]: unknown;
332
+ }
333
+
334
+ export namespace FallbackConfig {
335
+ /**
336
+ * External LLM fallback configuration.
337
+ */
338
+ export interface ExternalLlm {
339
+ /**
340
+ * Authentication method used when connecting to the external LLM endpoint.
341
+ */
342
+ authentication_method?: 'token' | 'certificate';
343
+
344
+ /**
345
+ * Base URL for the external LLM endpoint.
346
+ */
347
+ base_url?: string;
348
+
349
+ /**
350
+ * Integration secret identifier for the client certificate used with certificate
351
+ * authentication.
352
+ */
353
+ certificate_ref?: string;
354
+
355
+ /**
356
+ * When enabled, Telnyx forwards the assistant's dynamic variables to the external
357
+ * LLM endpoint. Defaults to false. The chat completion request includes a
358
+ * top-level `extra_metadata` object when dynamic variables are available. For
359
+ * example:
360
+ * `{"extra_metadata":{"customer_name":"Jane","account_id":"acct_789","telnyx_agent_target":"+13125550100","telnyx_end_user_target":"+13125550123"}}`.
361
+ */
362
+ forward_metadata?: boolean;
363
+
364
+ /**
365
+ * Integration secret identifier for the external LLM API key.
366
+ */
367
+ llm_api_key_ref?: string;
368
+
369
+ /**
370
+ * Model identifier to use with the external LLM endpoint.
371
+ */
372
+ model?: string;
373
+
374
+ /**
375
+ * URL used to retrieve an access token when certificate authentication is enabled.
376
+ */
377
+ token_retrieval_url?: string;
378
+ }
379
+ }
380
+ }
381
+
259
382
  export interface CustomSipHeader {
260
383
  /**
261
384
  * The name of the header to add.
@@ -507,7 +630,9 @@ export interface CallDialParams {
507
630
 
508
631
  /**
509
632
  * Optional configuration parameters to modify 'answering_machine_detection'
510
- * performance.
633
+ * performance. Only `total_analysis_time_millis` and `greeting_duration_millis`
634
+ * parameters are applicable when `premium` is selected as
635
+ * answering_machine_detection.
511
636
  */
512
637
  answering_machine_detection_config?: CallDialParams.AnsweringMachineDetectionConfig;
513
638
 
@@ -566,6 +691,14 @@ export interface CallDialParams {
566
691
  */
567
692
  custom_headers?: Array<CustomSipHeader>;
568
693
 
694
+ /**
695
+ * Enables deepfake detection on the call. When enabled, audio from the remote
696
+ * party is streamed to a detection service that analyzes whether the voice is
697
+ * AI-generated. Results are delivered via the `call.deepfake_detection.result`
698
+ * webhook.
699
+ */
700
+ deepfake_detection?: CallDialParams.DeepfakeDetection;
701
+
569
702
  dialogflow_config?: DialogflowConfig;
570
703
 
571
704
  /**
@@ -802,6 +935,13 @@ export interface CallDialParams {
802
935
 
803
936
  transcription_config?: ActionsAPI.TranscriptionStartRequest;
804
937
 
938
+ /**
939
+ * A map of event types to retry policies. Each retry policy contains an array of
940
+ * `retries_ms` specifying the delays between retry attempts in milliseconds.
941
+ * Maximum 5 retries, total delay cannot exceed 60 seconds.
942
+ */
943
+ webhook_retries_policies?: { [key: string]: CallDialParams.WebhookRetriesPolicies };
944
+
805
945
  /**
806
946
  * Use this field to override the URL for which Telnyx will send subsequent
807
947
  * webhooks to for this call.
@@ -812,12 +952,27 @@ export interface CallDialParams {
812
952
  * HTTP request type used for `webhook_url`.
813
953
  */
814
954
  webhook_url_method?: 'POST' | 'GET';
955
+
956
+ /**
957
+ * A map of event types to webhook URLs. When an event of the specified type
958
+ * occurs, the webhook URL associated with that event type will be called instead
959
+ * of the default webhook URL. Events not mapped here will use the default webhook
960
+ * URL.
961
+ */
962
+ webhook_urls?: { [key: string]: string };
963
+
964
+ /**
965
+ * HTTP request method to invoke `webhook_urls`.
966
+ */
967
+ webhook_urls_method?: 'POST' | 'GET';
815
968
  }
816
969
 
817
970
  export namespace CallDialParams {
818
971
  /**
819
972
  * Optional configuration parameters to modify 'answering_machine_detection'
820
- * performance.
973
+ * performance. Only `total_analysis_time_millis` and `greeting_duration_millis`
974
+ * parameters are applicable when `premium` is selected as
975
+ * answering_machine_detection.
821
976
  */
822
977
  export interface AnsweringMachineDetectionConfig {
823
978
  /**
@@ -974,6 +1129,38 @@ export namespace CallDialParams {
974
1129
  */
975
1130
  whisper_call_control_ids?: Array<string>;
976
1131
  }
1132
+
1133
+ /**
1134
+ * Enables deepfake detection on the call. When enabled, audio from the remote
1135
+ * party is streamed to a detection service that analyzes whether the voice is
1136
+ * AI-generated. Results are delivered via the `call.deepfake_detection.result`
1137
+ * webhook.
1138
+ */
1139
+ export interface DeepfakeDetection {
1140
+ /**
1141
+ * Whether deepfake detection is enabled.
1142
+ */
1143
+ enabled: boolean;
1144
+
1145
+ /**
1146
+ * Maximum time in seconds to wait for RTP audio before timing out. If no audio is
1147
+ * received within this window, detection stops with an error.
1148
+ */
1149
+ rtp_timeout?: number;
1150
+
1151
+ /**
1152
+ * Maximum time in seconds to wait for a detection result before timing out.
1153
+ */
1154
+ timeout?: number;
1155
+ }
1156
+
1157
+ export interface WebhookRetriesPolicies {
1158
+ /**
1159
+ * Array of delays in milliseconds between retry attempts. Total sum cannot exceed
1160
+ * 60000ms.
1161
+ */
1162
+ retries_ms?: Array<number>;
1163
+ }
977
1164
  }
978
1165
 
979
1166
  Calls.Actions = Actions;
@@ -1095,17 +1095,6 @@ export {
1095
1095
  type ShortCodeUpdateParams,
1096
1096
  type ShortCodeListParams,
1097
1097
  } from './short-codes';
1098
- export {
1099
- SpeechToText,
1100
- SpeechToTextWS,
1101
- WebSocketError as SpeechToTextWebSocketError,
1102
- type SpeechToTextTranscribeParams,
1103
- type SpeechToTextStreamParams,
1104
- type SttClientEvent,
1105
- type SttServerEvent,
1106
- type TranscriptFrame,
1107
- type SttErrorFrame,
1108
- } from './speech-to-text';
1109
1098
  export {
1110
1099
  SimCardDataUsageNotifications,
1111
1100
  type SimCardDataUsageNotification,
@@ -1230,13 +1219,13 @@ export {
1230
1219
  } from './texml-applications';
1231
1220
  export {
1232
1221
  TextToSpeech,
1233
- TextToSpeechWS,
1234
1222
  type TextToSpeechGenerateResponse,
1235
1223
  type TextToSpeechListVoicesResponse,
1236
1224
  type StreamClientEvent,
1237
1225
  type StreamServerEvent,
1238
1226
  type TextToSpeechGenerateParams,
1239
1227
  type TextToSpeechListVoicesParams,
1228
+ type TextToSpeechStreamParams,
1240
1229
  } from './text-to-speech';
1241
1230
  export {
1242
1231
  TrafficPolicyProfiles,
@@ -1428,12 +1417,15 @@ export {
1428
1417
  type CallConversationEndedWebhookEvent,
1429
1418
  type CallConversationInsightsGeneratedWebhookEvent,
1430
1419
  type CallCostWebhookEvent,
1420
+ type CallDeepfakeDetectionErrorWebhookEvent,
1421
+ type CallDeepfakeDetectionResultWebhookEvent,
1431
1422
  type CallDtmfReceivedWebhookEvent,
1432
1423
  type CallEnqueuedWebhookEvent,
1433
1424
  type CallForkStartedWebhookEvent,
1434
1425
  type CallForkStoppedWebhookEvent,
1435
1426
  type CallGatherEndedWebhookEvent,
1436
1427
  type CallHangupWebhookEvent,
1428
+ type CallHoldWebhookEvent,
1437
1429
  type CallInitiatedWebhookEvent,
1438
1430
  type CallLeftQueueWebhookEvent,
1439
1431
  type CallMachineDetectionEndedWebhookEvent,
@@ -1456,6 +1448,7 @@ export {
1456
1448
  type CallStreamingFailedWebhookEvent,
1457
1449
  type CallStreamingStartedWebhookEvent,
1458
1450
  type CallStreamingStoppedWebhookEvent,
1451
+ type CallUnholdWebhookEvent,
1459
1452
  type ConferenceCreatedWebhookEvent,
1460
1453
  type ConferenceEndedWebhookEvent,
1461
1454
  type ConferenceParticipantJoinedWebhookEvent,
@@ -1470,6 +1463,7 @@ export {
1470
1463
  type ConferenceSpeakEndedWebhookEvent,
1471
1464
  type ConferenceSpeakStartedWebhookEvent,
1472
1465
  type DeliveryUpdateWebhookEvent,
1466
+ type HostedNumberOrderEventWebhookEvent,
1473
1467
  type InboundMessageWebhookEvent,
1474
1468
  type ReplacedLinkClickWebhookEvent,
1475
1469
  type TranscriptionWebhookEvent,
@@ -2070,6 +2070,11 @@ export interface MessageSendWhatsappParams {
2070
2070
 
2071
2071
  whatsapp_message: WhatsappMessageContent;
2072
2072
 
2073
+ /**
2074
+ * Messaging profile ID - required if the 'from' number is not SMS-enabled
2075
+ */
2076
+ messaging_profile_id?: string;
2077
+
2073
2078
  /**
2074
2079
  * Message type - must be set to "WHATSAPP"
2075
2080
  */
@@ -135,11 +135,6 @@ export namespace EventNode {
135
135
  export interface SessionAnalysisRetrieveResponse {
136
136
  cost: SessionAnalysisRetrieveResponse.Cost;
137
137
 
138
- /**
139
- * When the session started.
140
- */
141
- created_at: string;
142
-
143
138
  meta: SessionAnalysisRetrieveResponse.Meta;
144
139
 
145
140
  root: EventNode;
@@ -148,16 +143,6 @@ export interface SessionAnalysisRetrieveResponse {
148
143
  * Identifier for the analyzed session.
149
144
  */
150
145
  session_id: string;
151
-
152
- /**
153
- * Analysis status (e.g. "completed").
154
- */
155
- status: string;
156
-
157
- /**
158
- * When the session completed.
159
- */
160
- completed_at?: string | null;
161
146
  }
162
147
 
163
148
  export namespace SessionAnalysisRetrieveResponse {
@@ -193,7 +178,9 @@ export interface SessionAnalysisRetrieveParams {
193
178
  record_type: string;
194
179
 
195
180
  /**
196
- * Query param: ISO 8601 timestamp to narrow index selection for faster lookups.
181
+ * Query param: ISO 8601 timestamp or date to narrow index selection for faster
182
+ * lookups. Accepts full datetime (e.g., 2026-03-17T10:00:00Z) or date-only format
183
+ * (e.g., 2026-03-17).
197
184
  */
198
185
  date_time?: string;
199
186
 
@@ -735,6 +735,24 @@ export namespace CallCallsParams {
735
735
  */
736
736
  CustomHeaders?: Array<WithURL.CustomHeader>;
737
737
 
738
+ /**
739
+ * Enables Deepfake Detection on the dialed call. When enabled, audio from the
740
+ * remote party is analyzed to determine whether the voice is AI-generated. Results
741
+ * are delivered asynchronously via a callback.
742
+ */
743
+ DeepfakeDetection?: 'Enable';
744
+
745
+ /**
746
+ * HTTP request type used for `DeepfakeDetectionCallbackUrl`.
747
+ */
748
+ DeepfakeDetectionCallbackMethod?: 'GET' | 'POST';
749
+
750
+ /**
751
+ * URL destination for Telnyx to send deepfake detection callback events to for the
752
+ * call.
753
+ */
754
+ DeepfakeDetectionCallbackUrl?: string;
755
+
738
756
  /**
739
757
  * Allows you to chose between Premium and Standard detections.
740
758
  */
@@ -985,6 +1003,24 @@ export namespace CallCallsParams {
985
1003
  */
986
1004
  CustomHeaders?: Array<WithTeXml.CustomHeader>;
987
1005
 
1006
+ /**
1007
+ * Enables Deepfake Detection on the dialed call. When enabled, audio from the
1008
+ * remote party is analyzed to determine whether the voice is AI-generated. Results
1009
+ * are delivered asynchronously via a callback.
1010
+ */
1011
+ DeepfakeDetection?: 'Enable';
1012
+
1013
+ /**
1014
+ * HTTP request type used for `DeepfakeDetectionCallbackUrl`.
1015
+ */
1016
+ DeepfakeDetectionCallbackMethod?: 'GET' | 'POST';
1017
+
1018
+ /**
1019
+ * URL destination for Telnyx to send deepfake detection callback events to for the
1020
+ * call.
1021
+ */
1022
+ DeepfakeDetectionCallbackUrl?: string;
1023
+
988
1024
  /**
989
1025
  * Allows you to chose between Premium and Standard detections.
990
1026
  */
@@ -1229,6 +1265,24 @@ export namespace CallCallsParams {
1229
1265
  */
1230
1266
  CustomHeaders?: Array<ApplicationDefault.CustomHeader>;
1231
1267
 
1268
+ /**
1269
+ * Enables Deepfake Detection on the dialed call. When enabled, audio from the
1270
+ * remote party is analyzed to determine whether the voice is AI-generated. Results
1271
+ * are delivered asynchronously via a callback.
1272
+ */
1273
+ DeepfakeDetection?: 'Enable';
1274
+
1275
+ /**
1276
+ * HTTP request type used for `DeepfakeDetectionCallbackUrl`.
1277
+ */
1278
+ DeepfakeDetectionCallbackMethod?: 'GET' | 'POST';
1279
+
1280
+ /**
1281
+ * URL destination for Telnyx to send deepfake detection callback events to for the
1282
+ * call.
1283
+ */
1284
+ DeepfakeDetectionCallbackUrl?: string;
1285
+
1232
1286
  /**
1233
1287
  * Allows you to chose between Premium and Standard detections.
1234
1288
  */
@@ -10,4 +10,5 @@ export {
10
10
  type TextToSpeechListVoicesParams,
11
11
  type TextToSpeechStreamParams,
12
12
  } from './text-to-speech';
13
- export { TextToSpeechWS } from './ws';
13
+ export { TextToSpeechWS, type TextToSpeechWSClientOptions } from './ws';
14
+ export { type TextToSpeechWSReconnectOptions } from './ws-base';
@@ -1,97 +1,8 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as TextToSpeechAPI from './text-to-speech';
4
- import { Telnyx } from '../../client';
5
- import { EventEmitter } from '../../core/EventEmitter';
6
- import { TelnyxError } from '../../core/error';
7
- import { stringifyQuery } from '../../internal/utils';
8
-
9
- export type TextToSpeechStreamMessage =
10
- | { type: 'connecting' | 'open' | 'closing' | 'close' }
11
- | { type: 'message'; message: TextToSpeechAPI.StreamServerEvent }
12
- | { type: 'error'; error: WebSocketError };
13
-
14
- export class WebSocketError extends TelnyxError {
15
- /**
16
- * The error data that the API sent back in an error event.
17
- */
18
- error?: TextToSpeechAPI.StreamServerEvent.ErrorFrame | undefined;
19
-
20
- constructor(message: string, event: TextToSpeechAPI.StreamServerEvent.ErrorFrame | null) {
21
- super(message);
22
-
23
- this.error = event ?? undefined;
24
- }
25
- }
26
-
27
- type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
28
-
29
- type WebSocketEvents = Simplify<
30
- {
31
- event: (event: TextToSpeechAPI.StreamServerEvent) => void;
32
- error: (error: WebSocketError) => void;
33
- } & {
34
- [EventType in Exclude<NonNullable<TextToSpeechAPI.StreamServerEvent['type']>, 'error'>]: (
35
- event: Extract<TextToSpeechAPI.StreamServerEvent, { type?: EventType }>,
36
- ) => unknown;
37
- }
38
- >;
39
-
40
- export abstract class TextToSpeechEmitter extends EventEmitter<WebSocketEvents> {
41
- /**
42
- * Send an event to the API.
43
- */
44
- abstract send(event: TextToSpeechAPI.StreamClientEvent): void;
45
-
46
- /**
47
- * Close the WebSocket connection.
48
- */
49
- abstract close(props?: { code: number; reason: string }): void;
50
-
51
- protected _onError(event: null, message: string, cause: any): void;
52
- protected _onError(event: TextToSpeechAPI.StreamServerEvent.ErrorFrame, message?: string | undefined): void;
53
- protected _onError(
54
- event: TextToSpeechAPI.StreamServerEvent.ErrorFrame | null,
55
- message?: string | undefined,
56
- cause?: any,
57
- ): void {
58
- message = message ?? safeJSONStringify(event) ?? 'unknown error';
59
-
60
- if (!this._hasListener('error')) {
61
- const error = new WebSocketError(
62
- message +
63
- `\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`ws.on('error', (error) => ...)\` `,
64
- event,
65
- );
66
- // @ts-ignore
67
- error.cause = cause;
68
- Promise.reject(error);
69
- return;
70
- }
71
-
72
- const error = new WebSocketError(message, event);
73
- // @ts-ignore
74
- error.cause = cause;
75
-
76
- this._emit('error', error);
77
- }
78
- }
79
-
80
- export function buildURL(client: Telnyx, query?: object | null): URL {
81
- const path = '/text-to-speech/speech';
82
- const baseURL = client.baseURL;
83
- const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
84
- if (query) {
85
- url.search = stringifyQuery(query);
86
- }
87
- url.protocol = url.protocol === 'http:' ? 'ws:' : 'wss:';
88
- return url;
89
- }
90
-
91
- function safeJSONStringify(value: unknown): string | null {
92
- try {
93
- return JSON.stringify(value);
94
- } catch {
95
- return null;
96
- }
97
- }
3
+ export {
4
+ TextToSpeechEmitter,
5
+ WebSocketError,
6
+ buildURL,
7
+ type TextToSpeechStreamMessage,
8
+ } from '../../lib/text-to-speech-ws-internal';
@@ -23,7 +23,7 @@ export class TextToSpeech extends APIResource {
23
23
  * with provider-specific parameters.
24
24
  *
25
25
  * Supported providers: `aws`, `telnyx`, `azure`, `elevenlabs`, `minimax`, `rime`,
26
- * `resemble`, `inworld`.
26
+ * `resemble`, `xai`.
27
27
  *
28
28
  * The Telnyx `Ultra` model supports 44 languages with emotion control, speed
29
29
  * adjustment, and volume control. Use the `telnyx` provider-specific parameters to
@@ -281,7 +281,7 @@ export interface TextToSpeechGenerateParams {
281
281
  /**
282
282
  * TTS provider. Required unless `voice` is provided.
283
283
  */
284
- provider?: 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'rime' | 'resemble' | 'inworld';
284
+ provider?: 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'rime' | 'resemble' | 'inworld' | 'xai';
285
285
 
286
286
  /**
287
287
  * Resemble AI provider-specific parameters.
@@ -325,6 +325,11 @@ export interface TextToSpeechGenerateParams {
325
325
  * provider-specific parameter objects below.
326
326
  */
327
327
  voice_settings?: { [key: string]: unknown };
328
+
329
+ /**
330
+ * xAI provider-specific parameters.
331
+ */
332
+ xai?: TextToSpeechGenerateParams.Xai;
328
333
  }
329
334
 
330
335
  export namespace TextToSpeechGenerateParams {
@@ -535,6 +540,31 @@ export namespace TextToSpeechGenerateParams {
535
540
  */
536
541
  volume?: number;
537
542
  }
543
+
544
+ /**
545
+ * xAI provider-specific parameters.
546
+ */
547
+ export interface Xai {
548
+ /**
549
+ * xAI voice identifier.
550
+ */
551
+ voice_id: 'eve' | 'ara' | 'rex' | 'sal' | 'leo';
552
+
553
+ /**
554
+ * Language code, or `auto` to detect.
555
+ */
556
+ language?: string;
557
+
558
+ /**
559
+ * Audio output format.
560
+ */
561
+ output_format?: 'mp3' | 'wav' | 'pcm' | 'mulaw' | 'alaw';
562
+
563
+ /**
564
+ * Audio sample rate in Hz.
565
+ */
566
+ sample_rate?: 8000 | 16000 | 22050 | 24000 | 44100 | 48000;
567
+ }
538
568
  }
539
569
 
540
570
  export interface TextToSpeechListVoicesParams {
@@ -546,7 +576,7 @@ export interface TextToSpeechListVoicesParams {
546
576
  /**
547
577
  * Filter voices by provider. If omitted, voices from all providers are returned.
548
578
  */
549
- provider?: 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'rime' | 'resemble' | 'inworld';
579
+ provider?: 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'rime' | 'resemble' | 'inworld' | 'xai';
550
580
  }
551
581
 
552
582
  export declare namespace TextToSpeech {
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ TextToSpeechWSBase,
5
+ type TextToSpeechWSBaseOptions,
6
+ type TextToSpeechWSReconnectOptions,
7
+ } from '../../lib/text-to-speech-ws-base';