@sentdm/sentdm 0.45.0 → 0.47.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 (191) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/client.d.mts +6 -11
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -11
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -10
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -10
  9. package/client.mjs.map +1 -1
  10. package/core/pagination.d.mts +25 -0
  11. package/core/pagination.d.mts.map +1 -1
  12. package/core/pagination.d.ts +25 -0
  13. package/core/pagination.d.ts.map +1 -1
  14. package/core/pagination.js +28 -1
  15. package/core/pagination.js.map +1 -1
  16. package/core/pagination.mjs +26 -0
  17. package/core/pagination.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/resources/channels/channels.d.mts +2 -2
  20. package/resources/channels/channels.d.mts.map +1 -1
  21. package/resources/channels/channels.d.ts +2 -2
  22. package/resources/channels/channels.d.ts.map +1 -1
  23. package/resources/channels/channels.js.map +1 -1
  24. package/resources/channels/channels.mjs.map +1 -1
  25. package/resources/channels/index.d.mts +1 -1
  26. package/resources/channels/index.d.mts.map +1 -1
  27. package/resources/channels/index.d.ts +1 -1
  28. package/resources/channels/index.d.ts.map +1 -1
  29. package/resources/channels/index.js.map +1 -1
  30. package/resources/channels/index.mjs.map +1 -1
  31. package/resources/channels/voice.d.mts +72 -115
  32. package/resources/channels/voice.d.mts.map +1 -1
  33. package/resources/channels/voice.d.ts +72 -115
  34. package/resources/channels/voice.d.ts.map +1 -1
  35. package/resources/channels/voice.js +35 -45
  36. package/resources/channels/voice.js.map +1 -1
  37. package/resources/channels/voice.mjs +35 -45
  38. package/resources/channels/voice.mjs.map +1 -1
  39. package/resources/index.d.mts +1 -1
  40. package/resources/index.d.mts.map +1 -1
  41. package/resources/index.d.ts +1 -1
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +3 -3
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +1 -1
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/messages.d.mts +8 -1
  48. package/resources/messages.d.mts.map +1 -1
  49. package/resources/messages.d.ts +8 -1
  50. package/resources/messages.d.ts.map +1 -1
  51. package/resources/profiles/campaigns.d.mts +3 -2
  52. package/resources/profiles/campaigns.d.mts.map +1 -1
  53. package/resources/profiles/campaigns.d.ts +3 -2
  54. package/resources/profiles/campaigns.d.ts.map +1 -1
  55. package/resources/profiles/campaigns.js +3 -2
  56. package/resources/profiles/campaigns.js.map +1 -1
  57. package/resources/profiles/campaigns.mjs +3 -2
  58. package/resources/profiles/campaigns.mjs.map +1 -1
  59. package/resources/templates.d.mts +14 -13
  60. package/resources/templates.d.mts.map +1 -1
  61. package/resources/templates.d.ts +14 -13
  62. package/resources/templates.d.ts.map +1 -1
  63. package/resources/voice/agents.d.mts +524 -0
  64. package/resources/voice/agents.d.mts.map +1 -0
  65. package/resources/voice/agents.d.ts +524 -0
  66. package/resources/voice/agents.d.ts.map +1 -0
  67. package/resources/voice/agents.js +193 -0
  68. package/resources/voice/agents.js.map +1 -0
  69. package/resources/voice/agents.mjs +189 -0
  70. package/resources/voice/agents.mjs.map +1 -0
  71. package/resources/{calls → voice/calls}/calls.d.mts +103 -26
  72. package/resources/voice/calls/calls.d.mts.map +1 -0
  73. package/resources/{calls → voice/calls}/calls.d.ts +103 -26
  74. package/resources/voice/calls/calls.d.ts.map +1 -0
  75. package/resources/{calls → voice/calls}/calls.js +35 -28
  76. package/resources/voice/calls/calls.js.map +1 -0
  77. package/resources/{calls → voice/calls}/calls.mjs +34 -27
  78. package/resources/voice/calls/calls.mjs.map +1 -0
  79. package/resources/voice/calls/index.d.mts.map +1 -0
  80. package/resources/voice/calls/index.d.ts.map +1 -0
  81. package/resources/voice/calls/index.js.map +1 -0
  82. package/resources/voice/calls/index.mjs.map +1 -0
  83. package/resources/{calls → voice/calls}/participants.d.mts +16 -14
  84. package/resources/voice/calls/participants.d.mts.map +1 -0
  85. package/resources/{calls → voice/calls}/participants.d.ts +16 -14
  86. package/resources/voice/calls/participants.d.ts.map +1 -0
  87. package/resources/{calls → voice/calls}/participants.js +19 -17
  88. package/resources/voice/calls/participants.js.map +1 -0
  89. package/resources/{calls → voice/calls}/participants.mjs +19 -17
  90. package/resources/voice/calls/participants.mjs.map +1 -0
  91. package/resources/voice/calls.d.mts.map +1 -0
  92. package/resources/voice/calls.d.ts.map +1 -0
  93. package/resources/{calls.js → voice/calls.js} +1 -1
  94. package/resources/voice/calls.js.map +1 -0
  95. package/resources/voice/calls.mjs.map +1 -0
  96. package/resources/voice/catalogue.d.mts +86 -0
  97. package/resources/voice/catalogue.d.mts.map +1 -0
  98. package/resources/voice/catalogue.d.ts +86 -0
  99. package/resources/voice/catalogue.d.ts.map +1 -0
  100. package/resources/voice/catalogue.js +40 -0
  101. package/resources/voice/catalogue.js.map +1 -0
  102. package/resources/voice/catalogue.mjs +36 -0
  103. package/resources/voice/catalogue.mjs.map +1 -0
  104. package/resources/voice/index.d.mts +6 -0
  105. package/resources/voice/index.d.mts.map +1 -0
  106. package/resources/voice/index.d.ts +6 -0
  107. package/resources/voice/index.d.ts.map +1 -0
  108. package/resources/voice/index.js +15 -0
  109. package/resources/voice/index.js.map +1 -0
  110. package/resources/voice/index.mjs +7 -0
  111. package/resources/voice/index.mjs.map +1 -0
  112. package/resources/voice/tokens.d.mts +111 -0
  113. package/resources/voice/tokens.d.mts.map +1 -0
  114. package/resources/voice/tokens.d.ts +111 -0
  115. package/resources/voice/tokens.d.ts.map +1 -0
  116. package/resources/voice/tokens.js +47 -0
  117. package/resources/voice/tokens.js.map +1 -0
  118. package/resources/voice/tokens.mjs +43 -0
  119. package/resources/voice/tokens.mjs.map +1 -0
  120. package/resources/voice/voice.d.mts +22 -0
  121. package/resources/voice/voice.d.mts.map +1 -0
  122. package/resources/voice/voice.d.ts +22 -0
  123. package/resources/voice/voice.d.ts.map +1 -0
  124. package/resources/voice/voice.js +29 -0
  125. package/resources/voice/voice.js.map +1 -0
  126. package/resources/voice/voice.mjs +24 -0
  127. package/resources/voice/voice.mjs.map +1 -0
  128. package/resources/voice.d.mts +2 -0
  129. package/resources/voice.d.mts.map +1 -0
  130. package/resources/voice.d.ts +2 -0
  131. package/resources/voice.d.ts.map +1 -0
  132. package/resources/voice.js +6 -0
  133. package/resources/voice.js.map +1 -0
  134. package/resources/voice.mjs +3 -0
  135. package/resources/voice.mjs.map +1 -0
  136. package/resources/webhooks.d.mts +154 -31
  137. package/resources/webhooks.d.mts.map +1 -1
  138. package/resources/webhooks.d.ts +154 -31
  139. package/resources/webhooks.d.ts.map +1 -1
  140. package/resources/webhooks.js +51 -11
  141. package/resources/webhooks.js.map +1 -1
  142. package/resources/webhooks.mjs +51 -11
  143. package/resources/webhooks.mjs.map +1 -1
  144. package/src/client.ts +12 -45
  145. package/src/core/pagination.ts +64 -0
  146. package/src/resources/channels/channels.ts +0 -6
  147. package/src/resources/channels/index.ts +0 -3
  148. package/src/resources/channels/voice.ts +74 -144
  149. package/src/resources/index.ts +1 -18
  150. package/src/resources/messages.ts +8 -1
  151. package/src/resources/profiles/campaigns.ts +3 -2
  152. package/src/resources/templates.ts +14 -13
  153. package/src/resources/voice/agents.ts +729 -0
  154. package/src/resources/{calls → voice/calls}/calls.ts +122 -33
  155. package/src/resources/{calls → voice/calls}/participants.ts +23 -21
  156. package/src/resources/voice/catalogue.ts +118 -0
  157. package/src/resources/voice/index.ts +55 -0
  158. package/src/resources/voice/tokens.ts +146 -0
  159. package/src/resources/voice/voice.ts +134 -0
  160. package/src/resources/voice.ts +3 -0
  161. package/src/resources/webhooks.ts +162 -31
  162. package/src/version.ts +1 -1
  163. package/version.d.mts +1 -1
  164. package/version.d.ts +1 -1
  165. package/version.js +1 -1
  166. package/version.mjs +1 -1
  167. package/resources/calls/calls.d.mts.map +0 -1
  168. package/resources/calls/calls.d.ts.map +0 -1
  169. package/resources/calls/calls.js.map +0 -1
  170. package/resources/calls/calls.mjs.map +0 -1
  171. package/resources/calls/index.d.mts.map +0 -1
  172. package/resources/calls/index.d.ts.map +0 -1
  173. package/resources/calls/index.js.map +0 -1
  174. package/resources/calls/index.mjs.map +0 -1
  175. package/resources/calls/participants.d.mts.map +0 -1
  176. package/resources/calls/participants.d.ts.map +0 -1
  177. package/resources/calls/participants.js.map +0 -1
  178. package/resources/calls/participants.mjs.map +0 -1
  179. package/resources/calls.d.mts.map +0 -1
  180. package/resources/calls.d.ts.map +0 -1
  181. package/resources/calls.js.map +0 -1
  182. package/resources/calls.mjs.map +0 -1
  183. /package/resources/{calls → voice/calls}/index.d.mts +0 -0
  184. /package/resources/{calls → voice/calls}/index.d.ts +0 -0
  185. /package/resources/{calls → voice/calls}/index.js +0 -0
  186. /package/resources/{calls → voice/calls}/index.mjs +0 -0
  187. /package/resources/{calls.d.mts → voice/calls.d.mts} +0 -0
  188. /package/resources/{calls.d.ts → voice/calls.d.ts} +0 -0
  189. /package/resources/{calls.mjs → voice/calls.mjs} +0 -0
  190. /package/src/resources/{calls → voice/calls}/index.ts +0 -0
  191. /package/src/resources/{calls.ts → voice/calls.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../core/resource';
4
- import * as WebhooksAPI from '../webhooks';
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as WebhooksAPI from '../../webhooks';
5
5
  import * as ParticipantsAPI from './participants';
6
6
  import {
7
7
  APIResponseOfListOfCallParticipant,
@@ -14,30 +14,34 @@ import {
14
14
  ParticipantUpdateParams,
15
15
  Participants,
16
16
  } from './participants';
17
- import { APIPromise } from '../../core/api-promise';
18
- import { CallsPage, type CallsPageParams, PagePromise } from '../../core/pagination';
19
- import { buildHeaders } from '../../internal/headers';
20
- import { RequestOptions } from '../../internal/request-options';
21
- import { path } from '../../internal/utils/path';
17
+ import { APIPromise } from '../../../core/api-promise';
18
+ import { CallsPage, type CallsPageParams, PagePromise } from '../../../core/pagination';
19
+ import { buildHeaders } from '../../../internal/headers';
20
+ import { RequestOptions } from '../../../internal/request-options';
21
+ import { path } from '../../../internal/utils/path';
22
22
 
23
23
  /**
24
24
  * Phone calls from the numbers you hold, driven by your own callback URL.
25
25
  *
26
- * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
26
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
27
27
  *
28
- * Every call is a record under `/v3/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
28
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
29
+ *
30
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
29
31
  */
30
32
  export class Calls extends APIResource {
31
33
  participants: ParticipantsAPI.Participants = new ParticipantsAPI.Participants(this._client);
32
34
 
33
35
  /**
34
- * Retrieves one of your calls by id: the parties, the owning number, the current
35
- * status with its failure reason, duration, price, recording availability, and a
36
- * timeline of when the call entered each status.
36
+ * Retrieves one of your calls by id: the parties, the owning number, the phone
37
+ * number the call was connected to and the caller id it showed, the current status
38
+ * with its failure reason, duration, price with the billed legs and what each
39
+ * cost, recording availability, and a timeline of when the call entered each
40
+ * status.
37
41
  *
38
42
  * @example
39
43
  * ```ts
40
- * const apiResponseOfCall = await client.calls.retrieve(
44
+ * const apiResponseOfCall = await client.voice.calls.retrieve(
41
45
  * 'call_9f2ab000-0000-4000-8000-000000000001',
42
46
  * );
43
47
  * ```
@@ -48,7 +52,7 @@ export class Calls extends APIResource {
48
52
  options?: RequestOptions,
49
53
  ): APIPromise<APIResponseOfCall> {
50
54
  const { 'x-profile-id': xProfileID } = params ?? {};
51
- return this._client.get(path`/v3/calls/${id}`, {
55
+ return this._client.get(path`/v3/voice/calls/${id}`, {
52
56
  ...options,
53
57
  headers: buildHeaders([
54
58
  { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
@@ -59,14 +63,17 @@ export class Calls extends APIResource {
59
63
 
60
64
  /**
61
65
  * Retrieves a paginated list of your calls, most recent first. Filter by
62
- * direction, status, the owning number, and the time the call started (from and to
63
- * are inclusive). Use the call webhooks for real-time updates; this list is for
64
- * looking calls up afterwards.
66
+ * direction, status, the owning number, the mode (inapp, or agent for calls your
67
+ * voice agents answered), the agent that answered, and the time the call started
68
+ * (from and to are inclusive). Each call carries the phone number it was connected
69
+ * to, the caller id it showed, and the billed legs with what each cost. Use the
70
+ * call webhooks for real-time updates; this list is for looking calls up
71
+ * afterwards.
65
72
  *
66
73
  * @example
67
74
  * ```ts
68
75
  * // Automatically fetches more pages as needed.
69
- * for await (const call of client.calls.list()) {
76
+ * for await (const call of client.voice.calls.list()) {
70
77
  * // ...
71
78
  * }
72
79
  * ```
@@ -76,7 +83,7 @@ export class Calls extends APIResource {
76
83
  options?: RequestOptions,
77
84
  ): PagePromise<CallsCallsPage, Call> {
78
85
  const { 'x-profile-id': xProfileID, ...query } = params ?? {};
79
- return this._client.getAPIList('/v3/calls', CallsPage<Call>, {
86
+ return this._client.getAPIList('/v3/voice/calls', CallsPage<Call>, {
80
87
  query,
81
88
  ...options,
82
89
  headers: buildHeaders([
@@ -90,19 +97,19 @@ export class Calls extends APIResource {
90
97
  * Ends one of your live calls. The call then ends the way any other call does once
91
98
  * the disconnect is reported: an answered call as COMPLETED with call.completed, a
92
99
  * call still ringing as NO_ANSWER, REJECTED or FAILED with call.failed. A call
93
- * that has already ended answers 409, and so does a call with no phone leg, such
94
- * as one between two app users.
100
+ * that has already ended answers 409, as do a call with no phone leg, such as one
101
+ * between two app users, and a call one of your voice agents answers.
95
102
  *
96
103
  * @example
97
104
  * ```ts
98
- * await client.calls.hangup(
105
+ * await client.voice.calls.hangup(
99
106
  * 'call_9f2ab000-0000-4000-8000-000000000001',
100
107
  * );
101
108
  * ```
102
109
  */
103
110
  hangup(id: string, params: CallHangupParams, options?: RequestOptions): APIPromise<void> {
104
111
  const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
105
- return this._client.post(path`/v3/calls/${id}/hangup`, {
112
+ return this._client.post(path`/v3/voice/calls/${id}/hangup`, {
106
113
  body,
107
114
  ...options,
108
115
  headers: buildHeaders([
@@ -128,7 +135,7 @@ export class Calls extends APIResource {
128
135
  * @example
129
136
  * ```ts
130
137
  * const apiResponseOfCallRecordings =
131
- * await client.calls.listRecordings(
138
+ * await client.voice.calls.listRecordings(
132
139
  * 'call_9f2ab000-0000-4000-8000-000000000001',
133
140
  * );
134
141
  * ```
@@ -139,7 +146,7 @@ export class Calls extends APIResource {
139
146
  options?: RequestOptions,
140
147
  ): APIPromise<APIResponseOfCallRecordings> {
141
148
  const { 'x-profile-id': xProfileID } = params ?? {};
142
- return this._client.get(path`/v3/calls/${id}/recordings`, {
149
+ return this._client.get(path`/v3/voice/calls/${id}/recordings`, {
143
150
  ...options,
144
151
  headers: buildHeaders([
145
152
  { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
@@ -151,20 +158,20 @@ export class Calls extends APIResource {
151
158
  /**
152
159
  * Starts or stops recording one of your live calls. Use start to begin recording
153
160
  * mid-call, or stop to end a recording, whether it was started here or by a
154
- * connect answer with record set. A call that has already ended answers 409, and
155
- * so does a call with no phone leg, such as one between two app users, which can't
156
- * be recorded.
161
+ * connect answer with record set. A call that has already ended answers 409, as do
162
+ * a call with no phone leg, such as one between two app users, and a call one of
163
+ * your voice agents answers, neither of which can be recorded this way.
157
164
  *
158
165
  * @example
159
166
  * ```ts
160
- * await client.calls.record(
167
+ * await client.voice.calls.record(
161
168
  * 'call_9f2ab000-0000-4000-8000-000000000001',
162
169
  * );
163
170
  * ```
164
171
  */
165
172
  record(id: string, params: CallRecordParams, options?: RequestOptions): APIPromise<void> {
166
173
  const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
167
- return this._client.post(path`/v3/calls/${id}/recordings`, {
174
+ return this._client.post(path`/v3/voice/calls/${id}/recordings`, {
168
175
  body,
169
176
  ...options,
170
177
  headers: buildHeaders([
@@ -266,12 +273,32 @@ export interface Call {
266
273
  */
267
274
  id?: string;
268
275
 
276
+ /**
277
+ * The voice agent that answered the call, such as
278
+ * agent_9f2ab000-0000-4000-8000-000000000001. Null for an inapp call
279
+ */
280
+ agent_id?: string | null;
281
+
269
282
  /**
270
283
  * When the call was answered (UTC). Null until then, and always null for a call
271
284
  * between two of your app users
272
285
  */
273
286
  answered_at?: string | null;
274
287
 
288
+ /**
289
+ * The caller id shown on the phone leg, in E.164 format: the one your answer
290
+ * chose, or the owning number when it chose none. Null for a call with no phone
291
+ * leg
292
+ */
293
+ caller_id_used?: string | null;
294
+
295
+ /**
296
+ * The phone number the call was connected to, in E.164 format: the number your
297
+ * answer dialed, or the fallback number a call to one of your voice agents
298
+ * reached. Null when the call was not connected to a phone number
299
+ */
300
+ connected_number?: string | null;
301
+
275
302
  /**
276
303
  * outbound for a call placed from your app, inbound for a call to one of your
277
304
  * numbers
@@ -290,9 +317,9 @@ export interface Call {
290
317
 
291
318
  /**
292
319
  * Why the call did not complete: callback_timeout, invalid_answer,
293
- * insufficient_balance, destination_blocked, callback_not_configured, rejected or
294
- * no_answer. Null while the call is live, when it completed, and when it failed
295
- * without a recorded reason
320
+ * insufficient_balance, destination_blocked, callback_not_configured, rejected,
321
+ * no_answer, or for an agent call agent_busy or agent_unreachable. Null while the
322
+ * call is live, when it completed, and when it failed without a recorded reason
296
323
  */
297
324
  failure_reason?: string | null;
298
325
 
@@ -301,6 +328,21 @@ export interface Call {
301
328
  */
302
329
  from?: CallParty;
303
330
 
331
+ /**
332
+ * The legs the price covers, one entry per billed leg, each with its own cost: a
333
+ * call your answer connected to a phone number ran the caller's leg to your number
334
+ * and the leg to the connected number at once, and both are billed. Null until the
335
+ * call has been priced
336
+ */
337
+ legs?: Array<Call.Leg> | null;
338
+
339
+ /**
340
+ * The calling mode: inapp for a call between people in your app and phone numbers,
341
+ * routed by your number's callback URL; agent for a call one of your voice agents
342
+ * answered
343
+ */
344
+ mode?: string;
345
+
304
346
  /**
305
347
  * Your number that owns the call, in E.164 format: the dialed number for an
306
348
  * inbound call, the caller's bound number for a call placed from your app
@@ -339,6 +381,41 @@ export interface Call {
339
381
  to?: CallParty;
340
382
  }
341
383
 
384
+ export namespace Call {
385
+ /**
386
+ * One leg of a call the price covers
387
+ */
388
+ export interface Leg {
389
+ /**
390
+ * The whole minutes the leg was billed for
391
+ */
392
+ billed_minutes?: number;
393
+
394
+ /**
395
+ * What the leg cost, in the same unit as the call's price
396
+ */
397
+ cost?: number;
398
+
399
+ /**
400
+ * The currency of the cost: USD
401
+ */
402
+ currency?: string;
403
+
404
+ /**
405
+ * inbound for the caller's leg to your number, outbound for a leg placed on your
406
+ * behalf
407
+ */
408
+ direction?: string;
409
+
410
+ /**
411
+ * The phone number the leg reached, in E.164 format: your number for the inbound
412
+ * leg, the number dialed for an outbound one. Null for a leg to one of your app
413
+ * users or a room
414
+ */
415
+ number?: string | null;
416
+ }
417
+ }
418
+
342
419
  /**
343
420
  * One end of a call
344
421
  */
@@ -428,6 +505,12 @@ export interface CallRetrieveParams {
428
505
  }
429
506
 
430
507
  export interface CallListParams extends CallsPageParams {
508
+ /**
509
+ * Query param: Optional filter on the voice agent that answered the call, such as
510
+ * agent_9f2ab000-0000-4000-8000-000000000001
511
+ */
512
+ agent_id?: string | null;
513
+
431
514
  /**
432
515
  * Query param: Optional direction filter: outbound for calls placed from your app,
433
516
  * inbound for calls to one of your numbers
@@ -439,6 +522,12 @@ export interface CallListParams extends CallsPageParams {
439
522
  */
440
523
  from?: string | null;
441
524
 
525
+ /**
526
+ * Query param: Optional mode filter: inapp for calls routed by your number's
527
+ * callback URL, agent for calls one of your voice agents answered
528
+ */
529
+ mode?: string | null;
530
+
442
531
  /**
443
532
  * Query param: Optional filter on the number that owns the call, one of your
444
533
  * voice-enabled numbers in E.164 format
@@ -1,19 +1,21 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../core/resource';
4
- import * as WebhooksAPI from '../webhooks';
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as WebhooksAPI from '../../webhooks';
5
5
  import * as CallsAPI from './calls';
6
- import { APIPromise } from '../../core/api-promise';
7
- import { buildHeaders } from '../../internal/headers';
8
- import { RequestOptions } from '../../internal/request-options';
9
- import { path } from '../../internal/utils/path';
6
+ import { APIPromise } from '../../../core/api-promise';
7
+ import { buildHeaders } from '../../../internal/headers';
8
+ import { RequestOptions } from '../../../internal/request-options';
9
+ import { path } from '../../../internal/utils/path';
10
10
 
11
11
  /**
12
12
  * Phone calls from the numbers you hold, driven by your own callback URL.
13
13
  *
14
- * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
14
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
15
15
  *
16
- * Every call is a record under `/v3/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
16
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
17
+ *
18
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
17
19
  */
18
20
  export class Participants extends APIResource {
19
21
  /**
@@ -26,7 +28,7 @@ export class Participants extends APIResource {
26
28
  *
27
29
  * @example
28
30
  * ```ts
29
- * await client.calls.participants.update(
31
+ * await client.voice.calls.participants.update(
30
32
  * 'call_9f2ab000-0000-4000-8000-000000000002',
31
33
  * { id: 'call_9f2ab000-0000-4000-8000-000000000001' },
32
34
  * );
@@ -34,7 +36,7 @@ export class Participants extends APIResource {
34
36
  */
35
37
  update(participantID: string, params: ParticipantUpdateParams, options?: RequestOptions): APIPromise<void> {
36
38
  const { id, 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
37
- return this._client.patch(path`/v3/calls/${id}/participants/${participantID}`, {
39
+ return this._client.patch(path`/v3/voice/calls/${id}/participants/${participantID}`, {
38
40
  body,
39
41
  ...options,
40
42
  headers: buildHeaders([
@@ -53,13 +55,13 @@ export class Participants extends APIResource {
53
55
  * participant's own call id, who they are, whether the room mutes them, and how
54
56
  * long they have been connected. The call itself is one of the participants. Use a
55
57
  * participant's id to mute or remove them; it is also a call id, so GET
56
- * /v3/calls/{id} accepts it. A call that has ended answers 409, as does a call
57
- * that is not in a conference.
58
+ * /v3/voice/calls/{id} accepts it. A call that has ended answers 409, as does a
59
+ * call that is not in a conference.
58
60
  *
59
61
  * @example
60
62
  * ```ts
61
63
  * const apiResponseOfListOfCallParticipant =
62
- * await client.calls.participants.list(
64
+ * await client.voice.calls.participants.list(
63
65
  * 'call_9f2ab000-0000-4000-8000-000000000001',
64
66
  * );
65
67
  * ```
@@ -70,7 +72,7 @@ export class Participants extends APIResource {
70
72
  options?: RequestOptions,
71
73
  ): APIPromise<APIResponseOfListOfCallParticipant> {
72
74
  const { 'x-profile-id': xProfileID } = params ?? {};
73
- return this._client.get(path`/v3/calls/${id}/participants`, {
75
+ return this._client.get(path`/v3/voice/calls/${id}/participants`, {
74
76
  ...options,
75
77
  headers: buildHeaders([
76
78
  { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
@@ -93,7 +95,7 @@ export class Participants extends APIResource {
93
95
  * @example
94
96
  * ```ts
95
97
  * const apiResponseOfCall =
96
- * await client.calls.participants.add(
98
+ * await client.voice.calls.participants.add(
97
99
  * 'call_9f2ab000-0000-4000-8000-000000000001',
98
100
  * );
99
101
  * ```
@@ -104,7 +106,7 @@ export class Participants extends APIResource {
104
106
  options?: RequestOptions,
105
107
  ): APIPromise<CallsAPI.APIResponseOfCall> {
106
108
  const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
107
- return this._client.post(path`/v3/calls/${id}/participants`, {
109
+ return this._client.post(path`/v3/voice/calls/${id}/participants`, {
108
110
  body,
109
111
  ...options,
110
112
  headers: buildHeaders([
@@ -126,7 +128,7 @@ export class Participants extends APIResource {
126
128
  *
127
129
  * @example
128
130
  * ```ts
129
- * await client.calls.participants.remove(
131
+ * await client.voice.calls.participants.remove(
130
132
  * 'call_9f2ab000-0000-4000-8000-000000000002',
131
133
  * { id: 'call_9f2ab000-0000-4000-8000-000000000001' },
132
134
  * );
@@ -134,7 +136,7 @@ export class Participants extends APIResource {
134
136
  */
135
137
  remove(participantID: string, params: ParticipantRemoveParams, options?: RequestOptions): APIPromise<void> {
136
138
  const { id, 'x-profile-id': xProfileID, ...body } = params;
137
- return this._client.delete(path`/v3/calls/${id}/participants/${participantID}`, {
139
+ return this._client.delete(path`/v3/voice/calls/${id}/participants/${participantID}`, {
138
140
  body,
139
141
  ...options,
140
142
  headers: buildHeaders([
@@ -152,14 +154,14 @@ export class Participants extends APIResource {
152
154
  *
153
155
  * @example
154
156
  * ```ts
155
- * await client.calls.participants.removeAll(
157
+ * await client.voice.calls.participants.removeAll(
156
158
  * 'call_9f2ab000-0000-4000-8000-000000000001',
157
159
  * );
158
160
  * ```
159
161
  */
160
162
  removeAll(id: string, params: ParticipantRemoveAllParams, options?: RequestOptions): APIPromise<void> {
161
163
  const { 'x-profile-id': xProfileID, ...body } = params;
162
- return this._client.delete(path`/v3/calls/${id}/participants`, {
164
+ return this._client.delete(path`/v3/voice/calls/${id}/participants`, {
163
165
  body,
164
166
  ...options,
165
167
  headers: buildHeaders([
@@ -201,7 +203,7 @@ export interface APIResponseOfListOfCallParticipant {
201
203
  export interface CallParticipant {
202
204
  /**
203
205
  * The participant's own call id: what the mute and remove endpoints take, and what
204
- * GET /v3/calls/{id} accepts
206
+ * GET /v3/voice/calls/{id} accepts
205
207
  */
206
208
  id?: string;
207
209
 
@@ -0,0 +1,118 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as WebhooksAPI from '../webhooks';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { buildHeaders } from '../../internal/headers';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+
9
+ /**
10
+ * Phone calls from the numbers you hold, driven by your own callback URL.
11
+ *
12
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
13
+ *
14
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
15
+ *
16
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
17
+ */
18
+ export class Catalogue extends APIResource {
19
+ /**
20
+ * The names a voice agent's `speech.voice` and `speech.language` accept, with the
21
+ * default marked. The list grows as voices are added; a name is never removed
22
+ * without notice.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const apiResponseOfVoiceCatalogue =
27
+ * await client.voice.catalogue.list();
28
+ * ```
29
+ */
30
+ list(
31
+ params: CatalogueListParams | null | undefined = {},
32
+ options?: RequestOptions,
33
+ ): APIPromise<APIResponseOfVoiceCatalogue> {
34
+ const { 'x-profile-id': xProfileID } = params ?? {};
35
+ return this._client.get('/v3/voice/voices', {
36
+ ...options,
37
+ headers: buildHeaders([
38
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
39
+ options?.headers,
40
+ ]),
41
+ });
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Standard API response envelope for all v3 endpoints
47
+ */
48
+ export interface APIResponseOfVoiceCatalogue {
49
+ /**
50
+ * The voices and languages a text-session agent may name in its speech settings:
51
+ * what GET /v3/voice/voices and the admin GET /voice/voices answer, in one shape.
52
+ */
53
+ data?: VoiceCatalogue | null;
54
+
55
+ /**
56
+ * Error information
57
+ */
58
+ error?: WebhooksAPI.ErrorDetail | null;
59
+
60
+ /**
61
+ * Request and response metadata
62
+ */
63
+ meta?: WebhooksAPI.APIMeta;
64
+
65
+ /**
66
+ * Indicates whether the request was successful
67
+ */
68
+ success?: boolean;
69
+ }
70
+
71
+ /**
72
+ * The voices and languages a text-session agent may name in its speech settings:
73
+ * what GET /v3/voice/voices and the admin GET /voice/voices answer, in one shape.
74
+ */
75
+ export interface VoiceCatalogue {
76
+ /**
77
+ * BCP 47 tags accepted as speech.language.
78
+ */
79
+ languages?: Array<string>;
80
+
81
+ voices?: Array<VoiceCatalogueVoice>;
82
+ }
83
+
84
+ export interface VoiceCatalogueVoice {
85
+ /**
86
+ * Whether this is the voice used when an agent names none.
87
+ */
88
+ default?: boolean;
89
+
90
+ description?: string;
91
+
92
+ /**
93
+ * The language the voice speaks.
94
+ */
95
+ language?: string;
96
+
97
+ /**
98
+ * The value to send as speech.voice.
99
+ */
100
+ name?: string;
101
+ }
102
+
103
+ export interface CatalogueListParams {
104
+ /**
105
+ * Profile UUID to scope the request to a child profile. Only organization API keys
106
+ * can use this header. The profile must belong to the calling organization.
107
+ */
108
+ 'x-profile-id'?: string;
109
+ }
110
+
111
+ export declare namespace Catalogue {
112
+ export {
113
+ type APIResponseOfVoiceCatalogue as APIResponseOfVoiceCatalogue,
114
+ type VoiceCatalogue as VoiceCatalogue,
115
+ type VoiceCatalogueVoice as VoiceCatalogueVoice,
116
+ type CatalogueListParams as CatalogueListParams,
117
+ };
118
+ }
@@ -0,0 +1,55 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Agents,
5
+ type APIResponseOfVoiceAgent,
6
+ type APIResponseOfVoiceAgentSecret,
7
+ type APIResponseOfVoiceAgentsList,
8
+ type VoiceAgent,
9
+ type VoiceAgentAudio,
10
+ type VoiceAgentAudioSpec,
11
+ type VoiceAgentLimits,
12
+ type VoiceAgentLimitsSpec,
13
+ type VoiceAgentParty,
14
+ type VoiceAgentPartySpec,
15
+ type VoiceAgentSecret,
16
+ type VoiceAgentSpeech,
17
+ type VoiceAgentSpeechSpec,
18
+ type VoiceAgentTranscripts,
19
+ type VoiceAgentTranscriptsSpec,
20
+ type VoiceAgentsList,
21
+ type AgentCreateParams,
22
+ type AgentRetrieveParams,
23
+ type AgentUpdateParams,
24
+ type AgentListParams,
25
+ type AgentDeleteParams,
26
+ type AgentRotateSecretParams,
27
+ type VoiceAgentsVoiceAgentsPage,
28
+ } from './agents';
29
+ export {
30
+ Calls,
31
+ type APIResponseOfCall,
32
+ type APIResponseOfCallRecordings,
33
+ type APIResponseOfCallsList,
34
+ type Call,
35
+ type CallParty,
36
+ type CallRecording,
37
+ type CallRecordings,
38
+ type CallTimelineEntry,
39
+ type CallsList,
40
+ type CallRetrieveParams,
41
+ type CallListParams,
42
+ type CallHangupParams,
43
+ type CallListRecordingsParams,
44
+ type CallRecordParams,
45
+ type CallsCallsPage,
46
+ } from './calls/index';
47
+ export {
48
+ Catalogue,
49
+ type APIResponseOfVoiceCatalogue,
50
+ type VoiceCatalogue,
51
+ type VoiceCatalogueVoice,
52
+ type CatalogueListParams,
53
+ } from './catalogue';
54
+ export { Tokens, type APIResponseOfVoiceToken, type VoiceToken, type TokenCreateParams } from './tokens';
55
+ export { Voice } from './voice';