@ecodrix/erix-api 1.0.3 → 1.0.5
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 +540 -241
- package/dist/cli.js +3 -3
- package/dist/index.d.cts +1597 -1489
- package/dist/index.d.ts +760 -760
- package/dist/ts/browser/index.global.js +5 -5
- package/dist/ts/browser/index.global.js.map +1 -1
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/index.cjs.map +1 -1
- package/dist/ts/cjs/index.d.cts +760 -760
- package/dist/ts/esm/index.d.ts +760 -760
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +12 -12
- package/src/cli.ts +18 -31
- package/src/core.ts +12 -16
- package/src/index.ts +18 -20
- package/src/resource.ts +6 -25
- package/src/resources/crm/activities.ts +1 -1
- package/src/resources/crm/automations.ts +9 -3
- package/src/resources/crm/index.ts +6 -6
- package/src/resources/crm/leads.ts +20 -15
- package/src/resources/crm/payments.ts +7 -1
- package/src/resources/crm/pipelines.ts +3 -1
- package/src/resources/crm/sequences.ts +5 -1
- package/src/resources/email.ts +2 -5
- package/src/resources/events.ts +12 -3
- package/src/resources/health.ts +3 -1
- package/src/resources/marketing.ts +8 -1
- package/src/resources/media.ts +1 -4
- package/src/resources/meet.ts +4 -1
- package/src/resources/webhooks.ts +3 -8
- package/src/resources/whatsapp/conversations.ts +8 -3
- package/src/resources/whatsapp/index.ts +4 -6
- package/src/resources/whatsapp/templates.ts +14 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig, Method } from
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig, Method } from "axios";
|
|
2
2
|
|
|
3
3
|
interface RequestOptions extends AxiosRequestConfig {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
/**
|
|
5
|
+
* If true, will not add the x-client-code header.
|
|
6
|
+
*/
|
|
7
|
+
ignoreClientCode?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Safe execution idempotency key.
|
|
10
|
+
* If provided, the backend will safely ignore duplicate requests retried with the same key.
|
|
11
|
+
*/
|
|
12
|
+
idempotencyKey?: string;
|
|
13
13
|
}
|
|
14
14
|
declare abstract class APIResource {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
protected readonly client: AxiosInstance;
|
|
16
|
+
constructor(client: AxiosInstance);
|
|
17
|
+
protected post<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
18
|
+
protected get<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
19
|
+
protected patch<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
20
|
+
protected put<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
21
|
+
protected deleteRequest<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
22
|
+
private buildConfig;
|
|
23
|
+
private handleError;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Parameters for sending a free-form WhatsApp message.
|
|
28
28
|
*/
|
|
29
29
|
interface SendMessageParams {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Recipient's phone number in E.164 format.
|
|
32
|
+
* @example "+919876543210"
|
|
33
|
+
*/
|
|
34
|
+
to: string;
|
|
35
|
+
/** Plain text body of the message. */
|
|
36
|
+
text?: string;
|
|
37
|
+
/** Public URL of the media asset to send. */
|
|
38
|
+
mediaUrl?: string;
|
|
39
|
+
/** MIME category of the media. */
|
|
40
|
+
mediaType?: "image" | "video" | "audio" | "document";
|
|
41
|
+
/** The `messageId` of the message to reply to (quoted replies). */
|
|
42
|
+
replyToId?: string;
|
|
43
|
+
/** Filename shown to the recipient (required for `document` type). */
|
|
44
|
+
filename?: string;
|
|
45
|
+
/** Arbitrary metadata stored with the message record. */
|
|
46
|
+
metadata?: Record<string, any>;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Parameters for sending a pre-approved WhatsApp Business template.
|
|
50
50
|
*/
|
|
51
51
|
interface SendTemplateParams {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Recipient's phone number in E.164 format.
|
|
54
|
+
* @example "+919876543210"
|
|
55
|
+
*/
|
|
56
|
+
to: string;
|
|
57
|
+
/** The exact template name as approved in Meta Business Manager. */
|
|
58
|
+
templateName: string;
|
|
59
|
+
/**
|
|
60
|
+
* BCP-47 language code for the template.
|
|
61
|
+
* @default "en_US"
|
|
62
|
+
*/
|
|
63
|
+
language?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Ordered array of variable substitutions for template placeholders.
|
|
66
|
+
* @example ["Alice", "10 April 2026", "10:00 AM"]
|
|
67
|
+
*/
|
|
68
|
+
variables?: string[];
|
|
69
|
+
/** Optional header media URL (for templates with media headers). */
|
|
70
|
+
mediaUrl?: string;
|
|
71
|
+
/** Media type for the header (e.g. "image", "document"). */
|
|
72
|
+
mediaType?: string;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* WhatsApp outbound messaging resource.
|
|
@@ -85,240 +85,243 @@ interface SendTemplateParams {
|
|
|
85
85
|
* ```
|
|
86
86
|
*/
|
|
87
87
|
declare class Messages extends APIResource {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Send a free-text or media message to a WhatsApp number.
|
|
90
|
+
*
|
|
91
|
+
* For text-only messages, supply `text`. For media, supply `mediaUrl`
|
|
92
|
+
* and `mediaType`. Both can be combined.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Message parameters.
|
|
95
|
+
* @returns The created message record.
|
|
96
|
+
*
|
|
97
|
+
* @example Text message
|
|
98
|
+
* ```typescript
|
|
99
|
+
* await ecod.whatsapp.messages.send({
|
|
100
|
+
* to: "+919876543210",
|
|
101
|
+
* text: "Hello!",
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Media message
|
|
106
|
+
* ```typescript
|
|
107
|
+
* await ecod.whatsapp.messages.send({
|
|
108
|
+
* to: "+919876543210",
|
|
109
|
+
* mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
|
|
110
|
+
* mediaType: "document",
|
|
111
|
+
* filename: "invoice.pdf",
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
send(params: SendMessageParams): Promise<unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Send a pre-approved WhatsApp Business template message.
|
|
118
|
+
*
|
|
119
|
+
* Templates must be approved in Meta Business Manager before use.
|
|
120
|
+
* Variable placeholders in the template body are filled left-to-right
|
|
121
|
+
* from the `variables` array.
|
|
122
|
+
*
|
|
123
|
+
* @param params - Template message parameters.
|
|
124
|
+
* @returns The created message record.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await ecod.whatsapp.messages.sendTemplate({
|
|
129
|
+
* to: "+919876543210",
|
|
130
|
+
* templateName: "appointment_reminder",
|
|
131
|
+
* language: "en_US",
|
|
132
|
+
* variables: ["Alice", "10 April", "10:00 AM"],
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
sendTemplate(params: SendTemplateParams): Promise<unknown>;
|
|
137
|
+
/**
|
|
138
|
+
* Star or unstar a message.
|
|
139
|
+
*
|
|
140
|
+
* @param messageId - The ID of the message.
|
|
141
|
+
* @param isStarred - Boolean indicating whether to star or unstar.
|
|
142
|
+
*/
|
|
143
|
+
star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* React to a message with an emoji.
|
|
146
|
+
*
|
|
147
|
+
* @param messageId - The ID of the message.
|
|
148
|
+
* @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
|
|
149
|
+
*/
|
|
150
|
+
react<T = any>(messageId: string, reaction: string): Promise<T>;
|
|
151
|
+
/**
|
|
152
|
+
* Mark all messages in a conversation as read (double-tick).
|
|
153
|
+
*
|
|
154
|
+
* @param conversationId - The conversation to mark as read.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* await ecod.whatsapp.messages.markRead("conv_64abc...");
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
markRead(conversationId: string): Promise<unknown>;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
interface ListParams {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
limit?: number;
|
|
166
|
+
before?: string;
|
|
167
|
+
after?: string;
|
|
168
|
+
status?: string;
|
|
169
169
|
}
|
|
170
170
|
declare class Conversations extends APIResource {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
171
|
+
/**
|
|
172
|
+
* List conversations for the tenant.
|
|
173
|
+
*/
|
|
174
|
+
list<T = any>(params?: ListParams): Promise<T>;
|
|
175
|
+
/**
|
|
176
|
+
* Create a new conversation explicitly.
|
|
177
|
+
*
|
|
178
|
+
* @param params - Conversation details.
|
|
179
|
+
*/
|
|
180
|
+
create<T = any>(params: {
|
|
181
|
+
phone: string;
|
|
182
|
+
name?: string;
|
|
183
|
+
}): Promise<T>;
|
|
184
|
+
/**
|
|
185
|
+
* Retrieve details of a specific conversation.
|
|
186
|
+
*/
|
|
187
|
+
retrieve<T = any>(conversationId: string): Promise<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Get messages for a specific conversation.
|
|
190
|
+
*/
|
|
191
|
+
messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Link a conversation to a lead.
|
|
194
|
+
*/
|
|
195
|
+
linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Delete a conversation.
|
|
198
|
+
*/
|
|
199
|
+
delete(conversationId: string): Promise<unknown>;
|
|
200
|
+
/**
|
|
201
|
+
* Bulk delete conversations.
|
|
202
|
+
*/
|
|
203
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
interface CreateBroadcastParams {
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
templateName: string;
|
|
208
|
+
recipients: string[];
|
|
209
209
|
}
|
|
210
210
|
declare class Broadcasts extends APIResource {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
/**
|
|
212
|
+
* List past and active broadcasts.
|
|
213
|
+
*/
|
|
214
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
215
|
+
/**
|
|
216
|
+
* Create a new broadcast to send a template message to multiple recipients.
|
|
217
|
+
*/
|
|
218
|
+
create<T = any>(params: CreateBroadcastParams): Promise<T>;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
interface TemplateMapping {
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
mappings: any[];
|
|
223
|
+
onEmptyVariable: string;
|
|
224
224
|
}
|
|
225
225
|
declare class Templates extends APIResource {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
226
|
+
/**
|
|
227
|
+
* List all templates from the tenant database.
|
|
228
|
+
*/
|
|
229
|
+
list<T = any>(params?: {
|
|
230
|
+
status?: string;
|
|
231
|
+
mappingStatus?: string;
|
|
232
|
+
channel?: string;
|
|
233
|
+
}): Promise<T>;
|
|
234
|
+
/**
|
|
235
|
+
* Synchronize templates from Meta API.
|
|
236
|
+
*/
|
|
237
|
+
sync<T = any>(): Promise<T>;
|
|
238
|
+
/**
|
|
239
|
+
* Get template details.
|
|
240
|
+
*/
|
|
241
|
+
retrieve<T = any>(templateIdentifier: string): Promise<T>;
|
|
242
|
+
/**
|
|
243
|
+
* Create a new template manually.
|
|
244
|
+
*/
|
|
245
|
+
create<T = any>(payload: any): Promise<T>;
|
|
246
|
+
/**
|
|
247
|
+
* Update an existing template.
|
|
248
|
+
*/
|
|
249
|
+
update<T = any>(templateId: string, payload: any): Promise<T>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete a template.
|
|
252
|
+
*/
|
|
253
|
+
deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
|
|
254
|
+
/**
|
|
255
|
+
* List curated mapping config options.
|
|
256
|
+
*/
|
|
257
|
+
mappingConfig<T = any>(): Promise<T>;
|
|
258
|
+
/**
|
|
259
|
+
* List CRM collections for variable mapping.
|
|
260
|
+
*/
|
|
261
|
+
collections<T = any>(): Promise<T>;
|
|
262
|
+
/**
|
|
263
|
+
* List CRM fields for a collection.
|
|
264
|
+
*/
|
|
265
|
+
collectionFields<T = any>(collectionName: string): Promise<T>;
|
|
266
|
+
/**
|
|
267
|
+
* Update variable mappings for a template.
|
|
268
|
+
*/
|
|
269
|
+
updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
|
|
270
|
+
/**
|
|
271
|
+
* Validate mapping readiness.
|
|
272
|
+
*/
|
|
273
|
+
validate<T = any>(templateName: string): Promise<T>;
|
|
274
|
+
/**
|
|
275
|
+
* Preview a template resolution.
|
|
276
|
+
*/
|
|
277
|
+
preview<T = any>(
|
|
278
|
+
templateName: string,
|
|
279
|
+
context: {
|
|
280
|
+
lead?: any;
|
|
281
|
+
vars?: any;
|
|
282
|
+
},
|
|
283
|
+
): Promise<T>;
|
|
284
|
+
/**
|
|
285
|
+
* Check automation usage of a template.
|
|
286
|
+
*/
|
|
287
|
+
checkUsage<T = any>(templateName: string): Promise<T>;
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
interface SendTemplatePayload {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
291
|
+
/** Phone number in E.164 format. */
|
|
292
|
+
phone: string;
|
|
293
|
+
/** Name of the pre-approved WhatsApp template. */
|
|
294
|
+
templateName: string;
|
|
295
|
+
/** Language code (defaults to "en"). */
|
|
296
|
+
languageCode?: string;
|
|
297
|
+
/** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
|
|
298
|
+
variables?: Record<string, string>;
|
|
299
|
+
/** Explicitly resolved variables if bypassing the internal resolution engine. */
|
|
300
|
+
resolvedVariables?: any[];
|
|
298
301
|
}
|
|
299
302
|
declare class WhatsApp extends APIResource {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
303
|
+
messages: Messages;
|
|
304
|
+
conversations: Conversations;
|
|
305
|
+
broadcasts: Broadcasts;
|
|
306
|
+
templates: Templates;
|
|
307
|
+
constructor(client: AxiosInstance);
|
|
308
|
+
/**
|
|
309
|
+
* Upload an asset directly to chat storage.
|
|
310
|
+
*/
|
|
311
|
+
upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
|
|
312
|
+
/**
|
|
313
|
+
* Dispatch a WhatsApp template message directly to a specific phone number.
|
|
314
|
+
* Bypasses the automation queue for immediate high-priority delivery.
|
|
315
|
+
*
|
|
316
|
+
* @param payload - The template dispatch payload.
|
|
317
|
+
* @returns Information about the dispatched message.
|
|
318
|
+
*/
|
|
319
|
+
sendTemplate(payload: SendTemplatePayload): Promise<{
|
|
320
|
+
success: boolean;
|
|
321
|
+
messageId?: string;
|
|
322
|
+
templateName?: string;
|
|
323
|
+
resolvedVariables?: any[];
|
|
324
|
+
}>;
|
|
322
325
|
}
|
|
323
326
|
|
|
324
327
|
/**
|
|
@@ -333,60 +336,60 @@ type LeadSource = "website" | "whatsapp" | "direct" | "referral" | string;
|
|
|
333
336
|
* Parameters for creating a new CRM Lead.
|
|
334
337
|
*/
|
|
335
338
|
interface CreateLeadParams {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
339
|
+
/** Lead's first name. Required. */
|
|
340
|
+
firstName: string;
|
|
341
|
+
/** Lead's last name. */
|
|
342
|
+
lastName?: string;
|
|
343
|
+
/** Lead's email address. */
|
|
344
|
+
email?: string;
|
|
345
|
+
/** Lead's phone number in E.164 format (e.g. "+919876543210"). */
|
|
346
|
+
phone?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Acquisition channel.
|
|
349
|
+
*/
|
|
350
|
+
source?: LeadSource;
|
|
351
|
+
/** Arbitrary key-value metadata (UTM params, order IDs, etc.). */
|
|
352
|
+
metadata?: Record<string, any>;
|
|
353
|
+
/** Pipeline ID to assign the lead */
|
|
354
|
+
pipelineId?: string;
|
|
355
|
+
/** Stage ID to assign the lead */
|
|
356
|
+
stageId?: string;
|
|
354
357
|
}
|
|
355
358
|
/**
|
|
356
359
|
* Options for listing leads.
|
|
357
360
|
*/
|
|
358
361
|
interface ListLeadsParams {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
362
|
+
status?: LeadStatus;
|
|
363
|
+
pipelineId?: string;
|
|
364
|
+
stageId?: string;
|
|
365
|
+
source?: LeadSource;
|
|
366
|
+
assignedTo?: string;
|
|
367
|
+
tags?: string[] | string;
|
|
368
|
+
minScore?: number;
|
|
369
|
+
search?: string;
|
|
370
|
+
startDate?: string;
|
|
371
|
+
endDate?: string;
|
|
372
|
+
appointmentId?: string;
|
|
373
|
+
bookingId?: string;
|
|
374
|
+
orderId?: string;
|
|
375
|
+
meetingId?: string;
|
|
376
|
+
page?: number;
|
|
377
|
+
limit?: number;
|
|
378
|
+
sortBy?: string;
|
|
379
|
+
sortDir?: "asc" | "desc";
|
|
377
380
|
}
|
|
378
381
|
/**
|
|
379
382
|
* Options for upserting a lead.
|
|
380
383
|
*/
|
|
381
384
|
interface UpsertLeadParams {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
leadData: Partial<CreateLeadParams> & {
|
|
386
|
+
phone: string;
|
|
387
|
+
name?: string;
|
|
388
|
+
};
|
|
389
|
+
moduleInfo?: any;
|
|
390
|
+
trigger?: string;
|
|
391
|
+
pipelineId?: string;
|
|
392
|
+
stageId?: string;
|
|
390
393
|
}
|
|
391
394
|
/**
|
|
392
395
|
* CRM Lead resource — full lifecycle management.
|
|
@@ -403,509 +406,527 @@ interface UpsertLeadParams {
|
|
|
403
406
|
* ```
|
|
404
407
|
*/
|
|
405
408
|
declare class Leads extends APIResource {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
409
|
+
/**
|
|
410
|
+
* Create a new lead in the CRM pipeline.
|
|
411
|
+
*
|
|
412
|
+
* @param params - Lead creation parameters. `firstName` is required.
|
|
413
|
+
* @returns The newly created Lead document.
|
|
414
|
+
*/
|
|
415
|
+
create<T = any>(params: CreateLeadParams): Promise<T>;
|
|
416
|
+
/**
|
|
417
|
+
* Upsert a lead by phone number. Creates if not exists, updates if exists.
|
|
418
|
+
*
|
|
419
|
+
* @param params - Upsert parameters containing leadData with a phone number.
|
|
420
|
+
* @returns The newly created or updated Lead document.
|
|
421
|
+
*/
|
|
422
|
+
upsert<T = any>(params: UpsertLeadParams): Promise<T>;
|
|
423
|
+
/**
|
|
424
|
+
* Bulk ingest leads efficiently in parallel using automatic chunking.
|
|
425
|
+
* Prevents rate limit exhaustion by executing `chunkSize` requests at a time.
|
|
426
|
+
*
|
|
427
|
+
* @param leads - Array of leads to create.
|
|
428
|
+
* @param chunkSize - Number of leads to send concurrently (default: 50)
|
|
429
|
+
* @returns Array of created lead results.
|
|
430
|
+
*/
|
|
431
|
+
createMany(leads: CreateLeadParams[], chunkSize?: number): Promise<any[]>;
|
|
432
|
+
/**
|
|
433
|
+
* Bulk upsert (import) leads.
|
|
434
|
+
*
|
|
435
|
+
* @param leads - Array of leads to import.
|
|
436
|
+
*/
|
|
437
|
+
import<T = any>(leads: Partial<CreateLeadParams>[]): Promise<T>;
|
|
438
|
+
/**
|
|
439
|
+
* List leads with optional filtering and pagination.
|
|
440
|
+
*
|
|
441
|
+
* @param params - Filter options (status, source, pipelineId, page, limit, etc.)
|
|
442
|
+
* @returns Paginated list of Lead documents.
|
|
443
|
+
*/
|
|
444
|
+
list<T = any>(params?: ListLeadsParams): Promise<T>;
|
|
445
|
+
/**
|
|
446
|
+
* Auto-paginating iterator for leads.
|
|
447
|
+
* Seamlessly fetches leads page by page as you iterate.
|
|
448
|
+
*/
|
|
449
|
+
listAutoPaging(params?: ListLeadsParams): AsyncGenerator<any, void, unknown>;
|
|
450
|
+
/**
|
|
451
|
+
* Retrieve a single lead by its unique ID.
|
|
452
|
+
*
|
|
453
|
+
* @param leadId - The MongoDB ObjectId of the lead.
|
|
454
|
+
* @returns The Lead document, or a 404 error if not found.
|
|
455
|
+
*/
|
|
456
|
+
retrieve<T = any>(leadId: string): Promise<T>;
|
|
457
|
+
/**
|
|
458
|
+
* Retrieve a single lead by its phone number.
|
|
459
|
+
*
|
|
460
|
+
* @param phone - Lead's phone number.
|
|
461
|
+
*/
|
|
462
|
+
retrieveByPhone<T = any>(phone: string): Promise<T>;
|
|
463
|
+
/**
|
|
464
|
+
* Retrieve a single lead by a reference key and value.
|
|
465
|
+
*
|
|
466
|
+
* @param refKey - Reference key metadata.
|
|
467
|
+
* @param refValue - Reference value.
|
|
468
|
+
*/
|
|
469
|
+
retrieveByRef<T = any>(refKey: string, refValue: string): Promise<T>;
|
|
470
|
+
/**
|
|
471
|
+
* Update the fields of an existing lead.
|
|
472
|
+
*
|
|
473
|
+
* @param leadId - The ID of the lead to update.
|
|
474
|
+
* @param params - Partial lead fields to update.
|
|
475
|
+
* @returns The updated Lead document.
|
|
476
|
+
*/
|
|
477
|
+
update<T = any>(leadId: string, params: Partial<CreateLeadParams>): Promise<T>;
|
|
478
|
+
/**
|
|
479
|
+
* Move a lead to a new stage in a pipeline.
|
|
480
|
+
*
|
|
481
|
+
* @param leadId - ID of the lead.
|
|
482
|
+
* @param stageId - Target stage ID.
|
|
483
|
+
*/
|
|
484
|
+
move<T = any>(leadId: string, stageId: string): Promise<T>;
|
|
485
|
+
/**
|
|
486
|
+
* Convert a lead (mark as won or lost with reason).
|
|
487
|
+
*
|
|
488
|
+
* @param leadId - ID of the lead.
|
|
489
|
+
* @param outcome - "won" | "lost"
|
|
490
|
+
* @param reason - Reason for the outcome.
|
|
491
|
+
*/
|
|
492
|
+
convert<T = any>(leadId: string, outcome: "won" | "lost", reason?: string): Promise<T>;
|
|
493
|
+
/**
|
|
494
|
+
* Update the tags of a lead.
|
|
495
|
+
*
|
|
496
|
+
* @param leadId - ID of the lead.
|
|
497
|
+
* @param options - Tags to add or remove.
|
|
498
|
+
*/
|
|
499
|
+
tags<T = any>(
|
|
500
|
+
leadId: string,
|
|
501
|
+
options: {
|
|
502
|
+
add?: string[];
|
|
503
|
+
remove?: string[];
|
|
504
|
+
},
|
|
505
|
+
): Promise<T>;
|
|
506
|
+
/**
|
|
507
|
+
* Recalculate lead score based on activities and interactions.
|
|
508
|
+
*
|
|
509
|
+
* @param leadId - ID of the lead.
|
|
510
|
+
*/
|
|
511
|
+
recalculateScore<T = any>(leadId: string): Promise<T>;
|
|
512
|
+
/**
|
|
513
|
+
* Update embedded metadata/references of a lead without touching core fields.
|
|
514
|
+
*
|
|
515
|
+
* @param leadId - ID of the lead.
|
|
516
|
+
* @param metadata - Metadata object indicating { refs, extra }
|
|
517
|
+
*/
|
|
518
|
+
updateMetadata<T = any>(
|
|
519
|
+
leadId: string,
|
|
520
|
+
metadata: {
|
|
521
|
+
refs?: Record<string, any>;
|
|
522
|
+
extra?: Record<string, any>;
|
|
523
|
+
},
|
|
524
|
+
): Promise<T>;
|
|
525
|
+
/**
|
|
526
|
+
* Introspect available custom fields configured by the tenant limit.
|
|
527
|
+
*/
|
|
528
|
+
fields<T = any>(): Promise<T>;
|
|
529
|
+
/**
|
|
530
|
+
* Archive (soft-delete) a single lead.
|
|
531
|
+
*
|
|
532
|
+
* @param leadId - The ID of the lead to archive.
|
|
533
|
+
*/
|
|
534
|
+
delete(leadId: string): Promise<unknown>;
|
|
535
|
+
/**
|
|
536
|
+
* Bulk archive multiple leads.
|
|
537
|
+
*
|
|
538
|
+
* @param ids - Array of lead IDs to archive.
|
|
539
|
+
*/
|
|
540
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
532
541
|
}
|
|
533
542
|
|
|
534
543
|
interface CreatePipelineParams {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
544
|
+
name: string;
|
|
545
|
+
isDefault?: boolean;
|
|
546
|
+
stages?: any[];
|
|
538
547
|
}
|
|
539
548
|
interface PipelineStageParams {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
549
|
+
name: string;
|
|
550
|
+
color?: string;
|
|
551
|
+
probability?: number;
|
|
543
552
|
}
|
|
544
553
|
declare class Pipelines extends APIResource {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
554
|
+
/**
|
|
555
|
+
* List all pipelines matching the optional query parameters.
|
|
556
|
+
*/
|
|
557
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
558
|
+
/**
|
|
559
|
+
* Create a new pipeline.
|
|
560
|
+
*/
|
|
561
|
+
create<T = any>(params: CreatePipelineParams): Promise<T>;
|
|
562
|
+
/**
|
|
563
|
+
* Retrieve a single pipeline.
|
|
564
|
+
*/
|
|
565
|
+
retrieve<T = any>(pipelineId: string): Promise<T>;
|
|
566
|
+
/**
|
|
567
|
+
* Update a pipeline's details.
|
|
568
|
+
*/
|
|
569
|
+
update<T = any>(
|
|
570
|
+
pipelineId: string,
|
|
571
|
+
params: {
|
|
572
|
+
name?: string;
|
|
573
|
+
description?: string;
|
|
574
|
+
},
|
|
575
|
+
): Promise<T>;
|
|
576
|
+
/**
|
|
577
|
+
* Set pipeline as the tenant's default.
|
|
578
|
+
*/
|
|
579
|
+
setDefault<T = any>(pipelineId: string): Promise<T>;
|
|
580
|
+
/**
|
|
581
|
+
* Duplicate a pipeline with a new name.
|
|
582
|
+
*/
|
|
583
|
+
duplicate<T = any>(pipelineId: string, newName: string): Promise<T>;
|
|
584
|
+
/**
|
|
585
|
+
* Archive a pipeline.
|
|
586
|
+
*/
|
|
587
|
+
archive<T = any>(pipelineId: string): Promise<T>;
|
|
588
|
+
/**
|
|
589
|
+
* Delete a pipeline permanently.
|
|
590
|
+
*/
|
|
591
|
+
delete(pipelineId: string): Promise<unknown>;
|
|
592
|
+
/**
|
|
593
|
+
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
594
|
+
*/
|
|
595
|
+
board<T = any>(pipelineId: string): Promise<T>;
|
|
596
|
+
/**
|
|
597
|
+
* Retrieve a revenue forecast based on stage probabilities for a pipeline.
|
|
598
|
+
*/
|
|
599
|
+
forecast<T = any>(pipelineId: string): Promise<T>;
|
|
600
|
+
/**
|
|
601
|
+
* Add a new stage to the pipeline.
|
|
602
|
+
*/
|
|
603
|
+
addStage<T = any>(pipelineId: string, params: PipelineStageParams): Promise<T>;
|
|
604
|
+
/**
|
|
605
|
+
* Change the order of stages inside the pipeline.
|
|
606
|
+
*/
|
|
607
|
+
reorderStages<T = any>(pipelineId: string, orderArray: string[]): Promise<T>;
|
|
608
|
+
/**
|
|
609
|
+
* Update a specific stage.
|
|
610
|
+
*/
|
|
611
|
+
updateStage<T = any>(stageId: string, params: Partial<PipelineStageParams>): Promise<T>;
|
|
612
|
+
/**
|
|
613
|
+
* Delete a stage. Optionally provide a fallback stageId to move active leads to.
|
|
614
|
+
*/
|
|
615
|
+
deleteStage(stageId: string, moveLeadsToStageId?: string): Promise<unknown>;
|
|
604
616
|
}
|
|
605
617
|
|
|
606
618
|
interface LogActivityParams {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
619
|
+
leadId: string;
|
|
620
|
+
type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
|
|
621
|
+
title: string;
|
|
622
|
+
body?: string;
|
|
623
|
+
metadata?: Record<string, any>;
|
|
612
624
|
}
|
|
613
625
|
interface LogCallParams {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
626
|
+
durationMinutes: number;
|
|
627
|
+
summary: string;
|
|
628
|
+
outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
|
|
617
629
|
}
|
|
618
630
|
declare class Notes extends APIResource {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
631
|
+
/**
|
|
632
|
+
* List all notes for a specific lead.
|
|
633
|
+
*/
|
|
634
|
+
list<T = any>(leadId: string): Promise<T>;
|
|
635
|
+
/**
|
|
636
|
+
* Add a note to a lead.
|
|
637
|
+
*/
|
|
638
|
+
create<T = any>(
|
|
639
|
+
leadId: string,
|
|
640
|
+
params: {
|
|
641
|
+
content: string;
|
|
642
|
+
},
|
|
643
|
+
): Promise<T>;
|
|
644
|
+
/**
|
|
645
|
+
* Update an existing note.
|
|
646
|
+
*/
|
|
647
|
+
update<T = any>(noteId: string, content: string): Promise<T>;
|
|
648
|
+
/**
|
|
649
|
+
* Pin or unpin a note to the top of the feed.
|
|
650
|
+
*/
|
|
651
|
+
pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
|
|
652
|
+
/**
|
|
653
|
+
* Delete a note.
|
|
654
|
+
*/
|
|
655
|
+
delete(noteId: string): Promise<unknown>;
|
|
641
656
|
}
|
|
642
657
|
declare class Activities extends APIResource {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
658
|
+
notes: Notes;
|
|
659
|
+
constructor(client: any);
|
|
660
|
+
/**
|
|
661
|
+
* Retrieve the complete chronological timeline for a lead.
|
|
662
|
+
*/
|
|
663
|
+
timeline<T = any>(
|
|
664
|
+
leadId: string,
|
|
665
|
+
params?: {
|
|
666
|
+
page?: number;
|
|
667
|
+
limit?: number;
|
|
668
|
+
},
|
|
669
|
+
): Promise<T>;
|
|
670
|
+
/**
|
|
671
|
+
* List specific activities (filtered by type).
|
|
672
|
+
*/
|
|
673
|
+
list<T = any>(
|
|
674
|
+
leadId: string,
|
|
675
|
+
params?: {
|
|
676
|
+
type?: string;
|
|
677
|
+
page?: number;
|
|
678
|
+
limit?: number;
|
|
679
|
+
},
|
|
680
|
+
): Promise<T>;
|
|
681
|
+
/**
|
|
682
|
+
* Generic method to log a business activity/event.
|
|
683
|
+
*/
|
|
684
|
+
log<T = any>(params: LogActivityParams): Promise<T>;
|
|
685
|
+
/**
|
|
686
|
+
* Specific method to log communication outcomes.
|
|
687
|
+
*/
|
|
688
|
+
logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
|
|
668
689
|
}
|
|
669
690
|
|
|
670
691
|
type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
|
|
671
692
|
interface AnalyticsParams {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
693
|
+
range?: AnalyticsRange;
|
|
694
|
+
from?: string;
|
|
695
|
+
to?: string;
|
|
696
|
+
pipelineId?: string;
|
|
676
697
|
}
|
|
677
698
|
declare class Analytics extends APIResource {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
699
|
+
/**
|
|
700
|
+
* KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
|
|
701
|
+
*/
|
|
702
|
+
overview<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
703
|
+
/**
|
|
704
|
+
* Stage-by-stage lead counts and conversion percentages.
|
|
705
|
+
*/
|
|
706
|
+
funnel<T = any>(pipelineId: string): Promise<T>;
|
|
707
|
+
/**
|
|
708
|
+
* Revenue forecast: deal value × stage probability.
|
|
709
|
+
*/
|
|
710
|
+
forecast<T = any>(pipelineId?: string): Promise<T>;
|
|
711
|
+
/**
|
|
712
|
+
* Lead source breakdown: count, conversion rate, total value per source.
|
|
713
|
+
*/
|
|
714
|
+
sources<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
715
|
+
/**
|
|
716
|
+
* Team leaderboard: won deals, revenue, activity count, conversion rate per member.
|
|
717
|
+
*/
|
|
718
|
+
team<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
719
|
+
/**
|
|
720
|
+
* Daily activity counts by type. For activity calendar.
|
|
721
|
+
*/
|
|
722
|
+
heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
723
|
+
/**
|
|
724
|
+
* Score distribution: how many leads in each score bucket.
|
|
725
|
+
*/
|
|
726
|
+
scores<T = any>(): Promise<T>;
|
|
727
|
+
/**
|
|
728
|
+
* Avg time leads spend in each stage. Helps find bottlenecks.
|
|
729
|
+
*/
|
|
730
|
+
stageTime<T = any>(pipelineId: string): Promise<T>;
|
|
731
|
+
/**
|
|
732
|
+
* Tiered Growth Report matching business sophistication.
|
|
733
|
+
*/
|
|
734
|
+
tiered<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
735
|
+
/**
|
|
736
|
+
* Consolidated analytics including CRM overview and WhatsApp.
|
|
737
|
+
*/
|
|
738
|
+
summary<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
739
|
+
/**
|
|
740
|
+
* WhatsApp volume and delivery analytics.
|
|
741
|
+
*/
|
|
742
|
+
whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
722
743
|
}
|
|
723
744
|
|
|
724
745
|
interface AutomationRulePayload {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
746
|
+
name: string;
|
|
747
|
+
trigger: string;
|
|
748
|
+
isActive?: boolean;
|
|
749
|
+
nodes: any[];
|
|
750
|
+
edges: any[];
|
|
730
751
|
}
|
|
731
752
|
declare class Automations extends APIResource {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
753
|
+
/**
|
|
754
|
+
* List all automation rules for the tenant.
|
|
755
|
+
*/
|
|
756
|
+
list<T = any>(): Promise<T>;
|
|
757
|
+
/**
|
|
758
|
+
* Create a new automation rule.
|
|
759
|
+
*/
|
|
760
|
+
create<T = any>(payload: AutomationRulePayload): Promise<T>;
|
|
761
|
+
/**
|
|
762
|
+
* Update an existing automation rule.
|
|
763
|
+
*/
|
|
764
|
+
update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
|
|
765
|
+
/**
|
|
766
|
+
* Enable or disable an automation rule.
|
|
767
|
+
*/
|
|
768
|
+
toggle<T = any>(ruleId: string): Promise<T>;
|
|
769
|
+
/**
|
|
770
|
+
* Delete an automation rule.
|
|
771
|
+
*/
|
|
772
|
+
deleteRule<T = any>(ruleId: string): Promise<T>;
|
|
773
|
+
/**
|
|
774
|
+
* Bulk delete rules.
|
|
775
|
+
*/
|
|
776
|
+
bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
|
|
777
|
+
/**
|
|
778
|
+
* Dry-run test an automation rule against a specific lead.
|
|
779
|
+
*/
|
|
780
|
+
test<T = any>(ruleId: string, leadId: string): Promise<T>;
|
|
781
|
+
/**
|
|
782
|
+
* List enrollments for a rule.
|
|
783
|
+
*/
|
|
784
|
+
enrollments<T = any>(ruleId: string): Promise<T>;
|
|
785
|
+
/**
|
|
786
|
+
* Get an enrollment detail.
|
|
787
|
+
*/
|
|
788
|
+
getEnrollment<T = any>(enrollmentId: string): Promise<T>;
|
|
789
|
+
/**
|
|
790
|
+
* Pause an enrollment.
|
|
791
|
+
*/
|
|
792
|
+
pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
793
|
+
/**
|
|
794
|
+
* Resume an enrollment.
|
|
795
|
+
*/
|
|
796
|
+
resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
797
|
+
/**
|
|
798
|
+
* List workflow runs.
|
|
799
|
+
*/
|
|
800
|
+
runs<T = any>(ruleId: string): Promise<T>;
|
|
801
|
+
/**
|
|
802
|
+
* Get run details.
|
|
803
|
+
*/
|
|
804
|
+
getRun<T = any>(runId: string): Promise<T>;
|
|
805
|
+
/**
|
|
806
|
+
* Resume a paused run.
|
|
807
|
+
*/
|
|
808
|
+
resumeRun<T = any>(runId: string): Promise<T>;
|
|
809
|
+
/**
|
|
810
|
+
* Abort a running workflow.
|
|
811
|
+
*/
|
|
812
|
+
abortRun<T = any>(runId: string): Promise<T>;
|
|
813
|
+
/**
|
|
814
|
+
* Emit an external webhook event to unlock a `wait_event` node inside a
|
|
815
|
+
* paused workflow run. Required when integrating third-party tools that
|
|
816
|
+
* need to resume a suspended automation.
|
|
817
|
+
*
|
|
818
|
+
* @param ruleId - The automation rule that contains the wait_event node.
|
|
819
|
+
* @param eventName - The event name that should match the node's condition.
|
|
820
|
+
* @param payload - Arbitrary data forwarded to the node context.
|
|
821
|
+
*/
|
|
822
|
+
webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
|
|
802
823
|
}
|
|
803
824
|
|
|
804
825
|
declare class Sequences extends APIResource {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
826
|
+
/**
|
|
827
|
+
* Manually enroll a lead in a drip sequence (automation rule).
|
|
828
|
+
*/
|
|
829
|
+
enroll<T = any>(payload: {
|
|
830
|
+
leadId: string;
|
|
831
|
+
ruleId: string;
|
|
832
|
+
variables?: Record<string, any>;
|
|
833
|
+
}): Promise<T>;
|
|
834
|
+
/**
|
|
835
|
+
* Unenroll a lead from a running sequence.
|
|
836
|
+
*/
|
|
837
|
+
unenroll<T = any>(enrollmentId: string): Promise<T>;
|
|
838
|
+
/**
|
|
839
|
+
* List active sequence enrollments for a specific lead.
|
|
840
|
+
*/
|
|
841
|
+
listForLead<T = any>(leadId: string): Promise<T>;
|
|
821
842
|
}
|
|
822
843
|
|
|
823
844
|
interface ScoringConfig {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
845
|
+
decayDays: number;
|
|
846
|
+
thresholds: {
|
|
847
|
+
hot: number;
|
|
848
|
+
warm: number;
|
|
849
|
+
};
|
|
850
|
+
rules: any[];
|
|
830
851
|
}
|
|
831
852
|
declare class Scoring extends APIResource {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
853
|
+
/**
|
|
854
|
+
* Retrieve the tenant's global lead scoring configuration.
|
|
855
|
+
*/
|
|
856
|
+
getConfig<T = any>(): Promise<T>;
|
|
857
|
+
/**
|
|
858
|
+
* Update scoring configuration.
|
|
859
|
+
*/
|
|
860
|
+
updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
|
|
861
|
+
/**
|
|
862
|
+
* Force recalculate the score for a specific lead.
|
|
863
|
+
*/
|
|
864
|
+
recalculate<T = any>(leadId: string): Promise<T>;
|
|
844
865
|
}
|
|
845
866
|
|
|
846
867
|
declare class Payments extends APIResource {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
868
|
+
/**
|
|
869
|
+
* Record an inbound payment against a lead or appointment.
|
|
870
|
+
*/
|
|
871
|
+
capture<T = any>(payload: {
|
|
872
|
+
leadId: string;
|
|
873
|
+
amount: number;
|
|
874
|
+
currency?: string;
|
|
875
|
+
description?: string;
|
|
876
|
+
appointmentId?: string;
|
|
877
|
+
}): Promise<T>;
|
|
857
878
|
}
|
|
858
879
|
|
|
859
880
|
declare class AutomationDashboard extends APIResource {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
881
|
+
/**
|
|
882
|
+
* Retrieve summary statistics for automation health.
|
|
883
|
+
*/
|
|
884
|
+
stats<T = any>(): Promise<T>;
|
|
885
|
+
/**
|
|
886
|
+
* List recent EventLog entries (automation logs).
|
|
887
|
+
*/
|
|
888
|
+
logs<T = any>(params?: {
|
|
889
|
+
limit?: number;
|
|
890
|
+
status?: string;
|
|
891
|
+
}): Promise<T>;
|
|
892
|
+
/**
|
|
893
|
+
* Re-emit a failed event log to process its automations again.
|
|
894
|
+
*/
|
|
895
|
+
retryFailedEvent<T = any>(logId: string): Promise<T>;
|
|
875
896
|
}
|
|
876
897
|
|
|
877
898
|
declare class CRM {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
899
|
+
leads: Leads;
|
|
900
|
+
pipelines: Pipelines;
|
|
901
|
+
activities: Activities;
|
|
902
|
+
analytics: Analytics;
|
|
903
|
+
automations: Automations;
|
|
904
|
+
sequences: Sequences;
|
|
905
|
+
scoring: Scoring;
|
|
906
|
+
payments: Payments;
|
|
907
|
+
automationDashboard: AutomationDashboard;
|
|
908
|
+
constructor(client: AxiosInstance);
|
|
888
909
|
}
|
|
889
910
|
|
|
890
911
|
/**
|
|
891
912
|
* Options for the `upload()` elite helper.
|
|
892
913
|
*/
|
|
893
914
|
interface UploadOptions {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
915
|
+
/**
|
|
916
|
+
* The destination folder key in R2.
|
|
917
|
+
* @example "customer_documents" | "avatars" | "invoices"
|
|
918
|
+
*/
|
|
919
|
+
folder: string;
|
|
920
|
+
/**
|
|
921
|
+
* The desired filename, including extension.
|
|
922
|
+
* @example "contract.pdf" | "profile.jpg"
|
|
923
|
+
*/
|
|
924
|
+
filename: string;
|
|
925
|
+
/**
|
|
926
|
+
* The MIME type of the file.
|
|
927
|
+
* @example "application/pdf" | "image/jpeg" | "video/mp4"
|
|
928
|
+
*/
|
|
929
|
+
contentType: string;
|
|
909
930
|
}
|
|
910
931
|
/**
|
|
911
932
|
* Cloudflare R2-backed media resource.
|
|
@@ -927,148 +948,151 @@ interface UploadOptions {
|
|
|
927
948
|
* ```
|
|
928
949
|
*/
|
|
929
950
|
declare class MediaResource extends APIResource {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
951
|
+
/**
|
|
952
|
+
* Get current storage usage metrics for the tenant.
|
|
953
|
+
*
|
|
954
|
+
* @returns `{ usedMB, limitMB, fileCount }`
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* const { data } = await ecod.media.getUsage();
|
|
959
|
+
* console.log(`${data.usedMB} / ${data.limitMB} MB used`);
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
getUsage(): Promise<unknown>;
|
|
963
|
+
/**
|
|
964
|
+
* Create a new top-level folder in the tenant's R2 bucket.
|
|
965
|
+
*
|
|
966
|
+
* @param name - Folder name (alphanumeric, hyphens, underscores).
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* await ecod.media.createFolder("patient_records");
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
createFolder(name: string): Promise<unknown>;
|
|
974
|
+
/**
|
|
975
|
+
* List files within a specific folder, with optional date filtering.
|
|
976
|
+
*
|
|
977
|
+
* @param folder - The folder key to list.
|
|
978
|
+
* @param params - Optional `year` and `month` filters (e.g. `{ year: "2026", month: "04" }`).
|
|
979
|
+
* @returns Array of file metadata objects.
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* const { data: files } = await ecod.media.list("invoices", { year: "2026" });
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
list(
|
|
987
|
+
folder: string,
|
|
988
|
+
params?: {
|
|
989
|
+
year?: string;
|
|
990
|
+
month?: string;
|
|
991
|
+
},
|
|
992
|
+
): Promise<unknown>;
|
|
993
|
+
/**
|
|
994
|
+
* Delete a file from R2 by its storage key.
|
|
995
|
+
*
|
|
996
|
+
* @param key - The full storage key of the file (e.g. `"invoices/contract.pdf"`).
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* await ecod.media.delete("invoices/old-contract.pdf");
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
delete(key: string): Promise<unknown>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Request a temporary presigned download URL for a private file.
|
|
1006
|
+
*
|
|
1007
|
+
* @param key - The full storage key of the file.
|
|
1008
|
+
* @returns `{ url }` — a time-limited download URL.
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```typescript
|
|
1012
|
+
* const { data } = await ecod.media.getDownloadUrl("invoices/contract.pdf");
|
|
1013
|
+
* // → { url: "https://cdn.ecodrix.com/...?token=..." }
|
|
1014
|
+
* ```
|
|
1015
|
+
*/
|
|
1016
|
+
getDownloadUrl(key: string): Promise<unknown>;
|
|
1017
|
+
/**
|
|
1018
|
+
* **Elite Upload Helper** — uploads a file to Cloudflare R2 in a single call.
|
|
1019
|
+
*
|
|
1020
|
+
* This orchestrates 3 steps transparently:
|
|
1021
|
+
* 1. Fetch a presigned `PUT` URL from the ECODrIx backend.
|
|
1022
|
+
* 2. Upload the file _directly_ to R2 (no API proxy, maximum throughput).
|
|
1023
|
+
* 3. Confirm the upload with the backend so it is indexed and tracked.
|
|
1024
|
+
*
|
|
1025
|
+
* Works with Node.js `Buffer`, browser `File`/`Blob`, or any stream-like
|
|
1026
|
+
* object that Axios can PUT.
|
|
1027
|
+
*
|
|
1028
|
+
* @param file - The file data to upload.
|
|
1029
|
+
* @param options - Folder, filename, and content type.
|
|
1030
|
+
* @returns Confirmed file metadata including `key` and `url`.
|
|
1031
|
+
*
|
|
1032
|
+
* @example Node.js
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* import { readFileSync } from "fs";
|
|
1035
|
+
* const buf = readFileSync("./invoice.pdf");
|
|
1036
|
+
* const { data } = await ecod.media.upload(buf, {
|
|
1037
|
+
* folder: "invoices",
|
|
1038
|
+
* filename: "invoice-001.pdf",
|
|
1039
|
+
* contentType: "application/pdf",
|
|
1040
|
+
* });
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @example Browser
|
|
1044
|
+
* ```typescript
|
|
1045
|
+
* const file = inputElement.files[0];
|
|
1046
|
+
* const { data } = await ecod.media.upload(file, {
|
|
1047
|
+
* folder: "avatars",
|
|
1048
|
+
* filename: file.name,
|
|
1049
|
+
* contentType: file.type,
|
|
1050
|
+
* });
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
upload(file: any, options: UploadOptions): Promise<any>;
|
|
1030
1054
|
}
|
|
1031
1055
|
|
|
1032
1056
|
/**
|
|
1033
1057
|
* Parameters for scheduling a new Google Meet appointment.
|
|
1034
1058
|
*/
|
|
1035
1059
|
interface CreateMeetingParams {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1060
|
+
/** The CRM Lead ID this meeting belongs to. */
|
|
1061
|
+
leadId: string;
|
|
1062
|
+
/** Full name of the external participant. */
|
|
1063
|
+
participantName: string;
|
|
1064
|
+
/** Phone number of the participant in E.164 format. */
|
|
1065
|
+
participantPhone: string;
|
|
1066
|
+
/**
|
|
1067
|
+
* Meeting start time.
|
|
1068
|
+
* @example new Date("2026-04-10T10:00:00.000Z")
|
|
1069
|
+
*/
|
|
1070
|
+
startTime: Date | string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Meeting end time.
|
|
1073
|
+
* @example new Date("2026-04-10T10:30:00.000Z")
|
|
1074
|
+
*/
|
|
1075
|
+
endTime: Date | string;
|
|
1076
|
+
/** Arbitrary metadata to attach to the meeting record. */
|
|
1077
|
+
metadata?: Record<string, any>;
|
|
1054
1078
|
}
|
|
1055
1079
|
/**
|
|
1056
1080
|
* Parameters for updating an existing meeting.
|
|
1057
1081
|
*/
|
|
1058
1082
|
interface UpdateMeetingParams {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1083
|
+
/**
|
|
1084
|
+
* Update the meeting status.
|
|
1085
|
+
* @example "scheduled" | "completed" | "cancelled"
|
|
1086
|
+
*/
|
|
1087
|
+
status?: string;
|
|
1088
|
+
/** Update the payment status for paid consultations. */
|
|
1089
|
+
paymentStatus?: string;
|
|
1090
|
+
/** New start time for rescheduling. */
|
|
1091
|
+
startTime?: Date | string;
|
|
1092
|
+
/** New end time for rescheduling. */
|
|
1093
|
+
endTime?: Date | string;
|
|
1094
|
+
/** Duration in minutes. */
|
|
1095
|
+
duration?: number;
|
|
1072
1096
|
}
|
|
1073
1097
|
/**
|
|
1074
1098
|
* Google Meet appointment scheduling resource.
|
|
@@ -1088,118 +1112,121 @@ interface UpdateMeetingParams {
|
|
|
1088
1112
|
* ```
|
|
1089
1113
|
*/
|
|
1090
1114
|
declare class Meetings extends APIResource {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1115
|
+
/**
|
|
1116
|
+
* Schedule a new Google Meet with a lead.
|
|
1117
|
+
*
|
|
1118
|
+
* The backend automatically creates a Google Calendar event and generates
|
|
1119
|
+
* a Meet link, then sends confirmation notifications via WhatsApp.
|
|
1120
|
+
*
|
|
1121
|
+
* @param data - Meeting details.
|
|
1122
|
+
* @returns The created Meeting document including `meetLink`.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const { data } = await ecod.meet.create({
|
|
1127
|
+
* leadId: "64abc...",
|
|
1128
|
+
* participantName: "Alice",
|
|
1129
|
+
* participantPhone: "+91...",
|
|
1130
|
+
* startTime: "2026-04-10T10:00:00Z",
|
|
1131
|
+
* endTime: "2026-04-10T10:30:00Z",
|
|
1132
|
+
* });
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
create(data: CreateMeetingParams): Promise<any>;
|
|
1136
|
+
/**
|
|
1137
|
+
* List all meetings for the tenant, with optional filters.
|
|
1138
|
+
*
|
|
1139
|
+
* @param params - `leadId` to filter by lead; `status` to filter by state.
|
|
1140
|
+
* @returns Array of Meeting documents.
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const { data } = await ecod.meet.list({ status: "scheduled" });
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
list(params?: {
|
|
1148
|
+
leadId?: string;
|
|
1149
|
+
status?: string;
|
|
1150
|
+
}): Promise<any>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Retrieve the full details for a specific meeting.
|
|
1153
|
+
*
|
|
1154
|
+
* @param meetingId - The unique meeting ID.
|
|
1155
|
+
* @returns The Meeting document.
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* const { data } = await ecod.meet.retrieve("meeting_id");
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
retrieve(meetingId: string): Promise<any>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Update or reschedule an existing meeting.
|
|
1165
|
+
*
|
|
1166
|
+
* Partial updates are supported — only supply the fields you wish to change.
|
|
1167
|
+
*
|
|
1168
|
+
* @param meetingId - The meeting to update.
|
|
1169
|
+
* @param data - Fields to update.
|
|
1170
|
+
* @returns The updated Meeting document.
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* // Reschedule
|
|
1175
|
+
* await ecod.meet.update("meeting_id", {
|
|
1176
|
+
* startTime: "2026-04-11T11:00:00Z",
|
|
1177
|
+
* endTime: "2026-04-11T11:30:00Z",
|
|
1178
|
+
* });
|
|
1179
|
+
* ```
|
|
1180
|
+
*/
|
|
1181
|
+
update<T = any>(meetingId: string, data: UpdateMeetingParams): Promise<T>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Reschedule an existing meeting. Provides explicit method for time modifications.
|
|
1184
|
+
*/
|
|
1185
|
+
reschedule<T = any>(
|
|
1186
|
+
meetingId: string,
|
|
1187
|
+
params: {
|
|
1188
|
+
startTime: Date | string;
|
|
1189
|
+
endTime: Date | string;
|
|
1190
|
+
duration?: number;
|
|
1191
|
+
},
|
|
1192
|
+
): Promise<T>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Cancel a meeting. This sets the meeting status to `"cancelled"`.
|
|
1195
|
+
*
|
|
1196
|
+
* @param meetingId - The meeting to cancel.
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```typescript
|
|
1200
|
+
* await ecod.meet.delete("meeting_id");
|
|
1201
|
+
* ```
|
|
1202
|
+
*/
|
|
1203
|
+
delete(meetingId: string): Promise<any>;
|
|
1177
1204
|
}
|
|
1178
1205
|
|
|
1179
1206
|
/**
|
|
1180
1207
|
* Filters for querying event and automation execution logs.
|
|
1181
1208
|
*/
|
|
1182
1209
|
interface LogFilter {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1210
|
+
/** Page number for pagination (1-indexed). */
|
|
1211
|
+
page?: number;
|
|
1212
|
+
/** Maximum number of records to return per page. */
|
|
1213
|
+
limit?: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* Filter by automation trigger name.
|
|
1216
|
+
* @example "lead_created" | "appointment_booked"
|
|
1217
|
+
*/
|
|
1218
|
+
trigger?: string;
|
|
1219
|
+
/**
|
|
1220
|
+
* Filter by execution status.
|
|
1221
|
+
* @example "success" | "failed" | "pending"
|
|
1222
|
+
*/
|
|
1223
|
+
status?: string;
|
|
1224
|
+
/** Filter logs associated with a specific phone number. */
|
|
1225
|
+
phone?: string;
|
|
1226
|
+
/** Start of the date range (inclusive). ISO 8601 or Date object. */
|
|
1227
|
+
startDate?: string | Date;
|
|
1228
|
+
/** End of the date range (inclusive). ISO 8601 or Date object. */
|
|
1229
|
+
endDate?: string | Date;
|
|
1203
1230
|
}
|
|
1204
1231
|
/**
|
|
1205
1232
|
* Automation event log and provider callback resource.
|
|
@@ -1221,264 +1248,264 @@ interface LogFilter {
|
|
|
1221
1248
|
* ```
|
|
1222
1249
|
*/
|
|
1223
1250
|
declare class Notifications extends APIResource {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1251
|
+
/**
|
|
1252
|
+
* List automation execution logs with optional filtering.
|
|
1253
|
+
*
|
|
1254
|
+
* Each log entry represents one automation run triggered by a platform event.
|
|
1255
|
+
* Filter by `status: "failed"` to build a failure alerting pipeline.
|
|
1256
|
+
*
|
|
1257
|
+
* @param params - Optional filter criteria.
|
|
1258
|
+
* @returns Paginated list of event log objects.
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```typescript
|
|
1262
|
+
* const { data: failed } = await ecod.notifications.listLogs({
|
|
1263
|
+
* status: "failed",
|
|
1264
|
+
* trigger: "lead_created",
|
|
1265
|
+
* limit: 50,
|
|
1266
|
+
* });
|
|
1267
|
+
* ```
|
|
1268
|
+
*/
|
|
1269
|
+
listLogs(params?: LogFilter): Promise<unknown>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Retrieve the full details for a single automation event log entry.
|
|
1272
|
+
*
|
|
1273
|
+
* @param logId - The unique log ID.
|
|
1274
|
+
* @returns A single event log document including the payload and error trace.
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```typescript
|
|
1278
|
+
* const { data } = await ecod.notifications.retrieveLog("log_64abc...");
|
|
1279
|
+
* console.log(data.error); // → "Provider timeout after 30s"
|
|
1280
|
+
* ```
|
|
1281
|
+
*/
|
|
1282
|
+
retrieveLog(logId: string): Promise<unknown>;
|
|
1283
|
+
/**
|
|
1284
|
+
* Get a summary statistics object for automation event execution.
|
|
1285
|
+
*
|
|
1286
|
+
* @param params - Optional date range for the summary window.
|
|
1287
|
+
* @returns `{ total, success, failed, pending }` counts.
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* const { data: stats } = await ecod.notifications.getStats({
|
|
1292
|
+
* startDate: "2026-04-01",
|
|
1293
|
+
* endDate: "2026-04-30",
|
|
1294
|
+
* });
|
|
1295
|
+
* console.log(`Failed: ${stats.failed} / ${stats.total}`);
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
getStats(params?: {
|
|
1299
|
+
startDate?: string;
|
|
1300
|
+
endDate?: string;
|
|
1301
|
+
}): Promise<unknown>;
|
|
1302
|
+
/**
|
|
1303
|
+
* List external provider webhook callback logs.
|
|
1304
|
+
*
|
|
1305
|
+
* These are inbound HTTP callbacks from third-party providers
|
|
1306
|
+
* (payment gateways, email services, etc.) stored for audit purposes.
|
|
1307
|
+
*
|
|
1308
|
+
* @param params - Pagination and date filter options.
|
|
1309
|
+
* @returns Paginated list of callback log records.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```typescript
|
|
1313
|
+
* const { data } = await ecod.notifications.listCallbacks({ limit: 20 });
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
|
|
1317
|
+
/**
|
|
1318
|
+
* List active CRM notifications/alerts for the current agent.
|
|
1319
|
+
*/
|
|
1320
|
+
listAlerts<T = any>(params?: {
|
|
1321
|
+
limit?: number;
|
|
1322
|
+
unreadOnly?: boolean;
|
|
1323
|
+
}): Promise<T>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Dismiss a specific notification alert.
|
|
1326
|
+
*/
|
|
1327
|
+
dismissAlert<T = any>(notificationId: string): Promise<T>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Clear (dismiss) all notifications for the current agent.
|
|
1330
|
+
*/
|
|
1331
|
+
clearAllAlerts<T = any>(): Promise<T>;
|
|
1332
|
+
/**
|
|
1333
|
+
* Retry an action from a notification (e.g. failed send).
|
|
1334
|
+
*/
|
|
1335
|
+
retryAction<T = any>(notificationId: string): Promise<T>;
|
|
1309
1336
|
}
|
|
1310
1337
|
|
|
1311
1338
|
/**
|
|
1312
1339
|
* Payload to send a high-throughput email campaign.
|
|
1313
1340
|
*/
|
|
1314
1341
|
interface SendCampaignPayload {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1342
|
+
/** Array of recipient email addresses. */
|
|
1343
|
+
recipients: string[];
|
|
1344
|
+
/** Subject line of the email. */
|
|
1345
|
+
subject: string;
|
|
1346
|
+
/** HTML body of the email. */
|
|
1347
|
+
html: string;
|
|
1321
1348
|
}
|
|
1322
1349
|
/**
|
|
1323
1350
|
* Interface representing the result of a campaign dispatch.
|
|
1324
1351
|
*/
|
|
1325
1352
|
interface CampaignResult {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1353
|
+
success: boolean;
|
|
1354
|
+
message?: string;
|
|
1355
|
+
[key: string]: any;
|
|
1329
1356
|
}
|
|
1330
1357
|
declare class EmailResource extends APIResource {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1358
|
+
/**
|
|
1359
|
+
* Send an HTML email campaign to a list of recipients.
|
|
1360
|
+
*
|
|
1361
|
+
* @param payload - The campaign details (recipients, subject, html).
|
|
1362
|
+
* @returns The dispatch result.
|
|
1363
|
+
*/
|
|
1364
|
+
sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Send a system verification/test email to validate SMTP configuration.
|
|
1367
|
+
*
|
|
1368
|
+
* @param to - The recipient's email address.
|
|
1369
|
+
* @returns The dispatch result.
|
|
1370
|
+
*/
|
|
1371
|
+
sendTestEmail(to: string): Promise<CampaignResult>;
|
|
1345
1372
|
}
|
|
1346
1373
|
|
|
1347
1374
|
/**
|
|
1348
1375
|
* Event definition representing an entry point capable of triggering automations.
|
|
1349
1376
|
*/
|
|
1350
1377
|
interface EventDefinition {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1378
|
+
name: string;
|
|
1379
|
+
displayName: string;
|
|
1380
|
+
description?: string;
|
|
1381
|
+
pipelineId?: string;
|
|
1382
|
+
stageId?: string;
|
|
1383
|
+
defaultSource?: string;
|
|
1384
|
+
[key: string]: any;
|
|
1358
1385
|
}
|
|
1359
1386
|
/**
|
|
1360
1387
|
* Payload to register/assign a new custom event definition.
|
|
1361
1388
|
*/
|
|
1362
1389
|
interface AssignEventPayload {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1390
|
+
/** The internal machine-readable name of the event (e.g. "webinar_joined") */
|
|
1391
|
+
name: string;
|
|
1392
|
+
/** Human-readable display name */
|
|
1393
|
+
displayName: string;
|
|
1394
|
+
/** Event description */
|
|
1395
|
+
description?: string;
|
|
1396
|
+
/** ID of the pipeline to associate with matching leads */
|
|
1397
|
+
pipelineId?: string;
|
|
1398
|
+
/** ID of the stage within the pipeline */
|
|
1399
|
+
stageId?: string;
|
|
1400
|
+
/** Default source tag for leads created via this event */
|
|
1401
|
+
defaultSource?: string;
|
|
1375
1402
|
}
|
|
1376
1403
|
/**
|
|
1377
1404
|
* Payload to programmatically trigger an event/workflow.
|
|
1378
1405
|
*/
|
|
1379
1406
|
interface TriggerPayload {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1407
|
+
/** The name of the event to fire (e.g., "webinar_joined") */
|
|
1408
|
+
trigger: string;
|
|
1409
|
+
/** Phone number of the lead (E.164 format) */
|
|
1410
|
+
phone: string;
|
|
1411
|
+
/** Email of the lead */
|
|
1412
|
+
email?: string;
|
|
1413
|
+
/** Key-value pairs for string templates */
|
|
1414
|
+
variables?: Record<string, string>;
|
|
1415
|
+
/** Deep payload data mapping to the event */
|
|
1416
|
+
data?: any;
|
|
1417
|
+
/** URL to receive an acknowledgment callback when processing completes */
|
|
1418
|
+
callbackUrl?: string;
|
|
1419
|
+
/** Secret metadata passed back to the callback URL */
|
|
1420
|
+
callbackMetadata?: any;
|
|
1421
|
+
/** Auto-create lead if phone does not exist in CRM */
|
|
1422
|
+
createLeadIfMissing?: boolean;
|
|
1423
|
+
/** Pre-fill data if creating a new lead */
|
|
1424
|
+
leadData?: {
|
|
1425
|
+
firstName?: string;
|
|
1426
|
+
lastName?: string;
|
|
1427
|
+
source?: string;
|
|
1428
|
+
};
|
|
1429
|
+
/** Delay execution of matched workflows (in seconds) */
|
|
1430
|
+
delaySeconds?: number;
|
|
1431
|
+
/** Delay execution of matched workflows (in minutes) */
|
|
1432
|
+
delayMinutes?: number;
|
|
1433
|
+
/** Explicit ISO timestamp to trigger the workflow run */
|
|
1434
|
+
runAt?: string;
|
|
1408
1435
|
}
|
|
1409
1436
|
/**
|
|
1410
1437
|
* Response returned when triggering an event.
|
|
1411
1438
|
*/
|
|
1412
1439
|
interface TriggerResponse {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1440
|
+
success: boolean;
|
|
1441
|
+
data?: {
|
|
1442
|
+
eventLogId: string;
|
|
1443
|
+
trigger: string;
|
|
1444
|
+
leadId: string;
|
|
1445
|
+
rulesMatched: number;
|
|
1446
|
+
};
|
|
1447
|
+
message?: string;
|
|
1448
|
+
code?: string;
|
|
1422
1449
|
}
|
|
1423
1450
|
declare class EventsResource extends APIResource {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1451
|
+
/**
|
|
1452
|
+
* Retrieve all valid events (system + custom) that can be used as Automation Rule triggers.
|
|
1453
|
+
*/
|
|
1454
|
+
list(): Promise<{
|
|
1455
|
+
success: boolean;
|
|
1456
|
+
data: EventDefinition[];
|
|
1457
|
+
}>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Register a new custom event entry point into the CRM automation engine.
|
|
1460
|
+
* Useful when introducing new granular triggers.
|
|
1461
|
+
*/
|
|
1462
|
+
assign(payload: AssignEventPayload): Promise<{
|
|
1463
|
+
success: boolean;
|
|
1464
|
+
data: EventDefinition;
|
|
1465
|
+
}>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Deactivate a custom event assignment by name.
|
|
1468
|
+
*/
|
|
1469
|
+
unassign(name: string): Promise<{
|
|
1470
|
+
success: boolean;
|
|
1471
|
+
data: any;
|
|
1472
|
+
}>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Deactivate multiple custom event assignments simultaneously.
|
|
1475
|
+
*/
|
|
1476
|
+
unassignBulk(names: string[]): Promise<{
|
|
1477
|
+
success: boolean;
|
|
1478
|
+
message: string;
|
|
1479
|
+
}>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Programmatically fire an event into the CRM automation engine.
|
|
1482
|
+
* Emits to the internal EventBus to match with active Workflow Automation Rules.
|
|
1483
|
+
*/
|
|
1484
|
+
trigger(payload: TriggerPayload): Promise<TriggerResponse>;
|
|
1485
|
+
/**
|
|
1486
|
+
* List all custom event definitions.
|
|
1487
|
+
*/
|
|
1488
|
+
listCustomEvents<T = any>(): Promise<T>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Create or upsert a custom event definition.
|
|
1491
|
+
*/
|
|
1492
|
+
createCustomEvent<T = any>(payload: {
|
|
1493
|
+
name: string;
|
|
1494
|
+
displayName: string;
|
|
1495
|
+
description?: string;
|
|
1496
|
+
}): Promise<T>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Delete a custom event definition.
|
|
1499
|
+
*/
|
|
1500
|
+
deleteCustomEvent<T = any>(id: string): Promise<T>;
|
|
1501
|
+
/**
|
|
1502
|
+
* Manually emit a custom event to trigger workflows based on its definition.
|
|
1503
|
+
*/
|
|
1504
|
+
emit<T = any>(payload: {
|
|
1505
|
+
eventName: string;
|
|
1506
|
+
leadId: string;
|
|
1507
|
+
data?: any;
|
|
1508
|
+
}): Promise<T>;
|
|
1482
1509
|
}
|
|
1483
1510
|
|
|
1484
1511
|
/**
|
|
@@ -1507,36 +1534,36 @@ declare class EventsResource extends APIResource {
|
|
|
1507
1534
|
*/
|
|
1508
1535
|
/** Base class for all ECODrIx SDK errors. */
|
|
1509
1536
|
declare class EcodrixError extends Error {
|
|
1510
|
-
|
|
1537
|
+
constructor(message: string);
|
|
1511
1538
|
}
|
|
1512
1539
|
/**
|
|
1513
1540
|
* Represents an error returned by the ECODrIx API.
|
|
1514
1541
|
* Carries the HTTP `status` code and an optional `code` string.
|
|
1515
1542
|
*/
|
|
1516
1543
|
declare class APIError extends EcodrixError {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1544
|
+
/** HTTP status code returned by the API (e.g. 400, 404, 500). */
|
|
1545
|
+
status?: number;
|
|
1546
|
+
/** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
|
|
1547
|
+
code?: string;
|
|
1548
|
+
constructor(message: string, status?: number, code?: string);
|
|
1522
1549
|
}
|
|
1523
1550
|
/**
|
|
1524
1551
|
* Thrown when the API key or client code is missing, invalid, or expired.
|
|
1525
1552
|
* HTTP 401.
|
|
1526
1553
|
*/
|
|
1527
1554
|
declare class AuthenticationError extends APIError {
|
|
1528
|
-
|
|
1555
|
+
constructor(message?: string);
|
|
1529
1556
|
}
|
|
1530
1557
|
/**
|
|
1531
1558
|
* Thrown when the rate limit for the API key has been exceeded.
|
|
1532
1559
|
* HTTP 429. Implement exponential backoff before retrying.
|
|
1533
1560
|
*/
|
|
1534
1561
|
declare class RateLimitError extends APIError {
|
|
1535
|
-
|
|
1562
|
+
constructor(message?: string);
|
|
1536
1563
|
}
|
|
1537
1564
|
|
|
1538
1565
|
declare class WebhookSignatureError extends APIError {
|
|
1539
|
-
|
|
1566
|
+
constructor(message: string);
|
|
1540
1567
|
}
|
|
1541
1568
|
/**
|
|
1542
1569
|
* Validates and constructs webhook events sent by the ECODrIx platform.
|
|
@@ -1562,209 +1589,219 @@ declare class WebhookSignatureError extends APIError {
|
|
|
1562
1589
|
* ```
|
|
1563
1590
|
*/
|
|
1564
1591
|
declare class Webhooks {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1592
|
+
/**
|
|
1593
|
+
* Cryptographically validates a webhook payload.
|
|
1594
|
+
* Note: This method dynamically imports Node's `crypto` module, meaning it will only execute gracefully in a Server environment.
|
|
1595
|
+
*
|
|
1596
|
+
* @param payload - The raw request body as a string or Buffer.
|
|
1597
|
+
* @param signature - The `x-ecodrix-signature` header value.
|
|
1598
|
+
* @param secret - The webhook signing secret for your tenant.
|
|
1599
|
+
* @returns The parsed JSON object of the event if the signature is valid.
|
|
1600
|
+
* @throws WebhookSignatureError if the validation fails.
|
|
1601
|
+
*/
|
|
1602
|
+
constructEvent(
|
|
1603
|
+
payload: string | Buffer,
|
|
1604
|
+
signature: string | string[] | undefined,
|
|
1605
|
+
secret: string,
|
|
1606
|
+
): Promise<any>;
|
|
1576
1607
|
}
|
|
1577
1608
|
|
|
1578
1609
|
declare class Folders extends APIResource {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1610
|
+
/**
|
|
1611
|
+
* Create a new folder.
|
|
1612
|
+
*/
|
|
1613
|
+
create<T = any>(name: string): Promise<T>;
|
|
1614
|
+
/**
|
|
1615
|
+
* Delete a folder and its contents.
|
|
1616
|
+
*/
|
|
1617
|
+
delete<T = any>(folderPath: string): Promise<T>;
|
|
1587
1618
|
}
|
|
1588
1619
|
declare class Files extends APIResource {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1620
|
+
/**
|
|
1621
|
+
* List files in a folder.
|
|
1622
|
+
*/
|
|
1623
|
+
list<T = any>(
|
|
1624
|
+
folder: string,
|
|
1625
|
+
params?: {
|
|
1626
|
+
year?: string;
|
|
1627
|
+
month?: string;
|
|
1628
|
+
},
|
|
1629
|
+
): Promise<T>;
|
|
1630
|
+
/**
|
|
1631
|
+
* Get a presigned upload URL for direct-to-cloud browser uploads.
|
|
1632
|
+
*/
|
|
1633
|
+
getUploadUrl<T = any>(params: {
|
|
1634
|
+
folder: string;
|
|
1635
|
+
filename: string;
|
|
1636
|
+
contentType: string;
|
|
1637
|
+
}): Promise<T>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Notify backend after a successful direct browser upload.
|
|
1640
|
+
*/
|
|
1641
|
+
confirmUpload<T = any>(params: {
|
|
1642
|
+
key: string;
|
|
1643
|
+
sizeBytes: number;
|
|
1644
|
+
}): Promise<T>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Get a presigned download URL for an R2 key.
|
|
1647
|
+
*/
|
|
1648
|
+
getDownloadUrl<T = any>(key: string): Promise<T>;
|
|
1649
|
+
/**
|
|
1650
|
+
* Delete a file by key.
|
|
1651
|
+
*/
|
|
1652
|
+
delete(key: string): Promise<unknown>;
|
|
1619
1653
|
}
|
|
1620
1654
|
declare class Storage extends APIResource {
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1655
|
+
folders: Folders;
|
|
1656
|
+
files: Files;
|
|
1657
|
+
constructor(client: any);
|
|
1658
|
+
/**
|
|
1659
|
+
* Get tenant storage usage and quota limitations.
|
|
1660
|
+
*/
|
|
1661
|
+
usage<T = any>(): Promise<T>;
|
|
1628
1662
|
}
|
|
1629
1663
|
|
|
1630
1664
|
interface SendCampaignParams {
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1665
|
+
recipients: string[];
|
|
1666
|
+
subject: string;
|
|
1667
|
+
html: string;
|
|
1634
1668
|
}
|
|
1635
1669
|
declare class Emails extends APIResource {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1670
|
+
/**
|
|
1671
|
+
* Dispatch a bulk email campaign.
|
|
1672
|
+
*/
|
|
1673
|
+
sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Send a test verification email (used to verify SMTP functionality).
|
|
1676
|
+
*/
|
|
1677
|
+
sendTest<T = any>(to: string): Promise<T>;
|
|
1644
1678
|
}
|
|
1645
1679
|
declare class Campaigns extends APIResource {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1680
|
+
/**
|
|
1681
|
+
* List email and SMS marketing campaigns.
|
|
1682
|
+
*/
|
|
1683
|
+
list<T = any>(params?: {
|
|
1684
|
+
status?: string;
|
|
1685
|
+
limit?: number;
|
|
1686
|
+
}): Promise<T>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Create a new campaign.
|
|
1689
|
+
*/
|
|
1690
|
+
create<T = any>(payload: {
|
|
1691
|
+
name: string;
|
|
1692
|
+
type: string;
|
|
1693
|
+
subject?: string;
|
|
1694
|
+
html?: string;
|
|
1695
|
+
templateId?: string;
|
|
1696
|
+
recipients?: string[];
|
|
1697
|
+
}): Promise<T>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Retrieve campaign details.
|
|
1700
|
+
*/
|
|
1701
|
+
retrieve<T = any>(campaignId: string): Promise<T>;
|
|
1702
|
+
/**
|
|
1703
|
+
* Update a campaign.
|
|
1704
|
+
*/
|
|
1705
|
+
update<T = any>(campaignId: string, payload: any): Promise<T>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Delete a campaign.
|
|
1708
|
+
*/
|
|
1709
|
+
delete<T = any>(campaignId: string): Promise<T>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Send or schedule a campaign.
|
|
1712
|
+
*/
|
|
1713
|
+
send<T = any>(
|
|
1714
|
+
campaignId: string,
|
|
1715
|
+
payload?: {
|
|
1716
|
+
scheduledAt?: string;
|
|
1717
|
+
},
|
|
1718
|
+
): Promise<T>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Get campaign stats (opens, clicks, bounces).
|
|
1721
|
+
*/
|
|
1722
|
+
stats<T = any>(campaignId: string): Promise<T>;
|
|
1686
1723
|
}
|
|
1687
1724
|
declare class Marketing extends APIResource {
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1725
|
+
emails: Emails;
|
|
1726
|
+
campaigns: Campaigns;
|
|
1727
|
+
constructor(client: any);
|
|
1691
1728
|
}
|
|
1692
1729
|
|
|
1693
1730
|
interface SystemHealth {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1731
|
+
status: string;
|
|
1732
|
+
version: string;
|
|
1733
|
+
env: string;
|
|
1734
|
+
uptime: number;
|
|
1735
|
+
db: string;
|
|
1736
|
+
queueDepth: number;
|
|
1737
|
+
timestamp: string;
|
|
1701
1738
|
}
|
|
1702
1739
|
interface ClientHealth {
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1740
|
+
clientCode: string;
|
|
1741
|
+
services: {
|
|
1742
|
+
whatsapp: "connected" | "not_configured";
|
|
1743
|
+
email: "configured" | "not_configured";
|
|
1744
|
+
googleMeet: "configured" | "not_configured";
|
|
1745
|
+
};
|
|
1746
|
+
activeAutomations: number;
|
|
1747
|
+
queueDepth: number;
|
|
1748
|
+
timestamp: string;
|
|
1712
1749
|
}
|
|
1713
1750
|
interface JobStatus {
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1751
|
+
jobId: string;
|
|
1752
|
+
status: string;
|
|
1753
|
+
attempts: number;
|
|
1754
|
+
maxAttempts: number;
|
|
1755
|
+
lastError: any;
|
|
1756
|
+
runAt: string;
|
|
1757
|
+
completedAt: string | null;
|
|
1758
|
+
failedAt: string | null;
|
|
1759
|
+
createdAt: string;
|
|
1723
1760
|
}
|
|
1724
1761
|
declare class Health extends APIResource {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1762
|
+
/**
|
|
1763
|
+
* Global platform health check.
|
|
1764
|
+
*/
|
|
1765
|
+
system(): Promise<SystemHealth>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Tenant-specific health check. Identifies configured services.
|
|
1768
|
+
*/
|
|
1769
|
+
clientHealth(): Promise<ClientHealth>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Job execution status lookup.
|
|
1772
|
+
*/
|
|
1773
|
+
jobStatus(jobId: string): Promise<JobStatus>;
|
|
1737
1774
|
}
|
|
1738
1775
|
|
|
1739
1776
|
/**
|
|
1740
1777
|
* Configuration options for the Ecodrix client.
|
|
1741
1778
|
*/
|
|
1742
1779
|
interface EcodrixOptions {
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1780
|
+
/**
|
|
1781
|
+
* Your ECODrIx Platform API key.
|
|
1782
|
+
* Obtain this from the ECODrIx dashboard under Settings → API Keys.
|
|
1783
|
+
* @example "ecod_live_sk_..."
|
|
1784
|
+
*/
|
|
1785
|
+
apiKey: string;
|
|
1786
|
+
/**
|
|
1787
|
+
* Your tenant ID (Client Code).
|
|
1788
|
+
* This scopes all API requests to your specific organisation.
|
|
1789
|
+
* Required for most operations.
|
|
1790
|
+
* @example "ERIX_CLNT_JHBJHF"
|
|
1791
|
+
*/
|
|
1792
|
+
clientCode?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* Override the base URL of the ECODrIx API.
|
|
1795
|
+
* Useful for pointing to a local development or staging server.
|
|
1796
|
+
* @default "https://api.ecodrix.com"
|
|
1797
|
+
*/
|
|
1798
|
+
baseUrl?: string;
|
|
1799
|
+
/**
|
|
1800
|
+
* Override the Socket.io server URL for real-time events.
|
|
1801
|
+
* Defaults to the same value as `baseUrl`.
|
|
1802
|
+
* @default "https://api.ecodrix.com"
|
|
1803
|
+
*/
|
|
1804
|
+
socketUrl?: string;
|
|
1768
1805
|
}
|
|
1769
1806
|
/**
|
|
1770
1807
|
* The primary entry point for the ECODrIx SDK.
|
|
@@ -1786,86 +1823,157 @@ interface EcodrixOptions {
|
|
|
1786
1823
|
* ```
|
|
1787
1824
|
*/
|
|
1788
1825
|
declare class Ecodrix {
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1826
|
+
private readonly client;
|
|
1827
|
+
private readonly socket;
|
|
1828
|
+
/** WhatsApp messaging and conversation management. */
|
|
1829
|
+
readonly whatsapp: WhatsApp;
|
|
1830
|
+
/** CRM resources — Leads and related sub-resources. */
|
|
1831
|
+
readonly crm: CRM;
|
|
1832
|
+
/** Cloudflare R2-backed media storage. */
|
|
1833
|
+
readonly media: MediaResource;
|
|
1834
|
+
/** Google Meet appointment scheduling. */
|
|
1835
|
+
readonly meet: Meetings;
|
|
1836
|
+
/** Automation execution logs and provider webhook callbacks. */
|
|
1837
|
+
readonly notifications: Notifications;
|
|
1838
|
+
/** Outbound email marketing engine. */
|
|
1839
|
+
readonly email: EmailResource;
|
|
1840
|
+
/** Lead events and workflow automation triggers. */
|
|
1841
|
+
readonly events: EventsResource;
|
|
1842
|
+
/** Cryptographic webhook signature verification. */
|
|
1843
|
+
readonly webhooks: Webhooks;
|
|
1844
|
+
/** Tenant Cloud Storage mapping. */
|
|
1845
|
+
readonly storage: Storage;
|
|
1846
|
+
/** Email and SMS Marketing Campaigns. */
|
|
1847
|
+
readonly marketing: Marketing;
|
|
1848
|
+
/** Platform and tenant health diagnostics. */
|
|
1849
|
+
readonly health: Health;
|
|
1850
|
+
constructor(options: EcodrixOptions);
|
|
1851
|
+
private setupSocket;
|
|
1852
|
+
/**
|
|
1853
|
+
* Subscribe to a real-time event emitted by the ECODrIx platform.
|
|
1854
|
+
*
|
|
1855
|
+
* The SDK maintains a persistent Socket.io connection. Events are
|
|
1856
|
+
* scoped to your `clientCode` — you will only receive events for
|
|
1857
|
+
* your own tenant.
|
|
1858
|
+
*
|
|
1859
|
+
* **Standard events:**
|
|
1860
|
+
* - `whatsapp.message_received` — inbound WhatsApp message
|
|
1861
|
+
* - `whatsapp.message_sent` — outbound message delivered
|
|
1862
|
+
* - `crm.lead_created` — new CRM lead ingested
|
|
1863
|
+
* - `crm.lead_updated` — lead details or stage changed
|
|
1864
|
+
* - `meet.scheduled` — Google Meet appointment booked
|
|
1865
|
+
* - `storage.upload_confirmed` — file upload completed
|
|
1866
|
+
* - `automation.failed` — automation execution error
|
|
1867
|
+
*
|
|
1868
|
+
* @param event - The event name to subscribe to.
|
|
1869
|
+
* @param callback - The handler function invoked when the event fires.
|
|
1870
|
+
* @returns `this` for method chaining.
|
|
1871
|
+
*
|
|
1872
|
+
* @example
|
|
1873
|
+
* ```typescript
|
|
1874
|
+
* ecod
|
|
1875
|
+
* .on("whatsapp.message_received", (msg) => console.log(msg.body))
|
|
1876
|
+
* .on("automation.failed", (err) => alertTeam(err));
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
on(event: string, callback: (...args: any[]) => void): this;
|
|
1880
|
+
/**
|
|
1881
|
+
* Gracefully disconnect the real-time Socket.io connection.
|
|
1882
|
+
* Call this when shutting down your server or when the client is
|
|
1883
|
+
* no longer needed to free up resources.
|
|
1884
|
+
*
|
|
1885
|
+
* @example
|
|
1886
|
+
* ```typescript
|
|
1887
|
+
* process.on("SIGTERM", () => ecod.disconnect());
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
disconnect(): void;
|
|
1891
|
+
/**
|
|
1892
|
+
* Raw Execution Escape-Hatch.
|
|
1893
|
+
* Send an authenticated HTTP request directly to the ECODrIx backend from ANY external project.
|
|
1894
|
+
*
|
|
1895
|
+
* This is extremely powerful giving you full unrestricted access to make calls
|
|
1896
|
+
* against new, experimental, or completely custom backend APIs while still benefitting
|
|
1897
|
+
* from the SDK's built-in authentication and automatic `axios-retry` logic.
|
|
1898
|
+
*
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* const { data } = await ecod.request("POST", "/api/saas/experimental-feature", { flag: true });
|
|
1902
|
+
* console.log(data);
|
|
1903
|
+
* ```
|
|
1904
|
+
*/
|
|
1905
|
+
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
1869
1906
|
}
|
|
1870
1907
|
|
|
1871
|
-
export {
|
|
1908
|
+
export {
|
|
1909
|
+
APIError,
|
|
1910
|
+
Activities,
|
|
1911
|
+
Analytics,
|
|
1912
|
+
type AnalyticsParams,
|
|
1913
|
+
type AnalyticsRange,
|
|
1914
|
+
type AssignEventPayload,
|
|
1915
|
+
AuthenticationError,
|
|
1916
|
+
AutomationDashboard,
|
|
1917
|
+
type AutomationRulePayload,
|
|
1918
|
+
Automations,
|
|
1919
|
+
Broadcasts,
|
|
1920
|
+
CRM,
|
|
1921
|
+
type CampaignResult,
|
|
1922
|
+
Campaigns,
|
|
1923
|
+
type ClientHealth,
|
|
1924
|
+
Conversations,
|
|
1925
|
+
type CreateBroadcastParams,
|
|
1926
|
+
type CreateLeadParams,
|
|
1927
|
+
type CreateMeetingParams,
|
|
1928
|
+
type CreatePipelineParams,
|
|
1929
|
+
Ecodrix,
|
|
1930
|
+
EcodrixError,
|
|
1931
|
+
type EcodrixOptions,
|
|
1932
|
+
EmailResource,
|
|
1933
|
+
Emails,
|
|
1934
|
+
type EventDefinition,
|
|
1935
|
+
EventsResource,
|
|
1936
|
+
Files,
|
|
1937
|
+
Folders,
|
|
1938
|
+
Health,
|
|
1939
|
+
type JobStatus,
|
|
1940
|
+
type LeadSource,
|
|
1941
|
+
type LeadStatus,
|
|
1942
|
+
Leads,
|
|
1943
|
+
type ListLeadsParams,
|
|
1944
|
+
type ListParams,
|
|
1945
|
+
type LogActivityParams,
|
|
1946
|
+
type LogCallParams,
|
|
1947
|
+
type LogFilter,
|
|
1948
|
+
Marketing,
|
|
1949
|
+
MediaResource,
|
|
1950
|
+
Meetings,
|
|
1951
|
+
Messages,
|
|
1952
|
+
Notes,
|
|
1953
|
+
Notifications,
|
|
1954
|
+
Payments,
|
|
1955
|
+
type PipelineStageParams,
|
|
1956
|
+
Pipelines,
|
|
1957
|
+
RateLimitError,
|
|
1958
|
+
Scoring,
|
|
1959
|
+
type ScoringConfig,
|
|
1960
|
+
type SendCampaignParams,
|
|
1961
|
+
type SendCampaignPayload,
|
|
1962
|
+
type SendMessageParams,
|
|
1963
|
+
type SendTemplateParams,
|
|
1964
|
+
type SendTemplatePayload,
|
|
1965
|
+
Sequences,
|
|
1966
|
+
Storage,
|
|
1967
|
+
type SystemHealth,
|
|
1968
|
+
type TemplateMapping,
|
|
1969
|
+
Templates,
|
|
1970
|
+
type TriggerPayload,
|
|
1971
|
+
type TriggerResponse,
|
|
1972
|
+
type UpdateMeetingParams,
|
|
1973
|
+
type UploadOptions,
|
|
1974
|
+
type UpsertLeadParams,
|
|
1975
|
+
WebhookSignatureError,
|
|
1976
|
+
Webhooks,
|
|
1977
|
+
WhatsApp,
|
|
1978
|
+
Ecodrix as default,
|
|
1979
|
+
};
|