nixflex 0.8.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /** Restricted metadata for raw uploads; credentials and destinations are never overridable. */
2
+ interface BodyOptions {
3
+ rawBody?: Uint8Array;
4
+ contentType?: 'application/octet-stream';
5
+ idempotencyKey?: string;
6
+ filename?: string;
7
+ sourceTitle?: string;
8
+ review?: boolean;
9
+ expectedRevision?: number;
10
+ }
11
+
1
12
  interface NixflexClientOptions {
2
13
  /** Your full API key: "nxf_xxx:nxfs_xxx" (key_id:key_secret). */
3
14
  apiKey: string;
@@ -5,20 +16,26 @@ interface NixflexClientOptions {
5
16
  baseUrl?: string;
6
17
  /** Per-request timeout in milliseconds. Default 30000. */
7
18
  timeoutMs?: number;
8
- /** Max automatic retries for retryable failures. Default 1. Set 0 to disable. */
19
+ /** Max automatic GET retries. Changes never retry. Default 1; 0 disables. */
9
20
  maxRetries?: number;
10
21
  }
11
- interface RequestOptions {
22
+
23
+ declare const SDK_VERSION: string;
24
+ interface RequestOptions extends BodyOptions {
12
25
  /** Override the client timeout for this one request. */
13
26
  timeoutMs?: number;
14
27
  /** AbortSignal to cancel the request from outside. */
15
28
  signal?: AbortSignal;
16
29
  }
17
30
  declare class HttpClient {
31
+ knowledgeUpload<T>(path: string, file: string, opts?: RequestOptions): Promise<T>;
32
+ knowledgeDownload(path: string, query?: Record<string, string | undefined>, opts?: RequestOptions): AsyncGenerator<Uint8Array>;
18
33
  private readonly apiKey;
19
34
  private readonly baseUrl;
20
35
  private readonly timeoutMs;
21
36
  private readonly maxRetries;
37
+ /** Streaming GET for activity CSV. No retry after the first returned byte. */
38
+ stream(path: string, query: Record<string, string | undefined>, opts?: RequestOptions): AsyncGenerator<Uint8Array>;
22
39
  constructor(opts: NixflexClientOptions);
23
40
  request<T>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown, query?: Record<string, string | number | boolean | undefined>, reqOpts?: RequestOptions): Promise<T>;
24
41
  private fetchWithTimeout;
@@ -26,42 +43,76 @@ declare class HttpClient {
26
43
 
27
44
  type ResponseLength = 'short' | 'medium' | 'long';
28
45
  type TransferType = 'cold' | 'warm';
46
+ type AgentRetentionDays = 90 | 30 | 7 | 1 | 0;
47
+ interface AgentExtractionField {
48
+ name: string;
49
+ type: 'text' | 'selector' | 'boolean' | 'number';
50
+ description?: string;
51
+ optional?: boolean;
52
+ format_example?: string;
53
+ choices?: string[];
54
+ }
55
+ interface AgentContractSettings {
56
+ voice_key?: string | null;
57
+ timezone?: string;
58
+ /** Confidence 0-1; silence in whole milliseconds, including 0. */
59
+ stt_confidence?: number;
60
+ stt_max_silence_ms?: number;
61
+ incall_sms_enabled?: boolean;
62
+ post_call_sms_enabled?: boolean;
63
+ post_call_sms_template?: string;
64
+ data_extraction_fields?: AgentExtractionField[];
65
+ wait_tag_seconds?: number | null;
66
+ ivr_timeout_seconds?: number;
67
+ remember_callers?: boolean;
68
+ require_booking_confirmation?: boolean;
69
+ /** Legacy agent number/model settings, not a number import or model selection. */
70
+ phone_number?: string | null;
71
+ llm_model?: string;
72
+ }
73
+ interface AgentWarning {
74
+ code: 'unknown_fields';
75
+ fields: string[];
76
+ message: string;
77
+ }
29
78
  /** Parameters for creating an agent. Every field is optional - the API has
30
79
  * sensible defaults for all of them. `name` is the only one recommended. */
31
- interface AgentCreateParams {
32
- /** Display name (max 100 chars). Default "Untitled Agent". */
80
+ interface AgentCreateParams extends AgentContractSettings {
81
+ /** Display name (max 200 chars). Default "Untitled Agent". */
33
82
  name?: string;
34
- /** The AI's instructions (max 16000 chars ~ 4000 tokens). Over-limit is rejected with `prompt_too_long`. */
83
+ /** Instructions: 3,000 canonical tokens with Knowledge enabled (100,000-character intake bound); legacy mode 16,000 characters. Changed/new prompts are checked by the server; unchanged same-agent prompts may be grandfathered. */
35
84
  system_prompt?: string;
36
85
  /** First line spoken on inbound calls. */
37
86
  welcome_message?: string;
38
87
  /** Voice name (browse in the dashboard). Default "Ashley". */
39
- voice_id?: string;
88
+ voice_id?: string | null;
40
89
  /** Language code, or "multi" (follows the caller across 10 languages). Arabic, Hebrew, Korean, Chinese and Polish need their own code. */
41
90
  language?: string;
42
91
  /** Set false to disable without deleting. */
43
92
  is_active?: boolean;
44
- /** AI temperature 0-1. Default 0.3. */
93
+ /** AI temperature 0-0.7. Explicit 0 is preserved; omitted defaults to 0.3. */
45
94
  temperature?: number;
46
95
  response_length?: ResponseLength;
47
96
  /** Agent greets the caller immediately. Default true. */
48
97
  ai_speaks_first?: boolean;
49
- /** AI improvises the greeting per call instead of the static welcome. */
98
+ /** New-agent default true: AI writes the inbound greeting from the prompt. */
50
99
  dynamic_greeting?: boolean;
51
100
  /** 0-100. Lower = harder to interrupt. Default 50. */
52
101
  interruption_sensitivity?: number;
53
102
  /** Milliseconds the agent waits after the caller stops speaking, 0-1000. Default 200. */
54
103
  response_eagerness?: number;
55
104
  /** Comma-separated words STT might mishear (staff names, treatments). Keep under 50 - too many are rejected at transcription time. */
56
- boosted_keywords?: string;
57
- /** Seconds the agent waits after pickup before speaking, 5-30. Default 10. */
105
+ boosted_keywords?: string | null;
106
+ /** Legacy pickup setting. This contract release does not change its handling or default (10). */
58
107
  pickup_delay?: number;
59
- /** Hard cap on call length, 60-1800 seconds. Default 600. */
60
- max_call_duration_seconds?: number;
61
- /** Hang up if the caller is silent this long, 5-45 seconds. Default 30. */
62
- silence_hangup_seconds?: number;
63
- /** Save call audio. Recordings delete after 90 days. Default true. */
108
+ /** Positive whole seconds; omitted create default 300. null uses the existing runtime fallback. */
109
+ max_call_duration_seconds?: number | null;
110
+ /** Positive whole seconds; omitted create default 10. null uses the existing runtime fallback. */
111
+ silence_hangup_seconds?: number | null;
112
+ /** Save call audio. Retention inherits the account default on create. Default true. */
64
113
  record_call?: boolean;
114
+ /** Who records when record_call is on. 'provider' = your carrier records (whole call, including after a transfer to a person; carrier recording charges apply). 'nixflex' = the voice engine records the conversation itself at no extra cost; a transfer to a person is not included. Default 'provider'. */
115
+ recording_source?: 'provider' | 'nixflex';
65
116
  /** Carrier answering-machine detection: fast hangup ~4s in, NO voicemail message, extra carrier cost. OFF lets the agent detect voicemail itself and leave a message. Default false. */
66
117
  amd_enabled?: boolean;
67
118
  /** Keypad digits instead of speech. Three-state: true/false explicit, null = not set (a number's own setting decides). */
@@ -74,11 +125,11 @@ interface AgentCreateParams {
74
125
  voicemail_message?: string | null;
75
126
  /** Where to POST post-call data. */
76
127
  webhook_url?: string | null;
77
- /** Agent can end the call cleanly. Default true. */
128
+ /** Enables duration/silence end-call timers; not an absolute model END_CALL prohibition. Default true. */
78
129
  func_end_call?: boolean;
79
130
  /** Warm-transfer briefing text. Empty = AI auto-generates from the conversation. */
80
131
  transfer_whisper?: string | null;
81
- /** NOT ENFORCED - accepted and returned, but the engine does not read it. Control texting in your prompt. */
132
+ /** Legacy, not enforced. Use incall_sms_enabled for the actual texting permission. */
82
133
  func_send_sms?: boolean;
83
134
  /** NOT ENFORCED - same as func_send_sms. Transfers are controlled by your prompt and transfer_number. */
84
135
  func_cold_transfer?: boolean;
@@ -91,20 +142,44 @@ interface AgentCreateParams {
91
142
  speaking_rate?: number | null;
92
143
  /** Greet recognised returning callers by name. Default true. */
93
144
  greet_by_name?: boolean;
94
- /** Said when transcription fails. */
145
+ /** Legacy compatibility field; not a configurable runtime fallback. */
95
146
  fallback_message?: string;
96
147
  }
97
- /** Update accepts any create field; omitted fields keep their values.
98
- * Unrecognised field names return 200 and change NOTHING - check spelling
99
- * against the docs if a setting is not taking effect. */
100
- type AgentUpdateParams = AgentCreateParams;
148
+ /** Empty/unknown-only updates fail. Mixed unknown keys return warnings.
149
+ * Omitted fields keep their values; retention is update-only. */
150
+ interface AgentUpdateParams extends AgentCreateParams {
151
+ call_retention_days?: AgentRetentionDays;
152
+ }
101
153
  /** The agent object as the API returns it. */
102
154
  interface Agent {
155
+ /** Read-only identity and historical fields are never create/update parameters. */
156
+ id?: string;
157
+ api_key_id?: string;
158
+ voice_key?: string | null;
159
+ timezone?: string | null;
160
+ stt_confidence?: number | null;
161
+ stt_max_silence_ms?: number | null;
162
+ wait_tag_seconds?: number | null;
163
+ ivr_timeout_seconds?: number | null;
164
+ remember_callers?: boolean;
165
+ require_booking_confirmation?: boolean;
166
+ phone_number?: string | null;
167
+ llm_model?: string | null;
168
+ boosted_keywords?: string | null;
169
+ twilio_account_sid?: string | null;
170
+ greeting_language?: string | null;
171
+ precall_webhook_url?: string | null;
172
+ tester_scenarios?: unknown[];
173
+ outbound_transfer_numbers?: unknown[];
174
+ outbound_warm_transfer_numbers?: unknown[];
175
+ outbound_post_call_sms_templates?: unknown[];
176
+ outbound_max_duration_seconds?: number | null;
177
+ outbound_silence_hangup_seconds?: number | null;
103
178
  agent_id: string;
104
179
  name: string;
105
180
  system_prompt: string;
106
181
  welcome_message: string;
107
- voice_id: string;
182
+ voice_id: string | null;
108
183
  language: string;
109
184
  temperature: number;
110
185
  response_length?: ResponseLength;
@@ -112,9 +187,10 @@ interface Agent {
112
187
  dynamic_greeting?: boolean;
113
188
  interruption_sensitivity?: number;
114
189
  pickup_delay?: number;
115
- max_call_duration_seconds: number;
116
- silence_hangup_seconds: number;
190
+ max_call_duration_seconds: number | null;
191
+ silence_hangup_seconds: number | null;
117
192
  record_call: boolean;
193
+ recording_source: 'provider' | 'nixflex';
118
194
  func_end_call?: boolean;
119
195
  transfer_whisper?: string | null;
120
196
  func_send_sms?: boolean;
@@ -135,20 +211,33 @@ interface Agent {
135
211
  post_call_sms_template?: string | null;
136
212
  voicemail_leave_enabled?: boolean;
137
213
  voicemail_message?: string | null;
138
- data_extraction_fields?: unknown[];
214
+ data_extraction_fields?: AgentExtractionField[];
215
+ call_retention_days?: AgentRetentionDays;
216
+ warnings?: AgentWarning[];
217
+ response_eagerness?: number;
139
218
  is_active: boolean;
140
219
  created_at: string;
141
220
  updated_at: string;
142
221
  }
143
222
  interface AgentDeleteResponse {
144
- agent_id: string;
145
- deleted: boolean;
223
+ /** Legacy message "Agent deleted" means soft disable, NOT permanent erasure. */
224
+ message: string;
146
225
  }
147
226
  interface ListParams {
148
227
  /** Hard-capped at 200 per request (higher values are reduced, not rejected). */
149
228
  limit?: number;
150
229
  offset?: number;
151
230
  }
231
+ /** Agents use strict bounds; other resources retain their existing ListParams rules. */
232
+ interface AgentListParams {
233
+ /** Whole number 1..200, default 100. Out-of-range values are rejected. */
234
+ limit?: number;
235
+ /** Whole number 0..1000000, default 0. */
236
+ offset?: number;
237
+ status?: 'active' | 'disabled' | 'all';
238
+ /** Case-insensitive literal substring of name or agent_id, at most 200 characters. */
239
+ search?: string;
240
+ }
152
241
 
153
242
  declare class Agents {
154
243
  private readonly http;
@@ -156,65 +245,205 @@ declare class Agents {
156
245
  /** Create an agent. Every field has a sensible default - `{ name }` alone works.
157
246
  * The agent is immediately usable for numbers and outbound calls. */
158
247
  create(params?: AgentCreateParams, opts?: RequestOptions): Promise<Agent>;
159
- /** List active agents, newest first. Default 100, hard cap 200 per page. */
160
- list(params?: ListParams, opts?: RequestOptions): Promise<Agent[]>;
161
- /** Iterate ALL agents across pages: `for await (const a of client.agents.iter()) { ... }` */
248
+ /** Bare array. Active by default; stable created_at DESC, agent_id DESC order. */
249
+ list(params?: AgentListParams, opts?: RequestOptions): Promise<Agent[]>;
250
+ /** Iterate active agents across pages. pageSize must be a whole number 1..200.
251
+ * Offset pages are not a snapshot: concurrent creates/disables can shift rows. */
162
252
  iter(pageSize?: number, opts?: RequestOptions): AsyncGenerator<Agent>;
163
253
  /** Fetch one agent with full configuration. Throws NixflexNotFoundError if the ID is not yours. */
164
254
  get(agentId: string, opts?: RequestOptions): Promise<Agent>;
165
255
  /** Update an agent. Send ONLY the fields you want to change - omitted fields
166
256
  * keep their values. Active calls are unaffected; new calls use the new config.
167
- * Unknown field names return 200 and change nothing - check spelling. */
257
+ * Empty/unknown-only updates fail; mixed unknown keys return warnings. */
168
258
  update(agentId: string, params: AgentUpdateParams, opts?: RequestOptions): Promise<Agent>;
169
- /** PERMANENTLY delete an agent. Attached numbers detach and stop routing;
170
- * historical calls stay accessible. To disable without losing setup, use
171
- * update(agentId, { is_active: false }) instead. */
259
+ /** Soft disable only (is_active=false). Does not detach numbers or erase history.
260
+ * The legacy response message is "Agent deleted". */
172
261
  delete(agentId: string, opts?: RequestOptions): Promise<AgentDeleteResponse>;
173
262
  }
174
263
 
175
- type CallDirection = 'inbound' | 'outbound';
264
+ /** Shared public mutation evidence. Duplicate lookups are not booking events. */
265
+ interface Booking {
266
+ action: 'created' | 'rescheduled' | 'cancelled';
267
+ booking_uid: string | null;
268
+ start: string | null;
269
+ end: string | null;
270
+ attendee_name: string | null;
271
+ attendee_email: string | null;
272
+ service: string | number | null;
273
+ timezone: string | null;
274
+ }
275
+ /** The booking part of the flat call.completed webhook; other fields remain available. */
276
+ interface CallCompletedBookingEvent {
277
+ event: 'call.completed';
278
+ bookings: Booking[];
279
+ [key: string]: unknown;
280
+ }
281
+ interface SmsBookingEvent {
282
+ event: 'sms.booking';
283
+ booking: Booking;
284
+ [key: string]: unknown;
285
+ }
286
+
287
+ /** Explicit decisions only. Omission never grants consent or wider calling hours. */
288
+ interface CampaignPolicy {
289
+ consent_confirmed?: boolean;
290
+ duplicate_policy?: 'allow' | 'warn' | 'reject';
291
+ allow_wider_hours?: boolean;
292
+ /** Required with wider hours: 20..1000 characters describing the approval. */
293
+ hours_confirmation?: string;
294
+ skip_invalid?: boolean;
295
+ source?: string;
296
+ /** Voice only; SMS does not implement reuse. */
297
+ reuse_campaign_id?: string | null;
298
+ reply_window_hours?: number;
299
+ }
300
+ interface RecipientLocation {
301
+ country?: string;
302
+ timezone?: string;
303
+ }
304
+ interface ContactLocation {
305
+ recipient_country?: string;
306
+ recipient_timezone?: string;
307
+ }
308
+ interface CampaignValidation {
309
+ total?: number;
310
+ total_recipients?: number;
311
+ duplicate_policy?: string;
312
+ duplicate_choice_required?: boolean;
313
+ duplicates?: unknown;
314
+ missing_details?: unknown;
315
+ validation?: unknown;
316
+ }
317
+
318
+ /** Optional, read-only history view. Legacy calls.list() still returns an array. */
319
+ interface CallHistoryParams {
320
+ limit?: number;
321
+ offset?: number;
322
+ cursor?: string;
323
+ agent?: string;
324
+ number?: string;
325
+ direction?: 'all' | 'inbound' | 'outbound' | 'web';
326
+ outcome?: 'all' | 'successful' | 'unsuccessful' | 'unknown' | 'failed';
327
+ source?: 'all' | 'campaign' | 'web' | 'test' | 'other';
328
+ /** today uses UTC; pass explicit since/until to match a browser's local dates. */
329
+ period?: 'all' | 'today' | 'week' | 'month';
330
+ since?: string;
331
+ until?: string;
332
+ search?: string;
333
+ }
334
+ interface CallRead {
335
+ call_id: string;
336
+ id?: string;
337
+ agent_id: string | null;
338
+ from_number?: string | null;
339
+ to_number?: string | null;
340
+ call_type: 'inbound' | 'outbound' | 'web' | null;
341
+ call_direction: 'inbound' | 'outbound' | 'web' | null;
342
+ call_status?: string | null;
343
+ duration_ms: number | null;
344
+ start_timestamp: number | null;
345
+ end_timestamp?: number | null;
346
+ answered_at?: number | null;
347
+ created_at: string | null;
348
+ ended_reason: string | null;
349
+ call_successful: boolean | null;
350
+ caller_sentiment?: string | null;
351
+ cost: number | null;
352
+ charged_minutes?: number | null;
353
+ campaign_id?: string | null;
354
+ test_requested_by?: string | null;
355
+ call_summary?: string | null;
356
+ transcript?: string | null;
357
+ extracted_data?: Record<string, unknown> | null;
358
+ call_events?: unknown[] | null;
359
+ recording_url?: null;
360
+ recording_status?: RecordingStatus;
361
+ payload_deleted_at?: string | null;
362
+ payload_deleted_reason?: string | null;
363
+ payload_scheduled_for_deletion?: boolean;
364
+ payload_in_own_storage?: boolean | null;
365
+ }
366
+ interface CallHistoryPage {
367
+ data: CallRead[];
368
+ totals: {
369
+ total: number;
370
+ minutes: number;
371
+ cost: number;
372
+ cost_unknown: number;
373
+ successful: number;
374
+ };
375
+ filters: Record<string, string | null>;
376
+ limit: number;
377
+ offset: number;
378
+ has_more: boolean;
379
+ next_cursor: string | null;
380
+ }
381
+ type RecordingStatus = 'available' | 'pending' | 'expired' | 'customer_bucket' | 'not_recorded' | 'unknown' | 'unavailable' | 'pending_deletion';
382
+ interface CallRecording {
383
+ call_id: string;
384
+ status: RecordingStatus;
385
+ url: string | null;
386
+ expires_at: string | null;
387
+ }
388
+ interface CallBilling {
389
+ call_id: string;
390
+ status: 'settled' | 'pending' | 'unknown' | 'not_started';
391
+ currency: 'USD';
392
+ cost: number | null;
393
+ recorded_cost?: number | null;
394
+ charged_minutes: number | null;
395
+ ai_billed_ms: number | null;
396
+ human_free_ms: number | null;
397
+ /** conservative is a protective billing cap, NOT proof of exact human handover time. */
398
+ basis: 'fenced' | 'conservative' | 'settled_no_takeover' | 'not_started' | null;
399
+ }
400
+
401
+ type CallDirection = 'inbound' | 'outbound' | 'web';
176
402
  type CallerSentiment = 'happy' | 'neutral' | 'frustrated';
177
- /** A call record. Both GET /calls and GET /calls/:id return this exact shape. */
403
+ /** Legacy call record. Retention/unfinished work can leave fields null or absent. */
178
404
  interface Call {
179
405
  call_id: string;
180
- agent_id: string;
181
- call_direction: CallDirection;
182
- /** Same meaning as call_direction; both are returned. */
183
- call_type?: CallDirection;
406
+ agent_id: string | null;
407
+ call_direction: CallDirection | null;
408
+ /** Historical classification can differ from call_direction; web is a separate type. */
409
+ call_type?: CallDirection | null;
184
410
  /** Caller's number, E.164. */
185
- from_number: string;
411
+ from_number?: string | null;
186
412
  /** Number that was called, E.164. */
187
- to_number: string;
188
- call_status: string;
413
+ to_number?: string | null;
414
+ call_status: string | null;
189
415
  /** Epoch MILLISECONDS. On outbound this is when dialling began - BEFORE ringing. */
190
- start_timestamp: number;
416
+ start_timestamp: number | null;
191
417
  /** Epoch MILLISECONDS. */
192
- end_timestamp: number;
418
+ end_timestamp: number | null;
193
419
  /** Epoch milliseconds when ANSWERED, or null (inbound / older calls). Ring time = answered_at - start_timestamp. */
194
- answered_at: number | null;
195
- /** TIME CONNECTED in ms (answer to hangup) - the number you are billed on. Ring time excluded, so on outbound this is NOT end_timestamp - start_timestamp. */
196
- duration_ms: number;
420
+ answered_at?: number | null;
421
+ /** Connected duration, not necessarily AI billed time. Amounts are returned by the API, never recalculated by the kit. */
422
+ duration_ms: number | null;
197
423
  /** Why the call ended: completed, transferred, voicemail_detected, silence_timeout,
198
424
  * ivr_timeout, max_duration_reached, caller_hangup (inbound), callee_hangup (outbound),
199
425
  * busy / failed / no-answer / canceled (carrier words for calls that never connected),
200
426
  * concurrency_limit, and rare infrastructure endings. */
201
- ended_reason: string;
427
+ ended_reason: string | null;
202
428
  /** Minutes actually charged for this call. Transfers stop the meter at handoff, so
203
429
  * this can be less than duration_ms suggests - the recording runs to the end either way. */
204
- charged_minutes?: number;
430
+ charged_minutes?: number | null;
431
+ cost?: number | null;
205
432
  /** A single string, one turn per line - not an array of turn objects. */
206
- transcript: string;
207
- call_summary: string;
208
- caller_sentiment: CallerSentiment;
209
- call_successful: boolean;
433
+ transcript?: string | null;
434
+ call_summary?: string | null;
435
+ caller_sentiment?: CallerSentiment | null;
436
+ call_successful?: boolean | null;
210
437
  /** Fields pulled from the call, per the agent's extraction settings. */
211
- extracted_data: Record<string, unknown>;
438
+ extracted_data?: Record<string, unknown> | null;
212
439
  /** Appointments booked during the call. */
213
- bookings: unknown[];
214
- /** MP3 link, or null if recording was off. This is the ONLY copy - the carrier's copy is deleted. */
440
+ bookings?: unknown[] | null;
441
+ /** Legacy pointer; null does not prove recording was off. Use calls.recording() for state and short link. */
215
442
  recording_url: string | null;
443
+ recording_status?: RecordingStatus;
444
+ recording_endpoint?: string | null;
216
445
  recording_duration_s?: number;
217
- voicemail_detected: boolean;
446
+ voicemail_detected?: boolean | null;
218
447
  voicemail_detection_method?: string | null;
219
448
  /** Carrier machine-detection verdict (e.g. 'human', 'machine_start'). Only when AMD is enabled. */
220
449
  amd_result?: string | null;
@@ -227,14 +456,16 @@ interface Call {
227
456
  created_at: string;
228
457
  }
229
458
  /** Parameters for POST /v1/calls/outbound. */
230
- interface OutboundCallParams {
459
+ interface OutboundCallParams extends ContactLocation {
460
+ /** Optional durable UUID. Save before sending; reuse only with identical inputs. */
461
+ request_id?: string;
231
462
  /** The agent that handles the call. Must belong to your API key. */
232
463
  agent_id: string;
233
464
  /** Who to call, E.164 ("+447386172392", not "07386172392"). NOTE: the field is to_number, not `to` - `to` is the SMS endpoints' field. */
234
465
  to_number: string;
235
- /** The call purpose - what to say and why. Sent fresh per call, stored nowhere. Must not be empty. */
466
+ /** Per-call purpose; may be retained with the call's actual prompt. Must not be empty. */
236
467
  prompt: string;
237
- /** Key-values interpolated into the prompt as {key}. Unmatched references stay literal - check your keys. */
468
+ /** Key-values interpolated as {{key}}. Supply every referenced key; missing values may refuse the call when validation is enabled. */
238
469
  dynamic_vars?: Record<string, string>;
239
470
  /** Which of your numbers to dial from. Must be outbound-enabled on this agent. Omit = the agent's first outbound-enabled number. */
240
471
  from_number?: string;
@@ -248,17 +479,21 @@ interface OutboundCallResponse {
248
479
  status: string;
249
480
  to: string;
250
481
  from: string;
482
+ request_id?: string;
483
+ replayed?: true;
484
+ request_status?: 'unconfirmed';
485
+ safe_to_retry?: false;
251
486
  }
252
- interface BatchRecipient {
487
+ interface BatchRecipient extends RecipientLocation {
253
488
  phone: string;
254
489
  /** Injected as context automatically - no {{placeholders}} needed in the prompt. */
255
- variables?: Record<string, string>;
490
+ variables?: Record<string, unknown>;
256
491
  /** Replaces the campaign prompt for this recipient only. */
257
- prompt_override?: string;
492
+ prompt_override?: string | null;
258
493
  }
259
494
  type Weekday = 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
260
495
  /** Parameters for POST /v1/calls/batch. */
261
- interface BatchCampaignParams {
496
+ interface BatchCampaignParams extends CampaignPolicy {
262
497
  agent_id: string;
263
498
  /** The call purpose for every call. Required. */
264
499
  prompt: string;
@@ -269,24 +504,28 @@ interface BatchCampaignParams {
269
504
  name?: string;
270
505
  /** false (default): reject the whole request on any invalid phone. true: dial valid ones, list invalid in the response. */
271
506
  skip_invalid?: boolean;
272
- /** 'now' (default, launches immediately) or 'schedule'. */
507
+ /** 'now' (default, requests launch subject to recipient gates) or 'schedule'. */
273
508
  schedule_type?: 'now' | 'schedule';
274
509
  /** YYYY-MM-DD. Required when schedule_type is 'schedule'. */
275
- scheduled_date?: string;
510
+ scheduled_date?: string | null;
276
511
  /** Calling window start, minutes since midnight (540 = 9:00am). */
277
- window_start_minutes?: number;
512
+ window_start_minutes?: number | null;
278
513
  /** Calling window end, minutes since midnight (1080 = 6:00pm). Overnight windows (start > end) are supported. */
279
- window_end_minutes?: number;
280
- window_days?: Weekday[];
281
- /** IANA timezone the window runs in (e.g. "Europe/London"). Priority: this > the agent's timezone > Europe/London. One campaign = one timezone - split multi-country lists into separate campaigns. */
282
- timezone?: string;
514
+ window_end_minutes?: number | null;
515
+ window_days?: Weekday[] | null;
516
+ /** Campaign IANA timezone. Recipient country/timezone and current contact policy still gate each dispatch. */
517
+ timezone?: string | null;
283
518
  }
284
519
  interface BatchInvalidEntry {
285
520
  phone: string;
286
521
  reason: string;
287
522
  row_index: number;
288
523
  }
289
- interface BatchCreateResponse {
524
+ interface BatchCreateResponse extends CampaignValidation {
525
+ dialed?: number;
526
+ queued?: number;
527
+ failed?: number;
528
+ message?: string;
290
529
  campaign_id: string;
291
530
  status: string;
292
531
  valid_count: number;
@@ -294,16 +533,30 @@ interface BatchCreateResponse {
294
533
  invalid: BatchInvalidEntry[];
295
534
  }
296
535
  interface BatchLaunchResponse {
536
+ total_recipients?: number;
297
537
  campaign_id: string;
298
538
  status: string;
299
- recipients_count: number;
300
- queued_count: number;
539
+ enqueued?: number;
540
+ failed_to_enqueue?: number;
541
+ message?: string;
301
542
  }
302
543
  interface CallDeleteResponse {
303
544
  call_id: string;
304
- deleted: boolean;
305
- /** Whether a recording file was found and removed from storage. */
545
+ deleted: true;
546
+ /** Managed cleanup indicator, not proof that every carrier/external copy is erased. */
306
547
  recording_deleted: boolean;
548
+ recording_cleanup: 'carrier_best_effort' | 'queued';
549
+ }
550
+ /** Voice/SMS campaign is hidden; history and used charges remain. No refunds. */
551
+ interface CampaignDeleteResponse {
552
+ campaign_id: string;
553
+ deleted: true;
554
+ message: string;
555
+ }
556
+ /** On NixflexServerError, status 503 and code hangup_pending. Not a success receipt. */
557
+ interface ContentDeletePendingDetails {
558
+ deleted: false;
559
+ retry_pending: true;
307
560
  }
308
561
  interface CallDeleteAllResponse {
309
562
  deleted: boolean;
@@ -312,45 +565,229 @@ interface CallDeleteAllResponse {
312
565
  sms_deleted: number;
313
566
  }
314
567
 
568
+ interface CallBookingTimeline extends Booking {
569
+ booking_uid: string;
570
+ at: string;
571
+ }
572
+ interface CallBookingFinal extends Omit<Booking, 'action'> {
573
+ booking_uid: string;
574
+ status: 'active' | 'cancelled';
575
+ }
576
+ /** This call's retained booking result, not current calendar inventory. */
577
+ interface CallBookingResult {
578
+ event: 'call.bookings';
579
+ call_id: string;
580
+ agent_id: string | null;
581
+ from: string | null;
582
+ to: string | null;
583
+ number: string | null;
584
+ ended_at: string | null;
585
+ timeline: CallBookingTimeline[];
586
+ final: CallBookingFinal[];
587
+ }
588
+ type CallBookings = {
589
+ call_id: string;
590
+ state: 'ready';
591
+ result: CallBookingResult;
592
+ } | {
593
+ call_id: string;
594
+ state: 'none' | 'processing' | 'deleted' | 'unavailable';
595
+ result: null;
596
+ };
597
+ type OutboundRequestState = 'pending' | 'accepted' | 'rejected' | 'unknown';
598
+ interface OutboundCallRequest {
599
+ request_id: string;
600
+ state: OutboundRequestState;
601
+ call_id: string | null;
602
+ reason: string | null;
603
+ }
604
+ type PreparedOutboundCall = OutboundCallParams & {
605
+ request_id: string;
606
+ };
607
+ /** POST acceptance is not a connected/completed call. A replay has no to/from fields. */
608
+ interface OutboundRequestReceipt {
609
+ call_id: string;
610
+ request_id: string;
611
+ status: 'initiated';
612
+ replayed?: true;
613
+ request_status?: 'unconfirmed';
614
+ safe_to_retry?: false;
615
+ to?: string;
616
+ from?: string;
617
+ [receiptField: string]: unknown;
618
+ }
619
+
620
+ /** C5 wire contract. Server defaults apply only when a field is omitted. */
621
+ type CampaignCancelResponse = {
622
+ "campaign_id": string;
623
+ "status": "cancelled";
624
+ "in_progress_may_finish": true;
625
+ };
626
+ type CampaignConsentParams = {
627
+ "event": "consent" | "consent_withdrawn";
628
+ "confirmed": true;
629
+ };
630
+ type CampaignConsentResponse = {
631
+ "campaign_id": string;
632
+ "recorded": true;
633
+ };
634
+ type CampaignResumeResponse = {
635
+ "campaign_id": string;
636
+ "status": "running";
637
+ "page_result": {
638
+ "enqueued"?: number;
639
+ "next"?: string | null;
640
+ "paused"?: boolean;
641
+ "held"?: number | string;
642
+ "outcome"?: string;
643
+ "reason"?: string | null;
644
+ "sent"?: number;
645
+ "failed"?: number;
646
+ "segments"?: number;
647
+ "campaign_done"?: boolean | null;
648
+ "dispatchSafety"?: boolean;
649
+ "attempt_outcome"?: string;
650
+ "attempt_sent"?: boolean;
651
+ "attempt_charged"?: boolean;
652
+ "attempt_safe_to_retry"?: boolean;
653
+ "safe_to_retry"?: boolean;
654
+ "stop_message"?: string;
655
+ "not_sent"?: number;
656
+ "stop_recorded"?: boolean;
657
+ "attempted_recipient_id"?: string;
658
+ [key: string]: unknown;
659
+ };
660
+ "safe_to_retry": false;
661
+ "message": string;
662
+ };
663
+ type CampaignListQuery = {
664
+ "status"?: string;
665
+ "limit"?: number;
666
+ };
667
+ type CampaignListResponse = {
668
+ "campaigns": ({
669
+ "campaign_id": string;
670
+ "agent_id": string;
671
+ "name": string | null;
672
+ "from_number": string | null;
673
+ "schedule_type": string;
674
+ "scheduled_date": string | null;
675
+ "window_start_minutes": number | null;
676
+ "window_end_minutes": number | null;
677
+ "window_days": (string)[] | null;
678
+ "timezone": string | null;
679
+ "source": string;
680
+ "status": string;
681
+ "total_count": number;
682
+ "started_at": string | null;
683
+ "completed_at": string | null;
684
+ "created_at": string | null;
685
+ "updated_at": string | null;
686
+ "allow_wider_hours": boolean;
687
+ "prompt": string | null;
688
+ "done_count": number;
689
+ "failed_count": number;
690
+ "voicemail_count": number;
691
+ })[];
692
+ };
693
+ type SmsCampaignUpdateParams = {
694
+ "is_active"?: boolean;
695
+ "reply_context_prompt"?: string | null;
696
+ "reply_window_hours"?: number;
697
+ };
698
+ type SmsCampaignUpdateResponse = {
699
+ "campaign_id": string;
700
+ "agent_id": string;
701
+ "name": string | null;
702
+ "from_number": string | null;
703
+ "schedule_type": string;
704
+ "scheduled_date": string | null;
705
+ "window_start_minutes": number | null;
706
+ "window_end_minutes": number | null;
707
+ "window_days": (string)[] | null;
708
+ "timezone": string | null;
709
+ "source": string;
710
+ "status": string;
711
+ "total_count": number;
712
+ "started_at": string | null;
713
+ "completed_at": string | null;
714
+ "created_at": string | null;
715
+ "updated_at": string | null;
716
+ "allow_wider_hours": boolean;
717
+ "id": string;
718
+ "api_key_id": string;
719
+ "message_template": string;
720
+ "reply_context_prompt": string | null;
721
+ "reply_window_hours": number;
722
+ "is_active": boolean;
723
+ "claimed_at": string | null;
724
+ "sent_count": number;
725
+ "delivered_count": number;
726
+ "failed_count": number;
727
+ "reply_count": number;
728
+ "total_segments": number;
729
+ };
730
+
315
731
  declare class Calls {
316
732
  private readonly http;
317
733
  constructor(http: HttpClient);
734
+ /** Generate a UUID locally before sending; save and reuse the returned body unchanged. */
735
+ prepare(params: OutboundCallParams): PreparedOutboundCall;
736
+ bookings(callId: string, opts?: RequestOptions): Promise<CallBookings>;
737
+ outboundRequest(requestId: string, opts?: RequestOptions): Promise<OutboundCallRequest>;
318
738
  /** Trigger an outbound AI call. FIRE-AND-FORGET: returns immediately with a
319
739
  * call_id; ringing, conversation and ending happen asynchronously. Set a
320
740
  * webhook_url on the agent or number to receive call.completed when it ends.
321
741
  * The dialling number must be OUTBOUND-ENABLED (inbound working does not
322
742
  * mean outbound works - separate switches). */
323
- create(params: OutboundCallParams, opts?: RequestOptions): Promise<OutboundCallResponse>;
743
+ create(params: OutboundCallParams & {
744
+ request_id: string;
745
+ }, opts?: RequestOptions): Promise<OutboundRequestReceipt>;
746
+ create(params: OutboundCallParams & {
747
+ request_id?: undefined;
748
+ }, opts?: RequestOptions): Promise<OutboundCallResponse>;
749
+ create(params: OutboundCallParams, opts?: RequestOptions): Promise<OutboundCallResponse | OutboundRequestReceipt>;
324
750
  /** List calls, newest first. Default 50, hard cap 200. The response is a
325
751
  * bare array with no total - page until you get fewer rows than you asked
326
- * for (or use iter()). Call data is retained 90 days. */
752
+ * for within the 200 cap (or use iter()). Availability depends on retention. */
327
753
  list(params?: ListParams, opts?: RequestOptions): Promise<Call[]>;
328
- /** Iterate ALL calls across pages: `for await (const c of client.calls.iter()) { ... }` */
754
+ /** Dashboard-style filtered metadata, totals and stable cursor order. Not a frozen database snapshot. */
755
+ history(params?: CallHistoryParams, opts?: RequestOptions): Promise<CallHistoryPage>;
756
+ /** Explicit nullable detail, failed-start and retained stubs; no raw storage URL. */
757
+ read(callId: string, opts?: RequestOptions): Promise<CallRead>;
758
+ /** Managed-storage link: use expires_at, never a hardcoded lifetime, or a truthful non-downloadable state. Never reads BYO storage. */
759
+ recording(callId: string, opts?: RequestOptions): Promise<CallRecording>;
760
+ /** Iterate calls across pages. pageSize must be a whole number 1..200.
761
+ * Offset pages are not a snapshot: concurrent changes can shift rows. */
329
762
  iter(pageSize?: number, opts?: RequestOptions): AsyncGenerator<Call>;
330
763
  /** Fetch one call: transcript, recording URL, post-call analysis. Note:
331
- * duration_ms is time CONNECTED (what you are billed on) - ring time is
764
+ * duration_ms is time CONNECTED (not necessarily AI billed time) - ring time is
332
765
  * excluded, so it will not equal end_timestamp - start_timestamp on
333
766
  * outbound calls. */
334
767
  get(callId: string, opts?: RequestOptions): Promise<Call>;
335
- /** GDPR: PERMANENTLY erase one call - the record AND its recording file.
336
- * Irreversible. Throws NixflexNotFoundError if the ID is not yours. */
768
+ /** End a running call, then delete its content. 503 hangup_pending with
769
+ * retry_pending:true means queued, not deleted. Recording cleanup may remain
770
+ * queued or carrier best effort. One DELETE; never automatically repeated. */
337
771
  delete(callId: string, opts?: RequestOptions): Promise<CallDeleteResponse>;
338
- /** GDPR: PERMANENTLY erase ALL calls, recordings, and SMS messages on this
339
- * key. Irreversible - intended for data-erasure requests and offboarding. */
772
+ /** Request guarded call cleanup, not account/SMS erasure. Safety holds can
773
+ * refuse it; legacy recording counters are not proof of every copy's erasure. */
340
774
  deleteAll(opts?: RequestOptions): Promise<CallDeleteAllResponse>;
341
775
  }
342
776
 
343
777
  declare class Campaigns {
344
778
  private readonly http;
779
+ /** Cancel waiting work, end running calls and hide the campaign. History and used
780
+ * charges remain; no refund. Owner/Admin only. 503 hangup_pending is queued.
781
+ * Missing/foreign is 404. One DELETE; never automatically repeated. */
782
+ delete(id: string, opts?: RequestOptions): Promise<CampaignDeleteResponse>;
783
+ cancel(id: string, opts?: RequestOptions): Promise<CampaignCancelResponse>;
784
+ consent(id: string, params: CampaignConsentParams, opts?: RequestOptions): Promise<CampaignConsentResponse>;
785
+ resume(id: string, opts?: RequestOptions): Promise<CampaignResumeResponse>;
786
+ list(params?: CampaignListQuery, opts?: RequestOptions): Promise<CampaignListResponse>;
345
787
  constructor(http: HttpClient);
346
- /** Create a batch campaign - many outbound calls under one campaign_id.
347
- * schedule_type 'now' launches immediately; 'schedule' waits for
348
- * scheduled_date and fires INSIDE the calling window in the campaign's
349
- * timezone (yours > the agent's > Europe/London). Overnight windows
350
- * supported. One campaign = one timezone - split multi-country lists. */
788
+ /** Create executable work, not a draft. The default requests immediate launch; scheduled work can start automatically. Each dispatch still checks consent and local hours. */
351
789
  create(params: BatchCampaignParams, opts?: RequestOptions): Promise<BatchCreateResponse>;
352
- /** Launch a scheduled campaign immediately, overriding its schedule.
353
- * Already running = no-op returning current status. */
790
+ /** Request launch; it does not bypass recipient checks or prove delivery. Never auto-retried. */
354
791
  launch(campaignId: string, opts?: RequestOptions): Promise<BatchLaunchResponse>;
355
792
  }
356
793
 
@@ -363,6 +800,103 @@ interface VerifyOptions {
363
800
  /** Returns true only if the signature is authentic AND fresh. Never throws. */
364
801
  declare function verifyWebhookSignature(rawBody: string | Buffer, signatureHeader: string | null | undefined, keySecret: string, options?: VerifyOptions): boolean;
365
802
 
803
+ type CalendarDay = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
804
+ /** All seven days are required when hours is supplied. No overnight interval. */
805
+ type CalendarHours = Record<CalendarDay, [string, string] | null>;
806
+ interface GoogleCalendarSettings {
807
+ timezone: string;
808
+ hours: CalendarHours;
809
+ slot_minutes: 15 | 30 | 45 | 60;
810
+ calendar_id: string;
811
+ send_invites: boolean;
812
+ }
813
+ /** Supply only changed fields. Omission keeps the saved setting; null does not clear. */
814
+ type GoogleCalendarSettingsPatch = Partial<GoogleCalendarSettings>;
815
+ interface GoogleCalendarStatus {
816
+ connected: boolean;
817
+ account_email: string | null;
818
+ calendar_id: string;
819
+ connected_at: string | null;
820
+ needs_reconnect: boolean;
821
+ send_invites: boolean;
822
+ }
823
+ interface GoogleCalendarConnect {
824
+ url: string;
825
+ expires_at: string;
826
+ }
827
+ interface GoogleCalendarDisconnect {
828
+ ok: true;
829
+ connected: false;
830
+ }
831
+ /** Supply privately from environment or a secret manager; never log this object. */
832
+ type NumberCredentials = {
833
+ twilio_sid: string;
834
+ twilio_token: string;
835
+ telnyx_api_key?: never;
836
+ telnyx_connection_id?: never;
837
+ } | {
838
+ telnyx_api_key: string;
839
+ telnyx_connection_id: string;
840
+ twilio_sid?: never;
841
+ twilio_token?: never;
842
+ };
843
+ interface NumberCredentialsUpdated {
844
+ phone_number: string;
845
+ provider: 'twilio' | 'telnyx';
846
+ updated: true;
847
+ }
848
+
849
+ interface PhoneNumberMoveParams {
850
+ agent_id: string;
851
+ }
852
+ interface PhoneNumberMoveResponse {
853
+ phone_number: {
854
+ phone_number: string;
855
+ agent_id: string;
856
+ agent_name: string;
857
+ changed: boolean;
858
+ };
859
+ }
860
+
861
+ type NumberUsagePeriod = 'today' | '7' | '14' | '30' | '90' | 'all';
862
+ interface NumberUsageParams {
863
+ /** Calendar days including today; default all (retained history). */
864
+ period?: NumberUsagePeriod;
865
+ /** IANA zone, e.g. Europe/London; default UTC. Match the dashboard browser zone. */
866
+ time_zone?: string;
867
+ }
868
+ interface NumberUsage {
869
+ phone_number: string;
870
+ period: NumberUsagePeriod;
871
+ time_zone: string;
872
+ /** null for all retained history; otherwise inclusive ISO timestamp. */
873
+ period_start: string | null;
874
+ /** Inclusive server snapshot cutoff, not the future end of the calendar day. */
875
+ period_end: string;
876
+ start_inclusive: true;
877
+ end_inclusive: true;
878
+ currency: 'USD';
879
+ duration_unit: 'milliseconds';
880
+ call_count: number;
881
+ total_ms: number;
882
+ /** total_ms / 60000 rounded to six decimal places; total_ms is authoritative. */
883
+ minutes: number;
884
+ last_call: string | null;
885
+ /** Exact decimal string of recorded call charges, not estimated/repriced costs. */
886
+ total_cost: string;
887
+ unpriced_calls: number;
888
+ sms_sent: number;
889
+ sms_received: number;
890
+ sms_count: number;
891
+ web_chats: number;
892
+ /** Zero calls AND zero SMS in this period; web chat does not affect unused. */
893
+ unused: boolean;
894
+ history_note: string;
895
+ }
896
+ interface NumberUsageResponse {
897
+ usage: NumberUsage;
898
+ }
899
+
366
900
  /** Import params - the carrier is INFERRED from which credentials you send.
367
901
  * Twilio: twilio_sid + twilio_token. Telnyx: telnyx_api_key + telnyx_connection_id
368
902
  * (the ID of a TeXML Application you created in your Telnyx portal, voice webhook
@@ -380,14 +914,16 @@ interface PhoneNumberImportParams {
380
914
  telnyx_api_key?: string;
381
915
  /** Your TeXML Application ID. Telnyx import. */
382
916
  telnyx_connection_id?: string;
917
+ /** Optional Telnyx signature public-key candidate; saving does not verify it. */
918
+ telnyx_public_key?: string;
383
919
  /** Per-number prompt override, max 8000 chars. */
384
- custom_prompt?: string;
920
+ custom_prompt?: string | null;
385
921
  }
386
922
  interface PhoneNumber {
387
923
  phone_number: string;
388
924
  agent_id: string;
389
- /** 'twilio' or 'telnyx'. */
390
- provider: string;
925
+ /** 'twilio' or 'telnyx'; absent from current Twilio-import/PATCH replies. */
926
+ provider?: string;
391
927
  /** Twilio numbers only; null on other carriers. */
392
928
  twilio_number_sid?: string | null;
393
929
  telnyx_number_id?: string | null;
@@ -406,12 +942,74 @@ interface PhoneNumber {
406
942
  web_prompt?: string | null;
407
943
  speaking_rate?: number | null;
408
944
  dtmf_enabled?: boolean | null;
945
+ require_booking_confirmation?: boolean | null;
946
+ monitor_enabled?: boolean;
947
+ web_calls_enabled?: boolean;
948
+ web_agent_enabled?: boolean;
949
+ web_functions_enabled?: boolean;
409
950
  record_call?: boolean | null;
951
+ recording_source?: 'provider' | 'nixflex' | null;
410
952
  created_at?: string;
953
+ /** Descriptive origin only, never permission or a writable setting. */
954
+ readonly source?: 'api' | 'dashboard' | null;
955
+ }
956
+ interface TelnyxKeyStatus {
957
+ provider: string | null;
958
+ set: boolean;
959
+ verified: boolean;
960
+ fingerprint: string | null;
961
+ previousKeyAcceptedUntil: string | null;
962
+ }
963
+ /** GET returns saved overrides (null stays null), not inherited agent settings. */
964
+ interface PhoneNumberDetails {
965
+ phone_number: string;
966
+ agent_id: string | null;
967
+ provider: 'twilio' | 'telnyx' | null;
968
+ readonly source: 'api' | 'dashboard' | null;
969
+ created_at: string | null;
970
+ inbound_enabled: boolean | null;
971
+ outbound_enabled: boolean | null;
972
+ sms_reply_enabled: boolean | null;
973
+ web_agent_enabled: boolean | null;
974
+ web_calls_enabled: boolean | null;
975
+ web_functions_enabled: boolean | null;
976
+ monitor_enabled: boolean | null;
977
+ custom_prompt: string | null;
978
+ sms_prompt: string | null;
979
+ web_prompt: string | null;
980
+ voice_id: string | null;
981
+ speaking_rate: number | null;
982
+ dtmf_enabled: boolean | null;
983
+ require_booking_confirmation: boolean | null;
984
+ record_call: boolean | null;
985
+ recording_source: 'provider' | 'nixflex' | null;
986
+ voicemail_leave_enabled: boolean | null;
987
+ voicemail_message: string | null;
988
+ /** Website voice switch eligibility only; active/billing checks still apply. */
989
+ readonly web_calls_effective: boolean;
990
+ readonly telnyx_key_status: TelnyxKeyStatus;
991
+ }
992
+ interface PhoneNumberListParams {
993
+ agent_id?: string;
994
+ provider?: 'twilio' | 'telnyx';
995
+ /** Opt into paging, 1..100. With cursor alone defaults to 50. */
996
+ limit?: number;
997
+ /** Opaque cursor from next_cursor; keep account and filters unchanged. */
998
+ cursor?: string;
411
999
  }
412
1000
  /** Every field optional - send only what changes; omitted fields are untouched.
413
- * An EMPTY body is rejected. null clears a field (falls back to the agent). */
1001
+ * An EMPTY body is rejected. Only nullable fields accept null; see each field. */
414
1002
  interface PhoneNumberUpdateParams {
1003
+ inbound_enabled?: boolean;
1004
+ outbound_enabled?: boolean;
1005
+ monitor_enabled?: boolean;
1006
+ web_calls_enabled?: boolean;
1007
+ web_agent_enabled?: boolean;
1008
+ /** Website visitors may use all enabled custom functions. Default OFF. */
1009
+ web_functions_enabled?: boolean;
1010
+ /** Telnyx webhook public-key candidate; saving it does not verify it. */
1011
+ telnyx_public_key?: string;
1012
+ require_booking_confirmation?: boolean | null;
415
1013
  /** Business profile layered on the agent prompt for CALLS only. Max 8000. null clears. */
416
1014
  custom_prompt?: string | null;
417
1015
  /** Voice override for this number. null falls back to the agent's voice. */
@@ -434,10 +1032,16 @@ interface PhoneNumberUpdateParams {
434
1032
  dtmf_enabled?: boolean | null;
435
1033
  /** Recording: null = inherit; false stops recording this number while the agent keeps recording. */
436
1034
  record_call?: boolean | null;
1035
+ /** Who records on this number: 'provider' (carrier) or 'nixflex' (voice engine). null = inherit the agent. Ignored while record_call is off. */
1036
+ recording_source?: 'provider' | 'nixflex' | null;
437
1037
  }
438
1038
  interface PhoneNumberListResponse {
439
1039
  phone_numbers: PhoneNumber[];
1040
+ /** Rows returned, NOT the account total. */
440
1041
  count: number;
1042
+ /** Present only when limit/cursor opts into paging. */
1043
+ next_cursor?: string | null;
1044
+ has_more?: boolean;
441
1045
  }
442
1046
  interface PhoneNumberDeleteResponse {
443
1047
  phone_number: {
@@ -456,94 +1060,147 @@ interface WebCallsToggleResponse {
456
1060
  web_calls_enabled: boolean;
457
1061
  }
458
1062
 
459
- /** NOTE: this endpoint uses `to` (NOT to_number - that is the outbound-call
460
- * field). Sending to_number here fails with a missing-field error. */
461
- interface SmsSendParams {
462
- /** Agent that owns this SMS - its prompt handles any replies. */
1063
+ /** SMS uses `to`, not the outbound-call field `to_number`. */
1064
+ interface SmsSendParams extends ContactLocation {
463
1065
  agent_id: string;
464
- /** Recipient, E.164. This endpoint uses `to`, not `to_number`. */
465
1066
  to: string;
466
- /** Message text. 600 chars recommended for reliable delivery (carrier hard caps ~1600). */
467
1067
  message: string;
468
- /** Which imported number to send from (either carrier). Omit = the agent's own number. */
469
- from_number?: string;
470
- /** Optional reply context: { reply_context: "..." } gives the agent background for replies to this message. */
1068
+ /** Required imported sender; no agent-number fallback. */
1069
+ from_number: string;
471
1070
  context?: {
472
- reply_context?: string;
1071
+ reply_context?: string | null;
1072
+ [key: string]: unknown;
473
1073
  };
474
1074
  }
475
1075
  interface SmsSendResponse {
476
1076
  status: string;
477
1077
  to: string;
478
1078
  from: string;
1079
+ message_id?: string | null;
1080
+ work_id?: string | null;
1081
+ persistence?: string;
1082
+ safe_to_retry?: false;
479
1083
  }
480
- interface SmsCampaignRecipient {
1084
+ interface SmsCampaignRecipient extends RecipientLocation {
481
1085
  phone: string;
482
- /** Fills {{placeholders}} in the template. Missing variables render as empty strings. */
483
- variables?: Record<string, string>;
484
- }
485
- /** from_number may be on EITHER carrier (Twilio or Telnyx) - the campaign
486
- * sends using that number's own credentials, so it must be a number on your
487
- * account. (An earlier doc page wrongly said Telnyx was rejected at create;
488
- * the engine routes by provider and has done since the Twilio-only lookup
489
- * was removed.) */
490
- interface SmsCampaignCreateParams {
1086
+ /** Missing referenced values may refuse creation or dispatch. */
1087
+ variables?: Record<string, unknown>;
1088
+ }
1089
+ interface SmsCampaignCreateParams extends Omit<CampaignPolicy, 'reuse_campaign_id'> {
491
1090
  agent_id: string;
492
- /** Your imported TWILIO number. */
493
1091
  from_number: string;
494
- /** Display name in the dashboard. */
495
- name: string;
496
- /** Message text with {{variable}} placeholders. */
1092
+ name?: string;
497
1093
  message_template: string;
498
- /** Up to 10,000. */
499
1094
  recipients: SmsCampaignRecipient[];
500
- schedule_type: 'now' | 'schedule';
501
- /** ISO date - required when schedule_type is 'schedule'. */
502
- scheduled_at?: string;
503
- }
504
- type SmsCampaignStatus = 'draft' | 'scheduled' | 'running' | 'done' | 'failed';
1095
+ schedule_type?: 'now' | 'schedule';
1096
+ scheduled_date?: string | null;
1097
+ window_start_minutes?: number | null;
1098
+ window_end_minutes?: number | null;
1099
+ window_days?: Weekday[] | null;
1100
+ timezone?: string | null;
1101
+ reply_context_prompt?: string | null;
1102
+ }
1103
+ type SmsCampaignStatus = 'draft' | 'scheduled' | 'launching' | 'running' | 'paused' | 'done' | 'failed' | 'cancelled';
505
1104
  interface SmsCampaign {
506
1105
  campaign_id: string;
507
1106
  agent_id: string;
508
- name: string;
509
- from_number?: string;
1107
+ name: string | null;
1108
+ status: string;
1109
+ from_number?: string | null;
510
1110
  message_template?: string;
511
- status: SmsCampaignStatus;
1111
+ id?: string;
1112
+ api_key_id?: string;
1113
+ schedule_type?: string;
1114
+ timezone?: string | null;
1115
+ window_start_minutes?: number | null;
1116
+ window_end_minutes?: number | null;
1117
+ window_days?: Weekday[] | null;
1118
+ started_at?: string | null;
1119
+ completed_at?: string | null;
1120
+ updated_at?: string | null;
1121
+ claimed_at?: string | null;
1122
+ allow_wider_hours?: boolean;
1123
+ reply_count?: number;
1124
+ total_segments?: number;
512
1125
  total_count: number;
513
- /** Carrier-confirmed handset delivery. Note: Twilio 'sent' (handed to carrier,
514
- * never confirmed) is counted as FAILED, not delivered. */
515
1126
  delivered_count: number;
516
1127
  failed_count: number;
517
1128
  pending_count: number;
1129
+ /** Handed to carrier; distinct from delivered and failed. */
1130
+ sent_count?: number;
1131
+ undelivered_count?: number;
1132
+ segments_count?: number;
1133
+ segments_estimated?: boolean;
518
1134
  source?: string;
519
- scheduled_at?: string | null;
520
- created_at: string;
521
- recipients?: Array<{
522
- phone: string;
523
- variables?: Record<string, string>;
524
- status: 'pending' | 'queued' | 'sent' | 'delivered' | 'undelivered' | 'failed';
525
- twilio_sid?: string;
526
- rendered_message?: string;
527
- error_message?: string;
528
- sent_at?: string;
529
- }>;
1135
+ scheduled_date?: string | null;
1136
+ created_at: string | null;
1137
+ is_active?: boolean;
1138
+ reply_context_prompt?: string | null;
1139
+ reply_window_hours?: number;
1140
+ }
1141
+ interface SmsCampaignCreateResponse extends CampaignValidation, SmsCampaignLaunchResponse {
1142
+ campaign_id: string;
1143
+ status: string;
1144
+ valid_count?: number;
1145
+ invalid_count?: number;
1146
+ invalid?: BatchInvalidEntry[];
1147
+ total_count?: number;
1148
+ message?: string;
1149
+ }
1150
+ interface SmsCampaignDetailParams {
1151
+ limit?: number;
1152
+ recipient_cursor?: string;
1153
+ message_cursor?: string;
1154
+ }
1155
+ interface SmsCampaignRecipientRecord {
1156
+ id: string;
1157
+ phone_number: string;
1158
+ status: string;
1159
+ variables?: Record<string, unknown>;
1160
+ rendered_message?: string | null;
1161
+ sent_at?: string | null;
1162
+ delivered_at?: string | null;
1163
+ error_message?: string | null;
1164
+ country?: string | null;
1165
+ timezone?: string | null;
1166
+ [field: string]: unknown;
1167
+ }
1168
+ interface SmsCampaignDetail {
1169
+ campaign: SmsCampaign;
1170
+ recipients: SmsCampaignRecipientRecord[];
1171
+ messages: Array<Record<string, unknown>>;
1172
+ pagination: {
1173
+ recipient_cursor: string | null;
1174
+ message_cursor: string | null;
1175
+ limit: number;
1176
+ paged: boolean;
1177
+ };
530
1178
  }
531
1179
  interface SmsCampaignListResponse {
532
1180
  campaigns: SmsCampaign[];
1181
+ next_cursor?: string | null;
533
1182
  }
1183
+ /** Launch acknowledgement; delivery remains asynchronous and policy-gated. */
534
1184
  interface SmsCampaignLaunchResponse {
535
- campaign_id: string;
536
- status: string;
537
- total_count: number;
538
- pending_count: number;
539
- delivered_count: number;
540
- failed_count: number;
541
- }
1185
+ campaign_id?: string;
1186
+ status: string | null;
1187
+ sent?: number;
1188
+ failed?: number;
1189
+ total_segments?: number;
1190
+ held?: number;
1191
+ reason?: string;
1192
+ stopped?: boolean;
1193
+ stop_reason?: string;
1194
+ not_sent?: number;
1195
+ safe_to_retry?: false;
1196
+ message?: string;
1197
+ }
1198
+ /** Legacy receipt construction remains source-compatible. The delete method returns
1199
+ * the complete B57 CampaignDeleteResponse with required campaign_id/deleted fields. */
542
1200
  interface SmsCampaignDeleteResponse {
543
- campaign_id: string;
544
- deleted: boolean;
545
- /** Pending recipients that will NOT be messaged. Already-sent messages cannot be recalled. */
546
- cancelled_count: number;
1201
+ message: string;
1202
+ campaign_id?: string;
1203
+ deleted?: true;
547
1204
  }
548
1205
 
549
1206
  interface KeyRotateResponse {
@@ -563,109 +1220,104 @@ interface KeyCreateResponse {
563
1220
  * described a different shape and is being corrected). All-time totals
564
1221
  * plus the account limits and this months concurrency peak. */
565
1222
  interface Usage {
566
- plan: string;
567
- total_calls: number;
1223
+ plan: string | null;
1224
+ total_calls: number | null;
568
1225
  /** Fractional minutes, e.g. 551.54. */
569
- total_minutes: number;
1226
+ total_minutes: number | null;
570
1227
  /** Nixflex charges only - carrier costs are billed to you by Twilio/Telnyx. */
571
- total_cost: number;
572
- rate_limit_per_minute: number;
1228
+ total_cost: number | null;
1229
+ rate_limit_per_minute: number | null;
573
1230
  max_concurrent: number;
574
1231
  peak_concurrent_this_month: number;
575
1232
  rejected_at_cap_this_month: number;
1233
+ occupied_call_slots?: number;
1234
+ capacity_source?: 'owned_reservations';
1235
+ capacity_measured_since?: string | null;
576
1236
  }
577
1237
  interface WebhookConfigResponse {
1238
+ webhook_url?: string | null;
1239
+ webhook_url_2?: string | null;
1240
+ is_set?: boolean;
1241
+ deleted?: boolean;
1242
+ provider?: string;
578
1243
  ok?: boolean;
579
1244
  phone_number?: string;
580
1245
  url?: string | null;
581
1246
  }
582
- /** Your own S3-compatible recording storage (BYO storage). */
583
- interface StorageConfig {
584
- storage_enabled: boolean;
585
- endpoint: string | null;
586
- region: string | null;
587
- bucket: string | null;
588
- access_key: string | null;
589
- }
590
- interface StorageSetParams {
591
- /** The exact bucket name at your provider. */
592
- bucket: string;
593
- /** Access key ID with permission to write objects. */
594
- access_key: string;
595
- /** Secret access key. Write-only - stored encrypted, never returned. */
596
- secret_key: string;
597
- /** https:// endpoint of your provider. Leave empty for Amazon S3. */
598
- endpoint?: string;
599
- /** Your bucket's region. Defaults to auto. */
600
- region?: string;
601
- }
602
- interface StorageSetResponse {
603
- ok: boolean;
604
- storage_enabled: boolean;
605
- bucket: string;
606
- endpoint: string | null;
607
- region: string;
608
- verified: boolean;
609
- }
610
- interface StorageDeleteResponse {
611
- ok: boolean;
612
- storage_enabled: boolean;
613
- }
614
- /** Your own LLM (BYO LLM) - an OpenAI-compatible endpoint answers every call. */
615
- interface LlmConfig {
616
- byo_llm_enabled: boolean;
617
- endpoint: string | null;
618
- model: string | null;
619
- }
620
- interface LlmSetParams {
621
- /** OpenAI-compatible https:// base URL, e.g. https://api.openai.com/v1 */
622
- endpoint: string;
623
- /** Model name as your provider knows it. Must support OpenAI-style tool calling. */
624
- model: string;
625
- /** Your provider API key. Write-only - stored encrypted, never returned. */
626
- api_key: string;
627
- }
628
- interface LlmSetResponse {
629
- ok: boolean;
630
- byo_llm_enabled: boolean;
631
- endpoint: string;
632
- model: string;
633
- verified: boolean;
634
- }
635
- interface LlmDeleteResponse {
636
- ok: boolean;
637
- byo_llm_enabled: boolean;
638
- }
639
- /** Your own TTS (BYO TTS) - your voice provider speaks on every phone call. */
640
- type TtsProvider = 'elevenlabs' | 'cartesia';
641
- interface TtsConfig {
642
- byo_tts_enabled: boolean;
643
- provider: TtsProvider | null;
644
- voice_id: string | null;
645
- }
646
- interface TtsSetParams {
647
- /** 'elevenlabs' or 'cartesia'. */
648
- provider: TtsProvider;
649
- /** Voice ID exactly as shown in your provider console. */
650
- voice_id: string;
651
- /** Your provider API key. Write-only - stored encrypted, never returned. */
652
- api_key: string;
1247
+
1248
+ /** Core public reads. Values are returned unchanged, including null and opaque cursors. */
1249
+ interface AccountRetention {
1250
+ call_retention_days: 90 | 30 | 7 | 1 | 0;
1251
+ applies_to: 'new_agents';
1252
+ processing_enabled: boolean;
1253
+ }
1254
+ interface KeyActivityParams {
1255
+ period?: 'today' | '7d';
1256
+ }
1257
+ interface KeyActivity {
1258
+ period: 'today' | '7d';
1259
+ timezone: string;
1260
+ requests: number;
1261
+ errors: number;
1262
+ requests_today: number;
1263
+ errors_today: number;
1264
+ day_start: string;
1265
+ period_start: string;
1266
+ as_of: string;
1267
+ last_used_at: string | null;
1268
+ top_endpoints: Array<{
1269
+ method: string;
1270
+ endpoint: string;
1271
+ requests: number;
1272
+ }>;
653
1273
  }
654
- interface TtsSetResponse {
655
- ok: boolean;
656
- byo_tts_enabled: boolean;
657
- provider: TtsProvider;
658
- voice_id: string;
659
- verified: boolean;
1274
+ interface VoiceContext {
1275
+ agent_id?: string;
1276
+ /** Takes precedence over agent_id; supports a fixed language or multi. */
1277
+ agent_language?: string;
660
1278
  }
661
- interface TtsDeleteResponse {
662
- ok: boolean;
663
- byo_tts_enabled: boolean;
1279
+ interface VoiceListParams extends VoiceContext {
1280
+ language?: string;
1281
+ gender?: 'male' | 'female' | 'unknown';
1282
+ /** Ordering preference, not a strict filter. */
1283
+ locale?: string;
1284
+ availability?: 'active' | 'all';
1285
+ /** Server default 50; clamps to 1..100. */
1286
+ limit?: number;
1287
+ /** Keep account and filters unchanged. On cursor_expired restart and deduplicate. */
1288
+ cursor?: string;
1289
+ }
1290
+ interface Voice {
1291
+ voice_key: string;
1292
+ displayName: string;
1293
+ gender: 'male' | 'female' | 'unknown';
1294
+ nativeLanguage: string | null;
1295
+ locale: string | null;
1296
+ accents: Array<{
1297
+ language: string;
1298
+ locale: string | null;
1299
+ label: string;
1300
+ }>;
1301
+ languages: string[];
1302
+ origin: 'standard' | 'connected';
1303
+ availability: 'active' | 'temporarily_unavailable' | 'unavailable';
1304
+ selectable: boolean;
1305
+ incompatibilityReason: string | null;
1306
+ previewLanguage: string | null;
1307
+ previewStatus: string;
1308
+ previewUrl: string | null;
1309
+ }
1310
+ interface VoiceListResponse {
1311
+ data: Voice[];
1312
+ next_cursor: string | null;
664
1313
  }
665
1314
 
666
1315
  declare class PhoneNumbers {
667
1316
  private readonly http;
668
1317
  constructor(http: HttpClient);
1318
+ updateCredentials(phoneNumber: string, body: NumberCredentials, opts?: RequestOptions): Promise<NumberCredentialsUpdated>;
1319
+ /** Retained-history usage, not a billing ledger. Defaults: all, UTC. */
1320
+ usage(phoneNumber: string, params?: NumberUsageParams, opts?: RequestOptions): Promise<NumberUsageResponse>;
669
1321
  /** Attach a number you already own. Carrier inferred from credentials
670
1322
  * (twilio_sid+twilio_token OR telnyx_api_key+telnyx_connection_id).
671
1323
  * WARNING: Twilio import REPLACES the number's existing webhooks - another
@@ -673,29 +1325,29 @@ declare class PhoneNumbers {
673
1325
  import(params: PhoneNumberImportParams, opts?: RequestOptions): Promise<{
674
1326
  phone_number: PhoneNumber;
675
1327
  }>;
676
- /** All numbers on your account (optionally one agent's), newest first.
677
- * Not paginated - returns up to 1,000; filter by agent_id above that. */
678
- list(params?: {
679
- agent_id?: string;
680
- }, opts?: RequestOptions): Promise<PhoneNumberListResponse>;
1328
+ /** Owned public numbers, newest first. Opt into paging with limit/cursor.
1329
+ * count is returned rows. Without paging, the server's row cap still applies. */
1330
+ list(params?: PhoneNumberListParams, opts?: RequestOptions): Promise<PhoneNumberListResponse>;
1331
+ /** Saved safe settings, effective website voice switch, and safe key status. */
1332
+ get(phoneNumber: string, opts?: RequestOptions): Promise<{
1333
+ phone_number: PhoneNumberDetails;
1334
+ }>;
681
1335
  /** Update per-number settings. Send ONLY what changes (empty body is
682
1336
  * rejected). null clears/inherits - see each field's JSDoc; speaking_rate
683
1337
  * null INHERITS the agent's speed (send 1, not null, to force normal). */
1338
+ update(phoneNumber: string, params: PhoneNumberMoveParams, opts?: RequestOptions): Promise<PhoneNumberMoveResponse>;
684
1339
  update(phoneNumber: string, params: PhoneNumberUpdateParams, opts?: RequestOptions): Promise<{
685
1340
  phone_number: PhoneNumber;
686
1341
  }>;
1342
+ /** Same-account move; busy work is refused. Own number settings and history stay. */
1343
+ move(phoneNumber: string, agentId: string, opts?: RequestOptions): Promise<PhoneNumberMoveResponse>;
687
1344
  /** Disconnect from Nixflex (clears carrier webhooks + our record). Does NOT
688
1345
  * release the number from your carrier - carrier billing continues until
689
1346
  * you release it in Twilio/Telnyx yourself. Reversible by re-importing. */
690
1347
  delete(phoneNumber: string, opts?: RequestOptions): Promise<PhoneNumberDeleteResponse>;
691
- /** Turn live call monitoring on/off for a number (off by default).
692
- * NOTE: enabling bills that number's inbound calls at $0.09/min. */
693
- setMonitor(phoneNumber: string, enabled: boolean, opts?: RequestOptions): Promise<MonitorToggleResponse>;
694
- /** Current monitoring state for a number. */
695
- getMonitor(phoneNumber: string, opts?: RequestOptions): Promise<MonitorToggleResponse>;
696
1348
  /** Enable/disable browser (web) calls for a number (off by default).
697
- * NOTE: enabling bills that number's calls at $0.09/min (same rule as
698
- * Live Monitor - either on means 0.09, both on is still 0.09). */
1349
+ * Enabling alone is free. Premium applies to actual browser calls,
1350
+ * not ordinary phone calls just because this switch is enabled. */
699
1351
  setWebCalls(phoneNumber: string, enabled: boolean, opts?: RequestOptions): Promise<WebCallsToggleResponse>;
700
1352
  /** Current web-calls state for a number. */
701
1353
  getWebCalls(phoneNumber: string, opts?: RequestOptions): Promise<WebCallsToggleResponse>;
@@ -703,24 +1355,29 @@ declare class PhoneNumbers {
703
1355
 
704
1356
  declare class SmsCampaigns {
705
1357
  private readonly http;
1358
+ cancel(id: string, opts?: RequestOptions): Promise<CampaignCancelResponse>;
1359
+ consent(id: string, params: CampaignConsentParams, opts?: RequestOptions): Promise<CampaignConsentResponse>;
1360
+ resume(id: string, opts?: RequestOptions): Promise<CampaignResumeResponse>;
1361
+ update(id: string, params: SmsCampaignUpdateParams, opts?: RequestOptions): Promise<SmsCampaignUpdateResponse>;
706
1362
  constructor(http: HttpClient);
707
1363
  /** Create a one-time SMS broadcast ({{variable}} templating per recipient,
708
- * up to 10,000 recipients). from_number may be on either carrier (Twilio or
1364
+ * up to 100,000 recipients). from_number may be on either carrier (Twilio or
709
1365
  * Telnyx) and must be a number on your own account. */
710
- create(params: SmsCampaignCreateParams, opts?: RequestOptions): Promise<SmsCampaign>;
711
- /** Launch a draft/scheduled campaign immediately. */
1366
+ create(params: SmsCampaignCreateParams, opts?: RequestOptions): Promise<SmsCampaignCreateResponse>;
1367
+ /** Request launch; scheduling and recipient contact-hour gates still apply. */
712
1368
  launch(campaignId: string, opts?: RequestOptions): Promise<SmsCampaignLaunchResponse>;
713
1369
  /** All campaigns, newest first, with live-computed delivery counts. */
714
1370
  list(params?: {
715
- status?: SmsCampaignStatus;
1371
+ status?: string;
716
1372
  limit?: number;
1373
+ before?: string;
717
1374
  }, opts?: RequestOptions): Promise<SmsCampaignListResponse>;
718
- /** One campaign with per-recipient statuses. Twilio 'sent' (handed to
719
- * carrier, never confirmed on the handset) counts as FAILED, not delivered. */
720
- get(campaignId: string, opts?: RequestOptions): Promise<SmsCampaign>;
721
- /** Cancel a scheduled/running campaign. Already-sent messages cannot be
722
- * recalled; cancelled_count = pending recipients that will not be messaged. */
723
- delete(campaignId: string, opts?: RequestOptions): Promise<SmsCampaignDeleteResponse>;
1375
+ /** Detail envelope with independent recipient/message cursors; sent is not failed. */
1376
+ get(campaignId: string, opts?: RequestOptions & SmsCampaignDetailParams): Promise<SmsCampaignDetail>;
1377
+ /** Cancel waiting work and hide the campaign. History/used charges remain, no refund
1378
+ * or recall of sent SMS. Owner/Admin only. 503 hangup_pending is queued, not success.
1379
+ * Missing/foreign is 404. One DELETE; never automatically repeated. */
1380
+ delete(campaignId: string, opts?: RequestOptions): Promise<CampaignDeleteResponse>;
724
1381
  }
725
1382
  declare class Sms {
726
1383
  private readonly http;
@@ -736,6 +1393,8 @@ declare class Sms {
736
1393
  declare class Keys {
737
1394
  private readonly http;
738
1395
  constructor(http: HttpClient);
1396
+ /** Retained request-log snapshot, not organisation audit events. Default today (UTC). */
1397
+ activity(params?: KeyActivityParams, opts?: RequestOptions): Promise<KeyActivity>;
739
1398
  /** Rotate the key SECRET (key_id stays stable - the Stripe model). The old
740
1399
  * secret stops working THE INSTANT this returns; the new one is shown ONCE.
741
1400
  * Update every deployed app before rotating in production. */
@@ -749,54 +1408,11 @@ declare class UsageResource {
749
1408
  get(opts?: RequestOptions): Promise<Usage>;
750
1409
  }
751
1410
 
752
- declare class Storage {
753
- private readonly http;
754
- constructor(http: HttpClient);
755
- /** Connect your own S3-compatible bucket for call recordings (data residency).
756
- * The connection is verified with a probe write BEFORE saving - broken
757
- * credentials are rejected, never stored. Recordings then upload to your
758
- * bucket and Nixflex keeps no copy; recording_url becomes a byo: path. */
759
- set(params: StorageSetParams, opts?: RequestOptions): Promise<StorageSetResponse>;
760
- /** Current storage configuration. The secret is never included. */
761
- get(opts?: RequestOptions): Promise<StorageConfig>;
762
- /** Disconnect and clear. Recordings return to Nixflex EU storage from the
763
- * next call; files already in your bucket are untouched - they are yours. */
764
- delete(opts?: RequestOptions): Promise<StorageDeleteResponse>;
765
- }
766
-
767
- declare class Llm {
768
- private readonly http;
769
- constructor(http: HttpClient);
770
- /** Connect an OpenAI-compatible model. Verified BEFORE saving with a real
771
- * completion + a tool-calling round trip (models without tool calling are
772
- * refused). Calls your model serves bill at a $0.015/min discount; if it
773
- * fails on a call the standard stack takes over and that call bills standard. */
774
- set(params: LlmSetParams, opts?: RequestOptions): Promise<LlmSetResponse>;
775
- /** Current LLM configuration. The provider key is never included. */
776
- get(opts?: RequestOptions): Promise<LlmConfig>;
777
- /** Disconnect. Calls return to the standard stack and rate from the next call. */
778
- delete(opts?: RequestOptions): Promise<LlmDeleteResponse>;
779
- }
780
- declare class Tts {
781
- private readonly http;
782
- constructor(http: HttpClient);
783
- /** Connect your voice provider (elevenlabs or cartesia). Verified BEFORE
784
- * saving with one real synthesis using the exact voice ID. Phone calls only -
785
- * web calls keep the standard voice. Calls your voice serves bill at a
786
- * $0.02/min discount; on failure the standard voice takes over and that call
787
- * bills the standard TTS rate. */
788
- set(params: TtsSetParams, opts?: RequestOptions): Promise<TtsSetResponse>;
789
- /** Current TTS configuration. The provider key is never included. */
790
- get(opts?: RequestOptions): Promise<TtsConfig>;
791
- /** Disconnect. Calls return to the standard voice and rate from the next call. */
792
- delete(opts?: RequestOptions): Promise<TtsDeleteResponse>;
793
- }
794
-
795
1411
  declare class Webhooks {
796
1412
  private readonly http;
797
1413
  constructor(http: HttpClient);
798
1414
  /** Verify a webhook delivery's X-Nixflex-Signature header. Pass the RAW
799
- * request body (string or Buffer) and your key_secret. Returns true only
1415
+ * request body (string or Buffer) and the organisation signing secret (independent of API-key rotation). Returns true only
800
1416
  * for an authentic, fresh signature. See webhook-verify.ts. */
801
1417
  verify(rawBody: string | Buffer, signatureHeader: string | null | undefined, keySecret: string, options?: VerifyOptions): boolean;
802
1418
  /** Point a number's post-call events at your HTTPS endpoint.
@@ -811,16 +1427,16 @@ declare class Webhooks {
811
1427
  /** The six fields a developer may set. Omitted = kept; null = removed. */
812
1428
  interface CallerContextSetParams {
813
1429
  /** Full name - first and last. */
814
- name?: string | null;
815
- email?: string | null;
1430
+ name?: string | number | null;
1431
+ email?: string | number | null;
816
1432
  /** A contact number other than the one they call from. */
817
- phone?: string | null;
1433
+ phone?: string | number | null;
818
1434
  /** Free text - city, area or postal code. */
819
- location?: string | null;
1435
+ location?: string | number | null;
820
1436
  /** An account, order or booking reference the caller uses. */
821
- reference_id?: string | null;
1437
+ reference_id?: string | number | null;
822
1438
  /** A short preference, e.g. "prefers morning appointments". */
823
- preference?: string | null;
1439
+ preference?: string | number | null;
824
1440
  }
825
1441
  /** The record as returned. Only fields with a value are present. */
826
1442
  interface CallerContextFields {
@@ -873,6 +1489,417 @@ declare class Callers {
873
1489
  import(phoneNumber: string, callers: CallerImportRow[], opts?: RequestOptions): Promise<CallerImportResponse>;
874
1490
  }
875
1491
 
1492
+ /** PUT replaces provider configuration. Omitted fields use the server defaults. */
1493
+ interface Common {
1494
+ is_active?: boolean;
1495
+ agent_id?: string;
1496
+ }
1497
+ interface CalcomSettings extends Common {
1498
+ api_key: string;
1499
+ username: string;
1500
+ event_slug: string;
1501
+ default_timezone?: string;
1502
+ }
1503
+ interface SlackSettings extends Common {
1504
+ webhook_url: string;
1505
+ }
1506
+ interface ZapierSettings extends Common {
1507
+ post_call_url: string;
1508
+ }
1509
+ type MakeSettings = Common & {
1510
+ tool_name?: string;
1511
+ tool_description?: string;
1512
+ parameters?: Record<string, unknown>;
1513
+ } & ({
1514
+ post_call_url: string;
1515
+ in_call_url?: string;
1516
+ } | {
1517
+ post_call_url?: string;
1518
+ in_call_url: string;
1519
+ });
1520
+ interface GoHighLevelSettings extends Common {
1521
+ pit: string;
1522
+ location_id: string;
1523
+ tags?: string[] | string;
1524
+ }
1525
+ interface IntegrationSettings {
1526
+ calcom: CalcomSettings;
1527
+ slack: SlackSettings;
1528
+ zapier: ZapierSettings;
1529
+ make: MakeSettings;
1530
+ gohighlevel: GoHighLevelSettings;
1531
+ webhook: {
1532
+ url: string;
1533
+ };
1534
+ webhook2: {
1535
+ url: string;
1536
+ };
1537
+ precall: {
1538
+ url: string;
1539
+ };
1540
+ 'web-calls': {
1541
+ enabled: boolean;
1542
+ };
1543
+ }
1544
+ type IntegrationProvider = keyof IntegrationSettings;
1545
+ interface NumberState {
1546
+ phone_number: string;
1547
+ }
1548
+ interface ActiveState extends NumberState {
1549
+ is_active: boolean;
1550
+ }
1551
+ interface IntegrationReads {
1552
+ calcom: ActiveState & {
1553
+ username: string;
1554
+ event_slug: string;
1555
+ default_timezone: string;
1556
+ api_key_set: boolean;
1557
+ };
1558
+ slack: ActiveState & {
1559
+ webhook_url_set: boolean;
1560
+ };
1561
+ zapier: ActiveState & {
1562
+ post_call_url_set: boolean;
1563
+ };
1564
+ make: ActiveState & {
1565
+ post_call_url_set: boolean;
1566
+ in_call_url_set: boolean;
1567
+ tool_name: string | null;
1568
+ tool_description: string | null;
1569
+ parameters: Record<string, unknown> | null;
1570
+ };
1571
+ gohighlevel: ActiveState & {
1572
+ pit_set: boolean;
1573
+ location_id: string;
1574
+ tags: string[];
1575
+ };
1576
+ webhook: NumberState & {
1577
+ webhook_url: string | null;
1578
+ is_set: boolean;
1579
+ };
1580
+ webhook2: NumberState & {
1581
+ webhook_url_2: string | null;
1582
+ is_set: boolean;
1583
+ };
1584
+ precall: NumberState & {
1585
+ precall_webhook_url: string | null;
1586
+ is_set: boolean;
1587
+ };
1588
+ 'web-calls': NumberState & {
1589
+ web_calls_enabled: boolean;
1590
+ };
1591
+ }
1592
+ interface IntegrationReceipt {
1593
+ ok: boolean;
1594
+ phone_number?: string;
1595
+ agent_id?: string;
1596
+ provider?: string;
1597
+ is_active?: boolean;
1598
+ deleted?: boolean;
1599
+ web_calls_enabled?: boolean;
1600
+ }
1601
+ interface AgentPrecall {
1602
+ agent_id: string;
1603
+ precall_webhook_url: string | null;
1604
+ is_set: boolean;
1605
+ }
1606
+ interface CustomFunctionInput {
1607
+ name: string;
1608
+ url: string;
1609
+ description?: string;
1610
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1611
+ headers?: Record<string, string>;
1612
+ parameters?: Record<string, unknown>;
1613
+ speak_during?: string | null;
1614
+ /** Server clamps to 1000..45000; default 5000. */
1615
+ timeout_ms?: number;
1616
+ is_active?: boolean;
1617
+ }
1618
+ interface CustomFunctionView {
1619
+ id: string;
1620
+ name: string;
1621
+ description: string;
1622
+ method: string;
1623
+ url: string;
1624
+ parameters: Record<string, unknown>;
1625
+ speak_during: string | null;
1626
+ timeout_ms: number;
1627
+ is_active: boolean;
1628
+ has_headers: boolean;
1629
+ }
1630
+ interface FunctionReceipt {
1631
+ ok: boolean;
1632
+ id: string;
1633
+ phone_number: string;
1634
+ name?: string;
1635
+ deleted?: boolean;
1636
+ }
1637
+
1638
+ /** API-key authority, owned numbers only. No automatic logging of configuration. */
1639
+ declare class Integrations {
1640
+ private readonly http;
1641
+ constructor(http: HttpClient);
1642
+ /** Returns a short-lived link for a human to open; never opens a browser. */
1643
+ connectGoogleCalendar(number: string, returnUrl: string, opts?: RequestOptions): Promise<GoogleCalendarConnect>;
1644
+ getGoogleCalendar(number: string, opts?: RequestOptions): Promise<GoogleCalendarStatus>;
1645
+ disconnectGoogleCalendar(number: string, opts?: RequestOptions): Promise<GoogleCalendarDisconnect>;
1646
+ updateGoogleCalendarSettings(number: string, body: GoogleCalendarSettingsPatch, opts?: RequestOptions): Promise<GoogleCalendarSettings>;
1647
+ get<P extends IntegrationProvider>(provider: P, number: string, opts?: RequestOptions): Promise<IntegrationReads[P]>;
1648
+ /** Provider PUT replaces configuration. Never automatically repeated. */
1649
+ set<P extends IntegrationProvider>(provider: P, number: string, body: IntegrationSettings[P], opts?: RequestOptions): Promise<IntegrationReceipt>;
1650
+ delete(provider: IntegrationProvider, number: string, opts?: RequestOptions): Promise<IntegrationReceipt>;
1651
+ getAgentPrecall(agentId: string, opts?: RequestOptions): Promise<AgentPrecall>;
1652
+ setAgentPrecall(agentId: string, url: string, opts?: RequestOptions): Promise<IntegrationReceipt>;
1653
+ /** Removing the agent default affects every number without an override. */
1654
+ deleteAgentPrecall(agentId: string, opts?: RequestOptions): Promise<IntegrationReceipt>;
1655
+ /** At most 15; an empty list is not proof that the number exists. */
1656
+ listFunctions(number: string, opts?: RequestOptions): Promise<{
1657
+ phone_number: string;
1658
+ functions: CustomFunctionView[];
1659
+ }>;
1660
+ createFunction(number: string, body: CustomFunctionInput, opts?: RequestOptions): Promise<FunctionReceipt>;
1661
+ /** PATCH changes supplied fields only. {} is refused by the server. */
1662
+ updateFunction(number: string, id: string, body: Partial<CustomFunctionInput>, opts?: RequestOptions): Promise<FunctionReceipt>;
1663
+ deleteFunction(number: string, id: string, opts?: RequestOptions): Promise<FunctionReceipt>;
1664
+ }
1665
+
1666
+ /** Keep server receipts intact; unknown additive fields are preserved. */
1667
+ interface KnowledgeObject {
1668
+ [key: string]: unknown;
1669
+ }
1670
+ /** B49g owned read. Counts describe returned arrays; limits are server-configured. */
1671
+ interface KnowledgeKeyterms {
1672
+ knowledge_keyterms: string[];
1673
+ knowledge_keyterms_count: number;
1674
+ knowledge_keyterms_limit: number;
1675
+ manual_keyterms: string[];
1676
+ manual_keyterms_count: number;
1677
+ /** New-edit limit; unchanged legacy manual lists may exceed it. */
1678
+ manual_keyterms_limit: number;
1679
+ }
1680
+ type KnowledgeChannel = 'inbound' | 'outbound' | 'web_voice' | 'web_chat' | 'sms';
1681
+ interface KnowledgeSettings {
1682
+ channels?: KnowledgeChannel[];
1683
+ match?: 'Strict' | 'Normal';
1684
+ not_found?: string;
1685
+ }
1686
+ interface PageQuery {
1687
+ limit?: number;
1688
+ cursor?: string;
1689
+ }
1690
+ interface TargetQuery extends PageQuery {
1691
+ q?: string;
1692
+ target?: string;
1693
+ }
1694
+ interface KnowledgePage {
1695
+ items: KnowledgeObject[];
1696
+ next_cursor: string | null;
1697
+ }
1698
+ interface RevisionInput {
1699
+ expected_revision: number;
1700
+ }
1701
+ interface ScopeInput {
1702
+ settings?: KnowledgeSettings;
1703
+ expected_revision?: number;
1704
+ }
1705
+ interface SettingsInput extends RevisionInput {
1706
+ settings: KnowledgeSettings;
1707
+ }
1708
+ type EmptyInput = Record<string, never>;
1709
+ interface TextSource {
1710
+ type: 'text';
1711
+ text: string;
1712
+ title?: string;
1713
+ }
1714
+ interface SourceInput {
1715
+ source: TextSource;
1716
+ review?: boolean;
1717
+ }
1718
+ interface SourceReplacement extends SourceInput, RevisionInput {
1719
+ }
1720
+ interface SourceDeletion extends RevisionInput {
1721
+ topic_ids: string[];
1722
+ manual?: 'keep' | 'delete';
1723
+ }
1724
+ interface WebsiteInput {
1725
+ discovery_id: string;
1726
+ page_ids: string[];
1727
+ review?: boolean;
1728
+ }
1729
+ interface KnowledgeTopic {
1730
+ facts: string;
1731
+ title?: string;
1732
+ questions?: string[];
1733
+ valid_from?: string | null;
1734
+ valid_until?: string | null;
1735
+ }
1736
+ interface TopicInput extends RevisionInput {
1737
+ topic: KnowledgeTopic;
1738
+ }
1739
+ interface DraftEdit extends TopicInput {
1740
+ expected_draft_revision: number;
1741
+ topic_id: string;
1742
+ }
1743
+ interface DraftAcceptance extends RevisionInput {
1744
+ expected_draft_revision: number;
1745
+ topic_ids: string[];
1746
+ acknowledge_warnings?: boolean;
1747
+ approved_flagged_topic_ids?: string[];
1748
+ }
1749
+ interface SessionInput {
1750
+ mode?: 'knowledge';
1751
+ channel?: KnowledgeChannel;
1752
+ draft_id?: string;
1753
+ }
1754
+ interface KnowledgeWriteOptions extends RequestOptions {
1755
+ idempotencyKey: string;
1756
+ }
1757
+ interface KnowledgeUploadOptions extends KnowledgeWriteOptions {
1758
+ /** Printable ASCII upload name; defaults to the local basename. File contents stream in chunks. */
1759
+ filename?: string;
1760
+ sourceTitle?: string;
1761
+ review?: boolean;
1762
+ expectedRevision?: number;
1763
+ }
1764
+ interface KnowledgeJob extends KnowledgeObject {
1765
+ id: string;
1766
+ kb: string;
1767
+ state: 'pending' | 'running' | 'needs_review' | 'ready' | 'failed' | 'cancelled' | 'deleted';
1768
+ stage: string;
1769
+ progress: {
1770
+ percent?: number;
1771
+ [key: string]: unknown;
1772
+ };
1773
+ result: KnowledgeObject | null;
1774
+ error: KnowledgeObject | null;
1775
+ paid_work_started: boolean;
1776
+ }
1777
+ interface JobPollOptions {
1778
+ maxAttempts?: number;
1779
+ intervalMs?: number;
1780
+ timeoutMs?: number;
1781
+ signal?: AbortSignal;
1782
+ }
1783
+ /** Oversized manual topics may create a review draft without a background job. */
1784
+ interface KnowledgeReview extends KnowledgeObject {
1785
+ kb: string;
1786
+ state: 'needs_review';
1787
+ draft_id: string;
1788
+ }
1789
+ type KnowledgeTopicResult = KnowledgeJob | KnowledgeReview;
1790
+
1791
+ /** Agent-owned knowledge. No automatic logging. Explicit idempotency keys for changes. */
1792
+ declare class Knowledge {
1793
+ private readonly http;
1794
+ constructor(http: HttpClient);
1795
+ /** DELETE /agents/:target/knowledge-base. Never auto-repeated; use a stable explicit operation key. */
1796
+ deleteScope(target: string, body: RevisionInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1797
+ /** GET /agents/:target/knowledge-base. Read result is private customer data. */
1798
+ getScope(target: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1799
+ /** PUT /agents/:target/knowledge-base. Never auto-repeated; use a stable explicit operation key. */
1800
+ putScope(target: string, body: ScopeInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1801
+ /** POST /agents/:target/knowledge-base/source-measure. Read result is private customer data. */
1802
+ measureSource(target: string, body: {
1803
+ text: string;
1804
+ }, opts?: RequestOptions): Promise<KnowledgeObject>;
1805
+ /** POST /agents/:target/knowledge-base/test-sessions. Never auto-repeated; use a stable explicit operation key. */
1806
+ startSession(target: string, body: SessionInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1807
+ /** GET /knowledge-bases/:kb. Read result is private customer data. */
1808
+ getBase(kb: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1809
+ /** DELETE /knowledge-bases/:kb/drafts/:id. Never auto-repeated; use a stable explicit operation key. */
1810
+ discardDraft(kb: string, id: string, body: {
1811
+ expected_draft_revision: number;
1812
+ }, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1813
+ /** GET /knowledge-bases/:kb/drafts/:id. Read result is private customer data. */
1814
+ getDraft(kb: string, id: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1815
+ /** PATCH /knowledge-bases/:kb/drafts/:id. Never auto-repeated; use a stable explicit operation key. */
1816
+ updateDraft(kb: string, id: string, body: DraftEdit, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1817
+ /** POST /knowledge-bases/:kb/drafts/:id/accept. Never auto-repeated; use a stable explicit operation key. */
1818
+ acceptDraft(kb: string, id: string, body: DraftAcceptance, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1819
+ /** POST /knowledge-bases/:kb/exports. Never auto-repeated; use a stable explicit operation key. */
1820
+ createExport(kb: string, body: EmptyInput, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1821
+ /** GET /knowledge-bases/:kb/overview. Read result is private customer data. */
1822
+ overview(kb: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1823
+ /** PATCH /knowledge-bases/:kb/settings. Never auto-repeated; use a stable explicit operation key. */
1824
+ updateSettings(kb: string, body: SettingsInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1825
+ /** GET /knowledge-bases/:kb/sources. Read result is private customer data. */
1826
+ listSources(kb: string, query?: PageQuery, opts?: RequestOptions): Promise<KnowledgePage>;
1827
+ /** POST /knowledge-bases/:kb/sources. Never auto-repeated; use a stable explicit operation key. */
1828
+ addSource(kb: string, body: SourceInput, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1829
+ /** DELETE /knowledge-bases/:kb/sources/:id. Never auto-repeated; use a stable explicit operation key. */
1830
+ deleteSource(kb: string, id: string, body: SourceDeletion, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1831
+ /** PATCH /knowledge-bases/:kb/sources/:id. Never auto-repeated; use a stable explicit operation key. */
1832
+ renameSource(kb: string, id: string, body: {
1833
+ expected_revision: number;
1834
+ title: string;
1835
+ }, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1836
+ /** POST /knowledge-bases/:kb/sources/:id/replacements. Never auto-repeated; use a stable explicit operation key. */
1837
+ replaceSource(kb: string, id: string, body: SourceReplacement, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1838
+ /** POST /knowledge-bases/:kb/sources/refresh. Never auto-repeated; use a stable explicit operation key. */
1839
+ refreshSources(kb: string, body: {
1840
+ source_ids: string[];
1841
+ review?: boolean;
1842
+ }, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1843
+ /** POST /knowledge-bases/:kb/topic-search. Read result is private customer data. */
1844
+ searchTopics(kb: string, body: {
1845
+ query: string;
1846
+ }, opts?: RequestOptions): Promise<KnowledgeObject>;
1847
+ /** GET /knowledge-bases/:kb/topics. Read result is private customer data. */
1848
+ listTopics(kb: string, query?: PageQuery, opts?: RequestOptions): Promise<KnowledgePage>;
1849
+ /** POST /knowledge-bases/:kb/topics. Never auto-repeated; use a stable explicit operation key. */
1850
+ createTopic(kb: string, body: TopicInput, opts: KnowledgeWriteOptions): Promise<KnowledgeTopicResult>;
1851
+ /** DELETE /knowledge-bases/:kb/topics/:id. Never auto-repeated; use a stable explicit operation key. */
1852
+ deleteTopic(kb: string, id: string, body: RevisionInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1853
+ /** GET /knowledge-bases/:kb/topics/:id. Read result is private customer data. */
1854
+ getTopic(kb: string, id: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1855
+ /** PATCH /knowledge-bases/:kb/topics/:id. Never auto-repeated; use a stable explicit operation key. */
1856
+ updateTopic(kb: string, id: string, body: TopicInput, opts: KnowledgeWriteOptions): Promise<KnowledgeTopicResult>;
1857
+ /** GET /knowledge-bases/:kb/unanswered. Read result is private customer data. */
1858
+ unanswered(kb: string, query?: PageQuery, opts?: RequestOptions): Promise<KnowledgePage>;
1859
+ /** POST /knowledge-bases/:kb/website-discoveries. Never auto-repeated; use a stable explicit operation key. */
1860
+ discoverWebsite(kb: string, body: {
1861
+ url: string;
1862
+ }, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1863
+ /** POST /knowledge-bases/:kb/website-imports. Never auto-repeated; use a stable explicit operation key. */
1864
+ importWebsite(kb: string, body: WebsiteInput, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1865
+ /** GET /knowledge/capabilities. Read result is private customer data. */
1866
+ capabilities(opts?: RequestOptions): Promise<KnowledgeObject>;
1867
+ /** GET /knowledge/events. Read result is private customer data. */
1868
+ events(query?: {
1869
+ cursor?: string;
1870
+ }, opts?: RequestOptions): Promise<KnowledgeObject[]>;
1871
+ /** GET /knowledge/exports/:id. Read result is private customer data. */
1872
+ downloadExport(id: string, query?: {
1873
+ format?: 'json' | 'text';
1874
+ }, opts?: RequestOptions): AsyncGenerator<Uint8Array>;
1875
+ /** GET /knowledge/jobs/:id. Read result is private customer data. */
1876
+ getJob(id: string, opts?: RequestOptions): Promise<KnowledgeJob>;
1877
+ /** POST /knowledge/jobs/:id/cancel. Never auto-repeated; use a stable explicit operation key. */
1878
+ cancelJob(id: string, body: EmptyInput, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1879
+ /** POST /knowledge/jobs/:id/retry. Never auto-repeated; use a stable explicit operation key. */
1880
+ retryJob(id: string, body: EmptyInput, opts: KnowledgeWriteOptions): Promise<KnowledgeJob>;
1881
+ /** GET /knowledge/targets. Read result is private customer data. */
1882
+ targets(query?: TargetQuery, opts?: RequestOptions): Promise<KnowledgePage>;
1883
+ /** GET /knowledge/test-sessions/:id. Read result is private customer data. */
1884
+ getSession(id: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1885
+ /** POST /knowledge/test-sessions/:id/cancel. Never auto-repeated; use a stable explicit operation key. */
1886
+ cancelSession(id: string, body: EmptyInput, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1887
+ /** POST /knowledge/test-sessions/:id/messages. Never auto-repeated; use a stable explicit operation key. */
1888
+ ask(id: string, body: {
1889
+ text: string;
1890
+ }, opts: KnowledgeWriteOptions): Promise<KnowledgeObject>;
1891
+ /** GET /knowledge/usage. Read result is private customer data. */
1892
+ usage(query?: {
1893
+ kb?: string;
1894
+ }, opts?: RequestOptions): Promise<KnowledgeObject>;
1895
+ /** GET /agents/:target/knowledge-keyterms. Read result is private customer data. */
1896
+ keyterms(target: string, opts?: RequestOptions): Promise<KnowledgeKeyterms>;
1897
+ uploadSource(kb: string, file: string, opts: KnowledgeUploadOptions): Promise<KnowledgeJob>;
1898
+ replaceSourceFile(kb: string, id: string, file: string, opts: KnowledgeUploadOptions): Promise<KnowledgeJob>;
1899
+ measureFile(target: string, file: string, opts?: RequestOptions): Promise<KnowledgeObject>;
1900
+ waitJob(id: string, options?: JobPollOptions): Promise<KnowledgeJob>;
1901
+ }
1902
+
876
1903
  interface NixflexAPIErrorBody {
877
1904
  error: {
878
1905
  type: string;
@@ -880,6 +1907,7 @@ interface NixflexAPIErrorBody {
880
1907
  message: string;
881
1908
  doc_url?: string;
882
1909
  details?: Record<string, unknown>;
1910
+ request_id?: string;
883
1911
  };
884
1912
  }
885
1913
  declare class NixflexError extends Error {
@@ -896,6 +1924,19 @@ declare class NixflexError extends Error {
896
1924
  /** The x-railway-request-id (or similar) header when present - quote it to support. */
897
1925
  readonly requestId?: string;
898
1926
  constructor(status: number, body: NixflexAPIErrorBody | null, requestId?: string, fallbackMessage?: string);
1927
+ get doc_url(): string | null;
1928
+ get request_id(): string | null;
1929
+ toJSON(): {
1930
+ error: {
1931
+ type: string;
1932
+ code: string;
1933
+ message: string;
1934
+ details: Record<string, unknown>;
1935
+ doc_url: string;
1936
+ status: number;
1937
+ request_id: string;
1938
+ };
1939
+ };
899
1940
  }
900
1941
  /** 401 - missing or invalid API key. */
901
1942
  declare class NixflexAuthenticationError extends NixflexError {
@@ -918,7 +1959,7 @@ declare class NixflexRateLimitError extends NixflexError {
918
1959
  declare class NixflexInvalidRequestError extends NixflexError {
919
1960
  constructor(...args: ConstructorParameters<typeof NixflexError>);
920
1961
  }
921
- /** 5xx - something failed on Nixflex's side. Retried automatically once. */
1962
+ /** 5xx - something failed on Nixflex's side. Only reads may retry. */
922
1963
  declare class NixflexServerError extends NixflexError {
923
1964
  constructor(...args: ConstructorParameters<typeof NixflexError>);
924
1965
  }
@@ -926,10 +1967,684 @@ declare class NixflexServerError extends NixflexError {
926
1967
  declare class NixflexConnectionError extends NixflexError {
927
1968
  constructor(message: string);
928
1969
  }
1970
+ /** A change may have reached the server. Never automatically repeat it. */
1971
+ declare class NixflexOutcomeUnknownError extends NixflexServerError {
1972
+ readonly outcome: "unknown";
1973
+ readonly safe_to_retry = false;
1974
+ constructor(status?: number, body?: NixflexAPIErrorBody | null, requestId?: string);
1975
+ }
929
1976
  /** Map a status + body to the right error class. */
930
- declare function errorFromResponse(status: number, body: NixflexAPIErrorBody | null, requestId: string | undefined, retryAfterSeconds: number): NixflexError;
1977
+ declare class NixflexConflictError extends NixflexError {
1978
+ constructor(...args: ConstructorParameters<typeof NixflexError>);
1979
+ }
1980
+ /** Confirmed suppression: nothing sent. Never bypass the opt-out or retry sending. */
1981
+ declare class NixflexDoNotContactError extends NixflexConflictError {
1982
+ constructor(...args: ConstructorParameters<typeof NixflexError>);
1983
+ }
1984
+ declare function errorFromResponse(status: number, body: NixflexAPIErrorBody | null, requestId: string | undefined, retryAfterSeconds: number, mutation?: boolean): NixflexError;
1985
+
1986
+ declare const calendarErrorCodes: readonly ["invalid_return_url", "number_not_found", "already_connected", "booking_provider_conflict", "not_connected", "agent_not_assigned", "invalid_settings", "invalid_timezone", "invalid_hours", "invalid_slot_minutes", "invalid_calendar_id", "invalid_send_invites", "calendar_unavailable", "expired_link", "not_configured", "guard_unavailable"];
1987
+ declare const credentialErrorCodes: readonly ["invalid_request", "invalid_credentials", "number_not_in_account", "number_not_found", "carrier_mismatch", "account_unavailable", "number_operation_pending", "number_release_pending", "carrier_unavailable", "credential_update_unavailable", "carrier_outcome_unknown", "credential_save_pending"];
1988
+ type GoogleCalendarErrorCode = typeof calendarErrorCodes[number];
1989
+ type NumberCredentialsErrorCode = typeof credentialErrorCodes[number];
1990
+ /** Safe, typed feature error. No raw response body/message, token, URL or carrier input. */
1991
+ declare class NixflexCalendarError extends NixflexError {
1992
+ }
1993
+ declare class NixflexCredentialError extends NixflexError {
1994
+ }
1995
+ declare function featureError(value: unknown, kind: 'calendar' | 'credentials', mutation: boolean): NixflexError;
1996
+
1997
+ type OrganisationRole = 'owner' | 'admin' | 'member';
1998
+ interface OrganisationContext {
1999
+ organisation_id: string;
2000
+ key_id: string;
2001
+ name: string;
2002
+ role: OrganisationRole;
2003
+ permissions: string[];
2004
+ user_id: string | null;
2005
+ membership_version: number | null;
2006
+ joined_at: string | null;
2007
+ is_active: true;
2008
+ dashboard_state: "active";
2009
+ }
2010
+ interface OrganisationMember {
2011
+ user_id: string;
2012
+ email: string;
2013
+ name: string;
2014
+ role: OrganisationRole;
2015
+ joined_at: string;
2016
+ last_active_at?: string | null;
2017
+ }
2018
+ interface OrganisationInvite {
2019
+ id: string;
2020
+ email: string;
2021
+ role: OrganisationRole;
2022
+ state: string;
2023
+ delivery: 'pending' | 'sent' | 'failed' | 'unknown';
2024
+ expires_at: string;
2025
+ }
2026
+ interface OrganisationMembers {
2027
+ members: OrganisationMember[];
2028
+ invites: OrganisationInvite[];
2029
+ limits: {
2030
+ members: number;
2031
+ invites_per_day: number;
2032
+ invites_used_today?: number;
2033
+ seats_used?: number;
2034
+ };
2035
+ }
2036
+ interface InvitationReceipt {
2037
+ id: string;
2038
+ delivery: string;
2039
+ expires_in?: number;
2040
+ created?: false;
2041
+ }
2042
+ interface MembershipReceipt {
2043
+ user_id: string;
2044
+ state: 'removed' | 'active';
2045
+ live_disconnect_pending: boolean;
2046
+ }
2047
+ interface ActivityFilters {
2048
+ before?: string;
2049
+ actor?: string;
2050
+ from?: string;
2051
+ to?: string;
2052
+ }
2053
+ interface ActivityEvent {
2054
+ id: string;
2055
+ created_at: string;
2056
+ actor_id: string | null;
2057
+ actor: string;
2058
+ sentence: string;
2059
+ result: "Done" | "Not allowed" | "Not confirmed";
2060
+ }
2061
+ interface ActivityPage {
2062
+ events: ActivityEvent[];
2063
+ next_cursor: string | null;
2064
+ }
2065
+ /** Organisation API-key authority. Personal accept/leave/transfer/closure require a dashboard login. */
2066
+ declare class Organisation {
2067
+ private readonly http;
2068
+ constructor(http: HttpClient);
2069
+ get(opts?: RequestOptions): Promise<OrganisationContext>;
2070
+ members(opts?: RequestOptions): Promise<OrganisationMembers>;
2071
+ invite(email: string, role?: 'admin' | 'member', opts?: RequestOptions): Promise<InvitationReceipt>;
2072
+ resend(inviteId: string, opts?: RequestOptions): Promise<InvitationReceipt>;
2073
+ revoke(inviteId: string, opts?: RequestOptions): Promise<{
2074
+ id: string;
2075
+ state: string;
2076
+ }>;
2077
+ removeMember(userId: string, opts?: RequestOptions): Promise<MembershipReceipt>;
2078
+ setRole(userId: string, role: 'admin' | 'member', opts?: RequestOptions): Promise<MembershipReceipt>;
2079
+ activity(params?: ActivityFilters, opts?: RequestOptions): Promise<ActivityPage>;
2080
+ /** Default JSON page is 50 events. Keep IDs/cursors as strings; from/to are inclusive UTC dates. */
2081
+ activityCsv(params?: ActivityFilters, opts?: RequestOptions): AsyncGenerator<Uint8Array>;
2082
+ /** Owner API-key authority; trims to 2..100 characters on the server. */
2083
+ rename(name: string, opts?: RequestOptions): Promise<{
2084
+ name: string;
2085
+ }>;
2086
+ /** Claim an existing API-only account: sends a verified-email invitation, never transfers an owned account. */
2087
+ claimInvite(email: string, opts?: RequestOptions): Promise<InvitationReceipt>;
2088
+ }
2089
+
2090
+ /** Account defaults only; account closure remains dashboard-owner-only. */
2091
+ declare class Account {
2092
+ private readonly http;
2093
+ constructor(http: HttpClient);
2094
+ retention(opts?: RequestOptions): Promise<AccountRetention>;
2095
+ }
2096
+ declare class Voices {
2097
+ private readonly http;
2098
+ constructor(http: HttpClient);
2099
+ list(params?: VoiceListParams, opts?: RequestOptions): Promise<VoiceListResponse>;
2100
+ get(voiceKey: string, params?: VoiceContext, opts?: RequestOptions): Promise<Voice>;
2101
+ }
2102
+
2103
+ /** C5 wire contract. Server defaults apply only when a field is omitted. */
2104
+ type ContactPreviewParams = {
2105
+ "agent_id": string;
2106
+ "recipients": ({
2107
+ "phone": string;
2108
+ "country"?: string;
2109
+ "timezone"?: string;
2110
+ })[];
2111
+ "campaign"?: {
2112
+ "allow_wider_hours"?: boolean;
2113
+ "start"?: string;
2114
+ "end"?: string;
2115
+ "days"?: ("sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat")[];
2116
+ "scheduled_date"?: string;
2117
+ [key: string]: unknown;
2118
+ };
2119
+ [key: string]: unknown;
2120
+ };
2121
+ type ContactPreviewResponse = {
2122
+ "preview_only": true;
2123
+ "mode": "global" | "legacy_recipient_estimate";
2124
+ "policy_version": string;
2125
+ "runtime_timezone_version": string;
2126
+ "as_of": string;
2127
+ "expires_at": string;
2128
+ "agent_timezone": string;
2129
+ "rows": ({
2130
+ "index": number;
2131
+ "country": string | null;
2132
+ "possible_zones": (string)[];
2133
+ "display_reason": string | null;
2134
+ "message": string;
2135
+ "next_allowed": {
2136
+ "at_utc": string;
2137
+ "local": ({
2138
+ "zone": string;
2139
+ "date": string;
2140
+ "time": string;
2141
+ })[];
2142
+ } | null;
2143
+ "next_unavailable": string | null;
2144
+ "advisory_only": true;
2145
+ "local_now": ({
2146
+ "zone": string;
2147
+ "date": string;
2148
+ "time": string;
2149
+ })[];
2150
+ "hold_reason": string | null;
2151
+ "allowed_now": boolean;
2152
+ "windows": ({
2153
+ "start_utc": string;
2154
+ "end_utc": string;
2155
+ "recipient": ({
2156
+ "zone": string;
2157
+ "start": {
2158
+ "date": string;
2159
+ "time": string;
2160
+ };
2161
+ "end": {
2162
+ "date": string;
2163
+ "time": string;
2164
+ };
2165
+ })[];
2166
+ "agent": {
2167
+ "zone": string;
2168
+ "start": {
2169
+ "date": string;
2170
+ "time": string;
2171
+ };
2172
+ "end": {
2173
+ "date": string;
2174
+ "time": string;
2175
+ };
2176
+ };
2177
+ })[];
2178
+ })[];
2179
+ };
2180
+ type ContactRemoveParams = {
2181
+ "phone_number": string;
2182
+ "channel"?: "all" | "voice" | "sms";
2183
+ };
2184
+ type ContactRemoveResponse = {
2185
+ "removed": true;
2186
+ "phone_number": string;
2187
+ "channel": "all" | "voice" | "sms";
2188
+ };
2189
+ type ContactListQuery = {
2190
+ "channel"?: "all" | "voice" | "sms";
2191
+ "after"?: string;
2192
+ };
2193
+ type ContactListResponse = {
2194
+ "entries": ({
2195
+ "phone_number": string;
2196
+ "channel": "all" | "voice" | "sms";
2197
+ "source": string;
2198
+ "created_at": string | null;
2199
+ "removal_locked": boolean;
2200
+ "opted_out_message"?: string | null;
2201
+ "opted_out_at"?: string | null;
2202
+ "opted_out_business_number"?: string | null;
2203
+ })[];
2204
+ "next_cursor": string | null;
2205
+ };
2206
+ type ContactAddParams = {
2207
+ "phone_numbers": (string)[];
2208
+ "channel"?: "all" | "voice" | "sms";
2209
+ };
2210
+ type ContactAddResponse = {
2211
+ "added": number;
2212
+ "submitted": number;
2213
+ "channel": "all" | "voice" | "sms";
2214
+ };
2215
+
2216
+ declare class Contacts {
2217
+ private readonly http;
2218
+ constructor(http: HttpClient);
2219
+ preview(params: ContactPreviewParams, opts?: RequestOptions): Promise<ContactPreviewResponse>;
2220
+ list(params?: ContactListQuery, opts?: RequestOptions): Promise<ContactListResponse>;
2221
+ add(params: ContactAddParams, opts?: RequestOptions): Promise<ContactAddResponse>;
2222
+ remove(params: ContactRemoveParams, opts?: RequestOptions): Promise<ContactRemoveResponse>;
2223
+ }
2224
+
2225
+ /** C5 wire contract. Server defaults apply only when a field is omitted. */
2226
+ type WebAgentReadResponse = {
2227
+ "phone_number": string;
2228
+ "agent_id": string | null;
2229
+ "web_prompt": string | null;
2230
+ "web_appearance": {
2231
+ "version": 1;
2232
+ "launcher": string;
2233
+ "window": "compact" | "side" | "centre" | "full";
2234
+ "visit": "nothing" | "greeting" | "open";
2235
+ "theme": "dark" | "light";
2236
+ "colourMode": "solid" | "gradient";
2237
+ "colour": string;
2238
+ "colour2": string;
2239
+ "text": {
2240
+ "greeting"?: string;
2241
+ "button"?: string;
2242
+ "title"?: string;
2243
+ "subtitle"?: string;
2244
+ "call"?: string;
2245
+ "chat"?: string;
2246
+ "welcome"?: string;
2247
+ "placeholder"?: string;
2248
+ "status"?: string;
2249
+ "send"?: string;
2250
+ "close"?: string;
2251
+ "footer"?: string;
2252
+ "typing"?: string;
2253
+ "error"?: string;
2254
+ "contact"?: string;
2255
+ "contactNote"?: string;
2256
+ "contactName"?: string;
2257
+ "contactPhone"?: string;
2258
+ "avatar"?: string;
2259
+ "voiceConnecting"?: string;
2260
+ "voicePrivacy"?: string;
2261
+ "voiceMute"?: string;
2262
+ "voiceUnmute"?: string;
2263
+ "voiceEnd"?: string;
2264
+ "voiceAllow"?: string;
2265
+ "voiceCancel"?: string;
2266
+ "voiceEnded"?: string;
2267
+ "voiceYouEnded"?: string;
2268
+ "voiceUnavailable"?: string;
2269
+ "voiceUnavailableNote"?: string;
2270
+ "voiceDisabled"?: string;
2271
+ "voiceInsecure"?: string;
2272
+ "voiceInsecureNote"?: string;
2273
+ "voicePermission"?: string;
2274
+ "voicePermissionNote"?: string;
2275
+ "voiceChecking"?: string;
2276
+ "voiceNeeded"?: string;
2277
+ "voiceBlocked"?: string;
2278
+ "voiceMissing"?: string;
2279
+ "voiceInUse"?: string;
2280
+ "voiceMicError"?: string;
2281
+ "voiceBusy"?: string;
2282
+ "voiceBusyNote"?: string;
2283
+ "voiceRinging"?: string;
2284
+ "voiceLive"?: string;
2285
+ "voiceError"?: string;
2286
+ "contactSave"?: string;
2287
+ "contactSavedEdit"?: string;
2288
+ "contactRequired"?: string;
2289
+ "beforeCallStart"?: string;
2290
+ "beforeCallCancel"?: string;
2291
+ };
2292
+ "contactFields"?: ({
2293
+ "id": string;
2294
+ "label": string;
2295
+ "enabled": boolean;
2296
+ "required": boolean;
2297
+ "askInChat"?: boolean;
2298
+ })[];
2299
+ "beforeCall"?: {
2300
+ "enabled": boolean;
2301
+ "message": string;
2302
+ "fields": ({
2303
+ "id": string;
2304
+ "required": boolean;
2305
+ })[];
2306
+ };
2307
+ } | null;
2308
+ "appearance_version": 1;
2309
+ "web_design": number;
2310
+ "web_color": string;
2311
+ "web_name": string;
2312
+ "web_chips": string;
2313
+ "web_calls_enabled": boolean;
2314
+ "web_agent_enabled": boolean | null;
2315
+ "revision": string;
2316
+ "install_id": string | null;
2317
+ "first_seen_at": string | null;
2318
+ "last_seen_at": string | null;
2319
+ };
2320
+ type WebAgentUpdateParams = {
2321
+ "revision": string;
2322
+ "settings": {
2323
+ "web_prompt"?: string;
2324
+ "web_design"?: number;
2325
+ "web_color"?: string;
2326
+ "web_name"?: string;
2327
+ "web_chips"?: string;
2328
+ "web_calls_enabled"?: boolean;
2329
+ "web_appearance"?: {
2330
+ "version": 1;
2331
+ "launcher": string;
2332
+ "window": "compact" | "side" | "centre" | "full";
2333
+ "visit": "nothing" | "greeting" | "open";
2334
+ "theme": "dark" | "light";
2335
+ "colourMode": "solid" | "gradient";
2336
+ "colour": string;
2337
+ "colour2": string;
2338
+ "text": {
2339
+ "greeting"?: string;
2340
+ "button"?: string;
2341
+ "title"?: string;
2342
+ "subtitle"?: string;
2343
+ "call"?: string;
2344
+ "chat"?: string;
2345
+ "welcome"?: string;
2346
+ "placeholder"?: string;
2347
+ "status"?: string;
2348
+ "send"?: string;
2349
+ "close"?: string;
2350
+ "footer"?: string;
2351
+ "typing"?: string;
2352
+ "error"?: string;
2353
+ "contact"?: string;
2354
+ "contactNote"?: string;
2355
+ "contactName"?: string;
2356
+ "contactPhone"?: string;
2357
+ "avatar"?: string;
2358
+ "voiceConnecting"?: string;
2359
+ "voicePrivacy"?: string;
2360
+ "voiceMute"?: string;
2361
+ "voiceUnmute"?: string;
2362
+ "voiceEnd"?: string;
2363
+ "voiceAllow"?: string;
2364
+ "voiceCancel"?: string;
2365
+ "voiceEnded"?: string;
2366
+ "voiceYouEnded"?: string;
2367
+ "voiceUnavailable"?: string;
2368
+ "voiceUnavailableNote"?: string;
2369
+ "voiceDisabled"?: string;
2370
+ "voiceInsecure"?: string;
2371
+ "voiceInsecureNote"?: string;
2372
+ "voicePermission"?: string;
2373
+ "voicePermissionNote"?: string;
2374
+ "voiceChecking"?: string;
2375
+ "voiceNeeded"?: string;
2376
+ "voiceBlocked"?: string;
2377
+ "voiceMissing"?: string;
2378
+ "voiceInUse"?: string;
2379
+ "voiceMicError"?: string;
2380
+ "voiceBusy"?: string;
2381
+ "voiceBusyNote"?: string;
2382
+ "voiceRinging"?: string;
2383
+ "voiceLive"?: string;
2384
+ "voiceError"?: string;
2385
+ "contactSave"?: string;
2386
+ "contactSavedEdit"?: string;
2387
+ "contactRequired"?: string;
2388
+ "beforeCallStart"?: string;
2389
+ "beforeCallCancel"?: string;
2390
+ };
2391
+ "contactFields"?: ({
2392
+ "id": string;
2393
+ "label": string;
2394
+ "enabled": boolean;
2395
+ "required": boolean;
2396
+ "askInChat"?: boolean;
2397
+ })[];
2398
+ "beforeCall"?: {
2399
+ "enabled": boolean;
2400
+ "message": string;
2401
+ "fields": ({
2402
+ "id": string;
2403
+ "required": boolean;
2404
+ })[];
2405
+ };
2406
+ };
2407
+ };
2408
+ };
2409
+ type WebAgentUpdateResponse = {
2410
+ "phone_number": string;
2411
+ "agent_id": string | null;
2412
+ "web_prompt": string | null;
2413
+ "web_appearance": {
2414
+ "version": 1;
2415
+ "launcher": string;
2416
+ "window": "compact" | "side" | "centre" | "full";
2417
+ "visit": "nothing" | "greeting" | "open";
2418
+ "theme": "dark" | "light";
2419
+ "colourMode": "solid" | "gradient";
2420
+ "colour": string;
2421
+ "colour2": string;
2422
+ "text": {
2423
+ "greeting"?: string;
2424
+ "button"?: string;
2425
+ "title"?: string;
2426
+ "subtitle"?: string;
2427
+ "call"?: string;
2428
+ "chat"?: string;
2429
+ "welcome"?: string;
2430
+ "placeholder"?: string;
2431
+ "status"?: string;
2432
+ "send"?: string;
2433
+ "close"?: string;
2434
+ "footer"?: string;
2435
+ "typing"?: string;
2436
+ "error"?: string;
2437
+ "contact"?: string;
2438
+ "contactNote"?: string;
2439
+ "contactName"?: string;
2440
+ "contactPhone"?: string;
2441
+ "avatar"?: string;
2442
+ "voiceConnecting"?: string;
2443
+ "voicePrivacy"?: string;
2444
+ "voiceMute"?: string;
2445
+ "voiceUnmute"?: string;
2446
+ "voiceEnd"?: string;
2447
+ "voiceAllow"?: string;
2448
+ "voiceCancel"?: string;
2449
+ "voiceEnded"?: string;
2450
+ "voiceYouEnded"?: string;
2451
+ "voiceUnavailable"?: string;
2452
+ "voiceUnavailableNote"?: string;
2453
+ "voiceDisabled"?: string;
2454
+ "voiceInsecure"?: string;
2455
+ "voiceInsecureNote"?: string;
2456
+ "voicePermission"?: string;
2457
+ "voicePermissionNote"?: string;
2458
+ "voiceChecking"?: string;
2459
+ "voiceNeeded"?: string;
2460
+ "voiceBlocked"?: string;
2461
+ "voiceMissing"?: string;
2462
+ "voiceInUse"?: string;
2463
+ "voiceMicError"?: string;
2464
+ "voiceBusy"?: string;
2465
+ "voiceBusyNote"?: string;
2466
+ "voiceRinging"?: string;
2467
+ "voiceLive"?: string;
2468
+ "voiceError"?: string;
2469
+ "contactSave"?: string;
2470
+ "contactSavedEdit"?: string;
2471
+ "contactRequired"?: string;
2472
+ "beforeCallStart"?: string;
2473
+ "beforeCallCancel"?: string;
2474
+ };
2475
+ "contactFields"?: ({
2476
+ "id": string;
2477
+ "label": string;
2478
+ "enabled": boolean;
2479
+ "required": boolean;
2480
+ "askInChat"?: boolean;
2481
+ })[];
2482
+ "beforeCall"?: {
2483
+ "enabled": boolean;
2484
+ "message": string;
2485
+ "fields": ({
2486
+ "id": string;
2487
+ "required": boolean;
2488
+ })[];
2489
+ };
2490
+ } | null;
2491
+ "appearance_version": 1;
2492
+ "web_design": number;
2493
+ "web_color": string;
2494
+ "web_name": string;
2495
+ "web_chips": string;
2496
+ "web_calls_enabled": boolean;
2497
+ "web_agent_enabled": boolean | null;
2498
+ "revision": string;
2499
+ "install_id": string | null;
2500
+ "first_seen_at": string | null;
2501
+ "last_seen_at": string | null;
2502
+ };
2503
+
2504
+ declare class WebAgent {
2505
+ private readonly http;
2506
+ constructor(http: HttpClient);
2507
+ get(number: string, opts?: RequestOptions): Promise<WebAgentReadResponse>;
2508
+ update(number: string, params: WebAgentUpdateParams, opts?: RequestOptions): Promise<WebAgentUpdateResponse>;
2509
+ }
2510
+
2511
+ /** C5 wire contract. Server defaults apply only when a field is omitted. */
2512
+ type InboxListQuery = {
2513
+ "archived"?: boolean;
2514
+ "unread"?: boolean;
2515
+ "search"?: string;
2516
+ "since"?: string;
2517
+ "period"?: "all" | "today" | "7" | "30" | "90";
2518
+ "limit"?: number;
2519
+ "offset"?: number;
2520
+ };
2521
+ type InboxListResponse = {
2522
+ "conversations": ({
2523
+ "thread_key": string;
2524
+ "last_at": string | null;
2525
+ "msg_count": number;
2526
+ "unread_count": number;
2527
+ "archived": boolean;
2528
+ "visits": number;
2529
+ "visitor_name": string | null;
2530
+ "visitor_phone": string | null;
2531
+ "matched": boolean;
2532
+ "last_message": string | null;
2533
+ })[];
2534
+ "total": number;
2535
+ "archived_new": number;
2536
+ "unread_total": number;
2537
+ };
2538
+ type InboxThreadQuery = {
2539
+ "limit"?: number;
2540
+ "before"?: string;
2541
+ "before_id"?: string;
2542
+ };
2543
+ type InboxThreadResponse = {
2544
+ "messages": ({
2545
+ "id": string;
2546
+ "thread_key": string;
2547
+ "content": string | null;
2548
+ "created_at": string | null;
2549
+ "incoming": boolean;
2550
+ "inbox_version": number | null;
2551
+ "visit_id": string | null;
2552
+ "visitor_name": string | null;
2553
+ "visitor_phone": string | null;
2554
+ "visitor_fields"?: ({
2555
+ [key: string]: unknown;
2556
+ })[] | null;
2557
+ "knowledge_given"?: {
2558
+ [key: string]: unknown;
2559
+ } | (unknown)[] | null;
2560
+ })[];
2561
+ "read_version": string;
2562
+ "has_more": boolean;
2563
+ };
2564
+ type InboxUpdateParams = {
2565
+ "archived"?: boolean;
2566
+ "read_version"?: string;
2567
+ };
2568
+ type InboxUpdateResponse = {
2569
+ "ok": true;
2570
+ "archived": boolean;
2571
+ };
2572
+ type InboxFeaturesResponse = {
2573
+ "enabled": boolean;
2574
+ };
2575
+ type InboxNumbersQuery = {
2576
+ "offset"?: number;
2577
+ };
2578
+ type InboxNumbersResponse = {
2579
+ "numbers": ({
2580
+ "phone_number": string;
2581
+ "agent_id": string | null;
2582
+ "source": string | null;
2583
+ "sms_prompt": string | null;
2584
+ "web_prompt": string | null;
2585
+ "sms_reply_enabled": boolean | null;
2586
+ "web_agent_enabled": boolean | null;
2587
+ "web_calls_enabled": boolean | null;
2588
+ })[];
2589
+ "agents": ({
2590
+ "agent_id": string;
2591
+ "name": string | null;
2592
+ })[];
2593
+ "has_more": boolean;
2594
+ };
2595
+ type InboxRetentionQuery = {
2596
+ "number"?: string;
2597
+ };
2598
+ type InboxRetentionResponse = {
2599
+ "call_retention_days": number;
2600
+ "web_days": number | null;
2601
+ "web_expiry_confirmed": boolean;
2602
+ "applies_to": "new_messages_agent_policy";
2603
+ "legacy_web_policy": "account_policy_at_creation_or_90_days";
2604
+ "zero_days_means": "next_cleanup_after_reply";
2605
+ "archive_changes_retention": false;
2606
+ "sms_days": 90;
2607
+ "sms_processing_enabled": boolean;
2608
+ "web_processing_enabled": boolean;
2609
+ };
2610
+
2611
+ declare class Inbox {
2612
+ private readonly http;
2613
+ constructor(http: HttpClient);
2614
+ list(channel: 'sms' | 'web', number: string, params?: InboxListQuery, opts?: RequestOptions): Promise<InboxListResponse>;
2615
+ thread(channel: 'sms' | 'web', number: string, thread: string, params?: InboxThreadQuery, opts?: RequestOptions): Promise<InboxThreadResponse>;
2616
+ update(channel: 'sms' | 'web', number: string, thread: string, params: InboxUpdateParams, opts?: RequestOptions): Promise<InboxUpdateResponse>;
2617
+ features(opts?: RequestOptions): Promise<InboxFeaturesResponse>;
2618
+ numbers(params?: InboxNumbersQuery, opts?: RequestOptions): Promise<InboxNumbersResponse>;
2619
+ retention(params?: InboxRetentionQuery, opts?: RequestOptions): Promise<InboxRetentionResponse>;
2620
+ }
2621
+
2622
+ declare class NixflexOutboundRequestError extends NixflexError {
2623
+ }
2624
+ declare class NixflexOutboundRequestPendingError extends NixflexOutboundRequestError {
2625
+ }
2626
+ declare class NixflexOutboundRequestUnknownError extends NixflexOutboundRequestError {
2627
+ }
2628
+ declare class NixflexRequestIdConflictError extends NixflexOutboundRequestError {
2629
+ }
2630
+ declare class NixflexOutboundRequestUnavailableError extends NixflexOutboundRequestError {
2631
+ }
2632
+ declare class NixflexCallBookingsUnavailableError extends NixflexError {
2633
+ }
2634
+ declare function outboundRequestError(value: unknown, requestId: string, mutation: boolean): NixflexError;
2635
+
2636
+ /** Local preparation only. Save this body before the first create, then reuse it unchanged. */
2637
+ declare function prepareOutboundCall(params: OutboundCallParams): PreparedOutboundCall;
931
2638
 
932
2639
  declare class Nixflex {
2640
+ readonly inbox: Inbox;
2641
+ readonly webAgent: WebAgent;
2642
+ readonly contacts: Contacts;
2643
+ readonly account: Account;
2644
+ readonly voices: Voices;
2645
+ readonly organisation: Organisation;
2646
+ readonly integrations: Integrations;
2647
+ readonly knowledge: Knowledge;
933
2648
  /** AI agents - create, list, get, update, delete. */
934
2649
  readonly agents: Agents;
935
2650
  /** Calls - trigger outbound, list history, fetch transcripts + analysis. */
@@ -946,12 +2661,6 @@ declare class Nixflex {
946
2661
  readonly usage: UsageResource;
947
2662
  /** Per-number post-call webhook configuration. */
948
2663
  readonly webhooks: Webhooks;
949
- /** Your own S3-compatible recording storage (data residency). */
950
- readonly storage: Storage;
951
- /** Your own LLM (OpenAI-compatible endpoint, verified with tool-calling probe). */
952
- readonly llm: Llm;
953
- /** Your own TTS (elevenlabs/cartesia, verified with a real synthesis). */
954
- readonly tts: Tts;
955
2664
  /** Caller context - what the agent knows about each caller on one of your numbers. */
956
2665
  readonly callers: Callers;
957
2666
  constructor(options: NixflexClientOptions);
@@ -959,9 +2668,9 @@ declare class Nixflex {
959
2668
  * developers use the dashboard instead). The key_secret is shown ONCE.
960
2669
  * Rate-limited per IP to prevent abuse. */
961
2670
  static createKey(params?: {
962
- name?: string;
963
- email?: string;
2671
+ name?: string | null;
2672
+ email?: string | null;
964
2673
  }, baseUrl?: string): Promise<KeyCreateResponse>;
965
2674
  }
966
2675
 
967
- export { type Agent, type AgentCreateParams, type AgentDeleteResponse, type AgentUpdateParams, type BatchCampaignParams, type BatchCreateResponse, type BatchInvalidEntry, type BatchLaunchResponse, type BatchRecipient, type Call, type CallDeleteAllResponse, type CallDeleteResponse, type CallDirection, type CallerContext, type CallerContextDeleteResponse, type CallerContextFields, type CallerContextResponse, type CallerContextSetParams, type CallerImportResponse, type CallerImportRow, type CallerSentiment, type KeyCreateResponse, type KeyRotateResponse, type ListParams, type LlmConfig, type LlmDeleteResponse, type LlmSetParams, type LlmSetResponse, type MonitorToggleResponse, Nixflex, type NixflexAPIErrorBody, NixflexAuthenticationError, type NixflexClientOptions, NixflexConnectionError, NixflexError, NixflexInvalidRequestError, NixflexNotFoundError, NixflexPaymentRequiredError, NixflexRateLimitError, NixflexServerError, type OutboundCallParams, type OutboundCallResponse, type PhoneNumber, type PhoneNumberDeleteResponse, type PhoneNumberImportParams, type PhoneNumberListResponse, type PhoneNumberUpdateParams, type RequestOptions, type ResponseLength, type SmsCampaign, type SmsCampaignCreateParams, type SmsCampaignDeleteResponse, type SmsCampaignLaunchResponse, type SmsCampaignListResponse, type SmsCampaignRecipient, type SmsCampaignStatus, type SmsSendParams, type SmsSendResponse, type StorageConfig, type StorageDeleteResponse, type StorageSetParams, type StorageSetResponse, type TransferType, type TtsConfig, type TtsDeleteResponse, type TtsProvider, type TtsSetParams, type TtsSetResponse, type Usage, type VerifyOptions, type WebCallsToggleResponse, type WebhookConfigResponse, type Weekday, Nixflex as default, errorFromResponse, verifyWebhookSignature };
2676
+ export { type AccountRetention, type ActivityEvent, type ActivityFilters, type ActivityPage, type Agent, type AgentContractSettings, type AgentCreateParams, type AgentDeleteResponse, type AgentExtractionField, type AgentListParams, type AgentPrecall, type AgentRetentionDays, type AgentUpdateParams, type AgentWarning, type BatchCampaignParams, type BatchCreateResponse, type BatchInvalidEntry, type BatchLaunchResponse, type BatchRecipient, type Booking, type CalcomSettings, type CalendarDay, type CalendarHours, type Call, type CallBilling, type CallBookingFinal, type CallBookingResult, type CallBookingTimeline, type CallBookings, type CallCompletedBookingEvent, type CallDeleteAllResponse, type CallDeleteResponse, type CallDirection, type CallHistoryPage, type CallHistoryParams, type CallRead, type CallRecording, type CallerContext, type CallerContextDeleteResponse, type CallerContextFields, type CallerContextResponse, type CallerContextSetParams, type CallerImportResponse, type CallerImportRow, type CallerSentiment, type CampaignCancelResponse, type CampaignConsentParams, type CampaignConsentResponse, type CampaignDeleteResponse, type CampaignListQuery, type CampaignListResponse, type CampaignPolicy, type CampaignResumeResponse, type CampaignValidation, type ContactAddParams, type ContactAddResponse, type ContactListQuery, type ContactListResponse, type ContactLocation, type ContactPreviewParams, type ContactPreviewResponse, type ContactRemoveParams, type ContactRemoveResponse, type ContentDeletePendingDetails, type CustomFunctionInput, type CustomFunctionView, type DraftAcceptance, type DraftEdit, type EmptyInput, type FunctionReceipt, type GoHighLevelSettings, type GoogleCalendarConnect, type GoogleCalendarDisconnect, type GoogleCalendarErrorCode, type GoogleCalendarSettings, type GoogleCalendarSettingsPatch, type GoogleCalendarStatus, HttpClient, type InboxFeaturesResponse, type InboxListQuery, type InboxListResponse, type InboxNumbersQuery, type InboxNumbersResponse, type InboxRetentionQuery, type InboxRetentionResponse, type InboxThreadQuery, type InboxThreadResponse, type InboxUpdateParams, type InboxUpdateResponse, type IntegrationProvider, type IntegrationReads, type IntegrationReceipt, type IntegrationSettings, type InvitationReceipt, type JobPollOptions, type KeyActivity, type KeyActivityParams, type KeyCreateResponse, type KeyRotateResponse, type KnowledgeChannel, type KnowledgeJob, type KnowledgeKeyterms, type KnowledgeObject, type KnowledgePage, type KnowledgeReview, type KnowledgeSettings, type KnowledgeTopic, type KnowledgeTopicResult, type KnowledgeUploadOptions, type KnowledgeWriteOptions, type ListParams, type MakeSettings, type MembershipReceipt, type MonitorToggleResponse, Nixflex, type NixflexAPIErrorBody, NixflexAuthenticationError, NixflexCalendarError, NixflexCallBookingsUnavailableError, type NixflexClientOptions, NixflexConflictError, NixflexConnectionError, NixflexCredentialError, NixflexDoNotContactError, NixflexError, NixflexInvalidRequestError, NixflexNotFoundError, NixflexOutboundRequestError, NixflexOutboundRequestPendingError, NixflexOutboundRequestUnavailableError, NixflexOutboundRequestUnknownError, NixflexOutcomeUnknownError, NixflexPaymentRequiredError, NixflexRateLimitError, NixflexRequestIdConflictError, NixflexServerError, type NumberCredentials, type NumberCredentialsErrorCode, type NumberCredentialsUpdated, type NumberUsage, type NumberUsageParams, type NumberUsagePeriod, type NumberUsageResponse, Organisation, type OrganisationContext, type OrganisationInvite, type OrganisationMember, type OrganisationMembers, type OrganisationRole, type OutboundCallParams, type OutboundCallRequest, type OutboundCallResponse, type OutboundRequestReceipt, type OutboundRequestState, type PageQuery, type PhoneNumber, type PhoneNumberDeleteResponse, type PhoneNumberDetails, type PhoneNumberImportParams, type PhoneNumberListParams, type PhoneNumberListResponse, type PhoneNumberMoveParams, type PhoneNumberMoveResponse, type PhoneNumberUpdateParams, type PreparedOutboundCall, type RecipientLocation, type RecordingStatus, type RequestOptions, type ResponseLength, type RevisionInput, SDK_VERSION, type ScopeInput, type SessionInput, type SettingsInput, type SlackSettings, type SmsBookingEvent, type SmsCampaign, type SmsCampaignCreateParams, type SmsCampaignCreateResponse, type SmsCampaignDeleteResponse, type SmsCampaignDetail, type SmsCampaignDetailParams, type SmsCampaignLaunchResponse, type SmsCampaignListResponse, type SmsCampaignRecipient, type SmsCampaignRecipientRecord, type SmsCampaignStatus, type SmsCampaignUpdateParams, type SmsCampaignUpdateResponse, type SmsSendParams, type SmsSendResponse, type SourceDeletion, type SourceInput, type SourceReplacement, type TargetQuery, type TelnyxKeyStatus, type TextSource, type TopicInput, type TransferType, type Usage, type VerifyOptions, type Voice, type VoiceContext, type VoiceListParams, type VoiceListResponse, type WebAgentReadResponse, type WebAgentUpdateParams, type WebAgentUpdateResponse, type WebCallsToggleResponse, type WebhookConfigResponse, type WebsiteInput, type Weekday, type ZapierSettings, calendarErrorCodes, credentialErrorCodes, Nixflex as default, errorFromResponse, featureError, outboundRequestError, prepareOutboundCall, verifyWebhookSignature };