@signalhouse-sms/sdk 1.13.0 → 1.15.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.
@@ -8,6 +8,7 @@ import { GlobalVoiceSettings } from "./voice/GlobalVoiceSettings.js";
8
8
  import { Tokens } from "./voice/Tokens.js";
9
9
  import { Analytics } from "./voice/Analytics.js";
10
10
  import { OutboundVoice } from "./voice/OutboundVoice.js";
11
+ import { CallFlows } from "./voice/CallFlows.js";
11
12
 
12
13
  /**
13
14
  * Voice domain — wraps the Voice service (mounted under /voice on the
@@ -19,6 +20,7 @@ import { OutboundVoice } from "./voice/OutboundVoice.js";
19
20
  * - `sdk.voice.sipProfiles` — SIP profile / endpoint (single registerable UA).
20
21
  * - `sdk.voice.programmableVoiceProfiles` — Programmable Voice Profile (route a set of numbers through Signal House).
21
22
  * - `sdk.voice.numberRoutes` — Per-number inbound route (overrides the profile and subgroup settings).
23
+ * - `sdk.voice.callFlows` — Call flows: customer-built call trees a number or profile can run.
22
24
  * - `sdk.voice.calls` — Twilio-compat programmatic call control (create/hangup/etc.).
23
25
  * - `sdk.voice.callLogs` — Account-scoped call history: list/get + presigned recording.
24
26
  * - `sdk.voice.globalVoiceSettings` — Account-wide voice defaults (accepted regions, max spend, E911).
@@ -39,5 +41,6 @@ export class Voice {
39
41
  this.tokens = new Tokens(client, enableAdmin);
40
42
  this.analytics = new Analytics(client, enableAdmin);
41
43
  this.outboundVoice = new OutboundVoice(client, enableAdmin);
44
+ this.callFlows = new CallFlows(client, enableAdmin);
42
45
  }
43
46
  }
@@ -0,0 +1,243 @@
1
+ /** @typedef {import('../../SignalHouseSDK.js').RequestOptions} RequestOptions */
2
+ /**
3
+ * @template T
4
+ * @typedef {import('../../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} CallFlowListFilters
9
+ * @property {number} [page] - Page number, from 1 (default 1).
10
+ * @property {number} [limit] - Page size, 1-100 (default 20).
11
+ * @property {string} [q] - Match against the flow name.
12
+ * @property {string} [subgroupId] - Only flows in this subgroup.
13
+ * @property {boolean} [includeDeleted] - Include deleted flows (default false).
14
+ * @property {"createdAt"|"updatedAt"|"name"} [sortBy] - Sort field (default "createdAt").
15
+ * @property {"asc"|"desc"} [sortOrder] - Sort direction (default "desc").
16
+ */
17
+
18
+ /**
19
+ * @typedef {Object} CreateCallFlowData
20
+ * @property {string} name - Flow name, unique within its subgroup.
21
+ * @property {string} subgroupId - The subgroup the flow belongs to. Fixed once created; only numbers and Programmable Voice Profiles in this subgroup can run the flow.
22
+ */
23
+
24
+ /**
25
+ * @typedef {Object} UpdateCallFlowData
26
+ * @property {string} [name] - New name, unique within the flow's subgroup.
27
+ * @property {"ACTIVE"|"DISABLED"} [status] - A disabled flow does not run; numbers routed to it fall through to their next routing layer.
28
+ */
29
+
30
+ /**
31
+ * @typedef {Object} CallFlowStep
32
+ * @property {string} id - A UUID you generate. It is kept as the step's id, so it stays stable across saves.
33
+ * @property {"inbound"|"answer"|"play"|"ivr"|"fwd_phone"|"voicemail"|"hangup"} type - The step kind. `catalog()` lists the kinds this service can run.
34
+ * @property {string} name - Display name.
35
+ * @property {Object} [config] - The step's settings, which depend on its type.
36
+ * @property {number} [positionX] - Canvas x position, for a visual builder.
37
+ * @property {number} [positionY] - Canvas y position, for a visual builder.
38
+ */
39
+
40
+ /**
41
+ * @typedef {Object} CallFlowConnection
42
+ * @property {string} id - A UUID you generate.
43
+ * @property {string} fromNodeId - The step the connection leaves.
44
+ * @property {string} toNodeId - The step it leads to.
45
+ * @property {string} port - The outcome of the source step it leaves from, e.g. "next", "success", "no_input" or "opt_<optionId>".
46
+ */
47
+
48
+ /**
49
+ * @typedef {Object} CallFlowDraft
50
+ * @property {CallFlowStep[]} nodes - Every step in the flow, including exactly one "inbound" step.
51
+ * @property {CallFlowConnection[]} edges - Every connection between steps.
52
+ */
53
+
54
+ /**
55
+ * Call Flows — customer-built call trees (greeting, menu, forward, voicemail, hang up)
56
+ * that run when a number's route, or its Programmable Voice Profile, names the flow
57
+ * with `routeAction: "CALL_FLOW"`.
58
+ *
59
+ * Each flow has one working draft you edit with `saveDraft`, and published versions.
60
+ * `publish` validates the draft and makes it the version calls run; the draft stays
61
+ * editable without affecting calls until you publish again.
62
+ *
63
+ * Calls the Voice service mounted under /voice. Accessed via `sdk.voice.callFlows`.
64
+ */
65
+ export class CallFlows {
66
+ constructor(client, enableAdmin) {
67
+ this.client = client;
68
+ this.enableAdmin = enableAdmin;
69
+ }
70
+
71
+ /**
72
+ * List the account's call flows, newest first by default.
73
+ * @async
74
+ * @roles api, admin, developer, billing, user
75
+ * @param {Object} [params] - Request parameters.
76
+ * @param {CallFlowListFilters} [params.filters] - Paging, search, subgroup and sort.
77
+ * @param {RequestOptions} [params.options] - Additional options for the request.
78
+ * @returns {Promise<SdkResponse<any>>} `{ data: [...], meta: { total, page, limit, totalPages } }`.
79
+ */
80
+ async list({ filters = {}, options = {} } = {}) {
81
+ const query = new URLSearchParams();
82
+ for (const [k, v] of Object.entries(filters)) {
83
+ if (v !== undefined && v !== null && v !== "") query.set(k, String(v));
84
+ }
85
+ const qs = query.toString();
86
+ return this.client(`/voice/api/v1/call-flows${qs ? `?${qs}` : ""}`, { method: "GET", ...options });
87
+ }
88
+
89
+ /**
90
+ * List the step types this service can run, with the outcomes each one offers.
91
+ * @async
92
+ * @roles api, admin, developer, billing, user
93
+ * @param {Object} [params] - Request parameters.
94
+ * @param {RequestOptions} [params.options] - Additional options for the request.
95
+ * @returns {Promise<SdkResponse<any>>} `{ data: { nodeTypes: [{ type, ports, configurable }] } }`.
96
+ */
97
+ async catalog({ options = {} } = {}) {
98
+ return this.client(`/voice/api/v1/call-flows/catalog`, { method: "GET", ...options });
99
+ }
100
+
101
+ /**
102
+ * Get a call flow with its working draft and the issues that stop the draft being published.
103
+ * @async
104
+ * @roles api, admin, developer, billing, user
105
+ * @param {Object} params - Request parameters.
106
+ * @param {string} params.id - The call flow UUID.
107
+ * @param {RequestOptions} [params.options] - Additional options for the request.
108
+ * @throws {Error} If id is missing.
109
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow, draft: { versionId, nodes, edges, issues } } }`.
110
+ */
111
+ async get({ id, options = {} }) {
112
+ this.client._require({ id });
113
+ const safeId = encodeURIComponent(id);
114
+ return this.client(`/voice/api/v1/call-flows/${safeId}`, { method: "GET", ...options });
115
+ }
116
+
117
+ /**
118
+ * Create a call flow, with its working draft and the Inbound Call step every flow starts from.
119
+ * @async
120
+ * @roles api, admin, developer
121
+ * @param {Object} params - Request parameters.
122
+ * @param {CreateCallFlowData} params.flowData - The flow to create.
123
+ * @param {RequestOptions} [params.options] - Additional options for the request.
124
+ * @throws {Error} If flowData is missing.
125
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow, draft } }`.
126
+ */
127
+ async create({ flowData, options = {} }) {
128
+ this.client._require({ flowData });
129
+ return this.client(`/voice/api/v1/call-flows`, { method: "POST", body: flowData, ...options });
130
+ }
131
+
132
+ /**
133
+ * Rename a call flow, or enable or disable it (partial update).
134
+ * @async
135
+ * @roles api, admin, developer
136
+ * @param {Object} params - Request parameters.
137
+ * @param {string} params.id - The call flow UUID.
138
+ * @param {UpdateCallFlowData} params.updateData - Fields to update.
139
+ * @param {RequestOptions} [params.options] - Additional options for the request.
140
+ * @throws {Error} If id or updateData is missing.
141
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow, draft } }`.
142
+ */
143
+ async update({ id, updateData, options = {} }) {
144
+ this.client._require({ id, updateData });
145
+ const safeId = encodeURIComponent(id);
146
+ return this.client(`/voice/api/v1/call-flows/${safeId}`, { method: "PATCH", body: updateData, ...options });
147
+ }
148
+
149
+ /**
150
+ * Delete a call flow. Reversible with `restore`: while deleted, numbers and profiles
151
+ * routed to it fall through to their next routing layer.
152
+ * @async
153
+ * @roles api, admin, developer
154
+ * @param {Object} params - Request parameters.
155
+ * @param {string} params.id - The call flow UUID.
156
+ * @param {RequestOptions} [params.options] - Additional options for the request.
157
+ * @throws {Error} If id is missing.
158
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow } }`.
159
+ */
160
+ async delete({ id, options = {} }) {
161
+ this.client._require({ id });
162
+ const safeId = encodeURIComponent(id);
163
+ return this.client(`/voice/api/v1/call-flows/${safeId}`, { method: "DELETE", ...options });
164
+ }
165
+
166
+ /**
167
+ * Restore a deleted call flow.
168
+ *
169
+ * Sends an empty JSON body: the SDK always declares JSON, and the Voice service
170
+ * rejects a JSON request with no body at all.
171
+ * @async
172
+ * @roles api, admin, developer
173
+ * @param {Object} params - Request parameters.
174
+ * @param {string} params.id - The call flow UUID.
175
+ * @param {RequestOptions} [params.options] - Additional options for the request.
176
+ * @throws {Error} If id is missing.
177
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow, draft } }`.
178
+ */
179
+ async restore({ id, options = {} }) {
180
+ this.client._require({ id });
181
+ const safeId = encodeURIComponent(id);
182
+ return this.client(`/voice/api/v1/call-flows/${safeId}/restore`, { method: "POST", body: {}, ...options });
183
+ }
184
+
185
+ /**
186
+ * Copy a call flow and its working draft into a new flow in the same subgroup. The copy is not published.
187
+ * @async
188
+ * @roles api, admin, developer
189
+ * @param {Object} params - Request parameters.
190
+ * @param {string} params.id - The call flow UUID to copy.
191
+ * @param {string} [params.name] - Name for the copy (default "<name> (copy)").
192
+ * @param {RequestOptions} [params.options] - Additional options for the request.
193
+ * @throws {Error} If id is missing.
194
+ * @returns {Promise<SdkResponse<any>>} `{ data: { ...flow, draft } }`.
195
+ */
196
+ async duplicate({ id, name, options = {} }) {
197
+ this.client._require({ id });
198
+ const safeId = encodeURIComponent(id);
199
+ return this.client(`/voice/api/v1/call-flows/${safeId}/duplicate`, {
200
+ method: "POST",
201
+ body: name ? { name } : {},
202
+ ...options,
203
+ });
204
+ }
205
+
206
+ /**
207
+ * Replace the working draft. The whole draft is saved, even when it is not finished;
208
+ * the issues that would stop it being published come back in the response.
209
+ * @async
210
+ * @roles api, admin, developer
211
+ * @param {Object} params - Request parameters.
212
+ * @param {string} params.id - The call flow UUID.
213
+ * @param {CallFlowDraft} params.draft - Every step and connection.
214
+ * @param {RequestOptions} [params.options] - Additional options for the request.
215
+ * @throws {Error} If id or draft is missing.
216
+ * @returns {Promise<SdkResponse<any>>} `{ data: { nodes, edges, issues } }`.
217
+ */
218
+ async saveDraft({ id, draft, options = {} }) {
219
+ this.client._require({ id, draft });
220
+ const safeId = encodeURIComponent(id);
221
+ return this.client(`/voice/api/v1/call-flows/${safeId}/draft`, { method: "PUT", body: draft, ...options });
222
+ }
223
+
224
+ /**
225
+ * Publish the working draft, making it the version calls run. A draft that is not
226
+ * ready returns 400 with `error.issues` listing each step that needs attention.
227
+ *
228
+ * Sends an empty JSON body: the SDK always declares JSON, and the Voice service
229
+ * rejects a JSON request with no body at all.
230
+ * @async
231
+ * @roles api, admin, developer
232
+ * @param {Object} params - Request parameters.
233
+ * @param {string} params.id - The call flow UUID.
234
+ * @param {RequestOptions} [params.options] - Additional options for the request.
235
+ * @throws {Error} If id is missing.
236
+ * @returns {Promise<SdkResponse<any>>} `{ data: { id, versionNumber, status, publishedAt } }`.
237
+ */
238
+ async publish({ id, options = {} }) {
239
+ this.client._require({ id });
240
+ const safeId = encodeURIComponent(id);
241
+ return this.client(`/voice/api/v1/call-flows/${safeId}/publish`, { method: "POST", body: {}, ...options });
242
+ }
243
+ }
@@ -6,7 +6,7 @@
6
6
 
7
7
  /**
8
8
  * @typedef {Object} NumberRouteData
9
- * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"|"VOICEMAIL"} routeAction - How inbound calls to the number are handled.
9
+ * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"|"VOICEMAIL"|"CALL_FLOW"} routeAction - How inbound calls to the number are handled. CALL_FLOW runs a call flow (see `sdk.voice.callFlows`).
10
10
  * @property {string|null} [forwardToE164] - FORWARD destination (required for FORWARD), or the WEBRTC no-answer destination when noAnswerAction is FORWARD.
11
11
  * @property {"VOICEMAIL"|"FORWARD"|"KEEP_RINGING"|null} [noAnswerAction] - WEBRTC only: what happens when nobody answers (default VOICEMAIL).
12
12
  * @property {number|null} [noAnswerSeconds] - WEBRTC only: seconds to ring before the no-answer action, 5-120 (default 20).
@@ -14,6 +14,7 @@
14
14
  * @property {string|null} [routeSipProfileId] - SIP endpoint to ring (required for SIP_PROFILE).
15
15
  * @property {string|null} [webhookUrl] - SHML program URL (required for CALL_CONTROL).
16
16
  * @property {string|null} [routeAgentProfileId] - AI agent profile id, AGP… (required for AI).
17
+ * @property {string|null} [routeCallFlowId] - Call flow to run (required for CALL_FLOW). Must be in the number's subgroup. It need not be published yet: until it is, calls fall through to the number's profile or subgroup settings, which `effective` shows.
17
18
  * @property {boolean} [recordingEnabled] - Record calls handled by this route.
18
19
  */
19
20
 
@@ -9,13 +9,14 @@
9
9
  * @property {string} name - Profile name (required).
10
10
  * @property {string[]} subgroupIds - Subgroups this profile spans (required, at least one).
11
11
  * @property {string} [region] - Region/POP label.
12
- * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"} [routeAction] - Inbound call action (default "FORWARD"). Deliver the call to a PSTN number (FORWARD), ring the profile's subgroup registered softphones (WEBRTC), send to a SIP trunk (SIP_TRUNK), ring a registered SIP endpoint (SIP_PROFILE), hand the call to your programmable call-control webhook that returns SHML (CALL_CONTROL), or answer it with an AI agent (AI).
12
+ * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"|"CALL_FLOW"} [routeAction] - Inbound call action (default "FORWARD"). Deliver the call to a PSTN number (FORWARD), ring the profile's subgroup registered softphones (WEBRTC), send to a SIP trunk (SIP_TRUNK), ring a registered SIP endpoint (SIP_PROFILE), hand the call to your programmable call-control webhook that returns SHML (CALL_CONTROL), answer it with an AI agent (AI), or run a call flow (CALL_FLOW).
13
13
  * @property {string} [forwardToE164] - Destination number, required when routeAction is "FORWARD".
14
14
  * @property {number} [forwardAfterSeconds] - Ring seconds before the action fires.
15
15
  * @property {string} [routeSipTrunkId] - SIP trunk id, required when routeAction is "SIP_TRUNK".
16
16
  * @property {string} [routeSipProfileId] - SIP endpoint id, required when routeAction is "SIP_PROFILE".
17
17
  * @property {string} [webhookUrl] - Your inbound voice webhook (SHML program URL), required when routeAction is "CALL_CONTROL". Inbound calls to this profile's numbers are driven by the SHML your webhook returns.
18
18
  * @property {string} [routeAgentProfileId] - AI agent profile id (AGP…), required when routeAction is "AI". The agent's prompt, voice, model and tools are read when the call lands, so editing the agent takes effect on the next call with nothing to re-save here.
19
+ * @property {string} [routeCallFlowId] - Call flow to run, required when routeAction is "CALL_FLOW". Must be in one of the profile's subgroups.
19
20
  * @property {boolean} [recordingEnabled] - Record calls on this profile.
20
21
  * @property {boolean} [enabled] - Active state (default true).
21
22
  */
@@ -25,13 +26,14 @@
25
26
  * @property {string} [name] - Profile name.
26
27
  * @property {string[]} [subgroupIds] - Subgroups this profile spans.
27
28
  * @property {string|null} [region] - Region/POP label.
28
- * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"} [routeAction] - Inbound call action (FORWARD | WEBRTC | SIP_TRUNK | SIP_PROFILE | CALL_CONTROL | AI).
29
+ * @property {"FORWARD"|"WEBRTC"|"SIP_TRUNK"|"SIP_PROFILE"|"CALL_CONTROL"|"AI"|"CALL_FLOW"} [routeAction] - Inbound call action (FORWARD | WEBRTC | SIP_TRUNK | SIP_PROFILE | CALL_CONTROL | AI | CALL_FLOW).
29
30
  * @property {string|null} [forwardToE164] - FORWARD destination.
30
31
  * @property {number|null} [forwardAfterSeconds] - Ring seconds before the action fires.
31
32
  * @property {string|null} [routeSipTrunkId] - SIP trunk id (required when routeAction is "SIP_TRUNK").
32
33
  * @property {string|null} [routeSipProfileId] - SIP endpoint id (required when routeAction is "SIP_PROFILE").
33
34
  * @property {string|null} [webhookUrl] - Inbound voice webhook / SHML program URL (required when routeAction is "CALL_CONTROL"). Pass null to clear.
34
35
  * @property {string|null} [routeAgentProfileId] - AI agent profile id (AGP…), required when routeAction is "AI". Pass null to clear.
36
+ * @property {string|null} [routeCallFlowId] - Call flow to run, required when routeAction is "CALL_FLOW". Must be in one of the profile's subgroups; narrowing subgroupIds away from it is refused. Pass null to clear.
35
37
  * @property {boolean} [recordingEnabled] - Record calls on this profile.
36
38
  * @property {boolean} [enabled] - Active state.
37
39
  */
@@ -31,7 +31,9 @@ export class SignalHouseSDK {
31
31
  voice: Voice;
32
32
  agents: Agents;
33
33
  audit: Audit;
34
+ contracts: Contracts;
34
35
  verify: Verify;
36
+ compliance: Compliance;
35
37
  /**
36
38
  * Client for API requests
37
39
  * @private
@@ -118,4 +120,6 @@ import { Webhooks } from "./domains/Webhooks.js";
118
120
  import { Voice } from "./domains/Voice.js";
119
121
  import { Agents } from "./domains/Agents.js";
120
122
  import { Audit } from "./domains/Audit.js";
123
+ import { Contracts } from "./domains/Contracts.js";
121
124
  import { Verify } from "./domains/Verify.js";
125
+ import { Compliance } from "./domains/Compliance.js";
@@ -483,6 +483,20 @@ export class Brands {
483
483
  brandId: BrandLookupId;
484
484
  options?: RequestOptions;
485
485
  }): Promise<SdkResponse<any[]>>;
486
+ /**
487
+ * Get TCR's identity feedback for a brand: why TCR could not verify it (status UNVERIFIED)
488
+ * @async
489
+ * @roles api, admin, developer, billing, user
490
+ * @param {Object} params - The parameters for getting the feedback
491
+ * @param {BrandLookupId} params.brandId - Brand lookup id (carrier Brand ID, record `_id`, or internal reference).
492
+ * @param {RequestOptions} [params.options] - Additional options for the request
493
+ * @throws {Error} Throws an error if the brandId parameter is missing
494
+ * @returns {Promise<SdkResponse<Object>>} BrandFeedback: { brandId, category: [{ id, displayName, description, fields, errors: [{ code, message }] }] }
495
+ */
496
+ getBrandFeedback({ brandId, options }: {
497
+ brandId: BrandLookupId;
498
+ options?: RequestOptions;
499
+ }): Promise<SdkResponse<any>>;
486
500
  /**
487
501
  * Submit a brand identity status appeal with supporting documentation
488
502
  * @async
@@ -494,7 +508,7 @@ export class Brands {
494
508
  * @param {File|Blob} params.file - The supporting document file
495
509
  * @param {RequestOptions} [params.options] - Additional options for the request
496
510
  * @throws {Error} Throws an error if required parameters are missing
497
- * @returns {Promise<SdkResponse<any>>} The response from the server
511
+ * @returns {Promise<SdkResponse<any>>} The response from the server. When TCR refuses the appeal itself (a 4xx, e.g. code 592 for a brand older than 45 days), the error body is { error: "TCR refused the appeal: <reason>", details: { code, message } } with TCR's own code and message. Don't retry it unchanged; it will be refused again.
498
512
  */
499
513
  submitAppeal({ brandId, appealCategories, explanation, file, options }: {
500
514
  brandId: BrandLookupId;