@replicer/sdk 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +114 -2
- package/dist/index.cjs +299 -0
- package/dist/index.d.cts +818 -0
- package/dist/index.d.ts +818 -0
- package/dist/index.js +269 -0
- package/dist/webhooks.cjs +45 -0
- package/dist/webhooks.d.cts +23 -0
- package/dist/webhooks.d.ts +23 -0
- package/dist/webhooks.js +20 -0
- package/package.json +71 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,818 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response types of the Replicer API (`/v1`). Field names are the wire format (snake_case).
|
|
3
|
+
*/
|
|
4
|
+
interface PageParams {
|
|
5
|
+
/** 1-based page number (default 1). */
|
|
6
|
+
page?: number;
|
|
7
|
+
/** Page size, 1..100 (default 20). */
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
interface Pagination {
|
|
11
|
+
page: number;
|
|
12
|
+
limit: number;
|
|
13
|
+
total: number;
|
|
14
|
+
total_pages: number;
|
|
15
|
+
}
|
|
16
|
+
/** Envelope returned by every list method. */
|
|
17
|
+
interface Page<T> {
|
|
18
|
+
data: T[];
|
|
19
|
+
pagination: Pagination;
|
|
20
|
+
}
|
|
21
|
+
interface OkResponse {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `code` values the API returns in its flat error body `{ error, code }`. Branch on `code`, never on
|
|
26
|
+
* the human-readable `error` text. New codes may be added; fall back to the HTTP status.
|
|
27
|
+
*/
|
|
28
|
+
type ApiErrorCode = 'validation_error' | 'bad_request' | 'unauthorized' | 'forbidden' | 'insufficient_scope' | 'not_found' | 'method_not_allowed' | 'conflict' | '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 & {});
|
|
29
|
+
interface CreatePhoneCallInput {
|
|
30
|
+
/** Agent id; must belong to your organization. */
|
|
31
|
+
agent_id: string;
|
|
32
|
+
/**
|
|
33
|
+
* Phone number id (see `phoneNumber.list`). Selects the caller ID. Required unless the agent has a
|
|
34
|
+
* default phone number. A number of another organization → 404 `not_found`.
|
|
35
|
+
*/
|
|
36
|
+
from_number_id?: string;
|
|
37
|
+
/** Informational only: it does not select the caller ID. Use `from_number_id`. */
|
|
38
|
+
from_number?: string;
|
|
39
|
+
to_number: string;
|
|
40
|
+
/** Sparse override merged on top of the stored agent. */
|
|
41
|
+
agent_override?: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* `{{name}}` substitutions for the prompt, greeting and voicemail message. Up to 100 entries,
|
|
44
|
+
* names `[a-zA-Z_][a-zA-Z0-9_]{0,63}`, values up to 5,000 characters; `null` becomes an empty string.
|
|
45
|
+
* Wins over `agent_override.dynamicVariables`, which wins over the agent's own variables.
|
|
46
|
+
*/
|
|
47
|
+
dynamic_variables?: Record<string, string | number | boolean | null>;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* RFC 3339 date-time **with an offset** (`2026-05-01T09:30:00Z` or `+02:00`); the call is scheduled
|
|
51
|
+
* instead of dialed immediately. A past time dials immediately; an invalid one → 400.
|
|
52
|
+
*/
|
|
53
|
+
scheduled_at?: string;
|
|
54
|
+
customer_name?: string;
|
|
55
|
+
/** 0..5 (default 0). Retries repeat the original call (same number, override and metadata). */
|
|
56
|
+
max_retries?: number;
|
|
57
|
+
/** 5..1440 minutes. */
|
|
58
|
+
retry_delay_minutes?: number;
|
|
59
|
+
/**
|
|
60
|
+
* A retry with the same key (per organization) returns the call already created and never dials
|
|
61
|
+
* again. A call that failed to enqueue stays failed: retry with a new key.
|
|
62
|
+
*/
|
|
63
|
+
idempotency_key?: string;
|
|
64
|
+
}
|
|
65
|
+
interface EnqueueCallResponse {
|
|
66
|
+
call_id: string;
|
|
67
|
+
/** `pending` or `scheduled` for a new call; a replay of an `idempotency_key` returns the call's current status. */
|
|
68
|
+
status: 'pending' | 'scheduled' | (string & {});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* `cancel-campaign-pending` first pauses the campaign (RUNNING / SCHEDULED → PAUSED), then cancels its
|
|
72
|
+
* pending and queued calls. Resume with `campaign.start`; contacts whose call was cancelled are not redialed.
|
|
73
|
+
*/
|
|
74
|
+
interface CancelCampaignPendingResponse {
|
|
75
|
+
ok: boolean;
|
|
76
|
+
calls_cancelled: number;
|
|
77
|
+
calls_marked: number;
|
|
78
|
+
queue_removed: number;
|
|
79
|
+
/** Campaign status after the call, e.g. `PAUSED`. */
|
|
80
|
+
campaign_status: string | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Call statuses. Final states: `analyzed` (the normal end state once post-call analysis is done),
|
|
84
|
+
* `completed` (ended, analysis pending), `failed`, `cancelled`, `missed`, `error`.
|
|
85
|
+
*/
|
|
86
|
+
type CallStatus = 'pending' | 'scheduled' | 'queued' | 'retry' | 'in-progress' | 'completed' | 'analyzed' | 'failed' | 'cancelled' | 'missed' | 'error';
|
|
87
|
+
interface ListCallsParams extends PageParams {
|
|
88
|
+
status?: CallStatus | (string & {});
|
|
89
|
+
direction?: string;
|
|
90
|
+
/** ISO 8601 lower bound on `started_at`. */
|
|
91
|
+
date_from?: string;
|
|
92
|
+
/** ISO 8601 upper bound on `started_at`. */
|
|
93
|
+
date_to?: string;
|
|
94
|
+
}
|
|
95
|
+
interface Call {
|
|
96
|
+
id: string;
|
|
97
|
+
customer_name: string | null;
|
|
98
|
+
customer_phone: string | null;
|
|
99
|
+
duration: number | null;
|
|
100
|
+
status: CallStatus | (string & {});
|
|
101
|
+
direction: string | null;
|
|
102
|
+
disconnection_reason: string | null;
|
|
103
|
+
sentiment: string | null;
|
|
104
|
+
summary: string | null;
|
|
105
|
+
/** Only returned by `call.get`; list items omit it. */
|
|
106
|
+
transcript?: unknown;
|
|
107
|
+
recording: string | null;
|
|
108
|
+
call_successful: boolean | null;
|
|
109
|
+
token_cost: number | null;
|
|
110
|
+
agent_id: string | null;
|
|
111
|
+
campaign_id: string | null;
|
|
112
|
+
started_at: string | null;
|
|
113
|
+
ended_at: string | null;
|
|
114
|
+
scheduled_at: string | null;
|
|
115
|
+
created_at: string | null;
|
|
116
|
+
}
|
|
117
|
+
interface CreateCampaignInput {
|
|
118
|
+
name: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
user_agent_id: string;
|
|
121
|
+
/** Ignored for API keys (the campaign is attributed to your organization's owner). Only trusted internal callers need it. */
|
|
122
|
+
user_id?: string;
|
|
123
|
+
from_phone_number_id?: string;
|
|
124
|
+
from_number_attempts?: string[];
|
|
125
|
+
from_number_strategy?: 'rolling' | 'clamp' | 'custom';
|
|
126
|
+
contact_attempt_strategy?: 'rolling' | 'clamp' | 'custom';
|
|
127
|
+
/** Non-empty; every contact needs `phone_number`. Up to 100,000 (and the 10 MiB body limit). */
|
|
128
|
+
contacts: Record<string, unknown>[];
|
|
129
|
+
variable_mapping?: Record<string, string>;
|
|
130
|
+
/** RFC 3339 with an offset; invalid → 400. */
|
|
131
|
+
scheduled_at?: string;
|
|
132
|
+
/** 0..5 (default 0). */
|
|
133
|
+
max_retries?: number;
|
|
134
|
+
/** 5..1440 (default 30). */
|
|
135
|
+
retry_delay_minutes?: number;
|
|
136
|
+
/** Unique integers 0..6 (0 = Sunday); `[]` = every day. */
|
|
137
|
+
calling_days?: number[];
|
|
138
|
+
/** `HH:MM`; set both or neither, start before end. */
|
|
139
|
+
calling_start_time?: string;
|
|
140
|
+
calling_end_time?: string;
|
|
141
|
+
/** IANA time zone (default `Europe/Rome`). */
|
|
142
|
+
timezone?: string;
|
|
143
|
+
/** 1..100 and at most your plan's concurrency. */
|
|
144
|
+
max_concurrency?: number | null;
|
|
145
|
+
/** 0..50 and at most your plan's concurrency. */
|
|
146
|
+
keep_free_for_inbound?: number;
|
|
147
|
+
}
|
|
148
|
+
interface CreateCampaignResponse {
|
|
149
|
+
success: boolean;
|
|
150
|
+
campaign: Campaign;
|
|
151
|
+
}
|
|
152
|
+
interface GetCampaignResponse {
|
|
153
|
+
success: boolean;
|
|
154
|
+
campaign: Campaign & {
|
|
155
|
+
/** Up to 1,000 contacts, in campaign order. */
|
|
156
|
+
contacts: Record<string, unknown>[];
|
|
157
|
+
/** True when the campaign has more contacts than returned (`contact_count` > `contacts.length`). */
|
|
158
|
+
contacts_truncated: boolean;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
interface ListCampaignsParams extends PageParams {
|
|
162
|
+
/** DRAFT | SCHEDULED | RUNNING | PAUSED | COMPLETED | CANCELLED (case-insensitive). */
|
|
163
|
+
status?: string;
|
|
164
|
+
}
|
|
165
|
+
/** Campaign as returned by create, get and list (the same field whitelist everywhere). */
|
|
166
|
+
interface Campaign {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string | null;
|
|
170
|
+
status: string;
|
|
171
|
+
agent_id: string;
|
|
172
|
+
from_phone_number_id: string | null;
|
|
173
|
+
/** E.164 caller ID (the campaign's number). */
|
|
174
|
+
from_number: string | null;
|
|
175
|
+
/** E.164 caller IDs, in order. */
|
|
176
|
+
from_number_attempts: string[] | null;
|
|
177
|
+
from_number_strategy: string | null;
|
|
178
|
+
contact_attempt_strategy: string | null;
|
|
179
|
+
total_contacts: number;
|
|
180
|
+
contact_count: number;
|
|
181
|
+
variable_mapping: Record<string, string> | null;
|
|
182
|
+
max_retries: number;
|
|
183
|
+
retry_delay_minutes: number;
|
|
184
|
+
max_concurrency: number | null;
|
|
185
|
+
keep_free_for_inbound: number;
|
|
186
|
+
calling_days: number[] | null;
|
|
187
|
+
calling_start_time: string | null;
|
|
188
|
+
calling_end_time: string | null;
|
|
189
|
+
timezone: string;
|
|
190
|
+
calls_started: number;
|
|
191
|
+
calls_completed: number;
|
|
192
|
+
calls_failed: number;
|
|
193
|
+
scheduled_at: string | null;
|
|
194
|
+
started_at: string | null;
|
|
195
|
+
completed_at: string | null;
|
|
196
|
+
created_at: string | null;
|
|
197
|
+
updated_at: string | null;
|
|
198
|
+
}
|
|
199
|
+
/** @deprecated Use `Campaign`. */
|
|
200
|
+
type CampaignListItem = Campaign;
|
|
201
|
+
interface StartCampaignResponse {
|
|
202
|
+
id: string;
|
|
203
|
+
status: 'RUNNING';
|
|
204
|
+
}
|
|
205
|
+
interface ProvisionInboundInput {
|
|
206
|
+
/** Phone number id. */
|
|
207
|
+
id: string;
|
|
208
|
+
label?: string;
|
|
209
|
+
from_number: string;
|
|
210
|
+
}
|
|
211
|
+
interface ProvisionInboundResponse {
|
|
212
|
+
inbound_trunk_id: string;
|
|
213
|
+
inbound_dispatch_rule_id: string;
|
|
214
|
+
}
|
|
215
|
+
interface PhoneNumber {
|
|
216
|
+
/** Pass as `from_number_id` to `call.createPhoneCall` and as `id` to the inbound routes. */
|
|
217
|
+
id: string;
|
|
218
|
+
/** E.164. */
|
|
219
|
+
phone_number: string;
|
|
220
|
+
label: string | null;
|
|
221
|
+
country: string | null;
|
|
222
|
+
number_type: string | null;
|
|
223
|
+
is_active: boolean;
|
|
224
|
+
inbound_agent_id: string | null;
|
|
225
|
+
inbound_enabled: boolean;
|
|
226
|
+
created_at: string;
|
|
227
|
+
}
|
|
228
|
+
/** `remaining` in the 502 `bad_gateway` body when only part of an inbound deprovision succeeded. */
|
|
229
|
+
interface DeprovisionInboundRemaining {
|
|
230
|
+
trunk_id?: string;
|
|
231
|
+
rule_id?: string;
|
|
232
|
+
}
|
|
233
|
+
/** Up to 50 per request; `text` non-empty, at most 100 KB (1 MB total per request). */
|
|
234
|
+
interface KnowledgeBaseTextSource {
|
|
235
|
+
title?: string;
|
|
236
|
+
text: string;
|
|
237
|
+
}
|
|
238
|
+
/** A URL whose host did not resolve: skipped instead of failing the whole request. */
|
|
239
|
+
interface KnowledgeBaseRejectedUrl {
|
|
240
|
+
url: string;
|
|
241
|
+
reason: string;
|
|
242
|
+
}
|
|
243
|
+
interface KnowledgeBaseCreateInput {
|
|
244
|
+
knowledge_base_name?: string;
|
|
245
|
+
name?: string;
|
|
246
|
+
description?: string;
|
|
247
|
+
knowledge_base_urls?: string[];
|
|
248
|
+
knowledge_base_texts?: KnowledgeBaseTextSource[];
|
|
249
|
+
chunks_to_retrieve?: number;
|
|
250
|
+
similarity_threshold?: number;
|
|
251
|
+
instruction?: string;
|
|
252
|
+
use_llm_extraction?: boolean;
|
|
253
|
+
}
|
|
254
|
+
interface KnowledgeBaseUpdateInput {
|
|
255
|
+
name?: string;
|
|
256
|
+
description?: string | null;
|
|
257
|
+
chunks_to_retrieve?: number;
|
|
258
|
+
similarity_threshold?: number;
|
|
259
|
+
instruction?: string | null;
|
|
260
|
+
use_llm_extraction?: boolean;
|
|
261
|
+
}
|
|
262
|
+
interface KnowledgeBaseAddSourcesInput {
|
|
263
|
+
knowledge_base_urls?: string[];
|
|
264
|
+
knowledge_base_texts?: KnowledgeBaseTextSource[];
|
|
265
|
+
}
|
|
266
|
+
interface KnowledgeBaseSourceSummary {
|
|
267
|
+
source_id: string;
|
|
268
|
+
type: string;
|
|
269
|
+
title: string;
|
|
270
|
+
url?: string | null;
|
|
271
|
+
status: string;
|
|
272
|
+
error?: string | null;
|
|
273
|
+
chunk_count: number;
|
|
274
|
+
filename?: string | null;
|
|
275
|
+
}
|
|
276
|
+
interface KnowledgeBaseResponse {
|
|
277
|
+
knowledge_base_id: string;
|
|
278
|
+
knowledge_base_name: string;
|
|
279
|
+
name: string;
|
|
280
|
+
description?: string | null;
|
|
281
|
+
status: string;
|
|
282
|
+
chunks_to_retrieve: number;
|
|
283
|
+
similarity_threshold: number;
|
|
284
|
+
instruction?: string | null;
|
|
285
|
+
use_llm_extraction: boolean;
|
|
286
|
+
source_count: number;
|
|
287
|
+
knowledge_base_sources: KnowledgeBaseSourceSummary[];
|
|
288
|
+
sources: KnowledgeBaseSourceSummary[];
|
|
289
|
+
created_at: string;
|
|
290
|
+
updated_at: string;
|
|
291
|
+
}
|
|
292
|
+
/** Returned by `knowledgeBase.create` and `knowledgeBase.addSources`. */
|
|
293
|
+
interface KnowledgeBaseSourcesResponse extends KnowledgeBaseResponse {
|
|
294
|
+
rejected_urls: KnowledgeBaseRejectedUrl[];
|
|
295
|
+
}
|
|
296
|
+
interface KnowledgeBaseListResponse {
|
|
297
|
+
knowledge_bases: KnowledgeBaseResponse[];
|
|
298
|
+
}
|
|
299
|
+
interface PresignFileInput {
|
|
300
|
+
filename: string;
|
|
301
|
+
mime_type: string;
|
|
302
|
+
/** Exact upload size in bytes: the presigned URL signs it, so the PUT body must match. */
|
|
303
|
+
size_bytes: number;
|
|
304
|
+
title?: string;
|
|
305
|
+
}
|
|
306
|
+
interface PresignFileResponse {
|
|
307
|
+
source_id: string;
|
|
308
|
+
upload_url: string;
|
|
309
|
+
required_headers: Record<string, string>;
|
|
310
|
+
expires_in: number;
|
|
311
|
+
storage_key: string;
|
|
312
|
+
}
|
|
313
|
+
interface FailFileInput {
|
|
314
|
+
error?: string;
|
|
315
|
+
}
|
|
316
|
+
interface UpdateSourceInput {
|
|
317
|
+
extracted_markdown?: string;
|
|
318
|
+
title?: string;
|
|
319
|
+
}
|
|
320
|
+
interface UpdateChunkInput {
|
|
321
|
+
enabled?: boolean;
|
|
322
|
+
relevance_weight?: number;
|
|
323
|
+
}
|
|
324
|
+
interface KnowledgeBaseChunk {
|
|
325
|
+
id: string;
|
|
326
|
+
chunk_index: number;
|
|
327
|
+
content: string;
|
|
328
|
+
enabled: boolean;
|
|
329
|
+
relevance_weight: number;
|
|
330
|
+
}
|
|
331
|
+
interface KnowledgeBaseSourceDetail {
|
|
332
|
+
id: string;
|
|
333
|
+
knowledge_base_id: string;
|
|
334
|
+
type: string;
|
|
335
|
+
title: string;
|
|
336
|
+
url: string | null;
|
|
337
|
+
filename: string | null;
|
|
338
|
+
mime_type: string | null;
|
|
339
|
+
size_bytes: number | null;
|
|
340
|
+
raw_text: string | null;
|
|
341
|
+
extracted_markdown: string | null;
|
|
342
|
+
status: string;
|
|
343
|
+
error: string | null;
|
|
344
|
+
chunk_count: number;
|
|
345
|
+
chunks: KnowledgeBaseChunk[];
|
|
346
|
+
}
|
|
347
|
+
interface PresignFileDownloadResponse {
|
|
348
|
+
download_url: string;
|
|
349
|
+
expires_in: number;
|
|
350
|
+
filename: string;
|
|
351
|
+
mime_type: string | null;
|
|
352
|
+
}
|
|
353
|
+
interface ListContactsParams extends PageParams {
|
|
354
|
+
/** Case-insensitive match on name, phone, email or company. */
|
|
355
|
+
search?: string;
|
|
356
|
+
}
|
|
357
|
+
interface Contact {
|
|
358
|
+
id: string;
|
|
359
|
+
first_name: string | null;
|
|
360
|
+
last_name: string | null;
|
|
361
|
+
company: string | null;
|
|
362
|
+
job_title: string | null;
|
|
363
|
+
phone_number: string | null;
|
|
364
|
+
email: string | null;
|
|
365
|
+
street: string | null;
|
|
366
|
+
city: string | null;
|
|
367
|
+
state: string | null;
|
|
368
|
+
postal_code: string | null;
|
|
369
|
+
country: string | null;
|
|
370
|
+
website: string | null;
|
|
371
|
+
birthday: string | null;
|
|
372
|
+
notes: string | null;
|
|
373
|
+
created_at: string;
|
|
374
|
+
updated_at: string;
|
|
375
|
+
}
|
|
376
|
+
/** At least one of `first_name` / `last_name` is required. */
|
|
377
|
+
interface CreateContactInput {
|
|
378
|
+
first_name?: string;
|
|
379
|
+
last_name?: string;
|
|
380
|
+
company?: string;
|
|
381
|
+
job_title?: string;
|
|
382
|
+
phone_number?: string;
|
|
383
|
+
email?: string;
|
|
384
|
+
street?: string;
|
|
385
|
+
city?: string;
|
|
386
|
+
state?: string;
|
|
387
|
+
postal_code?: string;
|
|
388
|
+
country?: string;
|
|
389
|
+
website?: string;
|
|
390
|
+
notes?: string;
|
|
391
|
+
}
|
|
392
|
+
interface ContactIdentityConflict {
|
|
393
|
+
type: 'PHONE' | 'EMAIL';
|
|
394
|
+
value: string;
|
|
395
|
+
/** The contact that already owns this address (it is not reassigned). */
|
|
396
|
+
owner_contact_id: string;
|
|
397
|
+
}
|
|
398
|
+
interface CreateContactResponse {
|
|
399
|
+
id: string;
|
|
400
|
+
first_name: string;
|
|
401
|
+
last_name: string;
|
|
402
|
+
/** Usually empty. */
|
|
403
|
+
identity_conflicts: ContactIdentityConflict[];
|
|
404
|
+
}
|
|
405
|
+
interface Agent {
|
|
406
|
+
id: string;
|
|
407
|
+
agent_name: string;
|
|
408
|
+
agent_type: string;
|
|
409
|
+
call_direction: string | null;
|
|
410
|
+
voice_id: string | null;
|
|
411
|
+
language: string | null;
|
|
412
|
+
is_active: boolean;
|
|
413
|
+
/** The agent's default outbound phone number id, if any. */
|
|
414
|
+
phone_number_id: string | null;
|
|
415
|
+
created_at: string;
|
|
416
|
+
}
|
|
417
|
+
type CalendarEventStatus = 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NO_SHOW';
|
|
418
|
+
interface ListCalendarEventsParams extends PageParams {
|
|
419
|
+
calendar_id?: string;
|
|
420
|
+
status?: CalendarEventStatus;
|
|
421
|
+
/** RFC 3339 lower bound on `start_time`; unparseable values are ignored by the API. */
|
|
422
|
+
date_from?: string;
|
|
423
|
+
/** RFC 3339 upper bound on `start_time`; unparseable values are ignored by the API. */
|
|
424
|
+
date_to?: string;
|
|
425
|
+
}
|
|
426
|
+
interface CalendarEvent {
|
|
427
|
+
id: string;
|
|
428
|
+
calendar_id: string;
|
|
429
|
+
event_type_id: string;
|
|
430
|
+
start_time: string;
|
|
431
|
+
end_time: string;
|
|
432
|
+
timezone: string;
|
|
433
|
+
customer_name: string;
|
|
434
|
+
customer_phone: string;
|
|
435
|
+
customer_email: string | null;
|
|
436
|
+
notes: string | null;
|
|
437
|
+
title: string | null;
|
|
438
|
+
location: string | null;
|
|
439
|
+
status: string;
|
|
440
|
+
booked_via: string | null;
|
|
441
|
+
created_at: string;
|
|
442
|
+
}
|
|
443
|
+
interface CreateCalendarEventInput {
|
|
444
|
+
calendar_id: string;
|
|
445
|
+
event_type_id: string;
|
|
446
|
+
/** RFC 3339 with an offset, e.g. `2026-04-05T14:00:00Z`. Impossible dates (Feb 30, `T24:00`) → 400. */
|
|
447
|
+
start_time: string;
|
|
448
|
+
customer_name: string;
|
|
449
|
+
customer_phone: string;
|
|
450
|
+
customer_email?: string;
|
|
451
|
+
notes?: string;
|
|
452
|
+
title?: string;
|
|
453
|
+
location?: string;
|
|
454
|
+
}
|
|
455
|
+
interface CreateCalendarEventResponse {
|
|
456
|
+
id: string;
|
|
457
|
+
start_time: string;
|
|
458
|
+
end_time: string;
|
|
459
|
+
status: 'CONFIRMED';
|
|
460
|
+
}
|
|
461
|
+
type MessageChannel = 'sms' | 'whatsapp' | 'email';
|
|
462
|
+
interface ListMessagesParams extends PageParams {
|
|
463
|
+
channel?: MessageChannel;
|
|
464
|
+
}
|
|
465
|
+
interface Message {
|
|
466
|
+
id: string;
|
|
467
|
+
channel: 'SMS' | 'WHATSAPP' | 'EMAIL' | (string & {});
|
|
468
|
+
direction: string;
|
|
469
|
+
status: string;
|
|
470
|
+
from_address: string;
|
|
471
|
+
to_address: string;
|
|
472
|
+
subject: string | null;
|
|
473
|
+
body: string;
|
|
474
|
+
external_id: string | null;
|
|
475
|
+
error_message: string | null;
|
|
476
|
+
created_at: string;
|
|
477
|
+
}
|
|
478
|
+
interface SendSmsInput {
|
|
479
|
+
to: string;
|
|
480
|
+
body: string;
|
|
481
|
+
/**
|
|
482
|
+
* Optional. SMS always goes out from your organization's default approved Sender ID; `from` may only
|
|
483
|
+
* name that sender (a phone number or another sender → 422 `sender_not_supported`).
|
|
484
|
+
*/
|
|
485
|
+
from?: string;
|
|
486
|
+
}
|
|
487
|
+
interface SendWhatsappInput {
|
|
488
|
+
to: string;
|
|
489
|
+
body: string;
|
|
490
|
+
from?: string;
|
|
491
|
+
/** Attachments are not supported: a non-empty array → 422 `media_not_supported`. */
|
|
492
|
+
media_url?: string[];
|
|
493
|
+
}
|
|
494
|
+
interface SendEmailInput {
|
|
495
|
+
to: string;
|
|
496
|
+
subject: string;
|
|
497
|
+
body: string;
|
|
498
|
+
/** Must be the sender address configured in your SMTP email settings, if given. */
|
|
499
|
+
from?: string;
|
|
500
|
+
}
|
|
501
|
+
/** Returned (HTTP 202) by every send method: the message is queued, not yet delivered. */
|
|
502
|
+
interface SendMessageResponse {
|
|
503
|
+
task_id: string;
|
|
504
|
+
channel: MessageChannel;
|
|
505
|
+
status: 'queued';
|
|
506
|
+
}
|
|
507
|
+
interface CreateTtsInput {
|
|
508
|
+
/** Up to 10,000 characters (Unicode code points; an emoji counts as 1). */
|
|
509
|
+
text: string;
|
|
510
|
+
/** One of the 29 built-in voice names (case-insensitive) or a raw provider voice id. */
|
|
511
|
+
voice?: string;
|
|
512
|
+
language?: string;
|
|
513
|
+
speed?: number;
|
|
514
|
+
stability?: number;
|
|
515
|
+
similarity_boost?: number;
|
|
516
|
+
style?: number;
|
|
517
|
+
}
|
|
518
|
+
interface CreateTtsResponse {
|
|
519
|
+
id: string;
|
|
520
|
+
status: 'queued';
|
|
521
|
+
character_count: number;
|
|
522
|
+
}
|
|
523
|
+
interface ListTtsParams extends PageParams {
|
|
524
|
+
status?: string;
|
|
525
|
+
}
|
|
526
|
+
interface TtsGeneration {
|
|
527
|
+
id: string;
|
|
528
|
+
text: string;
|
|
529
|
+
character_count: number;
|
|
530
|
+
voice: string;
|
|
531
|
+
language: string;
|
|
532
|
+
speed: number;
|
|
533
|
+
stability: number;
|
|
534
|
+
similarity_boost: number;
|
|
535
|
+
style: number;
|
|
536
|
+
source: string;
|
|
537
|
+
call_id: string | null;
|
|
538
|
+
status: string;
|
|
539
|
+
audio_url: string | null;
|
|
540
|
+
audio_duration_seconds: number | null;
|
|
541
|
+
token_cost: number | null;
|
|
542
|
+
error_message: string | null;
|
|
543
|
+
created_at: string;
|
|
544
|
+
completed_at: string | null;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
declare const DEFAULT_BASE_URL = "https://api.replicer.ai";
|
|
548
|
+
interface ReplicerOptions {
|
|
549
|
+
/** Your API key. Keep it server-side. */
|
|
550
|
+
apiKey: string;
|
|
551
|
+
/** Override the API host. Defaults to `https://api.replicer.ai`. */
|
|
552
|
+
baseURL?: string;
|
|
553
|
+
/** Custom `fetch` (tests, proxies, older runtimes). Defaults to the global `fetch`. */
|
|
554
|
+
fetch?: typeof fetch;
|
|
555
|
+
}
|
|
556
|
+
declare class Replicer {
|
|
557
|
+
private readonly apiKey;
|
|
558
|
+
private readonly baseURL;
|
|
559
|
+
private readonly fetchImpl;
|
|
560
|
+
constructor(options: ReplicerOptions);
|
|
561
|
+
readonly call: {
|
|
562
|
+
createPhoneCall: (input: CreatePhoneCallInput) => Promise<EnqueueCallResponse>;
|
|
563
|
+
cancel: (call_id: string) => Promise<OkResponse>;
|
|
564
|
+
cancelCampaignPending: (campaign_id: string) => Promise<CancelCampaignPendingResponse>;
|
|
565
|
+
list: (params?: ListCallsParams) => Promise<Page<Call>>;
|
|
566
|
+
get: (id: string) => Promise<Call>;
|
|
567
|
+
};
|
|
568
|
+
readonly campaign: {
|
|
569
|
+
create: (input: CreateCampaignInput) => Promise<CreateCampaignResponse>;
|
|
570
|
+
/** Includes up to 1,000 contacts (`contacts_truncated` tells whether there are more). */
|
|
571
|
+
get: (id: string) => Promise<GetCampaignResponse>;
|
|
572
|
+
list: (params?: ListCampaignsParams) => Promise<Page<Campaign>>;
|
|
573
|
+
/** Starts a campaign, or resumes one paused by `call.cancelCampaignPending`. */
|
|
574
|
+
start: (id: string) => Promise<StartCampaignResponse>;
|
|
575
|
+
};
|
|
576
|
+
readonly phoneNumber: {
|
|
577
|
+
/** Your organization's phone numbers; `id` is the `from_number_id` for `call.createPhoneCall`. */
|
|
578
|
+
list: (params?: PageParams) => Promise<Page<PhoneNumber>>;
|
|
579
|
+
provisionInbound: (input: ProvisionInboundInput) => Promise<ProvisionInboundResponse>;
|
|
580
|
+
deprovisionInbound: (id: string, trunk_id: string, rule_id: string) => Promise<OkResponse>;
|
|
581
|
+
};
|
|
582
|
+
readonly knowledgeBase: {
|
|
583
|
+
create: (input: KnowledgeBaseCreateInput) => Promise<KnowledgeBaseSourcesResponse>;
|
|
584
|
+
retrieve: (knowledgeBaseId: string) => Promise<KnowledgeBaseResponse>;
|
|
585
|
+
list: () => Promise<KnowledgeBaseListResponse>;
|
|
586
|
+
delete: (knowledgeBaseId: string) => Promise<void>;
|
|
587
|
+
addSources: (knowledgeBaseId: string, input: KnowledgeBaseAddSourcesInput) => Promise<KnowledgeBaseSourcesResponse>;
|
|
588
|
+
deleteSource: (sourceId: string, knowledgeBaseId: string) => Promise<KnowledgeBaseResponse>;
|
|
589
|
+
update: (knowledgeBaseId: string, input: KnowledgeBaseUpdateInput) => Promise<KnowledgeBaseResponse>;
|
|
590
|
+
presignFile: (knowledgeBaseId: string, input: PresignFileInput) => Promise<PresignFileResponse>;
|
|
591
|
+
completeFile: (knowledgeBaseId: string, sourceId: string) => Promise<KnowledgeBaseResponse>;
|
|
592
|
+
failFile: (knowledgeBaseId: string, sourceId: string, input?: FailFileInput) => Promise<KnowledgeBaseResponse>;
|
|
593
|
+
reindex: (knowledgeBaseId: string) => Promise<KnowledgeBaseResponse>;
|
|
594
|
+
updateSource: (knowledgeBaseId: string, sourceId: string, input: UpdateSourceInput) => Promise<KnowledgeBaseResponse>;
|
|
595
|
+
updateChunk: (knowledgeBaseId: string, chunkId: string, input: UpdateChunkInput) => Promise<OkResponse>;
|
|
596
|
+
getSource: (knowledgeBaseId: string, sourceId: string) => Promise<KnowledgeBaseSourceDetail>;
|
|
597
|
+
presignFileDownload: (knowledgeBaseId: string, sourceId: string) => Promise<PresignFileDownloadResponse>;
|
|
598
|
+
};
|
|
599
|
+
readonly contact: {
|
|
600
|
+
list: (params?: ListContactsParams) => Promise<Page<Contact>>;
|
|
601
|
+
create: (input: CreateContactInput) => Promise<CreateContactResponse>;
|
|
602
|
+
};
|
|
603
|
+
readonly agent: {
|
|
604
|
+
list: (params?: PageParams) => Promise<Page<Agent>>;
|
|
605
|
+
};
|
|
606
|
+
readonly calendar: {
|
|
607
|
+
listEvents: (params?: ListCalendarEventsParams) => Promise<Page<CalendarEvent>>;
|
|
608
|
+
createEvent: (input: CreateCalendarEventInput) => Promise<CreateCalendarEventResponse>;
|
|
609
|
+
};
|
|
610
|
+
readonly message: {
|
|
611
|
+
list: (params?: ListMessagesParams) => Promise<Page<Message>>;
|
|
612
|
+
sendSms: (input: SendSmsInput) => Promise<SendMessageResponse>;
|
|
613
|
+
sendWhatsapp: (input: SendWhatsappInput) => Promise<SendMessageResponse>;
|
|
614
|
+
sendEmail: (input: SendEmailInput) => Promise<SendMessageResponse>;
|
|
615
|
+
};
|
|
616
|
+
readonly tts: {
|
|
617
|
+
create: (input: CreateTtsInput) => Promise<CreateTtsResponse>;
|
|
618
|
+
list: (params?: ListTtsParams) => Promise<Page<TtsGeneration>>;
|
|
619
|
+
get: (id: string) => Promise<TtsGeneration>;
|
|
620
|
+
};
|
|
621
|
+
private request;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** Thrown for every non-2xx response, network failure or unparseable 2xx response. */
|
|
625
|
+
declare class ReplicerError extends Error {
|
|
626
|
+
/** HTTP status code (0 when the request never produced a response). */
|
|
627
|
+
readonly status: number;
|
|
628
|
+
/** `body.code` when the API sent one, else `network_error`, `invalid_response` or `http_<status>`. */
|
|
629
|
+
readonly code: string;
|
|
630
|
+
/** Parsed JSON error body, or the raw response text when it was not JSON. */
|
|
631
|
+
readonly body: unknown;
|
|
632
|
+
/** Request path (without the base URL or query string). */
|
|
633
|
+
readonly path: string;
|
|
634
|
+
/** `x-request-id` response header, when present. */
|
|
635
|
+
readonly requestId: string | undefined;
|
|
636
|
+
/** Seconds to wait before retrying (from `Retry-After` on a 429), when provided. */
|
|
637
|
+
readonly retryAfter: number | undefined;
|
|
638
|
+
constructor(init: {
|
|
639
|
+
status: number;
|
|
640
|
+
code: string;
|
|
641
|
+
message: string;
|
|
642
|
+
body?: unknown;
|
|
643
|
+
path?: string;
|
|
644
|
+
requestId?: string;
|
|
645
|
+
retryAfter?: number;
|
|
646
|
+
cause?: unknown;
|
|
647
|
+
});
|
|
648
|
+
/** Best human-readable message: the API's `error` string, else the raw text body, else `message`. */
|
|
649
|
+
get errorMessage(): string;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* HTTP surface of the SDK. Every SDK method is driven by one entry (looked up by `sdk`), and
|
|
654
|
+
* `test/contract.test.ts` checks this table against the public route list
|
|
655
|
+
* (`microservices/internal/apiserver/proxy_routes.json`) so the two cannot drift. `:name` segments
|
|
656
|
+
* are path params (URL-encoded by the client).
|
|
657
|
+
*/
|
|
658
|
+
declare const ROUTES: readonly [{
|
|
659
|
+
readonly method: "POST";
|
|
660
|
+
readonly path: "/v1/create-phone-call";
|
|
661
|
+
readonly sdk: "call.createPhoneCall";
|
|
662
|
+
}, {
|
|
663
|
+
readonly method: "POST";
|
|
664
|
+
readonly path: "/v1/cancel-call";
|
|
665
|
+
readonly sdk: "call.cancel";
|
|
666
|
+
}, {
|
|
667
|
+
readonly method: "POST";
|
|
668
|
+
readonly path: "/v1/cancel-campaign-pending";
|
|
669
|
+
readonly sdk: "call.cancelCampaignPending";
|
|
670
|
+
}, {
|
|
671
|
+
readonly method: "GET";
|
|
672
|
+
readonly path: "/v1/list-calls";
|
|
673
|
+
readonly sdk: "call.list";
|
|
674
|
+
}, {
|
|
675
|
+
readonly method: "GET";
|
|
676
|
+
readonly path: "/v1/get-call/:id";
|
|
677
|
+
readonly sdk: "call.get";
|
|
678
|
+
}, {
|
|
679
|
+
readonly method: "POST";
|
|
680
|
+
readonly path: "/v1/campaigns";
|
|
681
|
+
readonly sdk: "campaign.create";
|
|
682
|
+
}, {
|
|
683
|
+
readonly method: "GET";
|
|
684
|
+
readonly path: "/v1/campaigns/:id";
|
|
685
|
+
readonly sdk: "campaign.get";
|
|
686
|
+
}, {
|
|
687
|
+
readonly method: "GET";
|
|
688
|
+
readonly path: "/v1/list-campaigns";
|
|
689
|
+
readonly sdk: "campaign.list";
|
|
690
|
+
}, {
|
|
691
|
+
readonly method: "POST";
|
|
692
|
+
readonly path: "/v1/start-campaign/:id";
|
|
693
|
+
readonly sdk: "campaign.start";
|
|
694
|
+
}, {
|
|
695
|
+
readonly method: "GET";
|
|
696
|
+
readonly path: "/v1/list-phone-numbers";
|
|
697
|
+
readonly sdk: "phoneNumber.list";
|
|
698
|
+
}, {
|
|
699
|
+
readonly method: "POST";
|
|
700
|
+
readonly path: "/v1/phone-numbers/inbound";
|
|
701
|
+
readonly sdk: "phoneNumber.provisionInbound";
|
|
702
|
+
}, {
|
|
703
|
+
readonly method: "DELETE";
|
|
704
|
+
readonly path: "/v1/phone-numbers/inbound/:id";
|
|
705
|
+
readonly sdk: "phoneNumber.deprovisionInbound";
|
|
706
|
+
}, {
|
|
707
|
+
readonly method: "POST";
|
|
708
|
+
readonly path: "/v1/create-knowledge-base";
|
|
709
|
+
readonly sdk: "knowledgeBase.create";
|
|
710
|
+
}, {
|
|
711
|
+
readonly method: "GET";
|
|
712
|
+
readonly path: "/v1/get-knowledge-base/:id";
|
|
713
|
+
readonly sdk: "knowledgeBase.retrieve";
|
|
714
|
+
}, {
|
|
715
|
+
readonly method: "GET";
|
|
716
|
+
readonly path: "/v1/list-knowledge-bases";
|
|
717
|
+
readonly sdk: "knowledgeBase.list";
|
|
718
|
+
}, {
|
|
719
|
+
readonly method: "DELETE";
|
|
720
|
+
readonly path: "/v1/delete-knowledge-base/:id";
|
|
721
|
+
readonly sdk: "knowledgeBase.delete";
|
|
722
|
+
}, {
|
|
723
|
+
readonly method: "POST";
|
|
724
|
+
readonly path: "/v1/add-knowledge-base-sources/:id";
|
|
725
|
+
readonly sdk: "knowledgeBase.addSources";
|
|
726
|
+
}, {
|
|
727
|
+
readonly method: "DELETE";
|
|
728
|
+
readonly path: "/v1/delete-knowledge-base-source/:source_id";
|
|
729
|
+
readonly sdk: "knowledgeBase.deleteSource";
|
|
730
|
+
}, {
|
|
731
|
+
readonly method: "PATCH";
|
|
732
|
+
readonly path: "/v1/update-knowledge-base/:id";
|
|
733
|
+
readonly sdk: "knowledgeBase.update";
|
|
734
|
+
}, {
|
|
735
|
+
readonly method: "POST";
|
|
736
|
+
readonly path: "/v1/presign-knowledge-base-file/:id";
|
|
737
|
+
readonly sdk: "knowledgeBase.presignFile";
|
|
738
|
+
}, {
|
|
739
|
+
readonly method: "POST";
|
|
740
|
+
readonly path: "/v1/complete-knowledge-base-file/:id/:source_id";
|
|
741
|
+
readonly sdk: "knowledgeBase.completeFile";
|
|
742
|
+
}, {
|
|
743
|
+
readonly method: "POST";
|
|
744
|
+
readonly path: "/v1/fail-knowledge-base-file/:id/:source_id";
|
|
745
|
+
readonly sdk: "knowledgeBase.failFile";
|
|
746
|
+
}, {
|
|
747
|
+
readonly method: "PUT";
|
|
748
|
+
readonly path: "/v1/reindex-knowledge-base/:id";
|
|
749
|
+
readonly sdk: "knowledgeBase.reindex";
|
|
750
|
+
}, {
|
|
751
|
+
readonly method: "PATCH";
|
|
752
|
+
readonly path: "/v1/update-knowledge-base-source/:id/:source_id";
|
|
753
|
+
readonly sdk: "knowledgeBase.updateSource";
|
|
754
|
+
}, {
|
|
755
|
+
readonly method: "PATCH";
|
|
756
|
+
readonly path: "/v1/update-knowledge-base-chunk/:id/:chunk_id";
|
|
757
|
+
readonly sdk: "knowledgeBase.updateChunk";
|
|
758
|
+
}, {
|
|
759
|
+
readonly method: "GET";
|
|
760
|
+
readonly path: "/v1/get-knowledge-base-source/:id/:source_id";
|
|
761
|
+
readonly sdk: "knowledgeBase.getSource";
|
|
762
|
+
}, {
|
|
763
|
+
readonly method: "GET";
|
|
764
|
+
readonly path: "/v1/presign-knowledge-base-file-download/:id/:source_id";
|
|
765
|
+
readonly sdk: "knowledgeBase.presignFileDownload";
|
|
766
|
+
}, {
|
|
767
|
+
readonly method: "GET";
|
|
768
|
+
readonly path: "/v1/list-contacts";
|
|
769
|
+
readonly sdk: "contact.list";
|
|
770
|
+
}, {
|
|
771
|
+
readonly method: "POST";
|
|
772
|
+
readonly path: "/v1/create-contact";
|
|
773
|
+
readonly sdk: "contact.create";
|
|
774
|
+
}, {
|
|
775
|
+
readonly method: "GET";
|
|
776
|
+
readonly path: "/v1/list-agents";
|
|
777
|
+
readonly sdk: "agent.list";
|
|
778
|
+
}, {
|
|
779
|
+
readonly method: "GET";
|
|
780
|
+
readonly path: "/v1/list-calendar-events";
|
|
781
|
+
readonly sdk: "calendar.listEvents";
|
|
782
|
+
}, {
|
|
783
|
+
readonly method: "POST";
|
|
784
|
+
readonly path: "/v1/create-calendar-event";
|
|
785
|
+
readonly sdk: "calendar.createEvent";
|
|
786
|
+
}, {
|
|
787
|
+
readonly method: "GET";
|
|
788
|
+
readonly path: "/v1/list-messages";
|
|
789
|
+
readonly sdk: "message.list";
|
|
790
|
+
}, {
|
|
791
|
+
readonly method: "POST";
|
|
792
|
+
readonly path: "/v1/send-sms";
|
|
793
|
+
readonly sdk: "message.sendSms";
|
|
794
|
+
}, {
|
|
795
|
+
readonly method: "POST";
|
|
796
|
+
readonly path: "/v1/send-whatsapp";
|
|
797
|
+
readonly sdk: "message.sendWhatsapp";
|
|
798
|
+
}, {
|
|
799
|
+
readonly method: "POST";
|
|
800
|
+
readonly path: "/v1/send-email";
|
|
801
|
+
readonly sdk: "message.sendEmail";
|
|
802
|
+
}, {
|
|
803
|
+
readonly method: "POST";
|
|
804
|
+
readonly path: "/v1/create-tts";
|
|
805
|
+
readonly sdk: "tts.create";
|
|
806
|
+
}, {
|
|
807
|
+
readonly method: "GET";
|
|
808
|
+
readonly path: "/v1/list-tts";
|
|
809
|
+
readonly sdk: "tts.list";
|
|
810
|
+
}, {
|
|
811
|
+
readonly method: "GET";
|
|
812
|
+
readonly path: "/v1/get-tts/:id";
|
|
813
|
+
readonly sdk: "tts.get";
|
|
814
|
+
}];
|
|
815
|
+
type RouteDef = (typeof ROUTES)[number];
|
|
816
|
+
type SdkMethodName = RouteDef['sdk'];
|
|
817
|
+
|
|
818
|
+
export { type Agent, type ApiErrorCode, type CalendarEvent, type CalendarEventStatus, type Call, type CallStatus, type Campaign, type CampaignListItem, type CancelCampaignPendingResponse, type Contact, type ContactIdentityConflict, type CreateCalendarEventInput, type CreateCalendarEventResponse, type CreateCampaignInput, type CreateCampaignResponse, type CreateContactInput, type CreateContactResponse, type CreatePhoneCallInput, type CreateTtsInput, type CreateTtsResponse, DEFAULT_BASE_URL, type DeprovisionInboundRemaining, type EnqueueCallResponse, type FailFileInput, type GetCampaignResponse, type KnowledgeBaseAddSourcesInput, type KnowledgeBaseChunk, type KnowledgeBaseCreateInput, type KnowledgeBaseListResponse, type KnowledgeBaseRejectedUrl, type KnowledgeBaseResponse, type KnowledgeBaseSourceDetail, type KnowledgeBaseSourceSummary, type KnowledgeBaseSourcesResponse, type KnowledgeBaseTextSource, type KnowledgeBaseUpdateInput, type ListCalendarEventsParams, type ListCallsParams, type ListCampaignsParams, type ListContactsParams, type ListMessagesParams, type ListTtsParams, type Message, type MessageChannel, type OkResponse, type Page, type PageParams, type Pagination, type PhoneNumber, type PresignFileDownloadResponse, type PresignFileInput, type PresignFileResponse, type ProvisionInboundInput, type ProvisionInboundResponse, ROUTES, Replicer, ReplicerError, type ReplicerOptions, type RouteDef, type SdkMethodName, type SendEmailInput, type SendMessageResponse, type SendSmsInput, type SendWhatsappInput, type StartCampaignResponse, type TtsGeneration, type UpdateChunkInput, type UpdateSourceInput };
|