@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
package/README.md
CHANGED
|
@@ -45,30 +45,38 @@ Parameters and response fields are **snake_case**, exactly as on the wire.
|
|
|
45
45
|
|----------|---------|
|
|
46
46
|
| `replicer.call` | `createPhoneCall`, `cancel`, `cancelCampaignPending`, `list`, `get` |
|
|
47
47
|
| `replicer.campaign` | `create`, `get`, `list`, `start` |
|
|
48
|
-
| `replicer.phoneNumber` | `provisionInbound`, `deprovisionInbound` |
|
|
48
|
+
| `replicer.phoneNumber` | `list`, `provisionInbound`, `deprovisionInbound`, `update` |
|
|
49
49
|
| `replicer.knowledgeBase` | `create`, `retrieve`, `list`, `delete`, `addSources`, `deleteSource`, `update`, `presignFile`, `completeFile`, `failFile`, `reindex`, `updateSource`, `updateChunk`, `getSource`, `presignFileDownload` |
|
|
50
50
|
| `replicer.contact` | `list`, `create` |
|
|
51
51
|
| `replicer.agent` | `list` |
|
|
52
|
-
| `replicer.calendar` | `listEvents`, `createEvent` |
|
|
53
|
-
| `replicer.message` | `list`, `sendSms`, `sendWhatsapp`, `sendEmail` |
|
|
52
|
+
| `replicer.calendar` | `listCalendars`, `listEvents`, `createEvent`, `updateEvent`, `cancelEvent` |
|
|
53
|
+
| `replicer.message` | `list`, `get`, `sendSms`, `sendWhatsapp`, `sendEmail` |
|
|
54
54
|
| `replicer.tts` | `create`, `list`, `get` |
|
|
55
|
+
| `replicer.webhookEndpoint` | `create`, `list`, `get`, `update`, `delete`, `rotateSecret`, `test`, `listDeliveries`, `listDeliveryAttempts`, `redeliver` |
|
|
56
|
+
| `replicer.event` | `list`, `get` |
|
|
55
57
|
|
|
56
58
|
Single-resource methods resolve to the JSON body exactly as the API returns it (for example `createPhoneCall` resolves to `{ call_id, status }`). List methods resolve to `{ data, pagination: { page, limit, total, total_pages } }` and accept `page` / `limit` (1..100, default 20) plus resource filters:
|
|
57
59
|
|
|
58
60
|
```ts
|
|
59
61
|
await replicer.call.list({ status: 'completed', direction: 'outbound', date_from: '2026-01-01T00:00:00Z' })
|
|
60
|
-
await replicer.campaign.list({ status: '
|
|
62
|
+
await replicer.campaign.list({ status: 'running' })
|
|
61
63
|
await replicer.contact.list({ search: 'ann' })
|
|
62
|
-
await replicer.calendar.listEvents({ calendar_id: 'cal_1', status: '
|
|
63
|
-
await replicer.message.list({ channel: 'sms' })
|
|
64
|
+
await replicer.calendar.listEvents({ calendar_id: 'cal_1', status: 'confirmed', date_from: '2026-01-01T00:00:00Z' })
|
|
65
|
+
await replicer.message.list({ channel: 'sms', status: 'failed', date_from: '2026-11-01T00:00:00Z' })
|
|
64
66
|
await replicer.tts.list({ status: 'completed' })
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
Deleting a knowledge base resolves to `undefined` (HTTP 204).
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
`message.send*` methods queue the message and resolve to `{ id, task_id, channel, status: 'queued' }`: follow it with `message.get(id)` or the `message.updated` webhook (`task_id` is a deprecated alias of `id`). `tts.create` resolves to `{ id, status: 'queued', character_count }` (poll with `tts.get`).
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
## Idempotency
|
|
74
|
+
|
|
75
|
+
`call.createPhoneCall`, `campaign.create`, `message.sendSms` / `sendWhatsapp` / `sendEmail`, `tts.create` and `webhookEndpoint.create` accept an `idempotency_key`. A retry with the same key and the same body returns what the first request created and never creates, sends or bills twice; the same key with a different body rejects with `422 idempotency_key_reuse`.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
await replicer.message.sendSms({ to: '+39111111111', body: 'See you at 3pm', idempotency_key: `reminder-${appointmentId}` })
|
|
79
|
+
```
|
|
72
80
|
|
|
73
81
|
## Errors
|
|
74
82
|
|
|
@@ -94,22 +102,78 @@ new Replicer({
|
|
|
94
102
|
})
|
|
95
103
|
```
|
|
96
104
|
|
|
97
|
-
##
|
|
105
|
+
## Webhooks
|
|
106
|
+
|
|
107
|
+
Manage endpoints with `replicer.webhookEndpoint` (scope `webhooks:manage`). The signing secret is returned only by `create` and `rotateSecret`:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const endpoint = await replicer.webhookEndpoint.create({
|
|
111
|
+
url: 'https://example.com/replicer/webhooks',
|
|
112
|
+
events: ['call.ended', 'call.analyzed', 'message.updated'],
|
|
113
|
+
})
|
|
114
|
+
saveSecret(endpoint.secret) // whsec_…, shown once
|
|
115
|
+
|
|
116
|
+
const result = await replicer.webhookEndpoint.test(endpoint.id, { event_type: 'call.ended' })
|
|
117
|
+
console.log(result.status, result.status_code)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Every delivery is signed: `Replicer-Signature: t=<unix seconds>,v1=<hex>`, where `v1` is the hex HMAC-SHA256 of `"{t}.{raw body}"` with the endpoint secret. Verify it with the server-only subpath (it uses `node:crypto`, so the main entry stays edge/browser-bundle friendly):
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { constructEvent, WebhookSignatureError } from '@replicer/sdk/webhooks'
|
|
124
|
+
import type { AnyWebhookEvent } from '@replicer/sdk'
|
|
125
|
+
|
|
126
|
+
app.post('/replicer/webhooks', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
127
|
+
let event: AnyWebhookEvent
|
|
128
|
+
try {
|
|
129
|
+
event = constructEvent({
|
|
130
|
+
payload: req.body, // raw body (Buffer or string), never re-serialized JSON
|
|
131
|
+
header: req.header('replicer-signature'),
|
|
132
|
+
secret: process.env.REPLICER_WEBHOOK_SECRET!, // or secrets: [newSecret, oldSecret] during a rotation
|
|
133
|
+
}) as AnyWebhookEvent
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
if (err instanceof WebhookSignatureError) return res.status(400).end()
|
|
137
|
+
throw err
|
|
138
|
+
}
|
|
139
|
+
if (await alreadyProcessed(event.id)) return res.status(200).end() // at-least-once: de-duplicate on event.id
|
|
140
|
+
res.status(200).end()
|
|
141
|
+
// …handle event.type / event.data
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`constructEvent` also throws `WebhookSignatureError` for a correctly signed body that is not an event (`object` other than `"event"`), so a signed [API tool call](#api-tools) cannot pass as one. `verifyWebhookSignature({ payload, header, secret | secrets, toleranceSeconds = 300 })` returns a boolean instead of throwing. Signatures older (or newer) than `toleranceSeconds` are rejected.
|
|
146
|
+
|
|
147
|
+
## API tools
|
|
148
|
+
|
|
149
|
+
Give an agent a custom function with `replicer.agentTool` (scopes `agent_tools:read` / `agent_tools:write`). Calls are POSTed to your URL, signed like webhooks with the secret of the webhook endpoint you pick:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
await replicer.agentTool.create({
|
|
153
|
+
agent_id: 'agent_…',
|
|
154
|
+
name: 'book_table',
|
|
155
|
+
description: 'Books a table for the caller',
|
|
156
|
+
url: 'https://example.com/replicer/tools',
|
|
157
|
+
webhook_endpoint_id: endpoint.id,
|
|
158
|
+
parameters: { type: 'object', properties: { time: { type: 'string' } }, required: ['time'] },
|
|
159
|
+
})
|
|
160
|
+
```
|
|
98
161
|
|
|
99
|
-
|
|
162
|
+
Answer them with the server-only `@replicer/sdk/tools` subpath. `createToolHandler` takes a Fetch-API `Request` (Next.js, Hono, Workers, Bun); `handleToolCall` is the Express / plain Node variant returning `{ status, body }`:
|
|
100
163
|
|
|
101
164
|
```ts
|
|
102
|
-
import {
|
|
165
|
+
import { createToolHandler } from '@replicer/sdk/tools'
|
|
103
166
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
167
|
+
export const POST = createToolHandler({
|
|
168
|
+
secret: process.env.REPLICER_WEBHOOK_SECRET!, // or secrets: [newSecret, oldSecret] during a rotation
|
|
169
|
+
tools: {
|
|
170
|
+
book_table: async (args: { time: string }, call) => ({ booked: true, id: call.id }),
|
|
171
|
+
},
|
|
108
172
|
})
|
|
109
173
|
```
|
|
110
174
|
|
|
111
|
-
It
|
|
175
|
+
It answers `{ "result": … }`, 401 for a bad signature, 404 for an unknown tool and a generic 500 when a tool throws. `verifyToolCall({ payload, header, secret })` verifies and parses a call yourself (throws `ToolSignatureError`).
|
|
112
176
|
|
|
113
177
|
## Route table
|
|
114
178
|
|
|
115
|
-
`ROUTES` (`{ method, path, sdk }[]`) is exported and drives every SDK method; it is checked against the
|
|
179
|
+
`ROUTES` (`{ method, path, sdk, request, response, status, errors }[]`) is exported and drives every SDK method; it is checked against the public route table in CI.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/signature.ts
|
|
2
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
|
3
|
+
var SIGNATURE_HEADER = "Replicer-Signature";
|
|
4
|
+
var DEFAULT_TOLERANCE_SECONDS = 300;
|
|
5
|
+
var HEX_SHA256 = /^[0-9a-f]{64}$/i;
|
|
6
|
+
var UNIX_SECONDS = /^\d{1,12}$/;
|
|
7
|
+
function parseHeader(header) {
|
|
8
|
+
let timestamp = null;
|
|
9
|
+
const signatures = [];
|
|
10
|
+
for (const part of header.split(",")) {
|
|
11
|
+
const eq = part.indexOf("=");
|
|
12
|
+
if (eq <= 0) continue;
|
|
13
|
+
const key = part.slice(0, eq).trim();
|
|
14
|
+
const value = part.slice(eq + 1).trim();
|
|
15
|
+
if (key === "t") {
|
|
16
|
+
if (timestamp !== null || !UNIX_SECONDS.test(value)) return null;
|
|
17
|
+
timestamp = Number(value);
|
|
18
|
+
} else if (key === "v1" && HEX_SHA256.test(value)) {
|
|
19
|
+
signatures.push(Buffer.from(value, "hex"));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (timestamp === null || signatures.length === 0) return null;
|
|
23
|
+
return { timestamp, signatures };
|
|
24
|
+
}
|
|
25
|
+
function sign(secret, timestamp, payload) {
|
|
26
|
+
return createHmac("sha256", secret).update(`${timestamp}.`).update(payload).digest();
|
|
27
|
+
}
|
|
28
|
+
function verifySignatureHeader(input) {
|
|
29
|
+
if (!input || typeof input.header !== "string") return false;
|
|
30
|
+
const payload = input.payload;
|
|
31
|
+
if (typeof payload !== "string" && !(payload instanceof Uint8Array)) return false;
|
|
32
|
+
const secrets = [input.secret, ...Array.isArray(input.secrets) ? input.secrets : []].filter((s) => typeof s === "string" && s !== "");
|
|
33
|
+
if (secrets.length === 0) return false;
|
|
34
|
+
const parsed = parseHeader(input.header);
|
|
35
|
+
if (!parsed) return false;
|
|
36
|
+
const tolerance = typeof input.toleranceSeconds === "number" && Number.isFinite(input.toleranceSeconds) && input.toleranceSeconds >= 0 ? input.toleranceSeconds : DEFAULT_TOLERANCE_SECONDS;
|
|
37
|
+
const nowMs = (input.now ?? /* @__PURE__ */ new Date()).getTime();
|
|
38
|
+
if (!Number.isFinite(nowMs)) return false;
|
|
39
|
+
if (Math.abs(nowMs / 1e3 - parsed.timestamp) > tolerance) return false;
|
|
40
|
+
let match = false;
|
|
41
|
+
for (const secret of secrets) {
|
|
42
|
+
const expected = sign(secret, parsed.timestamp, payload);
|
|
43
|
+
for (const received of parsed.signatures) {
|
|
44
|
+
if (timingSafeEqual(expected, received)) match = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return match;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
SIGNATURE_HEADER,
|
|
52
|
+
DEFAULT_TOLERANCE_SECONDS,
|
|
53
|
+
verifySignatureHeader
|
|
54
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -63,45 +63,78 @@ var ReplicerError = class extends Error {
|
|
|
63
63
|
|
|
64
64
|
// src/routes.ts
|
|
65
65
|
var ROUTES = [
|
|
66
|
-
{ method: "POST", path: "/v1/create-phone-call", sdk: "call.createPhoneCall" },
|
|
67
|
-
{ method: "POST", path: "/v1/
|
|
68
|
-
{ method: "POST", path: "/v1/cancel-
|
|
69
|
-
{ method: "
|
|
70
|
-
{ method: "GET", path: "/v1/
|
|
71
|
-
{ method: "
|
|
72
|
-
{ method: "
|
|
73
|
-
{ method: "GET", path: "/v1/
|
|
74
|
-
{ method: "
|
|
75
|
-
{ method: "
|
|
76
|
-
{ method: "
|
|
77
|
-
{ method: "
|
|
78
|
-
{ method: "
|
|
79
|
-
{ method: "
|
|
80
|
-
{ method: "
|
|
81
|
-
{ method: "
|
|
82
|
-
{ method: "
|
|
83
|
-
{ method: "
|
|
84
|
-
{ method: "
|
|
85
|
-
{ method: "POST", path: "/v1/
|
|
86
|
-
{ method: "
|
|
87
|
-
{ method: "
|
|
88
|
-
{ method: "
|
|
89
|
-
{ method: "
|
|
90
|
-
{ method: "
|
|
91
|
-
{ method: "
|
|
92
|
-
{ method: "
|
|
93
|
-
{ method: "
|
|
94
|
-
{ method: "
|
|
95
|
-
{ method: "GET", path: "/v1/
|
|
96
|
-
{ method: "GET", path: "/v1/list-
|
|
97
|
-
{ method: "POST", path: "/v1/create-
|
|
98
|
-
{ method: "GET", path: "/v1/list-
|
|
99
|
-
{ method: "
|
|
100
|
-
{ method: "POST", path: "/v1/
|
|
101
|
-
{ method: "
|
|
102
|
-
{ method: "POST", path: "/v1/
|
|
103
|
-
{ method: "GET", path: "/v1/list-
|
|
104
|
-
{ method: "
|
|
66
|
+
{ method: "POST", path: "/v1/create-phone-call", sdk: "call.createPhoneCall", request: "CreatePhoneCallInput", response: "EnqueueCallResponse", status: 202, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [422, "idempotency_key_reuse"], [429, "rate_limit_exceeded"], [429, "rate_limited"], [502, "bad_gateway"]] },
|
|
67
|
+
{ method: "POST", path: "/v1/simulate-inbound-call", sdk: "call.simulateInbound", request: "SimulateInboundCallInput", response: "SimulateInboundCallResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [404, "not_found"], [409, "conflict"], [422, "idempotency_key_reuse"], [429, "rate_limit_exceeded"], [429, "rate_limited"]] },
|
|
68
|
+
{ method: "POST", path: "/v1/cancel-call", sdk: "call.cancel", request: "CancelCallInput", response: "OkResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
69
|
+
{ method: "POST", path: "/v1/cancel-campaign-pending", sdk: "call.cancelCampaignPending", request: "CancelCampaignPendingInput", response: "CancelCampaignPendingResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
70
|
+
{ method: "GET", path: "/v1/list-calls", sdk: "call.list", request: "ListCallsParams", response: "Page<Call>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
71
|
+
{ method: "GET", path: "/v1/get-call/:id", sdk: "call.get", request: "none", response: "Call", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
72
|
+
{ method: "POST", path: "/v1/campaigns", sdk: "campaign.create", request: "CreateCampaignInput", response: "CreateCampaignResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "forbidden"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [422, "idempotency_key_reuse"], [422, "validation_error"], [429, "rate_limit_exceeded"]] },
|
|
73
|
+
{ method: "GET", path: "/v1/campaigns/:id", sdk: "campaign.get", request: "none", response: "GetCampaignResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
74
|
+
{ method: "GET", path: "/v1/list-campaigns", sdk: "campaign.list", request: "ListCampaignsParams", response: "Page<Campaign>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
75
|
+
{ method: "POST", path: "/v1/start-campaign/:id", sdk: "campaign.start", request: "none", response: "StartCampaignResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [402, "insufficient_balance"], [403, "forbidden"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
76
|
+
{ method: "GET", path: "/v1/list-phone-numbers", sdk: "phoneNumber.list", request: "PageParams", response: "Page<PhoneNumber>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
77
|
+
{ method: "POST", path: "/v1/phone-numbers/inbound", sdk: "phoneNumber.provisionInbound", request: "ProvisionInboundInput", response: "ProvisionInboundResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
78
|
+
{ method: "DELETE", path: "/v1/phone-numbers/inbound/:id", sdk: "phoneNumber.deprovisionInbound", request: "DeprovisionInboundParams", response: "OkResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [404, "not_found"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
79
|
+
{ method: "PATCH", path: "/v1/update-phone-number/:id", sdk: "phoneNumber.update", request: "UpdatePhoneNumberInput", response: "PhoneNumber", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
80
|
+
{ method: "POST", path: "/v1/import-phone-number", sdk: "phoneNumber.import", request: "ImportPhoneNumberInput", response: "PhoneNumber", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [409, "conflict"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
81
|
+
{ method: "POST", path: "/v1/create-knowledge-base", sdk: "knowledgeBase.create", request: "KnowledgeBaseCreateInput", response: "KnowledgeBaseSourcesResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "quota_exceeded"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
82
|
+
{ method: "GET", path: "/v1/get-knowledge-base/:id", sdk: "knowledgeBase.retrieve", request: "none", response: "KnowledgeBaseResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
83
|
+
{ method: "GET", path: "/v1/list-knowledge-bases", sdk: "knowledgeBase.list", request: "none", response: "KnowledgeBaseListResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
84
|
+
{ method: "DELETE", path: "/v1/delete-knowledge-base/:id", sdk: "knowledgeBase.delete", request: "none", response: "none", status: 204, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
85
|
+
{ method: "POST", path: "/v1/add-knowledge-base-sources/:id", sdk: "knowledgeBase.addSources", request: "KnowledgeBaseAddSourcesInput", response: "KnowledgeBaseSourcesResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "quota_exceeded"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
86
|
+
{ method: "DELETE", path: "/v1/delete-knowledge-base-source/:source_id", sdk: "knowledgeBase.deleteSource", request: "DeleteKnowledgeBaseSourceParams", response: "KnowledgeBaseResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
87
|
+
{ method: "PATCH", path: "/v1/update-knowledge-base/:id", sdk: "knowledgeBase.update", request: "KnowledgeBaseUpdateInput", response: "KnowledgeBaseResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
88
|
+
{ method: "POST", path: "/v1/presign-knowledge-base-file/:id", sdk: "knowledgeBase.presignFile", request: "PresignFileInput", response: "PresignFileResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "quota_exceeded"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
89
|
+
{ method: "POST", path: "/v1/complete-knowledge-base-file/:id/:source_id", sdk: "knowledgeBase.completeFile", request: "none", response: "KnowledgeBaseResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
90
|
+
{ method: "POST", path: "/v1/fail-knowledge-base-file/:id/:source_id", sdk: "knowledgeBase.failFile", request: "FailFileInput", response: "KnowledgeBaseResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
91
|
+
{ method: "PUT", path: "/v1/reindex-knowledge-base/:id", sdk: "knowledgeBase.reindex", request: "none", response: "KnowledgeBaseResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
92
|
+
{ method: "PATCH", path: "/v1/update-knowledge-base-source/:id/:source_id", sdk: "knowledgeBase.updateSource", request: "UpdateSourceInput", response: "KnowledgeBaseResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
93
|
+
{ method: "PATCH", path: "/v1/update-knowledge-base-chunk/:id/:chunk_id", sdk: "knowledgeBase.updateChunk", request: "UpdateChunkInput", response: "OkResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
94
|
+
{ method: "GET", path: "/v1/get-knowledge-base-source/:id/:source_id", sdk: "knowledgeBase.getSource", request: "none", response: "KnowledgeBaseSourceDetail", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
95
|
+
{ method: "GET", path: "/v1/presign-knowledge-base-file-download/:id/:source_id", sdk: "knowledgeBase.presignFileDownload", request: "none", response: "PresignFileDownloadResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [503, "internal_error"]] },
|
|
96
|
+
{ method: "GET", path: "/v1/list-contacts", sdk: "contact.list", request: "ListContactsParams", response: "Page<Contact>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
97
|
+
{ method: "POST", path: "/v1/create-contact", sdk: "contact.create", request: "CreateContactInput", response: "CreateContactResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
98
|
+
{ method: "GET", path: "/v1/list-agents", sdk: "agent.list", request: "ListAgentsParams", response: "Page<Agent>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
99
|
+
{ method: "GET", path: "/v1/get-agent/:id", sdk: "agent.get", request: "none", response: "AgentDetail", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
100
|
+
{ method: "POST", path: "/v1/create-agent", sdk: "agent.create", request: "CreateAgentInput", response: "AgentDetail", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "quota_exceeded"], [403, "test_mode_unsupported"], [409, "conflict"], [429, "rate_limit_exceeded"]] },
|
|
101
|
+
{ method: "PATCH", path: "/v1/update-agent/:id", sdk: "agent.update", request: "UpdateAgentInput", response: "AgentDetail", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [403, "quota_exceeded"], [403, "test_mode_unsupported"], [404, "not_found"], [409, "agent_tool_name_conflict"], [409, "conflict"], [429, "rate_limit_exceeded"]] },
|
|
102
|
+
{ method: "POST", path: "/v1/deactivate-agent/:id", sdk: "agent.deactivate", request: "none", response: "AgentDetail", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [403, "test_mode_unsupported"], [404, "not_found"], [409, "agent_in_use"], [429, "rate_limit_exceeded"]] },
|
|
103
|
+
{ method: "GET", path: "/v1/list-calendars", sdk: "calendar.listCalendars", request: "PageParams", response: "Page<Calendar>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
104
|
+
{ method: "POST", path: "/v1/create-calendar", sdk: "calendar.create", request: "CreateCalendarInput", response: "CalendarDetail", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
105
|
+
{ method: "PATCH", path: "/v1/update-calendar/:id", sdk: "calendar.update", request: "UpdateCalendarInput", response: "CalendarDetail", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
106
|
+
{ method: "POST", path: "/v1/create-event-type", sdk: "calendar.createEventType", request: "CreateEventTypeInput", response: "EventTypeDetail", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
107
|
+
{ method: "PATCH", path: "/v1/update-event-type/:id", sdk: "calendar.updateEventType", request: "UpdateEventTypeInput", response: "EventTypeDetail", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
108
|
+
{ method: "GET", path: "/v1/list-calendar-events", sdk: "calendar.listEvents", request: "ListCalendarEventsParams", response: "Page<CalendarEvent>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
109
|
+
{ method: "POST", path: "/v1/create-calendar-event", sdk: "calendar.createEvent", request: "CreateCalendarEventInput", response: "CreateCalendarEventResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [429, "rate_limit_exceeded"]] },
|
|
110
|
+
{ method: "PATCH", path: "/v1/update-calendar-event/:id", sdk: "calendar.updateEvent", request: "UpdateCalendarEventInput", response: "CalendarEvent", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"]] },
|
|
111
|
+
{ method: "POST", path: "/v1/cancel-calendar-event/:id", sdk: "calendar.cancelEvent", request: "none", response: "CalendarEvent", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"]] },
|
|
112
|
+
{ method: "GET", path: "/v1/list-messages", sdk: "message.list", request: "ListMessagesParams", response: "Page<Message>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
113
|
+
{ method: "GET", path: "/v1/get-message/:id", sdk: "message.get", request: "none", response: "Message", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
114
|
+
{ method: "POST", path: "/v1/send-sms", sdk: "message.sendSms", request: "SendSmsInput", response: "SendMessageResponse", status: 202, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [422, "channel_not_configured"], [422, "idempotency_key_reuse"], [422, "sender_not_supported"], [422, "validation_error"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
115
|
+
{ method: "POST", path: "/v1/send-whatsapp", sdk: "message.sendWhatsapp", request: "SendWhatsappInput", response: "SendMessageResponse", status: 202, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [422, "channel_not_configured"], [422, "idempotency_key_reuse"], [422, "media_not_supported"], [422, "validation_error"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
116
|
+
{ method: "POST", path: "/v1/send-email", sdk: "message.sendEmail", request: "SendEmailInput", response: "SendMessageResponse", status: 202, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [422, "channel_not_configured"], [422, "email_provider_not_supported"], [422, "idempotency_key_reuse"], [422, "validation_error"], [429, "rate_limit_exceeded"], [502, "bad_gateway"]] },
|
|
117
|
+
{ method: "POST", path: "/v1/create-tts", sdk: "tts.create", request: "CreateTtsInput", response: "CreateTtsResponse", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [422, "idempotency_key_reuse"], [422, "validation_error"], [429, "rate_limit_exceeded"], [502, "bad_gateway"], [503, "service_unavailable"]] },
|
|
118
|
+
{ method: "GET", path: "/v1/list-tts", sdk: "tts.list", request: "ListTtsParams", response: "Page<TtsGeneration>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
119
|
+
{ method: "GET", path: "/v1/get-tts/:id", sdk: "tts.get", request: "none", response: "TtsGeneration", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
120
|
+
{ method: "POST", path: "/v1/create-webhook-endpoint", sdk: "webhookEndpoint.create", request: "CreateWebhookEndpointInput", response: "WebhookEndpointWithSecret", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [409, "conflict"], [409, "webhook_endpoint_limit"], [422, "idempotency_key_reuse"], [422, "validation_error"], [429, "rate_limit_exceeded"], [503, "service_unavailable"]] },
|
|
121
|
+
{ method: "GET", path: "/v1/list-webhook-endpoints", sdk: "webhookEndpoint.list", request: "PageParams", response: "Page<WebhookEndpoint>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
122
|
+
{ method: "GET", path: "/v1/get-webhook-endpoint/:id", sdk: "webhookEndpoint.get", request: "none", response: "WebhookEndpoint", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
123
|
+
{ method: "PATCH", path: "/v1/update-webhook-endpoint/:id", sdk: "webhookEndpoint.update", request: "UpdateWebhookEndpointInput", response: "WebhookEndpoint", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "webhook_endpoint_key_revoked"], [409, "webhook_endpoint_admin_disabled"], [429, "rate_limit_exceeded"]] },
|
|
124
|
+
{ method: "DELETE", path: "/v1/delete-webhook-endpoint/:id", sdk: "webhookEndpoint.delete", request: "none", response: "OkResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "webhook_endpoint_in_use"], [429, "rate_limit_exceeded"]] },
|
|
125
|
+
{ method: "POST", path: "/v1/rotate-webhook-endpoint-secret/:id", sdk: "webhookEndpoint.rotateSecret", request: "none", response: "WebhookEndpointWithSecret", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [503, "service_unavailable"]] },
|
|
126
|
+
{ method: "POST", path: "/v1/test-webhook-endpoint/:id", sdk: "webhookEndpoint.test", request: "TestWebhookEndpointInput", response: "TestWebhookEndpointResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [429, "rate_limit_exceeded"], [429, "rate_limited"]] },
|
|
127
|
+
{ method: "GET", path: "/v1/list-webhook-deliveries", sdk: "webhookEndpoint.listDeliveries", request: "ListWebhookDeliveriesParams", response: "Page<WebhookDelivery>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
128
|
+
{ method: "GET", path: "/v1/list-webhook-delivery-attempts", sdk: "webhookEndpoint.listDeliveryAttempts", request: "ListWebhookDeliveryAttemptsParams", response: "Page<WebhookDeliveryAttempt>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
129
|
+
{ method: "POST", path: "/v1/redeliver-webhook-delivery/:id", sdk: "webhookEndpoint.redeliver", request: "none", response: "WebhookDelivery", status: 201, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "conflict"], [409, "redelivery_limit"], [409, "webhook_endpoint_key_revoked"], [429, "rate_limit_exceeded"]] },
|
|
130
|
+
{ method: "POST", path: "/v1/create-agent-tool", sdk: "agentTool.create", request: "CreateAgentToolInput", response: "AgentTool", status: 201, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "agent_tool_limit"], [409, "agent_tool_name_conflict"], [409, "agent_tool_name_taken"], [409, "conflict"], [422, "idempotency_key_reuse"], [422, "validation_error"], [429, "rate_limit_exceeded"]] },
|
|
131
|
+
{ method: "GET", path: "/v1/list-agent-tools", sdk: "agentTool.list", request: "ListAgentToolsParams", response: "Page<AgentTool>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
132
|
+
{ method: "GET", path: "/v1/get-agent-tool/:id", sdk: "agentTool.get", request: "none", response: "AgentTool", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
133
|
+
{ method: "PATCH", path: "/v1/update-agent-tool/:id", sdk: "agentTool.update", request: "UpdateAgentToolInput", response: "AgentTool", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [409, "agent_tool_limit"], [409, "agent_tool_name_conflict"], [409, "agent_tool_name_taken"], [422, "validation_error"], [429, "rate_limit_exceeded"]] },
|
|
134
|
+
{ method: "DELETE", path: "/v1/delete-agent-tool/:id", sdk: "agentTool.delete", request: "none", response: "OkResponse", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] },
|
|
135
|
+
{ method: "POST", path: "/v1/test-agent-tool/:id", sdk: "agentTool.test", request: "TestAgentToolInput", response: "TestAgentToolResponse", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"], [429, "rate_limited"]] },
|
|
136
|
+
{ method: "GET", path: "/v1/list-events", sdk: "event.list", request: "ListEventsParams", response: "Page<WebhookEventEnvelope>", status: 200, errors: [[400, "validation_error"], [401, "unauthorized"], [403, "insufficient_scope"], [429, "rate_limit_exceeded"]] },
|
|
137
|
+
{ method: "GET", path: "/v1/get-event/:id", sdk: "event.get", request: "none", response: "WebhookEventEnvelope", status: 200, errors: [[401, "unauthorized"], [403, "insufficient_scope"], [404, "not_found"], [429, "rate_limit_exceeded"]] }
|
|
105
138
|
];
|
|
106
139
|
|
|
107
140
|
// src/client.ts
|
|
@@ -125,6 +158,8 @@ var Replicer = class {
|
|
|
125
158
|
}
|
|
126
159
|
call = {
|
|
127
160
|
createPhoneCall: (input) => this.request("call.createPhoneCall", { body: input }),
|
|
161
|
+
/** Test keys only: simulates an inbound call to the agent of one of your numbers; `call.ended` and `call.analyzed` follow with `livemode: false`. */
|
|
162
|
+
simulateInbound: (input) => this.request("call.simulateInbound", { body: input }),
|
|
128
163
|
cancel: (call_id) => this.request("call.cancel", { body: { call_id } }),
|
|
129
164
|
cancelCampaignPending: (campaign_id) => this.request("call.cancelCampaignPending", { body: { campaign_id } }),
|
|
130
165
|
list: (params) => this.request("call.list", { query: params }),
|
|
@@ -142,7 +177,11 @@ var Replicer = class {
|
|
|
142
177
|
/** Your organization's phone numbers; `id` is the `from_number_id` for `call.createPhoneCall`. */
|
|
143
178
|
list: (params) => this.request("phoneNumber.list", { query: params }),
|
|
144
179
|
provisionInbound: (input) => this.request("phoneNumber.provisionInbound", { body: input }),
|
|
145
|
-
deprovisionInbound: (id, trunk_id, rule_id) => this.request("phoneNumber.deprovisionInbound", { params: { id }, query: { trunk_id, rule_id } })
|
|
180
|
+
deprovisionInbound: (id, trunk_id, rule_id) => this.request("phoneNumber.deprovisionInbound", { params: { id }, query: { trunk_id, rule_id } }),
|
|
181
|
+
/** Connects a number you own (SIP trunk or forwarding). Live keys only. Not idempotent: a number already connected → `409 conflict`. Search, purchase and release stay in the dashboard. */
|
|
182
|
+
import: (input) => this.request("phoneNumber.import", { body: input }),
|
|
183
|
+
/** Sets (or clears, with `null`) the fallback number (inbound calls over the concurrent-call limit, or that the agent cannot take, are forwarded there) and/or the inbound agent. Live keys only. */
|
|
184
|
+
update: (id, input) => this.request("phoneNumber.update", { params: { id }, body: input })
|
|
146
185
|
};
|
|
147
186
|
knowledgeBase = {
|
|
148
187
|
create: (input) => this.request("knowledgeBase.create", { body: input }),
|
|
@@ -185,14 +224,37 @@ var Replicer = class {
|
|
|
185
224
|
create: (input) => this.request("contact.create", { body: input })
|
|
186
225
|
};
|
|
187
226
|
agent = {
|
|
188
|
-
list: (params) => this.request("agent.list", { query: params })
|
|
227
|
+
list: (params) => this.request("agent.list", { query: params }),
|
|
228
|
+
get: (id) => this.request("agent.get", { params: { id } }),
|
|
229
|
+
/** Live keys only. Not idempotent. Basic agents only: workflow agents and AI-written prompts stay in the dashboard. */
|
|
230
|
+
create: (input) => this.request("agent.create", { body: input }),
|
|
231
|
+
/** Live keys only. */
|
|
232
|
+
update: (id, input) => this.request("agent.update", { params: { id }, body: input }),
|
|
233
|
+
/** Live keys only. `409 agent_in_use` while a scheduled, running or paused campaign uses the agent. Reactivate with `update`. */
|
|
234
|
+
deactivate: (id) => this.request("agent.deactivate", { params: { id }, body: {} })
|
|
189
235
|
};
|
|
190
236
|
calendar = {
|
|
237
|
+
/** Active calendars with their active event types: the source of `calendar_id` and `event_type_id`. */
|
|
238
|
+
listCalendars: (params) => this.request("calendar.listCalendars", { query: params }),
|
|
239
|
+
/** Creates a calendar, optionally with its event types and weekly hours. Not idempotent: a retried create makes a second calendar. */
|
|
240
|
+
create: (input) => this.request("calendar.create", { body: input }),
|
|
241
|
+
/** Edits a calendar. `availability` replaces all weekly hours; `is_active: false` deactivates it (there is no delete). */
|
|
242
|
+
update: (id, input) => this.request("calendar.update", { params: { id }, body: input }),
|
|
243
|
+
/** Adds an event type to a calendar. Not idempotent. */
|
|
244
|
+
createEventType: (input) => this.request("calendar.createEventType", { body: input }),
|
|
245
|
+
/** Edits an event type; `is_active: false` deactivates it (there is no delete). */
|
|
246
|
+
updateEventType: (id, input) => this.request("calendar.updateEventType", { params: { id }, body: input }),
|
|
191
247
|
listEvents: (params) => this.request("calendar.listEvents", { query: params }),
|
|
192
|
-
createEvent: (input) => this.request("calendar.createEvent", { body: input })
|
|
248
|
+
createEvent: (input) => this.request("calendar.createEvent", { body: input }),
|
|
249
|
+
/** Reschedules a confirmed event (`start_time`) and/or edits customer fields, notes and metadata. */
|
|
250
|
+
updateEvent: (id, input) => this.request("calendar.updateEvent", { params: { id }, body: input }),
|
|
251
|
+
/** Soft cancel: the event stays listed with status `cancelled`. Cancelling twice is a no-op. */
|
|
252
|
+
cancelEvent: (id) => this.request("calendar.cancelEvent", { params: { id }, body: {} })
|
|
193
253
|
};
|
|
194
254
|
message = {
|
|
195
255
|
list: (params) => this.request("message.list", { query: params }),
|
|
256
|
+
/** One message by id (the `id` of a send response), with its current delivery `status`. */
|
|
257
|
+
get: (id) => this.request("message.get", { params: { id } }),
|
|
196
258
|
sendSms: (input) => this.request("message.sendSms", { body: input }),
|
|
197
259
|
sendWhatsapp: (input) => this.request("message.sendWhatsapp", { body: input }),
|
|
198
260
|
sendEmail: (input) => this.request("message.sendEmail", { body: input })
|
|
@@ -202,6 +264,38 @@ var Replicer = class {
|
|
|
202
264
|
list: (params) => this.request("tts.list", { query: params }),
|
|
203
265
|
get: (id) => this.request("tts.get", { params: { id } })
|
|
204
266
|
};
|
|
267
|
+
webhookEndpoint = {
|
|
268
|
+
/** Resolves with the signing `secret`, shown only here and in `rotateSecret`. */
|
|
269
|
+
create: (input) => this.request("webhookEndpoint.create", { body: input }),
|
|
270
|
+
list: (params) => this.request("webhookEndpoint.list", { query: params }),
|
|
271
|
+
get: (id) => this.request("webhookEndpoint.get", { params: { id } }),
|
|
272
|
+
update: (id, input) => this.request("webhookEndpoint.update", { params: { id }, body: input }),
|
|
273
|
+
delete: (id) => this.request("webhookEndpoint.delete", { params: { id } }),
|
|
274
|
+
/** New secret now; the previous one keeps signing deliveries for 24 hours. */
|
|
275
|
+
rotateSecret: (id) => this.request("webhookEndpoint.rotateSecret", { params: { id }, body: {} }),
|
|
276
|
+
/** Sends a test event (`livemode: false`) and waits up to 12 seconds for its first attempt. */
|
|
277
|
+
test: (id, input) => this.request("webhookEndpoint.test", { params: { id }, body: input ?? {} }),
|
|
278
|
+
listDeliveries: (params) => this.request("webhookEndpoint.listDeliveries", { query: params }),
|
|
279
|
+
/** HTTP attempts of one delivery, oldest first. */
|
|
280
|
+
listDeliveryAttempts: (params) => this.request("webhookEndpoint.listDeliveryAttempts", { query: params }),
|
|
281
|
+
/** Sends the event of a delivery again (same event id and body) as a new delivery. Events from the last 30 days only. */
|
|
282
|
+
redeliver: (deliveryId) => this.request("webhookEndpoint.redeliver", { params: { id: deliveryId }, body: {} })
|
|
283
|
+
};
|
|
284
|
+
agentTool = {
|
|
285
|
+
/** A signed API tool of an agent; requests are signed with the secret of `webhook_endpoint_id`. */
|
|
286
|
+
create: (input) => this.request("agentTool.create", { body: input }),
|
|
287
|
+
list: (params) => this.request("agentTool.list", { query: params }),
|
|
288
|
+
get: (id) => this.request("agentTool.get", { params: { id } }),
|
|
289
|
+
update: (id, input) => this.request("agentTool.update", { params: { id }, body: input }),
|
|
290
|
+
delete: (id) => this.request("agentTool.delete", { params: { id } }),
|
|
291
|
+
/** Sends one signed sample call to the tool URL and reports the outcome. */
|
|
292
|
+
test: (id, input) => this.request("agentTool.test", { params: { id }, body: input ?? {} })
|
|
293
|
+
};
|
|
294
|
+
event = {
|
|
295
|
+
/** Events of the last 30 days as delivered (each item is the parsed envelope). */
|
|
296
|
+
list: (params) => this.request("event.list", { query: params }),
|
|
297
|
+
get: (id) => this.request("event.get", { params: { id } })
|
|
298
|
+
};
|
|
205
299
|
async request(sdk, opts = {}) {
|
|
206
300
|
const route = ROUTE_BY_SDK.get(sdk);
|
|
207
301
|
if (!route) throw new Error(`Replicer: unknown route ${sdk}`);
|