@replicer/sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -17
- package/dist/chunk-CIXVIMX2.js +54 -0
- package/dist/index.cjs +136 -42
- package/dist/index.d.cts +499 -548
- package/dist/index.d.ts +499 -548
- package/dist/index.js +136 -42
- package/dist/tools.cjs +179 -0
- package/dist/tools.d.cts +79 -0
- package/dist/tools.d.ts +79 -0
- package/dist/tools.js +101 -0
- package/dist/types-DXQsrvOU.d.cts +1251 -0
- package/dist/types-DXQsrvOU.d.ts +1251 -0
- package/dist/webhooks.cjs +98 -14
- package/dist/webhooks.d.cts +36 -17
- package/dist/webhooks.d.ts +36 -17
- package/dist/webhooks.js +49 -14
- package/package.json +16 -2
|
@@ -0,0 +1,1251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response types of the Replicer API (`/v1`). Field names are the wire format (snake_case).
|
|
3
|
+
*/
|
|
4
|
+
/** A whole number on the wire (`integer` in the OpenAPI schemas). Plain `number` in TypeScript. */
|
|
5
|
+
type Int = number;
|
|
6
|
+
interface PageParams {
|
|
7
|
+
/**
|
|
8
|
+
* 1-based page number (default 1).
|
|
9
|
+
* @minimum 1
|
|
10
|
+
* @default 1
|
|
11
|
+
*/
|
|
12
|
+
page?: Int;
|
|
13
|
+
/**
|
|
14
|
+
* Page size, 1..100 (default 20). Out-of-range values fall back to the default.
|
|
15
|
+
* @minimum 1
|
|
16
|
+
* @maximum 100
|
|
17
|
+
* @default 20
|
|
18
|
+
*/
|
|
19
|
+
limit?: Int;
|
|
20
|
+
}
|
|
21
|
+
interface Pagination {
|
|
22
|
+
page: Int;
|
|
23
|
+
limit: Int;
|
|
24
|
+
total: Int;
|
|
25
|
+
total_pages: Int;
|
|
26
|
+
}
|
|
27
|
+
/** Envelope returned by every list method. */
|
|
28
|
+
interface Page<T> {
|
|
29
|
+
data: T[];
|
|
30
|
+
pagination: Pagination;
|
|
31
|
+
}
|
|
32
|
+
interface OkResponse {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `code` values the API returns in its flat error body `{ error, code }`. Branch on `code`, never on
|
|
37
|
+
* the human-readable `error` text. New codes may be added; fall back to the HTTP status.
|
|
38
|
+
*/
|
|
39
|
+
type ApiErrorCode = 'validation_error' | 'bad_request' | 'unauthorized' | 'forbidden' | 'insufficient_scope' | 'not_found' | 'method_not_allowed' | 'conflict' | 'idempotency_key_reuse' | 'webhook_endpoint_limit' | 'webhook_endpoint_key_revoked' | 'webhook_endpoint_admin_disabled' | 'webhook_endpoint_in_use' | 'agent_in_use' | 'redelivery_limit' | 'test_mode_unsupported' | 'payload_too_large' | 'rate_limited' | 'rate_limit_exceeded' | 'rate_limiter_unavailable' | 'insufficient_balance' | 'quota_exceeded' | 'channel_not_configured' | 'sender_not_supported' | 'media_not_supported' | 'email_provider_not_supported' | 'internal_error' | 'bad_gateway' | 'service_unavailable' | 'gateway_timeout' | 'upstream_timeout' | (string & {});
|
|
40
|
+
interface CreatePhoneCallInput {
|
|
41
|
+
/** Agent id; must belong to your organization. */
|
|
42
|
+
agent_id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Phone number id (see `phoneNumber.list`). Selects the caller ID. Required unless the agent has a
|
|
45
|
+
* default phone number. A number of another organization → 404 `not_found`.
|
|
46
|
+
*/
|
|
47
|
+
from_number_id?: string;
|
|
48
|
+
/** Informational only: it does not select the caller ID. Use `from_number_id`. */
|
|
49
|
+
from_number?: string;
|
|
50
|
+
to_number: string;
|
|
51
|
+
/** Sparse override merged on top of the stored agent. */
|
|
52
|
+
agent_override?: Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* `{{name}}` substitutions for the prompt, greeting and voicemail message. Up to 100 entries,
|
|
55
|
+
* names `[a-zA-Z_][a-zA-Z0-9_]{0,63}`, values up to 5,000 characters; `null` becomes an empty string.
|
|
56
|
+
* Wins over `agent_override.dynamicVariables`, which wins over the agent's own variables.
|
|
57
|
+
*/
|
|
58
|
+
dynamic_variables?: Record<string, string | number | boolean | null>;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* RFC 3339 date-time **with an offset** (`2026-05-01T09:30:00Z` or `+02:00`); the call is scheduled
|
|
62
|
+
* instead of dialed immediately. A past time dials immediately; an invalid one → 400.
|
|
63
|
+
*/
|
|
64
|
+
scheduled_at?: string;
|
|
65
|
+
customer_name?: string;
|
|
66
|
+
/** 0..5 (default 0). Retries repeat the original call (same number, override and metadata). */
|
|
67
|
+
max_retries?: Int;
|
|
68
|
+
/** 5..1440 minutes. */
|
|
69
|
+
retry_delay_minutes?: Int;
|
|
70
|
+
/**
|
|
71
|
+
* A retry with the same key (per organization) returns the call already created and never dials
|
|
72
|
+
* again. A call that failed to enqueue stays failed: retry with a new key.
|
|
73
|
+
*/
|
|
74
|
+
idempotency_key?: string;
|
|
75
|
+
}
|
|
76
|
+
interface CancelCallInput {
|
|
77
|
+
/** ID of a call that has not started yet. */
|
|
78
|
+
call_id: string;
|
|
79
|
+
}
|
|
80
|
+
interface CancelCampaignPendingInput {
|
|
81
|
+
campaign_id: string;
|
|
82
|
+
}
|
|
83
|
+
interface SimulateInboundCallInput {
|
|
84
|
+
/** Id of one of your phone numbers (see `phoneNumber.list`); it must have an active inbound agent. */
|
|
85
|
+
phone_number_id: string;
|
|
86
|
+
/**
|
|
87
|
+
* Caller number. Default `+15550100000`. Use `+15550100004` or `+15550100005` for the other
|
|
88
|
+
* documented test outcomes; the unanswered numbers (`+15550100001` to `+15550100003`) are rejected.
|
|
89
|
+
*/
|
|
90
|
+
from?: string;
|
|
91
|
+
/** Same key and body returns the same simulated call; same key, different body → 422 `idempotency_key_reuse`. */
|
|
92
|
+
idempotency_key?: string;
|
|
93
|
+
}
|
|
94
|
+
interface SimulateInboundCallResponse {
|
|
95
|
+
call_id: string;
|
|
96
|
+
/** `in_progress` for a new call; a replay returns the call's current status. */
|
|
97
|
+
status: string;
|
|
98
|
+
agent_id: string;
|
|
99
|
+
phone_number_id: string;
|
|
100
|
+
/** E.164 number that was called. */
|
|
101
|
+
phone_number: string;
|
|
102
|
+
}
|
|
103
|
+
interface EnqueueCallResponse {
|
|
104
|
+
call_id: string;
|
|
105
|
+
/** `pending` or `scheduled` for a new call; a replay of an `idempotency_key` returns the call's current status. */
|
|
106
|
+
status: 'pending' | 'scheduled' | (string & {});
|
|
107
|
+
}
|
|
108
|
+
/** Call direction, from the caller's point of view. Input is case-insensitive; responses are lowercase. */
|
|
109
|
+
type CallDirection = 'inbound' | 'outbound';
|
|
110
|
+
/**
|
|
111
|
+
* `cancel-campaign-pending` first pauses the campaign (`running` / `scheduled` → `paused`), then cancels its
|
|
112
|
+
* pending and queued calls. Resume with `campaign.start`; contacts whose call was cancelled are not redialed.
|
|
113
|
+
*/
|
|
114
|
+
interface CancelCampaignPendingResponse {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
calls_cancelled: Int;
|
|
117
|
+
calls_marked: Int;
|
|
118
|
+
queue_removed: Int;
|
|
119
|
+
/** Campaign status after the call, e.g. `paused`. */
|
|
120
|
+
campaign_status: CampaignStatus | null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Call statuses (lowercase snake_case; filters also accept any case and `in-progress`). Final states: `analyzed` (the normal end state once post-call analysis is done),
|
|
124
|
+
* `completed` (ended, analysis pending), `failed`, `cancelled`, `missed`, `error`, `forwarded`.
|
|
125
|
+
*
|
|
126
|
+
* `forwarding` and `forwarded` belong to inbound calls that could not be taken by the agent
|
|
127
|
+
* (concurrent-call limit reached, agent unavailable) on a number with a `fallback_number`: the
|
|
128
|
+
* call is `forwarding` while it is handed over, then `forwarded`. A forwarded call has `duration`
|
|
129
|
+
* 0, is not billed and has no transcript; `disconnection_reason` is `fallback_concurrency_limit`
|
|
130
|
+
* or `fallback_agent_unavailable`. If the handover fails the call ends `failed` with
|
|
131
|
+
* `disconnection_reason` `fallback_transfer_failed`.
|
|
132
|
+
*/
|
|
133
|
+
type CallStatus = 'pending' | 'scheduled' | 'queued' | 'retry' | 'in_progress' | 'completed' | 'analyzed' | 'failed' | 'cancelled' | 'missed' | 'error' | 'forwarding' | 'forwarded';
|
|
134
|
+
/** Sentiment detected by the post-call analysis (lowercase). */
|
|
135
|
+
type CallSentiment = 'positive' | 'neutral' | 'negative' | 'unknown';
|
|
136
|
+
interface ListCallsParams extends PageParams {
|
|
137
|
+
status?: CallStatus;
|
|
138
|
+
direction?: CallDirection;
|
|
139
|
+
/** Only calls handled by this agent. */
|
|
140
|
+
agent_id?: string;
|
|
141
|
+
/** Only calls that involve this phone number (the number called for inbound calls, the number placed from for outbound calls). Calls made before `phone_number_id` existed are not matched. */
|
|
142
|
+
phone_number_id?: string;
|
|
143
|
+
/** ISO 8601 lower bound on `started_at`. */
|
|
144
|
+
date_from?: string;
|
|
145
|
+
/** ISO 8601 upper bound on `started_at`. */
|
|
146
|
+
date_to?: string;
|
|
147
|
+
}
|
|
148
|
+
interface Call {
|
|
149
|
+
id: string;
|
|
150
|
+
customer_name: string | null;
|
|
151
|
+
customer_phone: string | null;
|
|
152
|
+
duration: Int | null;
|
|
153
|
+
status: CallStatus;
|
|
154
|
+
direction: CallDirection | null;
|
|
155
|
+
disconnection_reason: string | null;
|
|
156
|
+
sentiment: CallSentiment | null;
|
|
157
|
+
summary: string | null;
|
|
158
|
+
/** Only returned by `call.get`; list items omit it. */
|
|
159
|
+
transcript?: unknown;
|
|
160
|
+
recording: string | null;
|
|
161
|
+
call_successful: boolean | null;
|
|
162
|
+
/** Whole platform tokens debited from the organization's balance for the call (not a currency amount); `0` for a call that cost nothing (e.g. never connected), `null` until it is billed. */
|
|
163
|
+
token_cost: number | null;
|
|
164
|
+
agent_id: string | null;
|
|
165
|
+
campaign_id: string | null;
|
|
166
|
+
started_at: string | null;
|
|
167
|
+
ended_at: string | null;
|
|
168
|
+
scheduled_at: string | null;
|
|
169
|
+
created_at: string | null;
|
|
170
|
+
/** false when created with a test (`rpl_test_`) key: a simulated call that is never billed. See Test mode. */
|
|
171
|
+
livemode: boolean;
|
|
172
|
+
/** The `metadata` object sent when the call was created, or `null`. */
|
|
173
|
+
metadata: Record<string, unknown> | null;
|
|
174
|
+
/** When the post-call analysis finished (`summary`, `sentiment`, `call_successful` are final), or `null`. */
|
|
175
|
+
analyzed_at: string | null;
|
|
176
|
+
/** The organization's number involved in the call: the number called (inbound) or placed from (outbound), in E.164. `null` for calls made before this field existed. */
|
|
177
|
+
phone_number: string | null;
|
|
178
|
+
/** The id of `phone_number` (see `phoneNumber.list`), or `null`. Also `null` if the number was released afterwards. */
|
|
179
|
+
phone_number_id: string | null;
|
|
180
|
+
/** Variables the agent extracted during the call, by name, or `null` until the call is analyzed (`{}` when it extracted none). */
|
|
181
|
+
extracted_variables: Record<string, unknown> | null;
|
|
182
|
+
}
|
|
183
|
+
interface CreateCampaignInput {
|
|
184
|
+
name: string;
|
|
185
|
+
description?: string;
|
|
186
|
+
user_agent_id: string;
|
|
187
|
+
/** Ignored for API keys (the campaign is attributed to your organization's owner). Only trusted internal callers need it. */
|
|
188
|
+
user_id?: string;
|
|
189
|
+
from_phone_number_id?: string;
|
|
190
|
+
from_number_attempts?: string[];
|
|
191
|
+
from_number_strategy?: 'rolling' | 'clamp' | 'custom';
|
|
192
|
+
contact_attempt_strategy?: 'rolling' | 'clamp' | 'custom';
|
|
193
|
+
/** Non-empty; every contact needs `phone_number`. Up to 100,000 (and the 10 MiB body limit). */
|
|
194
|
+
contacts: Record<string, unknown>[];
|
|
195
|
+
variable_mapping?: Record<string, string>;
|
|
196
|
+
/** RFC 3339 with an offset; invalid → 400. */
|
|
197
|
+
scheduled_at?: string;
|
|
198
|
+
/** 0..5 (default 0). */
|
|
199
|
+
max_retries?: Int;
|
|
200
|
+
/** 5..1440 (default 30). */
|
|
201
|
+
retry_delay_minutes?: Int;
|
|
202
|
+
/** Unique integers 0..6 (0 = Sunday); `[]` = every day. */
|
|
203
|
+
calling_days?: Int[];
|
|
204
|
+
/** `HH:MM`; set both or neither, start before end. */
|
|
205
|
+
calling_start_time?: string;
|
|
206
|
+
calling_end_time?: string;
|
|
207
|
+
/** IANA time zone (default `Europe/Rome`). */
|
|
208
|
+
timezone?: string;
|
|
209
|
+
/** 1..100 and at most your plan's concurrency. */
|
|
210
|
+
max_concurrency?: Int | null;
|
|
211
|
+
/** 0..50 and at most your plan's concurrency. */
|
|
212
|
+
keep_free_for_inbound?: Int;
|
|
213
|
+
/**
|
|
214
|
+
* A retry with the same key (per organization) and body returns the campaign already created
|
|
215
|
+
* instead of creating a second one. Same key, different body → 422 `idempotency_key_reuse`.
|
|
216
|
+
* Non-empty, at most 200 characters. The `Idempotency-Key` header works too.
|
|
217
|
+
*/
|
|
218
|
+
idempotency_key?: string;
|
|
219
|
+
}
|
|
220
|
+
/** `POST /v1/campaigns` (201) returns the bare campaign, like `get-call`. */
|
|
221
|
+
type CreateCampaignResponse = Campaign;
|
|
222
|
+
/** `GET /v1/campaigns/:id` returns the bare campaign plus its contacts. */
|
|
223
|
+
interface GetCampaignResponse extends Campaign {
|
|
224
|
+
/** Up to 1,000 contacts, in campaign order. */
|
|
225
|
+
contacts: Record<string, unknown>[];
|
|
226
|
+
/** True when the campaign has more contacts than returned (`contact_count` > `contacts.length`). */
|
|
227
|
+
contacts_truncated: boolean;
|
|
228
|
+
}
|
|
229
|
+
/** Campaign statuses (lowercase). Filters accept any case. */
|
|
230
|
+
type CampaignStatus = 'draft' | 'scheduled' | 'running' | 'paused' | 'completed' | 'cancelled';
|
|
231
|
+
interface ListCampaignsParams extends PageParams {
|
|
232
|
+
/** `draft`, `scheduled`, `running`, `paused`, `completed` or `cancelled` (any case is accepted). */
|
|
233
|
+
status?: CampaignStatus;
|
|
234
|
+
}
|
|
235
|
+
/** Campaign as returned by create, get and list (the same field whitelist everywhere). */
|
|
236
|
+
interface Campaign {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
description: string | null;
|
|
240
|
+
status: CampaignStatus;
|
|
241
|
+
agent_id: string;
|
|
242
|
+
from_phone_number_id: string | null;
|
|
243
|
+
/** E.164 caller ID (the campaign's number). */
|
|
244
|
+
from_number: string | null;
|
|
245
|
+
/** E.164 caller IDs, in order. */
|
|
246
|
+
from_number_attempts: string[] | null;
|
|
247
|
+
from_number_strategy: string | null;
|
|
248
|
+
contact_attempt_strategy: string | null;
|
|
249
|
+
total_contacts: Int;
|
|
250
|
+
contact_count: Int;
|
|
251
|
+
variable_mapping: Record<string, string> | null;
|
|
252
|
+
max_retries: Int;
|
|
253
|
+
retry_delay_minutes: Int;
|
|
254
|
+
max_concurrency: Int | null;
|
|
255
|
+
keep_free_for_inbound: Int;
|
|
256
|
+
calling_days: Int[] | null;
|
|
257
|
+
calling_start_time: string | null;
|
|
258
|
+
calling_end_time: string | null;
|
|
259
|
+
timezone: string;
|
|
260
|
+
calls_started: Int;
|
|
261
|
+
calls_completed: Int;
|
|
262
|
+
calls_failed: Int;
|
|
263
|
+
scheduled_at: string | null;
|
|
264
|
+
started_at: string | null;
|
|
265
|
+
completed_at: string | null;
|
|
266
|
+
created_at: string | null;
|
|
267
|
+
/** false when created with a test (`rpl_test_`) key: its calls are simulated. See Test mode. */
|
|
268
|
+
livemode: boolean;
|
|
269
|
+
updated_at: string | null;
|
|
270
|
+
}
|
|
271
|
+
/** @deprecated Use `Campaign`. */
|
|
272
|
+
type CampaignListItem = Campaign;
|
|
273
|
+
interface StartCampaignResponse {
|
|
274
|
+
id: string;
|
|
275
|
+
status: 'running';
|
|
276
|
+
}
|
|
277
|
+
interface ProvisionInboundInput {
|
|
278
|
+
/** Phone number id. */
|
|
279
|
+
id: string;
|
|
280
|
+
label?: string;
|
|
281
|
+
from_number: string;
|
|
282
|
+
}
|
|
283
|
+
interface ProvisionInboundResponse {
|
|
284
|
+
inbound_trunk_id: string;
|
|
285
|
+
inbound_dispatch_rule_id: string;
|
|
286
|
+
}
|
|
287
|
+
/** Phone number kinds (lowercase). */
|
|
288
|
+
type PhoneNumberType = 'local' | 'mobile' | 'toll_free';
|
|
289
|
+
interface PhoneNumber {
|
|
290
|
+
/** Pass as `from_number_id` to `call.createPhoneCall` and as `id` to the inbound routes. */
|
|
291
|
+
id: string;
|
|
292
|
+
/** E.164. */
|
|
293
|
+
phone_number: string;
|
|
294
|
+
label: string | null;
|
|
295
|
+
country: string | null;
|
|
296
|
+
/** `local`, `mobile` or `toll_free`. */
|
|
297
|
+
number_type: PhoneNumberType | null;
|
|
298
|
+
is_active: boolean;
|
|
299
|
+
inbound_agent_id: string | null;
|
|
300
|
+
inbound_enabled: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* E.164 number that inbound calls are forwarded to when the agent cannot take them (concurrent-call
|
|
303
|
+
* limit reached, agent unavailable). `null` when not set.
|
|
304
|
+
*/
|
|
305
|
+
fallback_number: string | null;
|
|
306
|
+
created_at: string;
|
|
307
|
+
}
|
|
308
|
+
interface UpdatePhoneNumberInput {
|
|
309
|
+
/**
|
|
310
|
+
* The number to forward to, or `null` to remove it. E.164 (`+39 02 1234 5678` is accepted and
|
|
311
|
+
* normalized). It must be a valid number in the same country as the phone number, not a
|
|
312
|
+
* premium-rate or shared-cost number, and not one of your Replicer phone numbers. Only available
|
|
313
|
+
* on phone numbers purchased through Replicer (`409 conflict` otherwise).
|
|
314
|
+
*/
|
|
315
|
+
fallback_number?: string | null;
|
|
316
|
+
/**
|
|
317
|
+
* The inbound agent that answers this number: an active agent of your organization with direction
|
|
318
|
+
* `inbound` (`400 validation_error` otherwise). `null` removes the agent and turns inbound routing
|
|
319
|
+
* off (`inbound_enabled` becomes `false`). Changing to another agent keeps the routing as it is.
|
|
320
|
+
* Setting an agent does not turn routing on: use `phoneNumber.provisionInbound`.
|
|
321
|
+
* Send at least one of `fallback_number` and `inbound_agent_id`.
|
|
322
|
+
*/
|
|
323
|
+
inbound_agent_id?: string | null;
|
|
324
|
+
}
|
|
325
|
+
interface ImportPhoneNumberInput {
|
|
326
|
+
/** The number you own, E.164 (`+39 02 1234 5678` is accepted and normalized). Already connected → `409 conflict`. */
|
|
327
|
+
phone_number: string;
|
|
328
|
+
/** Free-text name, up to 100 characters. Returned as `label`. */
|
|
329
|
+
label?: string;
|
|
330
|
+
/** Two-letter ISO country code. */
|
|
331
|
+
country?: string;
|
|
332
|
+
/** SIP trunk details of your provider, used to dial out from this number. Never returned by the API. */
|
|
333
|
+
sip_domain?: string;
|
|
334
|
+
sip_username?: string;
|
|
335
|
+
sip_password?: string;
|
|
336
|
+
/**
|
|
337
|
+
* Inbound agent (active, direction `inbound`). When given, inbound routing is turned on at once;
|
|
338
|
+
* if that fails nothing is created.
|
|
339
|
+
*/
|
|
340
|
+
inbound_agent_id?: string;
|
|
341
|
+
}
|
|
342
|
+
/** Query parameters of `phoneNumber.deprovisionInbound`: the ids returned by `provisionInbound`. At least one is required. */
|
|
343
|
+
interface DeprovisionInboundParams {
|
|
344
|
+
trunk_id?: string;
|
|
345
|
+
rule_id?: string;
|
|
346
|
+
}
|
|
347
|
+
/** `remaining` in the 502 `bad_gateway` body when only part of an inbound deprovision succeeded. */
|
|
348
|
+
interface DeprovisionInboundRemaining {
|
|
349
|
+
trunk_id?: string;
|
|
350
|
+
rule_id?: string;
|
|
351
|
+
}
|
|
352
|
+
/** Up to 50 per request; `text` non-empty, at most 100 KB (1 MB total per request). */
|
|
353
|
+
interface KnowledgeBaseTextSource {
|
|
354
|
+
title?: string;
|
|
355
|
+
text: string;
|
|
356
|
+
}
|
|
357
|
+
/** A URL whose host did not resolve: skipped instead of failing the whole request. */
|
|
358
|
+
interface KnowledgeBaseRejectedUrl {
|
|
359
|
+
url: string;
|
|
360
|
+
reason: string;
|
|
361
|
+
}
|
|
362
|
+
interface KnowledgeBaseCreateInput {
|
|
363
|
+
knowledge_base_name?: string;
|
|
364
|
+
name?: string;
|
|
365
|
+
description?: string;
|
|
366
|
+
knowledge_base_urls?: string[];
|
|
367
|
+
knowledge_base_texts?: KnowledgeBaseTextSource[];
|
|
368
|
+
chunks_to_retrieve?: Int;
|
|
369
|
+
similarity_threshold?: number;
|
|
370
|
+
instruction?: string;
|
|
371
|
+
use_llm_extraction?: boolean;
|
|
372
|
+
}
|
|
373
|
+
interface KnowledgeBaseUpdateInput {
|
|
374
|
+
name?: string;
|
|
375
|
+
description?: string | null;
|
|
376
|
+
chunks_to_retrieve?: Int;
|
|
377
|
+
similarity_threshold?: number;
|
|
378
|
+
instruction?: string | null;
|
|
379
|
+
use_llm_extraction?: boolean;
|
|
380
|
+
}
|
|
381
|
+
interface KnowledgeBaseAddSourcesInput {
|
|
382
|
+
knowledge_base_urls?: string[];
|
|
383
|
+
knowledge_base_texts?: KnowledgeBaseTextSource[];
|
|
384
|
+
}
|
|
385
|
+
/** Query parameters of `knowledgeBase.deleteSource`. */
|
|
386
|
+
interface DeleteKnowledgeBaseSourceParams {
|
|
387
|
+
/** The knowledge base that owns the source. */
|
|
388
|
+
knowledge_base_id: string;
|
|
389
|
+
}
|
|
390
|
+
/** Knowledge base statuses (lowercase). */
|
|
391
|
+
type KnowledgeBaseStatus = 'processing' | 'ready' | 'error';
|
|
392
|
+
/** Knowledge source statuses (lowercase). */
|
|
393
|
+
type KnowledgeSourceStatus = 'pending' | 'queued' | 'processing' | 'ready' | 'error';
|
|
394
|
+
/** Knowledge source kinds (lowercase). */
|
|
395
|
+
type KnowledgeSourceType = 'url' | 'text' | 'file';
|
|
396
|
+
interface KnowledgeBaseSourceSummary {
|
|
397
|
+
source_id: string;
|
|
398
|
+
type: KnowledgeSourceType;
|
|
399
|
+
title: string;
|
|
400
|
+
url?: string | null;
|
|
401
|
+
status: KnowledgeSourceStatus;
|
|
402
|
+
error?: string | null;
|
|
403
|
+
chunk_count: Int;
|
|
404
|
+
filename?: string | null;
|
|
405
|
+
}
|
|
406
|
+
interface KnowledgeBaseResponse {
|
|
407
|
+
knowledge_base_id: string;
|
|
408
|
+
knowledge_base_name: string;
|
|
409
|
+
description?: string | null;
|
|
410
|
+
status: KnowledgeBaseStatus;
|
|
411
|
+
chunks_to_retrieve: Int;
|
|
412
|
+
similarity_threshold: number;
|
|
413
|
+
instruction?: string | null;
|
|
414
|
+
use_llm_extraction: boolean;
|
|
415
|
+
source_count: Int;
|
|
416
|
+
knowledge_base_sources: KnowledgeBaseSourceSummary[];
|
|
417
|
+
sources: KnowledgeBaseSourceSummary[];
|
|
418
|
+
created_at: string;
|
|
419
|
+
updated_at: string;
|
|
420
|
+
}
|
|
421
|
+
/** Returned by `knowledgeBase.create` and `knowledgeBase.addSources`. */
|
|
422
|
+
interface KnowledgeBaseSourcesResponse extends KnowledgeBaseResponse {
|
|
423
|
+
rejected_urls: KnowledgeBaseRejectedUrl[];
|
|
424
|
+
}
|
|
425
|
+
interface KnowledgeBaseListResponse {
|
|
426
|
+
knowledge_bases: KnowledgeBaseResponse[];
|
|
427
|
+
}
|
|
428
|
+
interface PresignFileInput {
|
|
429
|
+
filename: string;
|
|
430
|
+
mime_type: string;
|
|
431
|
+
/** Exact upload size in bytes: the presigned URL signs it, so the PUT body must match. */
|
|
432
|
+
size_bytes: Int;
|
|
433
|
+
title?: string;
|
|
434
|
+
}
|
|
435
|
+
interface PresignFileResponse {
|
|
436
|
+
source_id: string;
|
|
437
|
+
upload_url: string;
|
|
438
|
+
required_headers: Record<string, string>;
|
|
439
|
+
expires_in: Int;
|
|
440
|
+
storage_key: string;
|
|
441
|
+
}
|
|
442
|
+
interface FailFileInput {
|
|
443
|
+
error?: string;
|
|
444
|
+
}
|
|
445
|
+
interface UpdateSourceInput {
|
|
446
|
+
extracted_markdown?: string;
|
|
447
|
+
title?: string;
|
|
448
|
+
}
|
|
449
|
+
interface UpdateChunkInput {
|
|
450
|
+
enabled?: boolean;
|
|
451
|
+
relevance_weight?: number;
|
|
452
|
+
}
|
|
453
|
+
interface KnowledgeBaseChunk {
|
|
454
|
+
id: string;
|
|
455
|
+
chunk_index: Int;
|
|
456
|
+
content: string;
|
|
457
|
+
enabled: boolean;
|
|
458
|
+
relevance_weight: number;
|
|
459
|
+
}
|
|
460
|
+
interface KnowledgeBaseSourceDetail {
|
|
461
|
+
id: string;
|
|
462
|
+
knowledge_base_id: string;
|
|
463
|
+
type: KnowledgeSourceType;
|
|
464
|
+
title: string;
|
|
465
|
+
url: string | null;
|
|
466
|
+
filename: string | null;
|
|
467
|
+
mime_type: string | null;
|
|
468
|
+
size_bytes: Int | null;
|
|
469
|
+
raw_text: string | null;
|
|
470
|
+
extracted_markdown: string | null;
|
|
471
|
+
status: KnowledgeSourceStatus;
|
|
472
|
+
error: string | null;
|
|
473
|
+
chunk_count: Int;
|
|
474
|
+
chunks: KnowledgeBaseChunk[];
|
|
475
|
+
}
|
|
476
|
+
interface PresignFileDownloadResponse {
|
|
477
|
+
download_url: string;
|
|
478
|
+
expires_in: Int;
|
|
479
|
+
filename: string;
|
|
480
|
+
mime_type: string | null;
|
|
481
|
+
}
|
|
482
|
+
interface ListContactsParams extends PageParams {
|
|
483
|
+
/** Case-insensitive match on name, phone, email or company. */
|
|
484
|
+
search?: string;
|
|
485
|
+
}
|
|
486
|
+
interface Contact {
|
|
487
|
+
id: string;
|
|
488
|
+
first_name: string | null;
|
|
489
|
+
last_name: string | null;
|
|
490
|
+
company: string | null;
|
|
491
|
+
job_title: string | null;
|
|
492
|
+
phone_number: string | null;
|
|
493
|
+
email: string | null;
|
|
494
|
+
street: string | null;
|
|
495
|
+
city: string | null;
|
|
496
|
+
state: string | null;
|
|
497
|
+
postal_code: string | null;
|
|
498
|
+
country: string | null;
|
|
499
|
+
website: string | null;
|
|
500
|
+
birthday: string | null;
|
|
501
|
+
notes: string | null;
|
|
502
|
+
created_at: string;
|
|
503
|
+
updated_at: string;
|
|
504
|
+
}
|
|
505
|
+
/** At least one of `first_name` / `last_name` is required. */
|
|
506
|
+
interface CreateContactInput {
|
|
507
|
+
first_name?: string;
|
|
508
|
+
last_name?: string;
|
|
509
|
+
company?: string;
|
|
510
|
+
job_title?: string;
|
|
511
|
+
phone_number?: string;
|
|
512
|
+
email?: string;
|
|
513
|
+
street?: string;
|
|
514
|
+
city?: string;
|
|
515
|
+
state?: string;
|
|
516
|
+
postal_code?: string;
|
|
517
|
+
country?: string;
|
|
518
|
+
website?: string;
|
|
519
|
+
notes?: string;
|
|
520
|
+
}
|
|
521
|
+
/** Contact identity kinds (lowercase). */
|
|
522
|
+
type ContactIdentityType = 'phone' | 'email';
|
|
523
|
+
interface ContactIdentityConflict {
|
|
524
|
+
type: ContactIdentityType;
|
|
525
|
+
value: string;
|
|
526
|
+
/** The contact that already owns this address (it is not reassigned). */
|
|
527
|
+
owner_contact_id: string;
|
|
528
|
+
}
|
|
529
|
+
interface CreateContactResponse {
|
|
530
|
+
id: string;
|
|
531
|
+
first_name: string;
|
|
532
|
+
last_name: string;
|
|
533
|
+
/** Usually empty. */
|
|
534
|
+
identity_conflicts: ContactIdentityConflict[];
|
|
535
|
+
}
|
|
536
|
+
/** Agent kinds (lowercase). */
|
|
537
|
+
type AgentType = 'receptionist' | 'sales_qualifier' | 'callcenter_seller' | 'personal_secretary' | 'custom';
|
|
538
|
+
interface Agent {
|
|
539
|
+
id: string;
|
|
540
|
+
agent_name: string;
|
|
541
|
+
agent_type: AgentType;
|
|
542
|
+
call_direction: CallDirection;
|
|
543
|
+
voice_id: string | null;
|
|
544
|
+
language: string | null;
|
|
545
|
+
is_active: boolean;
|
|
546
|
+
/** The agent's default outbound phone number id, if any. */
|
|
547
|
+
phone_number_id: string | null;
|
|
548
|
+
created_at: string;
|
|
549
|
+
}
|
|
550
|
+
interface ListAgentsParams extends PageParams {
|
|
551
|
+
/** `false` lists the deactivated agents instead of the active ones (default `true`). */
|
|
552
|
+
is_active?: boolean;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* One tool of an agent. The same tools as the dashboard: `end_call`, `transfer_call`,
|
|
556
|
+
* `extract_dynamic_variable`, `press_digit`, `agent_swap`, `check_calendar_availability`,
|
|
557
|
+
* `book_calendar_appointment`, `send_sms`, `send_email`, `schedule_callback`, `integration` and the
|
|
558
|
+
* legacy `custom`. Fields depend on the type (for example `calendarId` for the calendar tools,
|
|
559
|
+
* `transfer_destination` for `transfer_call`). `send_whatsapp` tools are set up in the dashboard and
|
|
560
|
+
* rejected here. For your own endpoints prefer [API tools](`agentTool.create`).
|
|
561
|
+
*/
|
|
562
|
+
interface AgentToolConfig {
|
|
563
|
+
type: string;
|
|
564
|
+
name: string;
|
|
565
|
+
description?: string;
|
|
566
|
+
[field: string]: unknown;
|
|
567
|
+
}
|
|
568
|
+
interface AgentDetail {
|
|
569
|
+
id: string;
|
|
570
|
+
agent_name: string;
|
|
571
|
+
agent_type: AgentType;
|
|
572
|
+
call_direction: CallDirection;
|
|
573
|
+
description: string | null;
|
|
574
|
+
language: string | null;
|
|
575
|
+
/** Voice descriptor, as listed in the dashboard voice picker. */
|
|
576
|
+
voice: string | null;
|
|
577
|
+
prompt: string;
|
|
578
|
+
/** Spoken opening line; empty = generated by the agent. */
|
|
579
|
+
greeting: string;
|
|
580
|
+
knowledge_base_ids: string[];
|
|
581
|
+
tools: AgentToolConfig[];
|
|
582
|
+
is_active: boolean;
|
|
583
|
+
/** Workflow agents (`true`) can only be edited in the dashboard. */
|
|
584
|
+
is_advanced: boolean;
|
|
585
|
+
phone_number_id: string | null;
|
|
586
|
+
created_at: string;
|
|
587
|
+
updated_at: string;
|
|
588
|
+
}
|
|
589
|
+
type AgentTemplate = 'receptionist' | 'sales_qualifier' | 'callcenter_seller' | 'personal_secretary' | 'custom';
|
|
590
|
+
interface CreateAgentInput {
|
|
591
|
+
agent_name: string;
|
|
592
|
+
call_direction: CallDirection;
|
|
593
|
+
/** Starting prompt and greeting. Default `custom`, which needs your own `prompt`. */
|
|
594
|
+
template?: AgentTemplate;
|
|
595
|
+
/** Language code, for example `en-US` or `it-IT`. Default `en-US`. */
|
|
596
|
+
language?: string;
|
|
597
|
+
/** A voice of the catalog; default: the default voice of the language. */
|
|
598
|
+
voice?: string;
|
|
599
|
+
/** Replaces the template prompt. Required with the `custom` template. */
|
|
600
|
+
prompt?: string;
|
|
601
|
+
greeting?: string;
|
|
602
|
+
description?: string;
|
|
603
|
+
knowledge_base_ids?: string[];
|
|
604
|
+
/** An `end_call` tool is added when missing. */
|
|
605
|
+
tools?: AgentToolConfig[];
|
|
606
|
+
}
|
|
607
|
+
interface UpdateAgentInput {
|
|
608
|
+
agent_name?: string;
|
|
609
|
+
call_direction?: CallDirection;
|
|
610
|
+
language?: string;
|
|
611
|
+
voice?: string;
|
|
612
|
+
prompt?: string;
|
|
613
|
+
greeting?: string;
|
|
614
|
+
description?: string;
|
|
615
|
+
/** Replaces the agent's knowledge bases. */
|
|
616
|
+
knowledge_base_ids?: string[];
|
|
617
|
+
/** Replaces the agent's tools (WhatsApp tools it already has are kept). */
|
|
618
|
+
tools?: AgentToolConfig[];
|
|
619
|
+
/** Only `true`: reactivates a deactivated agent. */
|
|
620
|
+
is_active?: true;
|
|
621
|
+
}
|
|
622
|
+
/** Calendar event statuses (lowercase snake_case). */
|
|
623
|
+
type CalendarEventStatus = 'confirmed' | 'cancelled' | 'completed' | 'no_show';
|
|
624
|
+
type CalendarType = 'location' | 'team_member' | 'resource';
|
|
625
|
+
interface EventType {
|
|
626
|
+
/** Pass as `event_type_id` to `calendar.createEvent`. */
|
|
627
|
+
id: string;
|
|
628
|
+
name: string;
|
|
629
|
+
description: string | null;
|
|
630
|
+
duration_minutes: Int;
|
|
631
|
+
buffer_minutes: Int;
|
|
632
|
+
}
|
|
633
|
+
/** An active calendar with its active event types. */
|
|
634
|
+
interface Calendar {
|
|
635
|
+
/** Pass as `calendar_id` to `calendar.createEvent` and `calendar.listEvents`. */
|
|
636
|
+
id: string;
|
|
637
|
+
name: string;
|
|
638
|
+
description: string | null;
|
|
639
|
+
type: CalendarType;
|
|
640
|
+
/** IANA time zone. */
|
|
641
|
+
timezone: string;
|
|
642
|
+
event_types: EventType[];
|
|
643
|
+
}
|
|
644
|
+
/** One block of weekly opening hours of a calendar. */
|
|
645
|
+
interface CalendarAvailabilitySlot {
|
|
646
|
+
/** 0 (Sunday) to 6 (Saturday). */
|
|
647
|
+
day_of_week: Int;
|
|
648
|
+
/** `HH:MM`, 24-hour, in the calendar's time zone. */
|
|
649
|
+
start_time: string;
|
|
650
|
+
/** `HH:MM`, after `start_time`. */
|
|
651
|
+
end_time: string;
|
|
652
|
+
}
|
|
653
|
+
/** A calendar as returned by the calendar writes: the `Calendar` fields plus its state and weekly hours. */
|
|
654
|
+
interface CalendarDetail extends Calendar {
|
|
655
|
+
is_active: boolean;
|
|
656
|
+
/** Weekly opening hours, ordered by day then start time. */
|
|
657
|
+
availability: CalendarAvailabilitySlot[];
|
|
658
|
+
}
|
|
659
|
+
interface EventTypeInput {
|
|
660
|
+
name: string;
|
|
661
|
+
description?: string | null;
|
|
662
|
+
/** 5 to 480. */
|
|
663
|
+
duration_minutes: Int;
|
|
664
|
+
/** 0 to 60. Default 0. */
|
|
665
|
+
buffer_minutes?: Int;
|
|
666
|
+
}
|
|
667
|
+
interface CreateCalendarInput {
|
|
668
|
+
/** 1 to 100 characters. */
|
|
669
|
+
name: string;
|
|
670
|
+
description?: string | null;
|
|
671
|
+
type: CalendarType;
|
|
672
|
+
/** IANA time zone. Default `Europe/Rome`. */
|
|
673
|
+
timezone?: string;
|
|
674
|
+
/** Up to 32 event types to create together with the calendar. */
|
|
675
|
+
event_types?: EventTypeInput[];
|
|
676
|
+
/** Up to 100 weekly opening-hours blocks. */
|
|
677
|
+
availability?: CalendarAvailabilitySlot[];
|
|
678
|
+
}
|
|
679
|
+
interface UpdateCalendarInput {
|
|
680
|
+
name?: string;
|
|
681
|
+
description?: string | null;
|
|
682
|
+
type?: CalendarType;
|
|
683
|
+
timezone?: string;
|
|
684
|
+
/** `false` deactivates the calendar: it leaves `list-calendars` and cannot take new events. `true` reactivates it. */
|
|
685
|
+
is_active?: boolean;
|
|
686
|
+
/** Replaces ALL weekly opening hours; `[]` clears them. Omit to keep them. */
|
|
687
|
+
availability?: CalendarAvailabilitySlot[];
|
|
688
|
+
}
|
|
689
|
+
/** An event type as returned by the event type writes. */
|
|
690
|
+
interface EventTypeDetail extends EventType {
|
|
691
|
+
calendar_id: string;
|
|
692
|
+
is_active: boolean;
|
|
693
|
+
}
|
|
694
|
+
interface CreateEventTypeInput extends EventTypeInput {
|
|
695
|
+
calendar_id: string;
|
|
696
|
+
}
|
|
697
|
+
interface UpdateEventTypeInput {
|
|
698
|
+
name?: string;
|
|
699
|
+
description?: string | null;
|
|
700
|
+
duration_minutes?: Int;
|
|
701
|
+
buffer_minutes?: Int;
|
|
702
|
+
/** `false` deactivates the event type: it leaves `list-calendars`. `true` reactivates it. */
|
|
703
|
+
is_active?: boolean;
|
|
704
|
+
}
|
|
705
|
+
interface ListCalendarEventsParams extends PageParams {
|
|
706
|
+
calendar_id?: string;
|
|
707
|
+
/** Any case is accepted (`confirmed`, `NO_SHOW`, `no_show`). */
|
|
708
|
+
status?: CalendarEventStatus;
|
|
709
|
+
/** RFC 3339 with an offset, lower bound on `start_time`. A malformed value → 400 `validation_error`. */
|
|
710
|
+
date_from?: string;
|
|
711
|
+
/** RFC 3339 with an offset, upper bound on `start_time`. A malformed value → 400 `validation_error`. */
|
|
712
|
+
date_to?: string;
|
|
713
|
+
}
|
|
714
|
+
interface CalendarEvent {
|
|
715
|
+
id: string;
|
|
716
|
+
calendar_id: string;
|
|
717
|
+
event_type_id: string;
|
|
718
|
+
start_time: string;
|
|
719
|
+
end_time: string;
|
|
720
|
+
timezone: string;
|
|
721
|
+
customer_name: string;
|
|
722
|
+
customer_phone: string;
|
|
723
|
+
customer_email: string | null;
|
|
724
|
+
notes: string | null;
|
|
725
|
+
title: string | null;
|
|
726
|
+
location: string | null;
|
|
727
|
+
/** Free-form object stored with the event (see `metadata` on create/update), or `null`. */
|
|
728
|
+
metadata: Record<string, unknown> | null;
|
|
729
|
+
status: CalendarEventStatus;
|
|
730
|
+
booked_via: string | null;
|
|
731
|
+
created_at: string;
|
|
732
|
+
}
|
|
733
|
+
interface CreateCalendarEventInput {
|
|
734
|
+
calendar_id: string;
|
|
735
|
+
event_type_id: string;
|
|
736
|
+
/** RFC 3339 with an offset, e.g. `2026-04-05T14:00:00Z`. Impossible dates (Feb 30, `T24:00`) → 400. */
|
|
737
|
+
start_time: string;
|
|
738
|
+
customer_name: string;
|
|
739
|
+
customer_phone: string;
|
|
740
|
+
customer_email?: string;
|
|
741
|
+
notes?: string;
|
|
742
|
+
title?: string;
|
|
743
|
+
location?: string;
|
|
744
|
+
/** Free-form object, at most 10,000 characters once serialized. Returned as `metadata` on the event. */
|
|
745
|
+
metadata?: Record<string, unknown>;
|
|
746
|
+
}
|
|
747
|
+
/** At least one field is required. `null` clears `customer_email`, `notes`, `title`, `location` and `metadata`. */
|
|
748
|
+
interface UpdateCalendarEventInput {
|
|
749
|
+
/** RFC 3339 with an offset; moves the event (the end follows the event type's duration). Same conflict check as create, ignoring the event itself. */
|
|
750
|
+
start_time?: string;
|
|
751
|
+
customer_name?: string;
|
|
752
|
+
customer_phone?: string;
|
|
753
|
+
customer_email?: string | null;
|
|
754
|
+
notes?: string | null;
|
|
755
|
+
title?: string | null;
|
|
756
|
+
location?: string | null;
|
|
757
|
+
/** Free-form object, at most 10,000 characters once serialized. */
|
|
758
|
+
metadata?: Record<string, unknown> | null;
|
|
759
|
+
}
|
|
760
|
+
interface CreateCalendarEventResponse {
|
|
761
|
+
id: string;
|
|
762
|
+
start_time: string;
|
|
763
|
+
end_time: string;
|
|
764
|
+
status: 'confirmed';
|
|
765
|
+
}
|
|
766
|
+
type MessageChannel = 'sms' | 'whatsapp' | 'email';
|
|
767
|
+
/** Message direction (lowercase). */
|
|
768
|
+
type MessageDirection = 'outbound' | 'inbound';
|
|
769
|
+
/**
|
|
770
|
+
* Message delivery statuses (lowercase). A message only moves forward: `queued` → `sent` →
|
|
771
|
+
* `delivered` → `read`; `failed` (any channel) and `bounced` (email) are final.
|
|
772
|
+
*/
|
|
773
|
+
type MessageStatus = 'queued' | 'sent' | 'delivered' | 'read' | 'failed' | 'bounced';
|
|
774
|
+
interface ListMessagesParams extends PageParams {
|
|
775
|
+
/** Any case is accepted. */
|
|
776
|
+
channel?: MessageChannel;
|
|
777
|
+
/** Any case is accepted. */
|
|
778
|
+
status?: MessageStatus;
|
|
779
|
+
/** Exact recipient (`to_address`): an E.164 number or an email address. */
|
|
780
|
+
to?: string;
|
|
781
|
+
/** RFC 3339 with an offset, lower bound (inclusive) on `created_at`. A malformed value → 400 `validation_error`. */
|
|
782
|
+
date_from?: string;
|
|
783
|
+
/** RFC 3339 with an offset, upper bound (inclusive) on `created_at`. A malformed value → 400 `validation_error`. */
|
|
784
|
+
date_to?: string;
|
|
785
|
+
}
|
|
786
|
+
interface Message {
|
|
787
|
+
id: string;
|
|
788
|
+
channel: MessageChannel;
|
|
789
|
+
direction: MessageDirection;
|
|
790
|
+
status: MessageStatus;
|
|
791
|
+
from_address: string;
|
|
792
|
+
to_address: string;
|
|
793
|
+
subject: string | null;
|
|
794
|
+
body: string;
|
|
795
|
+
/** Provider message id, once the message was handed to the carrier or mail server. */
|
|
796
|
+
external_id: string | null;
|
|
797
|
+
/** Short reason when `status` is `failed` or `bounced`, e.g. `provider rejected the message (error 21211)`; else `null`. */
|
|
798
|
+
error_message: string | null;
|
|
799
|
+
created_at: string;
|
|
800
|
+
/** false when sent with a test (`rpl_test_`) key: simulated, never delivered or billed. See Test mode. */
|
|
801
|
+
livemode: boolean;
|
|
802
|
+
}
|
|
803
|
+
interface SendSmsInput {
|
|
804
|
+
to: string;
|
|
805
|
+
body: string;
|
|
806
|
+
/**
|
|
807
|
+
* Optional. SMS always goes out from your organization's default approved Sender ID; `from` may only
|
|
808
|
+
* name that sender (a phone number or another sender → 422 `sender_not_supported`).
|
|
809
|
+
*/
|
|
810
|
+
from?: string;
|
|
811
|
+
/** Makes the send safe to retry: same key + same body → the same message, never sent twice. Same key + different body → 422 `idempotency_key_reuse`; the `Idempotency-Key` header works too. */
|
|
812
|
+
idempotency_key?: string;
|
|
813
|
+
}
|
|
814
|
+
interface SendWhatsappInput {
|
|
815
|
+
to: string;
|
|
816
|
+
body: string;
|
|
817
|
+
from?: string;
|
|
818
|
+
/** Attachments are not supported: a non-empty array → 422 `media_not_supported`. */
|
|
819
|
+
media_url?: string[];
|
|
820
|
+
/** Makes the send safe to retry: same key + same body → the same message, never sent twice. Same key + different body → 422 `idempotency_key_reuse`; the `Idempotency-Key` header works too. */
|
|
821
|
+
idempotency_key?: string;
|
|
822
|
+
}
|
|
823
|
+
interface SendEmailInput {
|
|
824
|
+
to: string;
|
|
825
|
+
subject: string;
|
|
826
|
+
body: string;
|
|
827
|
+
/** Must be the sender address configured in your SMTP email settings, if given. */
|
|
828
|
+
from?: string;
|
|
829
|
+
/** Makes the send safe to retry: same key + same body → the same message, never sent twice. Same key + different body → 422 `idempotency_key_reuse`; the `Idempotency-Key` header works too. */
|
|
830
|
+
idempotency_key?: string;
|
|
831
|
+
}
|
|
832
|
+
/** Returned (HTTP 202) by every send method: the message is queued, not yet delivered. */
|
|
833
|
+
interface SendMessageResponse {
|
|
834
|
+
/** The message id: read it with `message.get`, find it in `message.list` and in `message.*` webhook events. */
|
|
835
|
+
id: string;
|
|
836
|
+
/** @deprecated Same value as `id`; kept for older integrations. */
|
|
837
|
+
task_id: string;
|
|
838
|
+
channel: MessageChannel;
|
|
839
|
+
/** `queued` for a new send; an idempotent replay returns the message's current status. */
|
|
840
|
+
status: MessageStatus;
|
|
841
|
+
}
|
|
842
|
+
interface CreateTtsInput {
|
|
843
|
+
/** Up to 10,000 characters (Unicode code points; an emoji counts as 1). */
|
|
844
|
+
text: string;
|
|
845
|
+
/** One of the 29 built-in voice names (case-insensitive) or a raw provider voice id. */
|
|
846
|
+
voice?: string;
|
|
847
|
+
language?: string;
|
|
848
|
+
speed?: number;
|
|
849
|
+
stability?: number;
|
|
850
|
+
similarity_boost?: number;
|
|
851
|
+
style?: number;
|
|
852
|
+
/**
|
|
853
|
+
* A retry with the same key (per organization) and body returns the generation already queued
|
|
854
|
+
* (and billed) instead of queueing a second one. Same key, different body → 422
|
|
855
|
+
* `idempotency_key_reuse`. Non-empty, at most 200 characters. The `Idempotency-Key` header works too.
|
|
856
|
+
*/
|
|
857
|
+
idempotency_key?: string;
|
|
858
|
+
}
|
|
859
|
+
interface CreateTtsResponse {
|
|
860
|
+
id: string;
|
|
861
|
+
/** `queued` for a new generation; an idempotent replay returns the generation's current status. */
|
|
862
|
+
status: TtsStatus;
|
|
863
|
+
character_count: Int;
|
|
864
|
+
}
|
|
865
|
+
/** Text-to-speech generation statuses (lowercase). */
|
|
866
|
+
type TtsStatus = 'queued' | 'processing' | 'completed' | 'failed';
|
|
867
|
+
interface ListTtsParams extends PageParams {
|
|
868
|
+
/** Any case is accepted. */
|
|
869
|
+
status?: TtsStatus;
|
|
870
|
+
}
|
|
871
|
+
interface TtsGeneration {
|
|
872
|
+
id: string;
|
|
873
|
+
text: string;
|
|
874
|
+
character_count: Int;
|
|
875
|
+
voice: string;
|
|
876
|
+
language: string;
|
|
877
|
+
speed: number;
|
|
878
|
+
stability: number;
|
|
879
|
+
similarity_boost: number;
|
|
880
|
+
style: number;
|
|
881
|
+
source: string;
|
|
882
|
+
call_id: string | null;
|
|
883
|
+
status: TtsStatus;
|
|
884
|
+
audio_url: string | null;
|
|
885
|
+
audio_duration_seconds: number | null;
|
|
886
|
+
token_cost: number | null;
|
|
887
|
+
error_message: string | null;
|
|
888
|
+
created_at: string;
|
|
889
|
+
/** false when created with a test (`rpl_test_`) key: a silent sample clip, never billed. See Test mode. */
|
|
890
|
+
livemode: boolean;
|
|
891
|
+
completed_at: string | null;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Every event type an endpoint can subscribe to. An endpoint created with an API key receives only
|
|
895
|
+
* the types that key's scopes can read (`call.*` → `calls:read`; `message.*`, `conversation.*`,
|
|
896
|
+
* `contact.opted_out` → `messages:read`; `calendar_event.*` → `calendar:read`). `webhook.test` is
|
|
897
|
+
* sent only by `webhookEndpoint.test`.
|
|
898
|
+
*/
|
|
899
|
+
type WebhookEventType = 'call.ended' | 'call.analyzed' | 'message.received' | 'message.updated' | 'conversation.created' | 'conversation.assigned' | 'conversation.closed' | 'conversation.reopened' | 'calendar_event.created' | 'calendar_event.updated' | 'calendar_event.cancelled' | 'contact.opted_out' | 'webhook.test';
|
|
900
|
+
/** Why an endpoint is disabled (`enabled: false`). */
|
|
901
|
+
type WebhookEndpointDisabledReason = 'manual' | 'consecutive_failures' | 'api_key_revoked' | 'admin';
|
|
902
|
+
/** Who created the endpoint: an API key (`id` = key id) or a dashboard user. */
|
|
903
|
+
interface WebhookEndpointCreatedBy {
|
|
904
|
+
type: 'api_key' | 'user';
|
|
905
|
+
id: string | null;
|
|
906
|
+
}
|
|
907
|
+
interface WebhookEndpoint {
|
|
908
|
+
id: string;
|
|
909
|
+
/** HTTPS URL on a public host. */
|
|
910
|
+
url: string;
|
|
911
|
+
description: string | null;
|
|
912
|
+
/** Subscribed event types, or `["*"]` for every type the creating key can read. */
|
|
913
|
+
events: Array<WebhookEventType | '*'>;
|
|
914
|
+
enabled: boolean;
|
|
915
|
+
/** Set while `enabled` is `false`. */
|
|
916
|
+
disabled_reason: WebhookEndpointDisabledReason | null;
|
|
917
|
+
disabled_at: string | null;
|
|
918
|
+
/** Start of the current failure streak; the endpoint is disabled after 3 days of failures. `null` once a delivery succeeds. */
|
|
919
|
+
failing_since: string | null;
|
|
920
|
+
last_success_at: string | null;
|
|
921
|
+
created_by: WebhookEndpointCreatedBy;
|
|
922
|
+
/** End of the 24-hour overlap during which the previous secret still signs deliveries, after `rotateSecret`. */
|
|
923
|
+
previous_secret_expires_at: string | null;
|
|
924
|
+
created_at: string;
|
|
925
|
+
/** false for an endpoint created with a test (`rpl_test_`) key: it receives only test-mode events; live endpoints receive only live events. */
|
|
926
|
+
livemode: boolean;
|
|
927
|
+
updated_at: string;
|
|
928
|
+
}
|
|
929
|
+
/** Returned by `create` and `rotateSecret` only: the signing secret is shown once. */
|
|
930
|
+
interface WebhookEndpointWithSecret extends WebhookEndpoint {
|
|
931
|
+
/** `whsec_…` signing secret. Store it now: it cannot be read again. */
|
|
932
|
+
secret: string;
|
|
933
|
+
}
|
|
934
|
+
interface CreateWebhookEndpointInput {
|
|
935
|
+
/** HTTPS URL on a public host (no private, loopback or link-local address). Redirects are not followed. */
|
|
936
|
+
url: string;
|
|
937
|
+
/** Non-empty list of event types the key's scopes can read, or `["*"]`. */
|
|
938
|
+
events: Array<WebhookEventType | '*'>;
|
|
939
|
+
description?: string;
|
|
940
|
+
/**
|
|
941
|
+
* A retry with the same key (per organization) and body returns the endpoint already created
|
|
942
|
+
* (with its secret) instead of creating a second one. Same key, different body → 422
|
|
943
|
+
* `idempotency_key_reuse`. The `Idempotency-Key` header works too.
|
|
944
|
+
*/
|
|
945
|
+
idempotency_key?: string;
|
|
946
|
+
}
|
|
947
|
+
/** At least one field. `enabled: true` re-enables a disabled endpoint, except one disabled with `api_key_revoked` (409 `webhook_endpoint_key_revoked`: create a new endpoint) or `admin` (409 `webhook_endpoint_admin_disabled`: contact support). */
|
|
948
|
+
interface UpdateWebhookEndpointInput {
|
|
949
|
+
url?: string;
|
|
950
|
+
events?: Array<WebhookEventType | '*'>;
|
|
951
|
+
/** `null` clears it. */
|
|
952
|
+
description?: string | null;
|
|
953
|
+
enabled?: boolean;
|
|
954
|
+
}
|
|
955
|
+
interface TestWebhookEndpointInput {
|
|
956
|
+
/** Sends a sample event of this type (`livemode: false`). Omitted: a `webhook.test` event with `data: { "object": "test" }`. */
|
|
957
|
+
event_type?: WebhookEventType;
|
|
958
|
+
/**
|
|
959
|
+
* How long to wait for the first attempt, in milliseconds (0 to 12000, default 12000). `0` returns
|
|
960
|
+
* as soon as the test delivery is queued, with `status: 'pending'`; read the outcome from the delivery list.
|
|
961
|
+
*/
|
|
962
|
+
wait_ms?: Int;
|
|
963
|
+
}
|
|
964
|
+
/** Delivery statuses (lowercase). */
|
|
965
|
+
type WebhookDeliveryStatus = 'pending' | 'succeeded' | 'failed' | 'abandoned';
|
|
966
|
+
/** Error classes of a failed attempt. */
|
|
967
|
+
type WebhookDeliveryErrorClass = 'timeout' | 'dns' | 'ssrf_blocked' | 'tls' | 'connect' | 'http_status' | 'redirect' | 'other';
|
|
968
|
+
/** Result of `webhookEndpoint.test`: the test delivery after its single attempt (`succeeded` or `failed`; a test is never retried), or still `pending` after 12 seconds. */
|
|
969
|
+
interface TestWebhookEndpointResponse {
|
|
970
|
+
delivery_id: string;
|
|
971
|
+
event_id: string;
|
|
972
|
+
status: WebhookDeliveryStatus;
|
|
973
|
+
/** HTTP status your endpoint answered, or `null` when no response was received. */
|
|
974
|
+
status_code: Int | null;
|
|
975
|
+
duration_ms: Int | null;
|
|
976
|
+
error_class: WebhookDeliveryErrorClass | null;
|
|
977
|
+
error: string | null;
|
|
978
|
+
/** Start of your endpoint's response body (at most 1 KB). */
|
|
979
|
+
response_excerpt: string | null;
|
|
980
|
+
}
|
|
981
|
+
/** One delivery of one event to one endpoint (retries are attempts of the same delivery; a redelivery is a new one). */
|
|
982
|
+
interface WebhookDelivery {
|
|
983
|
+
/** `whdl_…` id, also sent as the `Replicer-Delivery-Id` header. */
|
|
984
|
+
id: string;
|
|
985
|
+
event_id: string;
|
|
986
|
+
endpoint_id: string;
|
|
987
|
+
event_type: WebhookEventType;
|
|
988
|
+
/** 0 for the automatic delivery, then 1, 2, … for each manual redelivery. */
|
|
989
|
+
seq: Int;
|
|
990
|
+
/** `true` for a redelivery. */
|
|
991
|
+
manual: boolean;
|
|
992
|
+
status: WebhookDeliveryStatus;
|
|
993
|
+
/** Attempts made so far (at most 9). */
|
|
994
|
+
attempts: Int;
|
|
995
|
+
/** When the next attempt is due, while `status` is `pending`. */
|
|
996
|
+
next_attempt_at: string | null;
|
|
997
|
+
last_attempt_at: string | null;
|
|
998
|
+
last_status_code: Int | null;
|
|
999
|
+
last_error_class: WebhookDeliveryErrorClass | null;
|
|
1000
|
+
last_error: string | null;
|
|
1001
|
+
last_duration_ms: Int | null;
|
|
1002
|
+
created_at: string;
|
|
1003
|
+
}
|
|
1004
|
+
interface ListWebhookDeliveriesParams extends PageParams {
|
|
1005
|
+
/** Omit to list the deliveries of every endpoint of the organization. */
|
|
1006
|
+
endpoint_id?: string;
|
|
1007
|
+
event_id?: string;
|
|
1008
|
+
status?: WebhookDeliveryStatus;
|
|
1009
|
+
event_type?: WebhookEventType;
|
|
1010
|
+
/** RFC 3339 with an offset, lower bound on `created_at`. A malformed value → 400 `validation_error`. */
|
|
1011
|
+
created_after?: string;
|
|
1012
|
+
/** RFC 3339 with an offset, upper bound on `created_at`. A malformed value → 400 `validation_error`. */
|
|
1013
|
+
created_before?: string;
|
|
1014
|
+
}
|
|
1015
|
+
interface ListWebhookDeliveryAttemptsParams extends PageParams {
|
|
1016
|
+
/** `whdl_…` id of the delivery. Required. */
|
|
1017
|
+
delivery_id: string;
|
|
1018
|
+
}
|
|
1019
|
+
/** One HTTP attempt of a delivery (oldest first). */
|
|
1020
|
+
interface WebhookDeliveryAttempt {
|
|
1021
|
+
/** 1 for the first attempt, up to 9. */
|
|
1022
|
+
attempt: Int;
|
|
1023
|
+
delivered_at: string;
|
|
1024
|
+
success: boolean;
|
|
1025
|
+
/** HTTP status your endpoint answered, or `null` when no response was received. */
|
|
1026
|
+
status_code: Int | null;
|
|
1027
|
+
duration_ms: Int | null;
|
|
1028
|
+
error_class: WebhookDeliveryErrorClass | null;
|
|
1029
|
+
/** A fixed description of the failure (or `HTTP <status>`); never the raw network error. `null` on success. */
|
|
1030
|
+
error: string | null;
|
|
1031
|
+
/** Start of your endpoint's response body (at most 1 KB). */
|
|
1032
|
+
response_excerpt: string | null;
|
|
1033
|
+
}
|
|
1034
|
+
interface ListEventsParams extends PageParams {
|
|
1035
|
+
type?: WebhookEventType;
|
|
1036
|
+
/** Events about one resource (a call, message, conversation, calendar event or opt-out id). */
|
|
1037
|
+
resource_id?: string;
|
|
1038
|
+
/** RFC 3339 with an offset, lower bound on `created_at`. A malformed value → 400 `validation_error`. */
|
|
1039
|
+
created_after?: string;
|
|
1040
|
+
/** RFC 3339 with an offset, upper bound on `created_at`. A malformed value → 400 `validation_error`. */
|
|
1041
|
+
created_before?: string;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* The event envelope: exactly what is POSTed to your endpoint and what `event.get` / `event.list`
|
|
1045
|
+
* return. Every attempt and redelivery of an event sends the same bytes.
|
|
1046
|
+
*/
|
|
1047
|
+
interface WebhookEvent<T = Record<string, unknown>> {
|
|
1048
|
+
/** `evt_…` id, also sent as the `Replicer-Event-Id` header. De-duplicate on it. */
|
|
1049
|
+
id: string;
|
|
1050
|
+
object: 'event';
|
|
1051
|
+
type: WebhookEventType;
|
|
1052
|
+
/** Version of the payload format, e.g. `2026-11-30`. */
|
|
1053
|
+
api_version: string;
|
|
1054
|
+
/** When the change happened (not when it was delivered). */
|
|
1055
|
+
created_at: string;
|
|
1056
|
+
/**
|
|
1057
|
+
* `false` for events of test mode (resources created with a `rpl_test_` key; sent only to endpoints
|
|
1058
|
+
* created with a test key) and for test sends (`webhookEndpoint.test`).
|
|
1059
|
+
*/
|
|
1060
|
+
livemode: boolean;
|
|
1061
|
+
/** The resource as its `/v1` GET returns it, at the moment of the change. */
|
|
1062
|
+
data: T;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* `WebhookEvent` with an untyped `data`: the response of `event.get` / `event.list` and the
|
|
1066
|
+
* `WebhookEventEnvelope` schema of the OpenAPI document (a generic type cannot be a named schema).
|
|
1067
|
+
*/
|
|
1068
|
+
interface WebhookEventEnvelope extends WebhookEvent<Record<string, unknown>> {
|
|
1069
|
+
}
|
|
1070
|
+
/** `data` of an event whose resource was deleted before the event was rendered. */
|
|
1071
|
+
interface DeletedResource {
|
|
1072
|
+
id: string;
|
|
1073
|
+
object: 'call' | 'message' | 'conversation' | 'calendar_event' | 'opt_out';
|
|
1074
|
+
deleted: true;
|
|
1075
|
+
}
|
|
1076
|
+
/** Conversation channels (lowercase). */
|
|
1077
|
+
type ConversationChannel = 'whatsapp' | 'sms' | 'email';
|
|
1078
|
+
/** Conversation statuses (lowercase). */
|
|
1079
|
+
type ConversationStatus = 'open' | 'closed';
|
|
1080
|
+
/** `data` of `conversation.*` events: one inbox thread with a customer. */
|
|
1081
|
+
interface Conversation {
|
|
1082
|
+
id: string;
|
|
1083
|
+
channel: ConversationChannel;
|
|
1084
|
+
status: ConversationStatus;
|
|
1085
|
+
/** Your side of the thread: the business number (WhatsApp/SMS) or the inbox email address. */
|
|
1086
|
+
endpoint: string;
|
|
1087
|
+
/** The customer's number or email address. */
|
|
1088
|
+
contact_address: string;
|
|
1089
|
+
/** The customer's display name (e.g. the WhatsApp profile name), or `null`. */
|
|
1090
|
+
contact_name: string | null;
|
|
1091
|
+
/** The matching contact, if any. */
|
|
1092
|
+
contact_id: string | null;
|
|
1093
|
+
/** Email subject (email threads only). */
|
|
1094
|
+
subject: string | null;
|
|
1095
|
+
/** Dashboard user the conversation is assigned to, or `null`. */
|
|
1096
|
+
assigned_user_id: string | null;
|
|
1097
|
+
/** Messages not yet read by your team. */
|
|
1098
|
+
unread_count: number;
|
|
1099
|
+
last_message_at: string | null;
|
|
1100
|
+
last_inbound_at: string | null;
|
|
1101
|
+
/** Direction of the last message, or `null` before the first one. */
|
|
1102
|
+
last_message_direction: MessageDirection | null;
|
|
1103
|
+
created_at: string;
|
|
1104
|
+
updated_at: string;
|
|
1105
|
+
}
|
|
1106
|
+
/** How the contact opted out (lowercase). */
|
|
1107
|
+
type OptOutSource = 'keyword' | 'button' | 'manual';
|
|
1108
|
+
/** `data` of `contact.opted_out`: a number that will no longer receive WhatsApp messages from you. */
|
|
1109
|
+
interface OptOut {
|
|
1110
|
+
id: string;
|
|
1111
|
+
/** E.164. */
|
|
1112
|
+
phone: string;
|
|
1113
|
+
source: OptOutSource;
|
|
1114
|
+
created_at: string;
|
|
1115
|
+
}
|
|
1116
|
+
/** `data` of a `webhook.test` event sent without `event_type`. */
|
|
1117
|
+
interface WebhookTestData {
|
|
1118
|
+
object: 'test';
|
|
1119
|
+
}
|
|
1120
|
+
/** `data` type of each event type (a deleted resource arrives as `DeletedResource` instead). */
|
|
1121
|
+
interface WebhookEventDataMap {
|
|
1122
|
+
'call.ended': Call;
|
|
1123
|
+
'call.analyzed': Call;
|
|
1124
|
+
'message.received': Message;
|
|
1125
|
+
'message.updated': Message;
|
|
1126
|
+
'conversation.created': Conversation;
|
|
1127
|
+
'conversation.assigned': Conversation;
|
|
1128
|
+
'conversation.closed': Conversation;
|
|
1129
|
+
'conversation.reopened': Conversation;
|
|
1130
|
+
'calendar_event.created': CalendarEvent;
|
|
1131
|
+
'calendar_event.updated': CalendarEvent;
|
|
1132
|
+
'calendar_event.cancelled': CalendarEvent;
|
|
1133
|
+
'contact.opted_out': OptOut;
|
|
1134
|
+
'webhook.test': WebhookTestData;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Discriminated union of every event: narrow on `type` to get a typed `data`, e.g.
|
|
1138
|
+
* `const event = constructEvent(input) as AnyWebhookEvent`.
|
|
1139
|
+
*/
|
|
1140
|
+
type AnyWebhookEvent = {
|
|
1141
|
+
[K in WebhookEventType]: Omit<WebhookEvent<WebhookEventDataMap[K] | DeletedResource>, 'type'> & {
|
|
1142
|
+
type: K;
|
|
1143
|
+
};
|
|
1144
|
+
}[WebhookEventType];
|
|
1145
|
+
/** A custom API tool of an agent: one LLM function whose calls are POSTed, signed, to `url`. */
|
|
1146
|
+
interface AgentTool {
|
|
1147
|
+
/** `tool_…` id. */
|
|
1148
|
+
id: string;
|
|
1149
|
+
agent_id: string;
|
|
1150
|
+
/** LLM function name, unique per agent: `^[a-z][a-z0-9_]{0,63}$`. */
|
|
1151
|
+
name: string;
|
|
1152
|
+
/** Tells the agent when to use the tool. */
|
|
1153
|
+
description: string;
|
|
1154
|
+
/** HTTPS URL on a public host (port 443). Redirects are not followed. */
|
|
1155
|
+
url: string;
|
|
1156
|
+
/** JSON Schema object (`{ "type": "object", "properties": {…}, "required": […] }`) of the arguments the agent may send. */
|
|
1157
|
+
parameters: Record<string, unknown>;
|
|
1158
|
+
/** Request timeout in milliseconds (1000 to 20000, default 8000). Never retried. */
|
|
1159
|
+
timeout_ms: Int;
|
|
1160
|
+
/** Webhook endpoint whose signing secret signs the requests. The request goes to `url`, not to the endpoint URL. */
|
|
1161
|
+
webhook_endpoint_id: string;
|
|
1162
|
+
/** Whether the agent speaks `execution_message` while the call is running (only if it takes longer than about 0.7 s). */
|
|
1163
|
+
speak_during_execution: boolean;
|
|
1164
|
+
execution_message: string | null;
|
|
1165
|
+
/** What the agent says when the call fails or times out; `null` uses a generic sentence. */
|
|
1166
|
+
error_message: string | null;
|
|
1167
|
+
/** false for a tool created with a test (`rpl_test_`) key. */
|
|
1168
|
+
livemode: boolean;
|
|
1169
|
+
created_by: WebhookEndpointCreatedBy;
|
|
1170
|
+
created_at: string;
|
|
1171
|
+
updated_at: string;
|
|
1172
|
+
}
|
|
1173
|
+
interface CreateAgentToolInput {
|
|
1174
|
+
agent_id: string;
|
|
1175
|
+
name: string;
|
|
1176
|
+
description: string;
|
|
1177
|
+
url: string;
|
|
1178
|
+
/** JSON Schema object. Default: no arguments. */
|
|
1179
|
+
parameters?: Record<string, unknown>;
|
|
1180
|
+
/** 1000 to 20000, default 8000. */
|
|
1181
|
+
timeout_ms?: Int;
|
|
1182
|
+
webhook_endpoint_id: string;
|
|
1183
|
+
speak_during_execution?: boolean;
|
|
1184
|
+
execution_message?: string | null;
|
|
1185
|
+
error_message?: string | null;
|
|
1186
|
+
/**
|
|
1187
|
+
* A retry with the same key (per organization) and body returns the tool already created instead of
|
|
1188
|
+
* creating a second one. Same key, different body → 422 `idempotency_key_reuse`. The `Idempotency-Key`
|
|
1189
|
+
* header works too.
|
|
1190
|
+
*/
|
|
1191
|
+
idempotency_key?: string;
|
|
1192
|
+
}
|
|
1193
|
+
/** At least one field. `agent_id` cannot change. */
|
|
1194
|
+
interface UpdateAgentToolInput {
|
|
1195
|
+
name?: string;
|
|
1196
|
+
description?: string;
|
|
1197
|
+
url?: string;
|
|
1198
|
+
parameters?: Record<string, unknown>;
|
|
1199
|
+
timeout_ms?: Int;
|
|
1200
|
+
webhook_endpoint_id?: string;
|
|
1201
|
+
speak_during_execution?: boolean;
|
|
1202
|
+
/** `null` clears it. */
|
|
1203
|
+
execution_message?: string | null;
|
|
1204
|
+
/** `null` clears it. */
|
|
1205
|
+
error_message?: string | null;
|
|
1206
|
+
}
|
|
1207
|
+
interface ListAgentToolsParams extends PageParams {
|
|
1208
|
+
agent_id: string;
|
|
1209
|
+
}
|
|
1210
|
+
interface TestAgentToolInput {
|
|
1211
|
+
/** Sample arguments for the test call. Default `{}`. */
|
|
1212
|
+
arguments?: Record<string, unknown>;
|
|
1213
|
+
}
|
|
1214
|
+
/** Result of `agentTool.test`: one signed sample call to the tool URL. */
|
|
1215
|
+
interface TestAgentToolResponse {
|
|
1216
|
+
status: 'succeeded' | 'failed';
|
|
1217
|
+
latency_ms: Int;
|
|
1218
|
+
/** HTTP status your server answered, or `null` when no response was received. */
|
|
1219
|
+
response_status: Int | null;
|
|
1220
|
+
/** Start of your server's response body (at most 1 KB), only when it is a JSON object with a `result` key; any other body is not returned. */
|
|
1221
|
+
response_body_truncated: string | null;
|
|
1222
|
+
/** Fixed error sentence when `status` is `failed` (or a `2xx` answer has no `result`), else `null`. */
|
|
1223
|
+
error: string | null;
|
|
1224
|
+
}
|
|
1225
|
+
/** The JSON body Replicer POSTs to a tool URL. Verify `Replicer-Signature` before trusting it. */
|
|
1226
|
+
interface ToolCall<Args = Record<string, unknown>> {
|
|
1227
|
+
/** `tcall_…`, unique per invocation, also sent as `Replicer-Tool-Call-Id`. Use it for idempotency. */
|
|
1228
|
+
id: string;
|
|
1229
|
+
object: 'tool_call';
|
|
1230
|
+
created_at: string;
|
|
1231
|
+
tool: {
|
|
1232
|
+
id: string;
|
|
1233
|
+
name: string;
|
|
1234
|
+
};
|
|
1235
|
+
agent: {
|
|
1236
|
+
id: string;
|
|
1237
|
+
};
|
|
1238
|
+
call: {
|
|
1239
|
+
id: string;
|
|
1240
|
+
direction: 'inbound' | 'outbound' | 'web';
|
|
1241
|
+
from: string | null;
|
|
1242
|
+
to: string | null;
|
|
1243
|
+
};
|
|
1244
|
+
arguments: Args;
|
|
1245
|
+
}
|
|
1246
|
+
/** What your server answers with (2xx). `result` is read to the agent as data. */
|
|
1247
|
+
interface ToolCallResponse {
|
|
1248
|
+
result: unknown;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
export type { UpdateCalendarEventInput as $, ListAgentsParams as A, Agent as B, CreatePhoneCallInput as C, AgentDetail as D, EnqueueCallResponse as E, FailFileInput as F, GetCampaignResponse as G, CreateAgentInput as H, ImportPhoneNumberInput as I, UpdateAgentInput as J, KnowledgeBaseCreateInput as K, ListCallsParams as L, Calendar as M, CreateCalendarInput as N, OkResponse as O, Page as P, CalendarDetail as Q, UpdateCalendarInput as R, SimulateInboundCallInput as S, CreateEventTypeInput as T, UpdatePhoneNumberInput as U, EventTypeDetail as V, UpdateEventTypeInput as W, ListCalendarEventsParams as X, CalendarEvent as Y, CreateCalendarEventInput as Z, CreateCalendarEventResponse as _, SimulateInboundCallResponse as a, MessageChannel as a$, ListMessagesParams as a0, Message as a1, SendSmsInput as a2, SendMessageResponse as a3, SendWhatsappInput as a4, SendEmailInput as a5, CreateTtsInput as a6, CreateTtsResponse as a7, ListTtsParams as a8, TtsGeneration as a9, CallDirection as aA, CallSentiment as aB, CallStatus as aC, CampaignListItem as aD, CampaignStatus as aE, CancelCallInput as aF, CancelCampaignPendingInput as aG, ContactIdentityConflict as aH, ContactIdentityType as aI, Conversation as aJ, ConversationChannel as aK, ConversationStatus as aL, CreateCampaignResponse as aM, DeleteKnowledgeBaseSourceParams as aN, DeletedResource as aO, DeprovisionInboundParams as aP, DeprovisionInboundRemaining as aQ, EventType as aR, EventTypeInput as aS, Int as aT, KnowledgeBaseChunk as aU, KnowledgeBaseRejectedUrl as aV, KnowledgeBaseSourceSummary as aW, KnowledgeBaseStatus as aX, KnowledgeBaseTextSource as aY, KnowledgeSourceStatus as aZ, KnowledgeSourceType as a_, CreateWebhookEndpointInput as aa, WebhookEndpointWithSecret as ab, WebhookEndpoint as ac, UpdateWebhookEndpointInput as ad, TestWebhookEndpointInput as ae, TestWebhookEndpointResponse as af, ListWebhookDeliveriesParams as ag, WebhookDelivery as ah, ListWebhookDeliveryAttemptsParams as ai, WebhookDeliveryAttempt as aj, CreateAgentToolInput as ak, AgentTool as al, ListAgentToolsParams as am, UpdateAgentToolInput as an, TestAgentToolInput as ao, TestAgentToolResponse as ap, ListEventsParams as aq, WebhookEvent as ar, AgentTemplate as as, AgentToolConfig as at, AgentType as au, AnyWebhookEvent as av, ApiErrorCode as aw, CalendarAvailabilitySlot as ax, CalendarEventStatus as ay, CalendarType as az, CancelCampaignPendingResponse as b, MessageDirection as b0, MessageStatus as b1, OptOut as b2, OptOutSource as b3, Pagination as b4, PhoneNumberType as b5, ToolCall as b6, ToolCallResponse as b7, TtsStatus as b8, WebhookDeliveryErrorClass as b9, WebhookDeliveryStatus as ba, WebhookEndpointCreatedBy as bb, WebhookEndpointDisabledReason as bc, WebhookEventDataMap as bd, WebhookEventEnvelope as be, WebhookEventType as bf, WebhookTestData as bg, Call as c, CreateCampaignInput as d, Campaign as e, ListCampaignsParams as f, StartCampaignResponse as g, PageParams as h, PhoneNumber as i, ProvisionInboundInput as j, ProvisionInboundResponse as k, KnowledgeBaseSourcesResponse as l, KnowledgeBaseResponse as m, KnowledgeBaseListResponse as n, KnowledgeBaseAddSourcesInput as o, KnowledgeBaseUpdateInput as p, PresignFileInput as q, PresignFileResponse as r, UpdateSourceInput as s, UpdateChunkInput as t, KnowledgeBaseSourceDetail as u, PresignFileDownloadResponse as v, ListContactsParams as w, Contact as x, CreateContactInput as y, CreateContactResponse as z };
|