@ecodrix/erix-api 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts DELETED
@@ -1,3466 +0,0 @@
1
- import { AxiosInstance, AxiosRequestConfig, Method } from 'axios';
2
-
3
- interface RequestOptions extends AxiosRequestConfig {
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
- }
14
- declare abstract class APIResource {
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
- }
25
-
26
- declare class Agency extends APIResource {
27
- /**
28
- * List all available blueprints.
29
- */
30
- listBlueprints<T = any>(): Promise<T>;
31
- /**
32
- * Create a new blueprint configuration ("Gold Standard").
33
- */
34
- createBlueprint<T = any>(payload: any): Promise<T>;
35
- /**
36
- * Deploy a blueprint to a specific tenant client code.
37
- */
38
- deployBlueprint<T = any>(payload: {
39
- clientCode: string;
40
- blueprintId: string;
41
- }): Promise<T>;
42
- /**
43
- * Get aggregate portfolio statistics for an agency.
44
- */
45
- getPortfolioStats<T = any>(agencyCode: string): Promise<T>;
46
- /**
47
- * Get proactive health report for an agency portfolio.
48
- */
49
- getPortfolioHealth<T = any>(agencyCode: string): Promise<T>;
50
- /**
51
- * View consumption usage for a specific client code.
52
- */
53
- getUsage<T = any>(clientCode: string): Promise<T>;
54
- /**
55
- * List staff members under a specific agency code.
56
- */
57
- listStaff<T = any>(agencyCode: string): Promise<T>;
58
- /**
59
- * Create a new staff member for an agency.
60
- */
61
- createStaff<T = any>(payload: any): Promise<T>;
62
- }
63
-
64
- interface CheckoutProduct {
65
- externalId: string;
66
- name: string;
67
- price: number;
68
- image?: string;
69
- }
70
- interface CheckoutAmountBreakdown {
71
- subtotal: number;
72
- discount: number;
73
- delivery: number;
74
- total: number;
75
- }
76
- interface CheckoutSession {
77
- sessionId: string;
78
- product: {
79
- name: string;
80
- price: number;
81
- image?: string;
82
- };
83
- amounts: CheckoutAmountBreakdown;
84
- items: Array<{
85
- productId: string;
86
- quantity: number;
87
- }>;
88
- }
89
- interface CreateSessionPayload {
90
- productId: string;
91
- quantity: number;
92
- couponCode?: string;
93
- }
94
- interface ApplyCouponPayload {
95
- sessionId: string;
96
- couponCode: string;
97
- }
98
- interface VerifyPayload {
99
- sessionId: string;
100
- method: "truecaller" | "otp";
101
- token?: string;
102
- phone?: string;
103
- otp?: string;
104
- }
105
- interface CreateOrderPayload {
106
- sessionId: string;
107
- customer: {
108
- name: string;
109
- phone: string;
110
- email?: string;
111
- address: {
112
- line1: string;
113
- city: string;
114
- state: string;
115
- pincode: string;
116
- };
117
- };
118
- paymentProvider: "razorpay" | "cod";
119
- }
120
- interface CheckoutOrderResponse {
121
- order_id: string;
122
- payment_order_id?: string;
123
- amount?: number;
124
- currency?: string;
125
- status?: string;
126
- message?: string;
127
- }
128
-
129
- /**
130
- * Resource for managing the ErixCheckout one-click flow.
131
- *
132
- * This resource handles session creation, coupon application,
133
- * identity verification, and final order placement.
134
- */
135
- declare class Checkout extends APIResource {
136
- /**
137
- * Retrieves product information for the checkout modal.
138
- * @param productId - External SKU/ID of the product.
139
- */
140
- getProduct(productId: string): Promise<CheckoutProduct>;
141
- /**
142
- * Initializes a new checkout session.
143
- */
144
- createSession(payload: CreateSessionPayload): Promise<CheckoutSession>;
145
- /**
146
- * Applies a discount coupon to an active session.
147
- */
148
- applyCoupon(payload: ApplyCouponPayload): Promise<CheckoutSession>;
149
- /**
150
- * Verifies user identity via Truecaller or OTP.
151
- */
152
- verify(payload: VerifyPayload): Promise<{
153
- verified: boolean;
154
- data?: any;
155
- }>;
156
- /**
157
- * Finalizes the order and initiates payment.
158
- */
159
- createOrder(payload: CreateOrderPayload): Promise<CheckoutOrderResponse>;
160
- }
161
-
162
- interface CorsOriginCreatePayload {
163
- url: string;
164
- name?: string;
165
- allowedHeaders?: string[];
166
- allowedMethods?: string[];
167
- }
168
- interface CorsOriginUpdatePayload {
169
- url?: string;
170
- name?: string;
171
- allowedHeaders?: string[];
172
- allowedMethods?: string[];
173
- isActive?: boolean;
174
- }
175
- declare class Cors extends APIResource {
176
- /**
177
- * List all dynamic cross-origin policies.
178
- */
179
- list<T = any>(): Promise<T>;
180
- /**
181
- * Register a new cross-origin client for the SaaS API network dynamically.
182
- */
183
- create<T = any>(payload: CorsOriginCreatePayload): Promise<T>;
184
- /**
185
- * Adjust active states or configurations for an existing origin policy.
186
- */
187
- update<T = any>(id: string, payload: CorsOriginUpdatePayload): Promise<T>;
188
- /**
189
- * Irreversibly drop support for a cross-origin client URL policy permanently.
190
- */
191
- delete<T = any>(id: string): Promise<T>;
192
- }
193
-
194
- interface LogActivityParams {
195
- leadId: string;
196
- type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
197
- title: string;
198
- body?: string;
199
- metadata?: Record<string, any>;
200
- }
201
- interface LogCallParams {
202
- durationMinutes: number;
203
- summary: string;
204
- outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
205
- }
206
- declare class Notes extends APIResource {
207
- /**
208
- * List all notes for a specific lead.
209
- *
210
- * @param leadId - The unique ID of the lead.
211
- * @example
212
- * ```typescript
213
- * const notes = await erixClient.crm.activities.notes.list("lead_123");
214
- * ```
215
- */
216
- list<T = any>(leadId: string): Promise<T>;
217
- /**
218
- * Add a new descriptive note to a lead's profile.
219
- *
220
- * @param leadId - The unique ID of the lead.
221
- * @param params - The note content.
222
- * @example
223
- * ```typescript
224
- * await erixClient.crm.activities.notes.create("lead_123", {
225
- * content: "Customer is interested in the enterprise plan."
226
- * });
227
- * ```
228
- */
229
- create<T = any>(leadId: string, params: {
230
- content: string;
231
- }): Promise<T>;
232
- /**
233
- * Update an existing note.
234
- */
235
- update<T = any>(noteId: string, content: string): Promise<T>;
236
- /**
237
- * Pin or unpin a note to the top of the feed.
238
- */
239
- pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
240
- /**
241
- * Delete a note.
242
- */
243
- delete(noteId: string): Promise<unknown>;
244
- }
245
- declare class Activities extends APIResource {
246
- notes: Notes;
247
- constructor(client: any);
248
- /**
249
- * Retrieve the complete chronological timeline of all activities for a lead.
250
- *
251
- * @param leadId - The unique ID of the lead.
252
- * @param params - Optional pagination parameters.
253
- * @example
254
- * ```typescript
255
- * const timeline = await erixClient.crm.activities.timeline("lead_123", { limit: 10 });
256
- * ```
257
- */
258
- timeline<T = any>(leadId: string, params?: {
259
- page?: number;
260
- limit?: number;
261
- }): Promise<T>;
262
- /**
263
- * List specific activities (filtered by type).
264
- */
265
- list<T = any>(leadId: string, params?: {
266
- type?: string;
267
- page?: number;
268
- limit?: number;
269
- }): Promise<T>;
270
- /**
271
- * Generic method to log a business activity/event (e.g., system events, manual tasks).
272
- *
273
- * @param params - Activity details (leadId, type, title, body).
274
- * @example
275
- * ```typescript
276
- * await erixClient.crm.activities.log({
277
- * leadId: "lead_123",
278
- * type: "system",
279
- * title: "Meeting Scheduled",
280
- * body: "Initial consultation booked for Friday."
281
- * });
282
- * ```
283
- */
284
- log<T = any>(params: LogActivityParams): Promise<T>;
285
- /**
286
- * Specific method to log communication outcomes.
287
- */
288
- logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
289
- }
290
-
291
- type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
292
- interface AnalyticsParams {
293
- range?: AnalyticsRange;
294
- from?: string;
295
- to?: string;
296
- pipelineId?: string;
297
- }
298
- declare class Analytics extends APIResource {
299
- /**
300
- * Retrieve high-level CRM performance KPIs.
301
- * Includes total leads, pipeline value, won revenue, and conversion rates.
302
- *
303
- * @param params - Optional filters including time range (24h, 7d, 30d, etc.) and custom date bounds.
304
- * @returns {Promise<any>} KPI summary object containing core business metrics.
305
- * @example
306
- * ```typescript
307
- * const stats = await erixClient.crm.analytics.overview({ range: "30d" });
308
- * console.log(stats.avgScore);
309
- * ```
310
- */
311
- overview<T = any>(params?: AnalyticsParams): Promise<T>;
312
- /**
313
- * Get stage-by-stage lead counts and conversion percentages for a pipeline.
314
- * Useful for identifying funnel bottlenecks and drop-off points.
315
- *
316
- * @param pipelineId - The unique ID of the pipeline to analyze.
317
- * @returns {Promise<any>} Array of funnel stages with count and conversion data.
318
- * @example
319
- * ```typescript
320
- * const funnel = await erixClient.crm.analytics.funnel("pipe_123");
321
- * ```
322
- */
323
- funnel<T = any>(pipelineId: string): Promise<T>;
324
- /**
325
- * Revenue forecast: Calculates expected revenue based on deal value × stage probability.
326
- * Helps in sales planning and goal setting.
327
- *
328
- * @param pipelineId - Optional pipeline ID to filter the forecast.
329
- * @returns {Promise<any>} Forecast data including weighted expected revenue.
330
- * @example
331
- * ```typescript
332
- * const prognosis = await erixClient.crm.analytics.forecast("pipe_123");
333
- * ```
334
- */
335
- forecast<T = any>(pipelineId?: string): Promise<T>;
336
- /**
337
- * Lead source breakdown: count, conversion rate, and total value per source.
338
- *
339
- * @param params - Time range filters.
340
- * @returns {Promise<any>} Breakdown of how different marketing channels are performing.
341
- */
342
- sources<T = any>(params?: AnalyticsParams): Promise<T>;
343
- /**
344
- * Team leaderboard: Evaluates agent performance across won deals, revenue, and activity.
345
- *
346
- * @param params - Time range filters.
347
- * @returns {Promise<any>} Ranked list of team members by performance.
348
- */
349
- team<T = any>(params?: AnalyticsParams): Promise<T>;
350
- /**
351
- * Activity heatmap: Daily activity counts by type.
352
- * Ideal for visualizing engagement patterns on a calendar view.
353
- *
354
- * @param params - Time range filters.
355
- * @returns {Promise<any>} Time-series data of team activities.
356
- */
357
- heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
358
- /**
359
- * Score distribution: Groups leads into buckets based on their calculated score (0-100).
360
- *
361
- * @returns {Promise<any>} Volume of leads in different readiness tiers.
362
- */
363
- scores<T = any>(): Promise<T>;
364
- /**
365
- * Avg time in stage: Measures the velocity of leads through the sales pipeline.
366
- *
367
- * @param pipelineId - Target pipeline ID.
368
- * @returns {Promise<any>} Velocity metrics per stage.
369
- */
370
- stageTime<T = any>(pipelineId: string): Promise<T>;
371
- /**
372
- * Tiered Growth Report matching business sophistication (Pulse, Growth, Weapon).
373
- * Provides deep tactical and strategic insights.
374
- *
375
- * @param params - Filtering and range parameters.
376
- */
377
- tiered<T = any>(params?: AnalyticsParams): Promise<T>;
378
- /**
379
- * Consolidated analytics including CRM overview and WhatsApp messaging metrics.
380
- *
381
- * @param params - Time range filters.
382
- * @returns {Promise<any>} Consolidated analytics object containing CRM overview and WhatsApp messaging metrics.
383
- * @example
384
- * ```typescript
385
- * const stats = await erixClient.crm.analytics.summary({ range: "30d" });
386
- * console.log(stats.overview.totalLeads);
387
- * ```
388
- */
389
- summary<T = any>(params?: AnalyticsParams): Promise<T>;
390
- /**
391
- * Retrieve WhatsApp messaging volume and delivery performance analytics.
392
- * Includes total sent, delivered, read, and daily volume trends.
393
- *
394
- * @param params - Optional filters (time range).
395
- * @example
396
- * ```typescript
397
- * const waStats = await erixClient.crm.analytics.whatsapp({ range: "7d" });
398
- * console.log(waStats.totalSent);
399
- * ```
400
- */
401
- whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
402
- }
403
-
404
- declare class AutomationDashboard extends APIResource {
405
- /**
406
- * Retrieve summary statistics for automation health (total, success, failed).
407
- *
408
- * @returns Stats object.
409
- * @example
410
- * ```typescript
411
- * const stats = await erixClient.crm.automationDashboard.stats();
412
- * ```
413
- */
414
- stats<T = any>(): Promise<T>;
415
- /**
416
- * List recent EventLog entries representing automation executions.
417
- *
418
- * @param params - Optional filters (limit, status).
419
- * @example
420
- * ```typescript
421
- * const logs = await erixClient.crm.automationDashboard.logs({ status: "failed" });
422
- * ```
423
- */
424
- logs<T = any>(params?: {
425
- limit?: number;
426
- status?: string;
427
- }): Promise<T>;
428
- /**
429
- * Re-emit a failed event log to re-trigger its associated automation rules.
430
- *
431
- * @param logId - The unique ID of the failed event log.
432
- * @example
433
- * ```typescript
434
- * await erixClient.crm.automationDashboard.retryFailedEvent("log_123");
435
- * ```
436
- */
437
- retryFailedEvent<T = any>(logId: string): Promise<T>;
438
- }
439
-
440
- interface AutomationRulePayload {
441
- name: string;
442
- trigger: string;
443
- isActive?: boolean;
444
- nodes: any[];
445
- edges: any[];
446
- }
447
- declare class Automations extends APIResource {
448
- /**
449
- * List all automation rules (workflows) configured for the tenant.
450
- *
451
- * @returns Array of automation rule objects.
452
- * @example
453
- * ```typescript
454
- * const rules = await erixClient.crm.automations.list();
455
- * ```
456
- */
457
- list<T = any>(): Promise<T>;
458
- /**
459
- * Create a new automation rule with triggers and workflow nodes.
460
- *
461
- * @param payload - The automation rule definition (trigger, nodes, edges).
462
- * @returns The created automation rule.
463
- * @example
464
- * ```typescript
465
- * await erixClient.crm.automations.create({
466
- * name: "Welcome Email Workflow",
467
- * trigger: "contact_created",
468
- * nodes: [...],
469
- * edges: [...]
470
- * });
471
- * ```
472
- */
473
- create<T = any>(payload: AutomationRulePayload): Promise<T>;
474
- /**
475
- * Update an existing automation rule.
476
- */
477
- update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
478
- /**
479
- * Enable or disable an automation rule.
480
- */
481
- toggle<T = any>(ruleId: string): Promise<T>;
482
- /**
483
- * Delete an automation rule.
484
- */
485
- delete<T = any>(ruleId: string): Promise<unknown>;
486
- /**
487
- * Bulk delete rules.
488
- */
489
- bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
490
- /**
491
- * Dry-run test an automation rule against a specific lead to verify logic.
492
- *
493
- * @param ruleId - The ID of the rule to test.
494
- * @param leadId - The ID of the lead to run the test against.
495
- * @example
496
- * ```typescript
497
- * await erixClient.crm.automations.test("rule_123", "lead_456");
498
- * ```
499
- */
500
- test<T = any>(ruleId: string, leadId: string): Promise<T>;
501
- /**
502
- * Get available event triggers for automations.
503
- */
504
- getAvailableEvents<T = any>(): Promise<T>;
505
- /**
506
- * List enrollments for a rule.
507
- */
508
- enrollments<T = any>(ruleId: string, params?: {
509
- status?: string;
510
- page?: number;
511
- limit?: number;
512
- startDate?: string;
513
- endDate?: string;
514
- }): Promise<T>;
515
- /**
516
- * Get an enrollment detail.
517
- */
518
- getEnrollment<T = any>(enrollmentId: string): Promise<T>;
519
- /**
520
- * Pause an enrollment.
521
- */
522
- pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
523
- /**
524
- * Resume an enrollment.
525
- */
526
- resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
527
- /**
528
- * List workflow runs.
529
- */
530
- runs<T = any>(ruleId: string): Promise<T>;
531
- /**
532
- * Get run details.
533
- */
534
- getRun<T = any>(runId: string): Promise<T>;
535
- /**
536
- * Resume a paused run.
537
- */
538
- resumeRun<T = any>(runId: string): Promise<T>;
539
- /**
540
- * Abort a running workflow.
541
- */
542
- abortRun<T = any>(runId: string): Promise<T>;
543
- /**
544
- * Emit an external webhook event to unlock a `wait_event` node inside a
545
- * paused workflow run. Required when integrating third-party tools that
546
- * need to resume a suspended automation.
547
- *
548
- * @param ruleId - The automation rule that contains the wait_event node.
549
- * @param eventName - The event name that should match the node's condition.
550
- * @param payload - Arbitrary data forwarded to the node context.
551
- */
552
- webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
553
- /**
554
- * Fire a CRM automation trigger for a given phone number.
555
- *
556
- * @param params - Trigger payload (trigger name, phone, variables, etc.)
557
- */
558
- trigger<T = any>(params: {
559
- trigger: string;
560
- phone: string;
561
- email?: string;
562
- variables?: Record<string, string>;
563
- createLeadIfMissing?: boolean;
564
- leadData?: any;
565
- delayMinutes?: number;
566
- runAt?: Date | string;
567
- }): Promise<T>;
568
- }
569
-
570
- /**
571
- * The specific UI control type suggested for a field.
572
- */
573
- type FieldType = "string" | "number" | "boolean" | "date" | "datetime" | "select" | "multi-select" | "phone" | "email" | "currency" | "json" | "textarea" | "richtext" | "file" | "image";
574
- /**
575
- * Metadata defining a single field within a resource.
576
- * Used by UI kits to automatically generate forms and validation logic.
577
- */
578
- interface FieldManifest {
579
- /** The technical key name used in API requests. */
580
- key: string;
581
- /** Human-readable label (localized if possible). */
582
- label: string;
583
- /** Suggested UI type. */
584
- type: FieldType;
585
- /** Short hint/placeholder text. */
586
- description?: string;
587
- /** Whether the field is required for creation. */
588
- required: boolean;
589
- /** Whether the field should be hidden from standard create/edit forms. */
590
- hidden?: boolean;
591
- /** If type is 'select', the available options. */
592
- options?: Array<{
593
- label: string;
594
- value: string | number;
595
- }>;
596
- /** Validation constraints. */
597
- validation?: {
598
- regex?: string;
599
- min?: number;
600
- max?: number;
601
- message?: string;
602
- };
603
- /** Whether the field is read-only. */
604
- readOnly?: boolean;
605
- /** UI grouping/category name. */
606
- group?: string;
607
- }
608
- /**
609
- * A logical grouping of fields and UI hints for a top-level resource.
610
- * Provides a 'blueprint' for erix-react components.
611
- */
612
- interface ResourceManifest {
613
- /** The unique name of the resource (e.g., 'Lead', 'Template'). */
614
- name: string;
615
- /** All available fields for this resource. */
616
- fields: FieldManifest[];
617
- /** Suggested UI configurations. */
618
- uiHints?: {
619
- icon?: string;
620
- primaryColor?: string;
621
- /** Default sort order. */
622
- defaultSort?: {
623
- field: string;
624
- direction: "asc" | "desc";
625
- };
626
- /** Fields to show in a compact table view. */
627
- summaryFields?: string[];
628
- };
629
- }
630
-
631
- /**
632
- * Valid statuses for a CRM Lead.
633
- */
634
- type LeadStatus = "new" | "contacted" | "qualified" | "won" | "lost" | "archived";
635
- /**
636
- * Common lead acquisition sources. Additional string values are allowed.
637
- */
638
- type LeadSource = "website" | "whatsapp" | "direct" | "referral" | string;
639
- /**
640
- * Parameters for creating a new CRM Lead.
641
- */
642
- interface CreateLeadParams {
643
- /** Lead's full name (alternative to firstName/lastName). */
644
- name?: string;
645
- /** Lead's first name. Required for creation if name is not provided. */
646
- firstName?: string;
647
- /** Lead's last name. */
648
- lastName?: string;
649
- /** Lead's email address. */
650
- email?: string;
651
- /** Lead's phone number in E.164 format (e.g. "+919876543210"). */
652
- phone?: string;
653
- /**
654
- * Current status of the lead.
655
- */
656
- status?: LeadStatus;
657
- /**
658
- * Estimated value of the lead.
659
- */
660
- value?: number;
661
- /**
662
- * Acquisition channel.
663
- */
664
- source?: LeadSource;
665
- /** Primary message or enquiry from the lead. */
666
- message?: string;
667
- /** Internal note about the lead activity. */
668
- activityNote?: string;
669
- /** Arbitrary key-value metadata (UTM params, order IDs, etc.). */
670
- metadata?: Record<string, any>;
671
- /** Pipeline ID to assign the lead */
672
- pipelineId?: string;
673
- /** Stage ID to assign the lead */
674
- stageId?: string;
675
- }
676
- /**
677
- * Options for listing leads.
678
- */
679
- interface ListLeadsParams {
680
- status?: LeadStatus;
681
- pipelineId?: string;
682
- stageId?: string;
683
- source?: LeadSource;
684
- assignedTo?: string;
685
- tags?: string[] | string;
686
- minScore?: number;
687
- search?: string;
688
- startDate?: string;
689
- endDate?: string;
690
- appointmentId?: string;
691
- bookingId?: string;
692
- orderId?: string;
693
- meetingId?: string;
694
- page?: number;
695
- limit?: number;
696
- sortBy?: string;
697
- sortDir?: "asc" | "desc";
698
- }
699
- /**
700
- * Options for upserting a lead.
701
- */
702
- interface UpsertLeadParams {
703
- leadData: Partial<CreateLeadParams> & {
704
- phone: string;
705
- name?: string;
706
- };
707
- moduleInfo?: any;
708
- trigger?: string;
709
- pipelineId?: string;
710
- stageId?: string;
711
- }
712
- /**
713
- * CRM Lead resource — full lifecycle management.
714
- *
715
- * Access via `ecod.crm.leads`.
716
- *
717
- * @example
718
- * ```typescript
719
- * const { data: lead } = await ecod.crm.leads.create({
720
- * firstName: "Alice",
721
- * phone: "+919876543210",
722
- * source: "website",
723
- * });
724
- * ```
725
- */
726
- declare class Leads extends APIResource {
727
- /**
728
- * Create a new lead in the CRM pipeline.
729
- *
730
- * @param params - Lead creation parameters. `firstName` is required.
731
- * @returns The newly created Lead document.
732
- * @example
733
- * ```typescript
734
- * const lead = await erixClient.crm.leads.create({
735
- * firstName: "Alice",
736
- * phone: "+919876543210",
737
- * source: "website"
738
- * });
739
- * ```
740
- */
741
- create<T = any>(params: CreateLeadParams): Promise<T>;
742
- /**
743
- * Introspect the Leads resource and provide a "Blueprint" for UI generation.
744
- *
745
- * This method returns a list of all fields (standard + custom), their types,
746
- * labels, and suggested UI controls. Erix React uses this to render SmartForms
747
- * and tables dynamically.
748
- */
749
- describe(): Promise<ResourceManifest>;
750
- /**
751
- * Upsert a lead by phone number. If a lead with the same phone exists,
752
- * it will be updated; otherwise, a new lead is created.
753
- *
754
- * @param params - Upsert parameters containing leadData with a phone number.
755
- * @returns The newly created or updated Lead document.
756
- * @example
757
- * ```typescript
758
- * await erixClient.crm.leads.upsert({
759
- * leadData: { phone: "+919876543210", firstName: "Alice" }
760
- * });
761
- * ```
762
- */
763
- upsert<T = any>(params: UpsertLeadParams): Promise<T>;
764
- /**
765
- * Bulk ingest leads efficiently in parallel using automatic chunking.
766
- * Prevents rate limit exhaustion by executing `chunkSize` requests at a time.
767
- *
768
- * @param leads - Array of leads to create.
769
- * @param chunkSize - Number of leads to send concurrently (default: 50)
770
- * @returns Array of created lead results.
771
- */
772
- createMany(leads: CreateLeadParams[], chunkSize?: number): Promise<any[]>;
773
- /**
774
- * Bulk upsert (import) leads. Supports high-volume synchronization.
775
- *
776
- * @param leads - Array of leads to import.
777
- * ---- **Done** ---- API Endpoint
778
- */
779
- import<T = any>(leads: Partial<CreateLeadParams>[]): Promise<T>;
780
- /**
781
- * Alias for bulk upserting leads.
782
- *
783
- * @param leads - Array of leads to import.
784
- * ---- **Done** ---- API Endpoint
785
- */
786
- bulkUpsert<T = any>(leads: Partial<CreateLeadParams>[]): Promise<T>;
787
- /**
788
- * List CRM leads with optional filtering and pagination.
789
- *
790
- * @param params - Filter options (status, source, pipelineId, page, limit, etc.)
791
- * @returns Paginated list of Lead documents.
792
- * @example
793
- * ```typescript
794
- * const leads = await erixClient.crm.leads.list({
795
- * status: "new",
796
- * source: "website",
797
- * limit: 20
798
- * });
799
- * ```
800
- */
801
- list<T = any>(params?: ListLeadsParams): Promise<T>;
802
- /**
803
- * Auto-paginating iterator for leads.
804
- * Seamlessly fetches leads page by page as you iterate.
805
- *
806
- * @example
807
- * ```typescript
808
- * for await (const lead of ecod.crm.leads.listAutoPaging<Lead>()) {
809
- * console.log(lead.firstName);
810
- * }
811
- * ```
812
- */
813
- listAutoPaging<T = any>(params?: ListLeadsParams): AsyncGenerator<T, void, unknown>;
814
- /**
815
- * Retrieve a single lead by its unique ID.
816
- *
817
- * @param leadId - The MongoDB ObjectId of the lead.
818
- * @returns The Lead document, or a 404 error if not found.
819
- * @example
820
- * ```typescript
821
- * const lead = await erixClient.crm.leads.retrieve("64abc...");
822
- * ```
823
- */
824
- retrieve<T = any>(leadId: string): Promise<T>;
825
- /**
826
- * Retrieve a single lead by its phone number.
827
- *
828
- * @param phone - Lead's phone number.
829
- * ---- **Done** ---- API Endpoint
830
- */
831
- retrieveByPhone<T = any>(phone: string): Promise<T>;
832
- /**
833
- * Fetches all leads belonging to a specific Kanban column in a pipeline.
834
- *
835
- * @param pipelineId - Parent pipeline ID.
836
- * @param stageId - Target stage ID.
837
- * @param params - Pagination controls.
838
- * @returns Paginated result set.
839
- * ---- **Done** ---- API Endpoint
840
- */
841
- byStage<T = any>(pipelineId: string, stageId: string, params?: {
842
- page?: number;
843
- limit?: number;
844
- }): Promise<T>;
845
- /**
846
- * Retrieve a single lead by a reference key and value.
847
- *
848
- * @param refKey - Reference key metadata.
849
- * @param refValue - Reference value.
850
- */
851
- retrieveByRef<T = any>(refKey: string, refValue: string): Promise<T>;
852
- /**
853
- * Update the fields of an existing lead.
854
- *
855
- * @param leadId - The ID of the lead to update.
856
- * @param params - Partial lead fields to update.
857
- * @returns The updated Lead document.
858
- * @example
859
- * ```typescript
860
- * await erixClient.crm.leads.update("64abc...", {
861
- * lastName: "Smith",
862
- * status: "qualified"
863
- * });
864
- * ```
865
- */
866
- update<T = any>(leadId: string, params: Partial<CreateLeadParams>): Promise<T>;
867
- /**
868
- * Move a lead to a new stage in a pipeline.
869
- *
870
- * @param leadId - ID of the lead.
871
- * @param stageId - Target stage ID.
872
- */
873
- move<T = any>(leadId: string, stageId: string): Promise<T>;
874
- /**
875
- * Convert a lead (mark as won or lost with reason).
876
- *
877
- * @param leadId - ID of the lead.
878
- * @param outcome - "won" | "lost"
879
- * @param reason - Reason for the outcome.
880
- */
881
- convert<T = any>(leadId: string, outcome: "won" | "lost", reason?: string): Promise<T>;
882
- /**
883
- * Update the tags of a lead.
884
- *
885
- * @param leadId - ID of the lead.
886
- * @param options - Tags to add or remove.
887
- */
888
- tags<T = any>(leadId: string, options: {
889
- add?: string[];
890
- remove?: string[];
891
- }): Promise<T>;
892
- /**
893
- * Recalculate lead score based on activities and interactions.
894
- *
895
- * @param leadId - ID of the lead.
896
- */
897
- recalculateScore<T = any>(leadId: string): Promise<T>;
898
- /**
899
- * Update embedded metadata/references of a lead without touching core fields.
900
- *
901
- * @param leadId - ID of the lead.
902
- * @param metadata - Metadata object indicating { refs, extra }
903
- */
904
- updateMetadata<T = any>(leadId: string, metadata: {
905
- refs?: Record<string, any>;
906
- extra?: Record<string, any>;
907
- }): Promise<T>;
908
- /**
909
- * Introspect available custom fields configured by the tenant limit.
910
- */
911
- fields<T = any>(): Promise<T>;
912
- /**
913
- * List all notes for a specific lead.
914
- */
915
- notes<T = any>(leadId: string): Promise<T>;
916
- /**
917
- * Retrieve the complete chronological timeline for a lead.
918
- */
919
- activities<T = any>(leadId: string, params?: {
920
- page?: number;
921
- limit?: number;
922
- }): Promise<T>;
923
- /**
924
- * Add a note to a lead.
925
- */
926
- createNote<T = any>(leadId: string, params: {
927
- content: string;
928
- }): Promise<T>;
929
- /**
930
- * Update an existing note.
931
- */
932
- updateNote<T = any>(leadId: string, noteId: string, params: {
933
- content: string;
934
- }): Promise<T>;
935
- /**
936
- * Delete a note.
937
- */
938
- deleteNote<T = any>(leadId: string, noteId: string): Promise<unknown>;
939
- /**
940
- * Delete a single lead permanently.
941
- *
942
- * @param leadId - The ID of the lead to delete.
943
- * ---- **Done** ---- API Endpoint
944
- */
945
- delete(leadId: string): Promise<unknown>;
946
- /**
947
- * Bulk archive multiple leads.
948
- *
949
- * @param ids - Array of lead IDs to archive.
950
- * ---- **Done** ---- API Endpoint
951
- */
952
- bulkArchive<T = any>(ids: string[]): Promise<T>;
953
- /**
954
- * Bulk delete multiple leads permanently.
955
- *
956
- * @param ids - Array of lead IDs to archive.
957
- * ---- **Done** ---- API Endpoint
958
- */
959
- bulkDelete(ids: string[]): Promise<unknown>;
960
- /**
961
- * Archive a single lead.
962
- *
963
- * @param leadId - The ID of the lead to archive.
964
- */
965
- archive<T = any>(leadId: string): Promise<T>;
966
- }
967
-
968
- declare class Payments extends APIResource {
969
- /**
970
- * Record an inbound payment/transaction against a lead or specific appointment.
971
- *
972
- * @param payload - Payment details (leadId, amount, currency, description).
973
- * @example
974
- * ```typescript
975
- * await erixClient.crm.payments.capture({
976
- * leadId: "lead_123",
977
- * amount: 5000,
978
- * currency: "INR",
979
- * description: "Consultation Fee"
980
- * });
981
- * ```
982
- */
983
- capture<T = any>(payload: {
984
- leadId: string;
985
- amount: number;
986
- currency?: string;
987
- description?: string;
988
- appointmentId?: string;
989
- }): Promise<T>;
990
- }
991
-
992
- interface PipelineStageParams {
993
- name: string;
994
- color?: string;
995
- probability?: number;
996
- isWon?: boolean;
997
- isLost?: boolean;
998
- }
999
- declare class Pipelines extends APIResource {
1000
- /**
1001
- * List all CRM pipelines and their configured stages.
1002
- *
1003
- * @returns Array of pipeline objects with nested stages.
1004
- * @example
1005
- * ```typescript
1006
- * const pipelines = await erixClient.crm.pipelines.list();
1007
- * ```
1008
- */
1009
- list<T = any>(): Promise<T>;
1010
- /**
1011
- * Introspect a pipeline and provide a manifest of its stages.
1012
- *
1013
- * Returns metadata about stage colors, probabilities, and order.
1014
- * Erix React uses this to build kanban boards and stage pickers.
1015
- *
1016
- * @param pipelineId - The unique ID of the pipeline.
1017
- */
1018
- getStageManifest(pipelineId: string): Promise<ResourceManifest>;
1019
- /**
1020
- * Create a new CRM sales or support pipeline.
1021
- *
1022
- * @param payload - Pipeline details (name and array of stage names).
1023
- * @returns The created pipeline record.
1024
- * @example
1025
- * ```typescript
1026
- * await erixClient.crm.pipelines.create({
1027
- * name: "Sales Pipeline",
1028
- * stages: ["Lead", "Contacted", "Proposal", "Negotiation", "Closed"]
1029
- * });
1030
- * ```
1031
- */
1032
- create<T = any>(payload: {
1033
- name: string;
1034
- stages: string[];
1035
- }): Promise<T>;
1036
- /**
1037
- * Retrieve a single pipeline configuration by ID.
1038
- *
1039
- * @param pipelineId - The unique ID of the pipeline.
1040
- * @example
1041
- * ```typescript
1042
- * const pipeline = await erixClient.crm.pipelines.retrieve("pipe_123");
1043
- * ```
1044
- */
1045
- retrieve<T = any>(pipelineId: string): Promise<T>;
1046
- /**
1047
- * Update an existing pipeline.
1048
- */
1049
- update<T = any>(pipelineId: string, payload: Partial<{
1050
- name: string;
1051
- stages: string[];
1052
- }>): Promise<T>;
1053
- /**
1054
- * Set pipeline as the tenant's default.
1055
- */
1056
- setDefault<T = any>(pipelineId: string): Promise<T>;
1057
- /**
1058
- * Duplicate a pipeline with a new name.
1059
- */
1060
- duplicate<T = any>(pipelineId: string, newName: string): Promise<T>;
1061
- /**
1062
- * Archive a pipeline.
1063
- */
1064
- archive<T = any>(pipelineId: string): Promise<T>;
1065
- /**
1066
- * Delete a pipeline permanently.
1067
- */
1068
- delete(pipelineId: string): Promise<unknown>;
1069
- /**
1070
- * Check if a pipeline is in use (e.g. has leads attached).
1071
- */
1072
- checkInUse<T = any>(pipelineId: string): Promise<T>;
1073
- /**
1074
- * Retrieve a Kanban-style board representation of the pipeline with leads nested.
1075
- *
1076
- * @param pipelineId - The unique ID of the pipeline.
1077
- * @example
1078
- * ```typescript
1079
- * const board = await erixClient.crm.pipelines.board("pipe_123");
1080
- * ```
1081
- */
1082
- board<T = any>(pipelineId: string): Promise<T>;
1083
- /**
1084
- * Retrieve a revenue forecast based on stage probabilities for a pipeline.
1085
- */
1086
- forecast<T = any>(pipelineId: string): Promise<T>;
1087
- /**
1088
- * Add a new stage to the pipeline.
1089
- *
1090
- * @param pipelineId - The unique ID of the pipeline.
1091
- * @param params - Stage details (name, color, probability).
1092
- * @example
1093
- * ```typescript
1094
- * await erixClient.crm.pipelines.addStage("pipe_123", {
1095
- * name: "Decision Maker Bought In",
1096
- * color: "#FF5733",
1097
- * probability: 80
1098
- * });
1099
- * ```
1100
- */
1101
- addStage<T = any>(pipelineId: string, params: PipelineStageParams): Promise<T>;
1102
- /**
1103
- * Change the order of stages inside the pipeline.
1104
- */
1105
- reorderStages<T = any>(pipelineId: string, orderArray: string[]): Promise<T>;
1106
- /**
1107
- * Update a specific stage.
1108
- */
1109
- updateStage<T = any>(stageId: string, params: Partial<PipelineStageParams>): Promise<T>;
1110
- /**
1111
- * Delete a stage permanently.
1112
- *
1113
- * @param stageId - The unique ID of the stage to delete.
1114
- * @param moveLeadsToStageId - Optional fallback stageId to move active leads to before deletion.
1115
- */
1116
- deleteStage(stageId: string, moveLeadsToStageId?: string): Promise<unknown>;
1117
- }
1118
-
1119
- interface ScoringConfig {
1120
- /** Scoring rules — each rule adds/subtracts points based on field conditions. */
1121
- rules: any[];
1122
- /**
1123
- * Score threshold above which a lead is considered "hot".
1124
- * @default 70
1125
- */
1126
- hotThreshold?: number;
1127
- /**
1128
- * Score threshold below which a lead is considered "cold".
1129
- * @default 20
1130
- */
1131
- coldThreshold?: number;
1132
- /**
1133
- * List of CRM trigger names that cause an automatic score recalculation.
1134
- * @example ["lead_created", "appointment_booked"]
1135
- */
1136
- recalculateOnTriggers?: string[];
1137
- }
1138
- declare class Scoring extends APIResource {
1139
- /**
1140
- * Retrieve the tenant's global lead scoring configuration (rules, decay, thresholds).
1141
- *
1142
- * @returns The scoring configuration object.
1143
- * @example
1144
- * ```typescript
1145
- * const config = await erixClient.crm.scoring.getConfig();
1146
- * ```
1147
- */
1148
- getConfig<T = any>(): Promise<T>;
1149
- /**
1150
- * Update scoring configuration.
1151
- */
1152
- updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
1153
- /**
1154
- * Force an immediate score recalculation for a specific lead.
1155
- * Useful when profile data changes significantly.
1156
- *
1157
- * @param leadId - The unique ID of the lead.
1158
- * @example
1159
- * ```typescript
1160
- * await erixClient.crm.scoring.recalculate("lead_123");
1161
- * ```
1162
- */
1163
- recalculate<T = any>(leadId: string): Promise<T>;
1164
- }
1165
-
1166
- declare class Sequences extends APIResource {
1167
- /**
1168
- * Manually enroll a lead into a specific automation drip sequence (Workflow).
1169
- *
1170
- * @param payload - Enrollment details (leadId, ruleId, and custom variables).
1171
- * @example
1172
- * ```typescript
1173
- * await erixClient.crm.sequences.enroll({
1174
- * leadId: "lead_123",
1175
- * ruleId: "rule_456",
1176
- * variables: { start_date: "2026-05-01" }
1177
- * });
1178
- * ```
1179
- */
1180
- enroll<T = any>(payload: {
1181
- leadId: string;
1182
- ruleId: string;
1183
- variables?: Record<string, any>;
1184
- }): Promise<T>;
1185
- /**
1186
- * Unenroll a lead from a currently running automation sequence.
1187
- *
1188
- * @param enrollmentId - The unique ID of the sequence enrollment.
1189
- * @example
1190
- * ```typescript
1191
- * await erixClient.crm.sequences.unenroll("enroll_123");
1192
- * ```
1193
- */
1194
- unenroll<T = any>(enrollmentId: string): Promise<unknown>;
1195
- /**
1196
- * List all active and completed sequence enrollments for a specific lead.
1197
- *
1198
- * @param leadId - The unique ID of the lead.
1199
- * @returns Array of enrollment records.
1200
- * @example
1201
- * ```typescript
1202
- * const enrollments = await erixClient.crm.sequences.listForLead("lead_123");
1203
- * ```
1204
- */
1205
- listForLead<T = any>(leadId: string): Promise<T>;
1206
- }
1207
-
1208
- declare class CRM {
1209
- leads: Leads;
1210
- pipelines: Pipelines;
1211
- activities: Activities;
1212
- analytics: Analytics;
1213
- automations: Automations;
1214
- sequences: Sequences;
1215
- scoring: Scoring;
1216
- payments: Payments;
1217
- automationDashboard: AutomationDashboard;
1218
- constructor(client: AxiosInstance);
1219
- }
1220
-
1221
- /**
1222
- * Payload to send a high-throughput email campaign.
1223
- */
1224
- interface SendCampaignPayload {
1225
- /** Array of recipient email addresses. */
1226
- recipients: string[];
1227
- /** Subject line of the email. */
1228
- subject: string;
1229
- /** HTML body of the email. */
1230
- html: string;
1231
- }
1232
- /**
1233
- * Interface representing the result of a campaign dispatch.
1234
- */
1235
- interface CampaignResult {
1236
- /** Indicates if the campaign was successfully queued/sent. */
1237
- success: boolean;
1238
- /** Optional message detailing the result. */
1239
- message?: string;
1240
- /** Additional dynamic properties. */
1241
- [key: string]: any;
1242
- }
1243
- /**
1244
- * Represents an email template within the system.
1245
- */
1246
- interface EmailTemplate {
1247
- /** Unique identifier of the template. */
1248
- id: string;
1249
- /** Human-readable name of the template. */
1250
- name: string;
1251
- /** Optional description explaining the template's purpose. */
1252
- description?: string;
1253
- /** Subject line used when sending emails with this template. */
1254
- subject: string;
1255
- /** Optional preheader text (hidden snippet visible in email clients). */
1256
- preheader?: string;
1257
- /** Raw HTML content of the template. */
1258
- htmlBody: string;
1259
- /** Optional plain-text fallback content. */
1260
- textBody?: string;
1261
- /** Broad category classification for the template. */
1262
- category: "marketing" | "transactional" | "sequence";
1263
- /** Current state of the template. */
1264
- status: "draft" | "published" | "archived";
1265
- /** Type of template, whether standard or a reusable layout. */
1266
- type: "standard" | "layout";
1267
- /** Optional layout ID if this template inherits from a layout. */
1268
- layoutId?: string;
1269
- /** Optional URL to a thumbnail image representing the template. */
1270
- thumbnail?: string;
1271
- /** Array defining dynamic variables used within the template. */
1272
- variableMapping?: any[];
1273
- /** ISO timestamp of when the template was created. */
1274
- createdAt: string;
1275
- /** ISO timestamp of when the template was last updated. */
1276
- updatedAt: string;
1277
- }
1278
- /**
1279
- * Data transfer object for creating a new email template.
1280
- */
1281
- interface CreateTemplateDTO {
1282
- /** Name of the template. */
1283
- name: string;
1284
- /** Email subject line. */
1285
- subject: string;
1286
- /** Raw HTML content. */
1287
- htmlBody: string;
1288
- /** Optional description. */
1289
- description?: string;
1290
- /** Category of the template. Defaults to marketing if not provided. */
1291
- category?: "marketing" | "transactional" | "sequence";
1292
- /** Initial status. Defaults to draft. */
1293
- status?: "draft" | "published" | "archived";
1294
- /** Optional variable mapping definitions. */
1295
- variableMapping?: any[];
1296
- }
1297
- /**
1298
- * Response structure when previewing an email template.
1299
- */
1300
- interface TemplatePreviewResponse {
1301
- /** Indicates if the preview generation was successful. */
1302
- success: boolean;
1303
- /** The generated preview content. */
1304
- data: {
1305
- /** Resolved subject line. */
1306
- subject: string;
1307
- /** Resolved HTML body. */
1308
- html: string;
1309
- /** Resolved plain text fallback (if available). */
1310
- text?: string;
1311
- };
1312
- }
1313
- /**
1314
- * Outbound email marketing engine and template management.
1315
- *
1316
- * Access via `ecod.email`.
1317
- */
1318
- declare class Email extends APIResource {
1319
- /**
1320
- * Send an HTML email campaign to a list of recipients.
1321
- *
1322
- * @param payload - Data required to send a campaign.
1323
- * @returns A promise resolving to the campaign result.
1324
- * @example
1325
- * ```typescript
1326
- * await erixClient.email.sendCampaign({
1327
- * recipients: ["test@example.com"],
1328
- * subject: "Hello!",
1329
- * html: "<h1>Hi there</h1>"
1330
- * });
1331
- * ```
1332
- */
1333
- sendCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
1334
- /**
1335
- * Send a system test email to validate your current SMTP configuration.
1336
- *
1337
- * @param to - The recipient email address for the test email.
1338
- * @returns A promise resolving to the result of the test email dispatch.
1339
- * @example
1340
- * ```typescript
1341
- * await erixClient.email.sendTest("admin@mycompany.com");
1342
- * ```
1343
- */
1344
- sendTest(to: string): Promise<CampaignResult>;
1345
- /**
1346
- * List all email templates.
1347
- *
1348
- * @param query - Optional query parameters for filtering and pagination.
1349
- * @returns A promise resolving to a paginated or filtered list of templates.
1350
- * @example
1351
- * ```typescript
1352
- * const response = await erixClient.email.listTemplates({ category: "marketing" });
1353
- * console.log(response.data);
1354
- * ```
1355
- */
1356
- listTemplates(query?: any): Promise<{
1357
- success: boolean;
1358
- data: EmailTemplate[];
1359
- }>;
1360
- /**
1361
- * Get a single email template by ID.
1362
- *
1363
- * @param id - The unique identifier of the template.
1364
- * @returns A promise resolving to the requested template details.
1365
- * @example
1366
- * ```typescript
1367
- * const template = await erixClient.email.getTemplate("tpl_123abc");
1368
- * ```
1369
- */
1370
- getTemplate(id: string): Promise<{
1371
- success: boolean;
1372
- data: EmailTemplate;
1373
- }>;
1374
- /**
1375
- * Create a new email template.
1376
- *
1377
- * @param data - The template data transfer object containing the details.
1378
- * @returns A promise resolving to the newly created template.
1379
- * @example
1380
- * ```typescript
1381
- * const newTpl = await erixClient.email.createTemplate({
1382
- * name: "Welcome Series 1",
1383
- * subject: "Welcome to our platform!",
1384
- * htmlBody: "<h1>Welcome</h1><p>We are glad you are here.</p>"
1385
- * });
1386
- * ```
1387
- */
1388
- createTemplate(data: CreateTemplateDTO): Promise<{
1389
- success: boolean;
1390
- data: EmailTemplate;
1391
- }>;
1392
- /**
1393
- * Update an existing email template.
1394
- *
1395
- * @param id - The unique identifier of the template to update.
1396
- * @param data - The partial data transfer object to update the template with.
1397
- * @returns A promise resolving to the updated template.
1398
- * @example
1399
- * ```typescript
1400
- * await erixClient.email.updateTemplate("tpl_123abc", {
1401
- * subject: "Updated Welcome Subject"
1402
- * });
1403
- * ```
1404
- */
1405
- updateTemplate(id: string, data: Partial<CreateTemplateDTO>): Promise<{
1406
- success: boolean;
1407
- data: EmailTemplate;
1408
- }>;
1409
- /**
1410
- * Delete an email template.
1411
- *
1412
- * @param id - The unique identifier of the template to delete.
1413
- * @param force - Optional flag to force deletion even if the template is in use (default: false).
1414
- * @returns A promise resolving to a success indicator.
1415
- * @example
1416
- * ```typescript
1417
- * await erixClient.email.deleteTemplate("tpl_123abc");
1418
- * ```
1419
- */
1420
- deleteTemplate(id: string, force?: boolean): Promise<{
1421
- success: boolean;
1422
- }>;
1423
- /**
1424
- * Preview a template with dynamic variable resolution.
1425
- * Use this to see how a template renders with specific lead data or custom variables.
1426
- *
1427
- * @param id - The unique identifier of the template.
1428
- * @param params - Parameters containing the lead ID or custom variables to inject.
1429
- * @returns A promise resolving to the rendered HTML and subject.
1430
- * @example
1431
- * ```typescript
1432
- * const preview = await erixClient.email.previewTemplate("tpl_123abc", {
1433
- * variables: { first_name: "Jane" }
1434
- * });
1435
- * console.log(preview.data.html);
1436
- * ```
1437
- */
1438
- previewTemplate(id: string, params: {
1439
- leadId?: string;
1440
- variables?: Record<string, any>;
1441
- }): Promise<TemplatePreviewResponse>;
1442
- }
1443
-
1444
- /**
1445
- * Event definition representing an entry point capable of triggering automations.
1446
- */
1447
- interface EventDefinition {
1448
- name: string;
1449
- displayName: string;
1450
- description?: string;
1451
- pipelineId?: string;
1452
- stageId?: string;
1453
- defaultSource?: string;
1454
- [key: string]: any;
1455
- }
1456
- /**
1457
- * Payload to register/assign a new custom event definition.
1458
- */
1459
- interface AssignEventPayload {
1460
- /** The internal machine-readable name of the event (e.g. "webinar_joined") */
1461
- name: string;
1462
- /** Human-readable display name */
1463
- displayName: string;
1464
- /** Event description */
1465
- description?: string;
1466
- /** ID of the pipeline to associate with matching leads */
1467
- pipelineId?: string;
1468
- /** ID of the stage within the pipeline */
1469
- stageId?: string;
1470
- /** Default source tag for leads created via this event */
1471
- defaultSource?: string;
1472
- }
1473
- /**
1474
- * Payload to programmatically trigger an event/workflow.
1475
- */
1476
- interface TriggerPayload {
1477
- /** The name of the event to fire (e.g., "webinar_joined") */
1478
- trigger: string;
1479
- /** Phone number of the lead (E.164 format) */
1480
- phone: string;
1481
- /** Email of the lead */
1482
- email?: string;
1483
- /** Key-value pairs for string templates */
1484
- variables?: Record<string, string>;
1485
- /** Deep payload data mapping to the event */
1486
- data?: any;
1487
- /** URL to receive an acknowledgment callback when processing completes */
1488
- callbackUrl?: string;
1489
- /** Secret metadata passed back to the callback URL */
1490
- callbackMetadata?: any;
1491
- /** Auto-create lead if phone does not exist in CRM */
1492
- createLeadIfMissing?: boolean;
1493
- /** Pre-fill data if creating a new lead */
1494
- leadData?: {
1495
- firstName?: string;
1496
- lastName?: string;
1497
- source?: string;
1498
- };
1499
- /** Delay execution of matched workflows (in seconds) */
1500
- delaySeconds?: number;
1501
- /** Delay execution of matched workflows (in minutes) */
1502
- delayMinutes?: number;
1503
- /** Explicit ISO timestamp to trigger the workflow run */
1504
- runAt?: string;
1505
- /** Automatically generate a Google Meet appointment if matched actions require it */
1506
- requiresMeet?: boolean;
1507
- /** Configuration details for the generated Google Meet appointment */
1508
- meetConfig?: {
1509
- summary?: string;
1510
- description?: string;
1511
- startTime?: string;
1512
- duration?: number;
1513
- timezone?: string;
1514
- attendees?: string[];
1515
- };
1516
- }
1517
- /**
1518
- * Response returned when triggering an event.
1519
- */
1520
- interface TriggerResponse {
1521
- success: boolean;
1522
- data?: {
1523
- eventLogId: string;
1524
- trigger: string;
1525
- leadId: string;
1526
- rulesMatched: number;
1527
- };
1528
- message?: string;
1529
- code?: string;
1530
- }
1531
- declare class EventsResource extends APIResource {
1532
- /**
1533
- * List all available event definitions (both system and custom) that can trigger automations.
1534
- *
1535
- * @returns Array of event definitions.
1536
- * @example
1537
- * ```typescript
1538
- * const events = await erixClient.events.list();
1539
- * ```
1540
- */
1541
- list(): Promise<{
1542
- success: boolean;
1543
- data: EventDefinition[];
1544
- }>;
1545
- /**
1546
- * Register a new custom event entry point into the CRM automation engine.
1547
- * Useful when introducing new granular triggers.
1548
- */
1549
- assign(payload: AssignEventPayload): Promise<{
1550
- success: boolean;
1551
- data: EventDefinition;
1552
- }>;
1553
- /**
1554
- * Deactivate a custom event assignment by name.
1555
- */
1556
- unassign(name: string): Promise<{
1557
- success: boolean;
1558
- data: any;
1559
- }>;
1560
- /**
1561
- * Deactivate multiple custom event assignments simultaneously.
1562
- */
1563
- unassignBulk(names: string[]): Promise<{
1564
- success: boolean;
1565
- message: string;
1566
- }>;
1567
- /**
1568
- * Programmatically trigger an automation workflow by firing a specific event.
1569
- * This matches the event against active Automation Rules and executes linked actions.
1570
- *
1571
- * @param payload - The trigger details (event name, lead phone/email, variables).
1572
- * @returns Trigger response with diagnostic info (eventLogId, matched rules).
1573
- * @example
1574
- * ```typescript
1575
- * await erixClient.events.trigger({
1576
- * trigger: "webinar_joined",
1577
- * phone: "+919876543210",
1578
- * variables: { webinar_name: "AI Masterclass" },
1579
- * createLeadIfMissing: true
1580
- * });
1581
- * ```
1582
- */
1583
- trigger(payload: TriggerPayload): Promise<TriggerResponse>;
1584
- /**
1585
- * List all custom event definitions.
1586
- */
1587
- listCustomEvents<T = any>(): Promise<T>;
1588
- /**
1589
- * Create or upsert a custom event definition.
1590
- */
1591
- createCustomEvent<T = any>(payload: {
1592
- name: string;
1593
- displayName: string;
1594
- description?: string;
1595
- }): Promise<T>;
1596
- /**
1597
- * Delete a custom event definition.
1598
- */
1599
- deleteCustomEvent<T = any>(id: string): Promise<T>;
1600
- /**
1601
- * Manually emit a custom event to trigger workflows based on its definition.
1602
- */
1603
- emit<T = any>(payload: {
1604
- eventName: string;
1605
- leadId: string;
1606
- data?: any;
1607
- }): Promise<T>;
1608
- }
1609
-
1610
- interface SystemHealth {
1611
- status: string;
1612
- version: string;
1613
- env: string;
1614
- uptime: number;
1615
- db: string;
1616
- queueDepth: number;
1617
- timestamp: string;
1618
- }
1619
- interface ClientHealth {
1620
- clientCode: string;
1621
- services: {
1622
- whatsapp: "connected" | "not_configured";
1623
- email: "configured" | "not_configured";
1624
- googleMeet: "configured" | "not_configured";
1625
- };
1626
- activeAutomations: number;
1627
- queueDepth: number;
1628
- timestamp: string;
1629
- }
1630
- interface JobStatus {
1631
- jobId: string;
1632
- status: string;
1633
- attempts: number;
1634
- maxAttempts: number;
1635
- lastError: any;
1636
- runAt: string;
1637
- completedAt: string | null;
1638
- failedAt: string | null;
1639
- createdAt: string;
1640
- }
1641
- /**
1642
- * Platform and tenant-specific health diagnostics.
1643
- *
1644
- * Access via `ecod.health`.
1645
- */
1646
- declare class Health extends APIResource {
1647
- /**
1648
- * Perform a global platform health check.
1649
- * Verify that the core API, database, and background workers are operational.
1650
- */
1651
- system(): Promise<SystemHealth>;
1652
- /**
1653
- * Tenant-specific health check.
1654
- *
1655
- * Identifies correctly configured third-party integrations (WhatsApp, SMTP, Google Meet)
1656
- * and reports active automation counts.
1657
- */
1658
- clientHealth(): Promise<ClientHealth>;
1659
- /**
1660
- * Alias for clientHealth to match diagnostic terminology.
1661
- */
1662
- getDiagnosticReport(): Promise<ClientHealth>;
1663
- /**
1664
- * Lookup the execution status of a background job.
1665
- *
1666
- * Use this to poll for completion of long-running tasks like bulk exports
1667
- * or campaign dispatches.
1668
- *
1669
- * @param jobId - The unique ID of the background job.
1670
- */
1671
- jobStatus(jobId: string): Promise<JobStatus>;
1672
- }
1673
-
1674
- interface LogPaginationQuery {
1675
- page?: number;
1676
- limit?: number;
1677
- trigger?: string;
1678
- status?: "received" | "processing" | "completed" | "partial" | "failed";
1679
- from?: string;
1680
- to?: string;
1681
- }
1682
- interface EventLog {
1683
- id: string;
1684
- trigger: string;
1685
- phone?: string;
1686
- email?: string;
1687
- status: "received" | "processing" | "completed" | "partial" | "failed";
1688
- rulesMatched: number;
1689
- jobsCreated: number;
1690
- meetLink?: string;
1691
- callbackUrl?: string;
1692
- callbackStatus: "not_required" | "sent" | "failed";
1693
- payload: any;
1694
- error?: string;
1695
- idempotencyKey?: string;
1696
- processedAt?: string;
1697
- createdAt: string;
1698
- updatedAt: string;
1699
- }
1700
- interface CallbackLog {
1701
- id: string;
1702
- callbackUrl: string;
1703
- method: string;
1704
- payload: any;
1705
- jobId?: string;
1706
- enrollmentId?: string;
1707
- responseStatus: number;
1708
- responseBody: string;
1709
- status: "sent" | "failed" | "pending_retry";
1710
- attempts: number;
1711
- lastAttemptAt?: string;
1712
- signature?: string;
1713
- createdAt: string;
1714
- }
1715
- interface LogResponse<T> {
1716
- success: boolean;
1717
- data: T[];
1718
- pagination: {
1719
- total: number;
1720
- page: number;
1721
- limit: number;
1722
- pages: number;
1723
- };
1724
- }
1725
- /**
1726
- * Audit and execution logs for platform events and webhooks.
1727
- *
1728
- * Access via `ecod.logs`.
1729
- */
1730
- declare class Logs extends APIResource {
1731
- /**
1732
- * List event execution logs with optional filtering.
1733
- *
1734
- * Use this to audit automation triggers and debug workflow execution.
1735
- */
1736
- listEventLogs(query?: LogPaginationQuery): Promise<LogResponse<EventLog>>;
1737
- /**
1738
- * Get detailed information for a single event execution.
1739
- */
1740
- getEventLog(id: string): Promise<{
1741
- success: boolean;
1742
- data: EventLog;
1743
- }>;
1744
- /**
1745
- * List webhook callback logs (outbound responses from ECODrIx to your system).
1746
- */
1747
- listCallbackLogs(query?: LogPaginationQuery): Promise<LogResponse<CallbackLog>>;
1748
- /**
1749
- * Get high-level execution statistics for the tenant.
1750
- */
1751
- getStats(): Promise<{
1752
- success: boolean;
1753
- data: any;
1754
- }>;
1755
- }
1756
-
1757
- /**
1758
- * Parameters required to send an email campaign.
1759
- */
1760
- interface SendCampaignParams {
1761
- /** Array of recipient email addresses. */
1762
- recipients: string[];
1763
- /** Subject line of the email. */
1764
- subject: string;
1765
- /** HTML body content of the email. */
1766
- html: string;
1767
- }
1768
- declare class Emails extends APIResource {
1769
- /**
1770
- * Dispatch a bulk email campaign to a list of recipients.
1771
- *
1772
- * @param params - The campaign details (recipients, subject, html).
1773
- * @returns The dispatch result.
1774
- * @example
1775
- * ```typescript
1776
- * await erixClient.marketing.emails.sendCampaign({
1777
- * recipients: ["user@example.com"],
1778
- * subject: "Special Offer",
1779
- * html: "<p>Check out our deal!</p>"
1780
- * });
1781
- * ```
1782
- */
1783
- sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
1784
- /**
1785
- * Send a test verification email (used to verify SMTP functionality).
1786
- *
1787
- * @param to - The recipient email address for the test email.
1788
- * @returns A promise resolving to the result of the test email dispatch.
1789
- * @example
1790
- * ```typescript
1791
- * await erixClient.marketing.emails.sendTest("admin@mycompany.com");
1792
- * ```
1793
- */
1794
- sendTest<T = any>(to: string): Promise<T>;
1795
- }
1796
- declare class Campaigns extends APIResource {
1797
- /**
1798
- * List all email marketing campaigns with optional status filtering.
1799
- *
1800
- * @param params - Optional filters (status, limit, startDate, endDate, page).
1801
- * @returns Paginated list of campaign objects.
1802
- * @example
1803
- * ```typescript
1804
- * const campaigns = await erixClient.marketing.campaigns.list({ status: "sent" });
1805
- * ```
1806
- */
1807
- list<T = any>(params?: {
1808
- status?: string;
1809
- limit?: number;
1810
- page?: number;
1811
- startDate?: string;
1812
- endDate?: string;
1813
- }): Promise<T>;
1814
- /**
1815
- * Get detailed delivery and engagement statistics for a campaign.
1816
- * Includes opens, clicks, bounces, and delivery failures.
1817
- *
1818
- * @param campaignId - The ID of the campaign.
1819
- * @returns Stats summary object.
1820
- * @example
1821
- * ```typescript
1822
- * const report = await erixClient.marketing.campaigns.stats("camp_123");
1823
- * console.log(`Open Rate: ${report.data.openRate}%`);
1824
- * ```
1825
- */
1826
- stats<T = any>(campaignId: string): Promise<T>;
1827
- }
1828
- declare class WhatsAppMarketing extends APIResource {
1829
- /**
1830
- * Dispatch a template-based WhatsApp message with CRM-integrated variable resolution.
1831
- *
1832
- * Unlike direct WhatsApp sending, this endpoint automatically pulls data from the CRM
1833
- * based on the provided variables mapping.
1834
- *
1835
- * @param params - Template details and recipient phone.
1836
- * @example
1837
- * ```typescript
1838
- * await erixClient.marketing.whatsapp.sendTemplate({
1839
- * phone: "+919876543210",
1840
- * templateName: "order_update",
1841
- * variables: { "1": "Order #123" }
1842
- * });
1843
- * ```
1844
- */
1845
- sendTemplate<T = any>(params: {
1846
- /** Recipient's phone number. */
1847
- phone: string;
1848
- /** The WhatsApp template name approved in Meta. */
1849
- templateName: string;
1850
- /** Language code for the template (e.g. en_US). */
1851
- languageCode?: string;
1852
- /** CRM mapped variables. */
1853
- variables?: Record<string, string>;
1854
- /** Directly resolved variables to inject into the template. */
1855
- resolvedVariables?: Record<string, string>;
1856
- }): Promise<T>;
1857
- }
1858
- /**
1859
- * Global Marketing resource namespace.
1860
- *
1861
- * Access via `ecod.marketing`.
1862
- */
1863
- declare class Marketing extends APIResource {
1864
- /** Email marketing resources */
1865
- emails: Emails;
1866
- /** Campaign analytics and lists */
1867
- campaigns: Campaigns;
1868
- /** WhatsApp marketing resources */
1869
- whatsapp: WhatsAppMarketing;
1870
- constructor(client: any);
1871
- }
1872
-
1873
- /**
1874
- * Options for the `upload()` elite helper.
1875
- */
1876
- interface UploadOptions {
1877
- /**
1878
- * The destination folder key in R2.
1879
- * @example "customer_documents" | "avatars" | "invoices"
1880
- */
1881
- folder: string;
1882
- /**
1883
- * The desired filename, including extension.
1884
- * @example "contract.pdf" | "profile.jpg"
1885
- */
1886
- filename: string;
1887
- /**
1888
- * The MIME type of the file.
1889
- * @example "application/pdf" | "image/jpeg" | "video/mp4"
1890
- */
1891
- contentType: string;
1892
- }
1893
- /**
1894
- * Cloudflare R2-backed media resource.
1895
- *
1896
- * Access via `ecod.media`.
1897
- *
1898
- * The `upload()` method is the recommended approach. It acts as a client-side
1899
- * orchestrator: it fetches a presigned URL from the backend, uploads directly
1900
- * to R2 (bypassing the API server), then confirms the upload — all in one call.
1901
- *
1902
- * @example
1903
- * ```typescript
1904
- * const { data } = await ecod.media.upload(fileBuffer, {
1905
- * folder: "invoices",
1906
- * filename: "invoice-001.pdf",
1907
- * contentType: "application/pdf",
1908
- * });
1909
- * console.log(data.url); // → https://cdn.ecodrix.com/invoices/invoice-001.pdf
1910
- * ```
1911
- */
1912
- declare class Media extends APIResource {
1913
- /**
1914
- * Get current storage usage metrics for the tenant.
1915
- *
1916
- * @returns `{ usedMB, limitMB, fileCount }`
1917
- *
1918
- * @example
1919
- * ```typescript
1920
- * const { data } = await ecod.media.getUsage();
1921
- * console.log(`${data.usedMB} / ${data.limitMB} MB used`);
1922
- * ```
1923
- */
1924
- getUsage(): Promise<unknown>;
1925
- /**
1926
- * Create a new top-level folder in the tenant's R2 bucket.
1927
- *
1928
- * @param name - Folder name (alphanumeric, hyphens, underscores).
1929
- *
1930
- * @example
1931
- * ```typescript
1932
- * await ecod.media.createFolder("patient_records");
1933
- * ```
1934
- */
1935
- createFolder(name: string): Promise<unknown>;
1936
- /**
1937
- * List files within a folder, with optional date / search filtering.
1938
- *
1939
- * @param folder - The folder name to list, **or `"*"` to fetch all folders**
1940
- * for the tenant in a single call (returns a merged flat list with a
1941
- * `folder` field on each file so callers can group/filter client-side).
1942
- * @param params - Optional `year`, `month`, and keyword search `q` filters.
1943
- * @returns `{ data: { files, count, totalSizeBytes } }`.
1944
- *
1945
- * @example Single folder
1946
- * ```typescript
1947
- * const { data } = await ecod.media.list("invoices", { q: "contract" });
1948
- * // data.files → files only from the "invoices" folder
1949
- * ```
1950
- *
1951
- * @example All folders
1952
- * ```typescript
1953
- * const { data } = await ecod.media.list("*");
1954
- * // data.files → merged files from every folder the tenant has
1955
- * // Each file has a `folder` field indicating its source folder
1956
- * ```
1957
- */
1958
- list(folder: string, params?: {
1959
- year?: string;
1960
- month?: string;
1961
- q?: string;
1962
- }): Promise<unknown>;
1963
- /**
1964
- * Delete a file from R2 by its storage key.
1965
- *
1966
- * @param key - The full storage key of the file (e.g. `"invoices/contract.pdf"`).
1967
- *
1968
- * @example
1969
- * ```typescript
1970
- * await ecod.media.delete("invoices/old-contract.pdf");
1971
- * ```
1972
- */
1973
- delete(key: string): Promise<unknown>;
1974
- /**
1975
- * Request a temporary presigned download URL for a private file.
1976
- *
1977
- * @param key - The full storage key of the file.
1978
- * @returns `{ url }` — a time-limited download URL.
1979
- *
1980
- * @example
1981
- * ```typescript
1982
- * const { data } = await ecod.media.getDownloadUrl("invoices/contract.pdf");
1983
- * // → { url: "https://cdn.ecodrix.com/...?token=..." }
1984
- * ```
1985
- */
1986
- getDownloadUrl(key: string): Promise<unknown>;
1987
- /**
1988
- * **Elite Upload Helper** — uploads a file to Cloudflare R2 in a single call.
1989
- *
1990
- * This orchestrates 3 steps transparently:
1991
- * 1. Fetch a presigned `PUT` URL from the ECODrIx backend.
1992
- * 2. Upload the file _directly_ to R2 (no API proxy, maximum throughput).
1993
- * 3. Confirm the upload with the backend so it is indexed and tracked.
1994
- *
1995
- * Works with Node.js `Buffer`, browser `File`/`Blob`, or any stream-like
1996
- * object that Axios can PUT.
1997
- *
1998
- * @param file - The file data to upload.
1999
- * @param options - Folder, filename, and content type.
2000
- * @returns Confirmed file metadata including `key` and `url`.
2001
- *
2002
- * @example Node.js
2003
- * ```typescript
2004
- * import { readFileSync } from "fs";
2005
- * const buf = readFileSync("./invoice.pdf");
2006
- * const { data } = await ecod.media.upload(buf, {
2007
- * folder: "invoices",
2008
- * filename: "invoice-001.pdf",
2009
- * contentType: "application/pdf",
2010
- * });
2011
- * ```
2012
- *
2013
- * @example Browser
2014
- * ```typescript
2015
- * const file = inputElement.files[0];
2016
- * const { data } = await ecod.media.upload(file, {
2017
- * folder: "avatars",
2018
- * filename: file.name,
2019
- * contentType: file.type,
2020
- * });
2021
- * ```
2022
- */
2023
- upload(file: any, options: UploadOptions): Promise<any>;
2024
- }
2025
-
2026
- /**
2027
- * Parameters for scheduling a new Google Meet appointment.
2028
- */
2029
- interface CreateMeetingParams {
2030
- /** The CRM Lead ID this meeting belongs to. */
2031
- leadId: string;
2032
- /** Full name of the external participant. */
2033
- participantName: string;
2034
- /** Phone number of the participant in E.164 format. */
2035
- participantPhone: string;
2036
- /** Email addresses of the participants. */
2037
- participantEmails?: string[];
2038
- /**
2039
- * Meeting start time.
2040
- * @example new Date("2026-04-10T10:00:00.000Z")
2041
- */
2042
- startTime: Date | string;
2043
- /**
2044
- * Meeting end time.
2045
- * @example new Date("2026-04-10T10:30:00.000Z")
2046
- */
2047
- endTime: Date | string;
2048
- /** Duration in minutes. */
2049
- duration?: number;
2050
- /** Whether the meeting is online (Google Meet) or offline (In-person). */
2051
- meetingMode?: "online" | "offline";
2052
- /** Whether this is a free or paid consultation. */
2053
- type?: "free" | "paid";
2054
- /** Amount charged for paid consultations. */
2055
- amount?: number;
2056
- /** Arbitrary metadata to attach to the meeting record. */
2057
- metadata?: {
2058
- refs?: Record<string, string | undefined>;
2059
- extra?: Record<string, any>;
2060
- };
2061
- }
2062
- /**
2063
- * Parameters for updating an existing meeting.
2064
- */
2065
- interface UpdateMeetingParams {
2066
- /**
2067
- * Update the meeting status.
2068
- * @example "scheduled" | "completed" | "cancelled"
2069
- */
2070
- status?: "scheduled" | "completed" | "cancelled" | string;
2071
- /** Update the payment status for paid consultations. */
2072
- paymentStatus?: "pending" | "paid" | "na" | string;
2073
- /** New start time for rescheduling. */
2074
- startTime?: Date | string;
2075
- /** New end time for rescheduling. */
2076
- endTime?: Date | string;
2077
- /** Duration in minutes. */
2078
- duration?: number;
2079
- /** Update metadata. */
2080
- metadata?: any;
2081
- }
2082
- /**
2083
- * Google Meet appointment scheduling resource.
2084
- *
2085
- * Access via `ecod.meet`.
2086
- *
2087
- * @example
2088
- * ```typescript
2089
- * const { data } = await ecod.meet.create({
2090
- * leadId: "64abc...",
2091
- * participantName: "Alice",
2092
- * participantPhone: "+919876543210",
2093
- * startTime: "2026-04-10T10:00:00Z",
2094
- * endTime: "2026-04-10T10:30:00Z",
2095
- * });
2096
- * console.log(data.meetLink); // → https://meet.google.com/abc-defg-hij
2097
- * ```
2098
- */
2099
- declare class Meetings extends APIResource {
2100
- /**
2101
- * Schedule a new Google Meet with a lead.
2102
- *
2103
- * The backend automatically creates a Google Calendar event and generates
2104
- * a Meet link, then sends confirmation notifications via WhatsApp.
2105
- *
2106
- * @param data - Meeting details.
2107
- * @returns The created Meeting document including `meetLink`.
2108
- *
2109
- * @example
2110
- * ```typescript
2111
- * const { data } = await ecod.meet.create({
2112
- * leadId: "64abc...",
2113
- * participantName: "Alice",
2114
- * participantPhone: "+91...",
2115
- * startTime: "2026-04-10T10:00:00Z",
2116
- * endTime: "2026-04-10T10:30:00Z",
2117
- * });
2118
- * ```
2119
- */
2120
- create(data: CreateMeetingParams): Promise<any>;
2121
- /**
2122
- * List all meetings for the tenant, with optional filters.
2123
- *
2124
- * @param params - `leadId` to filter by lead; `status` to filter by state.
2125
- * @returns Array of Meeting documents.
2126
- *
2127
- * @example
2128
- * ```typescript
2129
- * const { data } = await ecod.meet.list({ status: "scheduled" });
2130
- * ```
2131
- */
2132
- list(params?: {
2133
- leadId?: string;
2134
- status?: string;
2135
- }): Promise<any>;
2136
- /**
2137
- * Retrieve the full details for a specific meeting.
2138
- *
2139
- * @param meetingId - The unique meeting ID.
2140
- * @returns The Meeting document.
2141
- *
2142
- * @example
2143
- * ```typescript
2144
- * const { data } = await ecod.meet.retrieve("meeting_id");
2145
- * ```
2146
- */
2147
- retrieve(meetingId: string): Promise<any>;
2148
- /**
2149
- * Update or reschedule an existing meeting.
2150
- *
2151
- * Partial updates are supported — only supply the fields you wish to change.
2152
- *
2153
- * @param meetingId - The meeting to update.
2154
- * @param data - Fields to update.
2155
- * @returns The updated Meeting document.
2156
- *
2157
- * @example
2158
- * ```typescript
2159
- * // Reschedule
2160
- * await ecod.meet.update("meeting_id", {
2161
- * startTime: "2026-04-11T11:00:00Z",
2162
- * endTime: "2026-04-11T11:30:00Z",
2163
- * });
2164
- * ```
2165
- */
2166
- update<T = any>(meetingId: string, data: UpdateMeetingParams): Promise<T>;
2167
- /**
2168
- * Reschedule an existing meeting. Provides explicit method for time modifications.
2169
- */
2170
- reschedule<T = any>(meetingId: string, params: {
2171
- startTime: Date | string;
2172
- endTime: Date | string;
2173
- duration?: number;
2174
- }): Promise<T>;
2175
- /**
2176
- * Cancel a meeting. This sets the meeting status to `"cancelled"`.
2177
- *
2178
- * @param meetingId - The meeting to cancel.
2179
- *
2180
- * @example
2181
- * ```typescript
2182
- * await ecod.meet.delete("meeting_id");
2183
- * ```
2184
- */
2185
- delete(meetingId: string): Promise<any>;
2186
- }
2187
-
2188
- /**
2189
- * Filters for querying event and automation execution logs.
2190
- */
2191
- interface LogFilter {
2192
- /** Page number for pagination (1-indexed). */
2193
- page?: number;
2194
- /** Maximum number of records to return per page. */
2195
- limit?: number;
2196
- /**
2197
- * Filter by automation trigger name.
2198
- * @example "lead_created" | "appointment_booked"
2199
- */
2200
- trigger?: string;
2201
- /**
2202
- * Filter by execution status.
2203
- * @example "success" | "failed" | "pending"
2204
- */
2205
- status?: string;
2206
- /** Filter logs associated with a specific phone number. */
2207
- phone?: string;
2208
- /** Start of the date range (inclusive). ISO 8601 or Date object. */
2209
- startDate?: string | Date;
2210
- /** End of the date range (inclusive). ISO 8601 or Date object. */
2211
- endDate?: string | Date;
2212
- }
2213
- /**
2214
- * Automation event log and provider callback resource.
2215
- *
2216
- * Access via `ecod.notifications`.
2217
- *
2218
- * This resource is **read-only**. It exposes platform audit trails — useful
2219
- * for debugging automation failures, monitoring webhook callbacks, and
2220
- * building internal ops dashboards.
2221
- *
2222
- * @example
2223
- * ```typescript
2224
- * // Find failed automations in April
2225
- * const { data } = await ecod.notifications.listLogs({
2226
- * status: "failed",
2227
- * startDate: "2026-04-01",
2228
- * endDate: "2026-04-30",
2229
- * });
2230
- * ```
2231
- */
2232
- declare class Notifications extends APIResource {
2233
- /**
2234
- * List automation execution logs with optional filtering.
2235
- *
2236
- * Each log entry represents one automation run triggered by a platform event.
2237
- * Filter by `status: "failed"` to build a failure alerting pipeline.
2238
- *
2239
- * @param params - Optional filter criteria.
2240
- * @returns Paginated list of event log objects.
2241
- *
2242
- * @example
2243
- * ```typescript
2244
- * const { data: failed } = await ecod.notifications.listLogs({
2245
- * status: "failed",
2246
- * trigger: "lead_created",
2247
- * limit: 50,
2248
- * });
2249
- * ```
2250
- */
2251
- listLogs(params?: LogFilter): Promise<unknown>;
2252
- /**
2253
- * Retrieve the full details for a single automation event log entry.
2254
- *
2255
- * @param logId - The unique log ID.
2256
- * @returns A single event log document including the payload and error trace.
2257
- *
2258
- * @example
2259
- * ```typescript
2260
- * const { data } = await ecod.notifications.retrieveLog("log_64abc...");
2261
- * console.log(data.error); // → "Provider timeout after 30s"
2262
- * ```
2263
- */
2264
- retrieveLog(logId: string): Promise<unknown>;
2265
- /**
2266
- * Get a summary statistics object for automation event execution.
2267
- *
2268
- * @param params - Optional date range for the summary window.
2269
- * @returns `{ total, success, failed, pending }` counts.
2270
- *
2271
- * @example
2272
- * ```typescript
2273
- * const { data: stats } = await ecod.notifications.getStats({
2274
- * startDate: "2026-04-01",
2275
- * endDate: "2026-04-30",
2276
- * });
2277
- * console.log(`Failed: ${stats.failed} / ${stats.total}`);
2278
- * ```
2279
- */
2280
- getStats(params?: {
2281
- startDate?: string;
2282
- endDate?: string;
2283
- }): Promise<unknown>;
2284
- /**
2285
- * List external provider webhook callback logs.
2286
- *
2287
- * These are inbound HTTP callbacks from third-party providers
2288
- * (payment gateways, email services, etc.) stored for audit purposes.
2289
- *
2290
- * @param params - Pagination and date filter options.
2291
- * @returns Paginated list of callback log records.
2292
- *
2293
- * @example
2294
- * ```typescript
2295
- * const { data } = await ecod.notifications.listCallbacks({ limit: 20 });
2296
- * ```
2297
- */
2298
- listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
2299
- /**
2300
- * List unread CRM notifications and alerts (e.g., lead assignments, system alerts).
2301
- *
2302
- * @param params - Optional filters (limit, unreadOnly).
2303
- * @returns Paginated list of notification objects.
2304
- * @example
2305
- * ```typescript
2306
- * const alerts = await erixClient.notifications.listAlerts({ unreadOnly: true });
2307
- * ```
2308
- */
2309
- listAlerts<T = any>(params?: {
2310
- limit?: number;
2311
- unreadOnly?: boolean;
2312
- }): Promise<T>;
2313
- /**
2314
- * Dismiss/mark a specific notification alert as read.
2315
- *
2316
- * @param notificationId - The unique ID of the notification.
2317
- * @example
2318
- * ```typescript
2319
- * await erixClient.notifications.dismissAlert("alert_123");
2320
- * ```
2321
- */
2322
- dismissAlert<T = any>(notificationId: string): Promise<T>;
2323
- /**
2324
- * Clear all notifications for the current tenant immediately.
2325
- *
2326
- * @example
2327
- * ```typescript
2328
- * await erixClient.notifications.clearAllAlerts();
2329
- * ```
2330
- */
2331
- clearAllAlerts<T = any>(): Promise<T>;
2332
- /**
2333
- * Retry an action from a notification (e.g. failed automation send).
2334
- *
2335
- * @param notificationId - The unique ID of the notification.
2336
- * @example
2337
- * ```typescript
2338
- * await erixClient.notifications.retryAction("alert_123");
2339
- * ```
2340
- */
2341
- retryAction<T = any>(notificationId: string): Promise<T>;
2342
- }
2343
-
2344
- interface JobStats {
2345
- waiting: number;
2346
- active: number;
2347
- completed: number;
2348
- failed: number;
2349
- delayed: number;
2350
- }
2351
- declare class Queue extends APIResource {
2352
- /**
2353
- * List all background jobs that have failed execution.
2354
- *
2355
- * @returns Array of failed job objects.
2356
- * @example
2357
- * ```typescript
2358
- * const failed = await erixClient.queue.listFailed();
2359
- * ```
2360
- */
2361
- listFailed<T = any>(): Promise<T>;
2362
- /**
2363
- * Get real-time health statistics for the background job queue (waiting, active, failed).
2364
- *
2365
- * @returns Queue statistics summary.
2366
- * @example
2367
- * ```typescript
2368
- * const stats = await erixClient.queue.getStats();
2369
- * console.log(`Active Jobs: ${stats.active}`);
2370
- * ```
2371
- */
2372
- getStats<T = JobStats>(): Promise<T>;
2373
- /**
2374
- * Manually retry a failed background job.
2375
- *
2376
- * @param jobId - The unique ID of the failed job.
2377
- * @example
2378
- * ```typescript
2379
- * await erixClient.queue.retryJob("job_123");
2380
- * ```
2381
- */
2382
- retryJob<T = any>(jobId: string): Promise<T>;
2383
- /**
2384
- * Remove a job from the queue.
2385
- *
2386
- * @param jobId - The unique ID of the job to delete.
2387
- * @example
2388
- * ```typescript
2389
- * await erixClient.queue.deleteJob("job_123");
2390
- * ```
2391
- */
2392
- deleteJob<T = any>(jobId: string): Promise<T>;
2393
- }
2394
-
2395
- declare class Clients extends APIResource {
2396
- /**
2397
- * List all clients in the ecosystem.
2398
- */
2399
- list<T = any>(): Promise<T>;
2400
- /**
2401
- * Get client count and auto-generate a unique code.
2402
- */
2403
- getCountAndGenerateCode<T = any>(): Promise<T>;
2404
- /**
2405
- * Retrieve a single client by client code.
2406
- */
2407
- retrieve<T = any>(clientCode: string): Promise<T>;
2408
- /**
2409
- * Get API Key for a specific client (Admin Only).
2410
- */
2411
- getApiKey<T = any>(clientCode: string): Promise<T>;
2412
- /**
2413
- * Generate or rotate API Key for a specific client (Admin Only).
2414
- */
2415
- rotateApiKey<T = any>(clientCode: string): Promise<T>;
2416
- /**
2417
- * Create a new client identity and provision initial resources.
2418
- */
2419
- create<T = any>(payload: {
2420
- name: string;
2421
- clientCode: string;
2422
- business?: any;
2423
- plan?: any;
2424
- }): Promise<T>;
2425
- /**
2426
- * Get active service configuration for a specific client.
2427
- */
2428
- getConfig<T = any>(clientCode: string): Promise<T>;
2429
- /**
2430
- * Update active service configuration for a specific client.
2431
- */
2432
- updateConfig<T = any>(clientCode: string, payload: any): Promise<T>;
2433
- /**
2434
- * Get decrypted secrets for a specific client.
2435
- */
2436
- getSecrets<T = any>(clientCode: string): Promise<T>;
2437
- /**
2438
- * Set secrets for a specific client.
2439
- */
2440
- updateSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
2441
- /**
2442
- * Completely replace secrets for a specific client.
2443
- */
2444
- replaceSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
2445
- /**
2446
- * Partially update secrets for a specific client.
2447
- */
2448
- patchSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
2449
- /**
2450
- * Retrieve Data Source connection metadata.
2451
- */
2452
- getDataSource<T = any>(clientCode: string): Promise<T>;
2453
- /**
2454
- * Configure Data Source metadata.
2455
- */
2456
- manageDataSource<T = any>(clientCode: string, payload: any): Promise<T>;
2457
- /**
2458
- * Update Client Identity and perform cascading updates if required.
2459
- */
2460
- updateIdentity<T = any>(id: string, payload: any): Promise<T>;
2461
- /**
2462
- * Initiate Google Re-authentication for OAuth tokens.
2463
- */
2464
- googleReauth<T = any>(clientCode: string, payload?: {
2465
- authCode?: string;
2466
- }): Promise<T>;
2467
- /**
2468
- * Delete a client and perform cascading cleanup.
2469
- */
2470
- delete<T = any>(id: string): Promise<T>;
2471
- }
2472
- declare class Blogs extends APIResource {
2473
- /**
2474
- * Retrieve public corporate blogs/news.
2475
- */
2476
- list<T = any>(): Promise<T>;
2477
- }
2478
- declare class GlobalLeads extends APIResource {
2479
- /**
2480
- * Add a corporate lead capture entry.
2481
- */
2482
- add<T = any>(payload: any): Promise<T>;
2483
- }
2484
- declare class Services extends APIResource {
2485
- clients: Clients;
2486
- blogs: Blogs;
2487
- globalLeads: GlobalLeads;
2488
- constructor(client: any);
2489
- }
2490
-
2491
- declare class EmailConfig extends APIResource {
2492
- /**
2493
- * Retrieve current email provider configuration and domain verification statuses.
2494
- */
2495
- getConfig<T = any>(): Promise<T>;
2496
- /**
2497
- * Switch the active email provider.
2498
- */
2499
- switchProvider<T = any>(provider: string): Promise<T>;
2500
- /**
2501
- * Provide explicit SMTP credentials and connection preferences.
2502
- */
2503
- saveSmtp<T = any>(payload: any): Promise<T>;
2504
- /**
2505
- * Initialize a new domain for SES identity verification.
2506
- */
2507
- initDomainVerification<T = any>(domain: string): Promise<T>;
2508
- /**
2509
- * Confirm "From" details and finalize configuration payload.
2510
- */
2511
- saveEmailConfig<T = any>(payload: {
2512
- fromName: string;
2513
- fromEmail: string;
2514
- replyTo?: string;
2515
- }): Promise<T>;
2516
- /**
2517
- * Check status of AWS SES domain validation DNS records.
2518
- */
2519
- checkSesVerification<T = any>(): Promise<T>;
2520
- /**
2521
- * Remove a verified SES domain identity and clean up local secrets.
2522
- */
2523
- removeSesIdentity<T = any>(): Promise<T>;
2524
- /**
2525
- * Send a test email to verify infrastructure is correctly bound.
2526
- */
2527
- sendTest<T = any>(toEmail: string): Promise<T>;
2528
- /**
2529
- * Define customized global email footers, limits, and specific campaign policies.
2530
- */
2531
- saveAdvancedConfig<T = any>(payload: any): Promise<T>;
2532
- /**
2533
- * Retrieve email configuration health properties including bounce limits metrics.
2534
- */
2535
- getHealth<T = any>(): Promise<T>;
2536
- /**
2537
- * Upgrade configurations dynamically to add DMARC enforcement records.
2538
- */
2539
- fixDmarc<T = any>(): Promise<T>;
2540
- /**
2541
- * Discover internally available providers constants metadata.
2542
- */
2543
- listProviders<T = any>(): Promise<T>;
2544
- }
2545
- declare class Settings extends APIResource {
2546
- email: EmailConfig;
2547
- constructor(client: any);
2548
- }
2549
-
2550
- declare class Folders extends APIResource {
2551
- /**
2552
- * Create a new folder in the tenant's cloud storage.
2553
- *
2554
- * @param name - The name of the folder to create.
2555
- * @example
2556
- * ```typescript
2557
- * await erixClient.storage.folders.create("Invoices");
2558
- * ```
2559
- */
2560
- create<T = any>(name: string): Promise<T>;
2561
- /**
2562
- * Delete a folder and its contents.
2563
- */
2564
- delete<T = any>(folderPath: string): Promise<T>;
2565
- }
2566
- declare class Files extends APIResource {
2567
- /**
2568
- * List files within a specific folder.
2569
- *
2570
- * @param folder - The folder name or path.
2571
- * @param params - Optional year/month filters for organized storage.
2572
- * @example
2573
- * ```typescript
2574
- * const files = await erixClient.storage.files.list("Invoices", { year: "2026" });
2575
- * ```
2576
- */
2577
- list<T = any>(folder: string, params?: {
2578
- year?: string;
2579
- month?: string;
2580
- }): Promise<T>;
2581
- /**
2582
- * Get a presigned upload URL for direct-to-cloud browser uploads.
2583
- * This allows the client to upload files directly to R2/S3 without hitting the backend.
2584
- *
2585
- * @param params - Upload parameters (folder, filename, contentType).
2586
- * @example
2587
- * ```typescript
2588
- * const { data } = await erixClient.storage.files.getUploadUrl({
2589
- * folder: "Invoices",
2590
- * filename: "inv_1.pdf",
2591
- * contentType: "application/pdf"
2592
- * });
2593
- * // Now use data.url with a PUT request
2594
- * ```
2595
- */
2596
- getUploadUrl<T = any>(params: {
2597
- folder: string;
2598
- filename: string;
2599
- contentType: string;
2600
- }): Promise<T>;
2601
- /**
2602
- * Notify backend after a successful direct browser upload.
2603
- */
2604
- confirmUpload<T = any>(params: {
2605
- key: string;
2606
- sizeBytes: number;
2607
- }): Promise<T>;
2608
- /**
2609
- * Get a presigned download URL for an R2 key.
2610
- */
2611
- getDownloadUrl<T = any>(key: string): Promise<T>;
2612
- /**
2613
- * Delete a file by key.
2614
- */
2615
- delete(key: string): Promise<unknown>;
2616
- }
2617
- declare class Storage extends APIResource {
2618
- folders: Folders;
2619
- files: Files;
2620
- constructor(client: any);
2621
- /**
2622
- * Get tenant storage usage and quota limitations.
2623
- */
2624
- usage<T = any>(): Promise<T>;
2625
- }
2626
-
2627
- /**
2628
- * Typed error hierarchy for the @ecodrix/erix-api SDK.
2629
- *
2630
- * All errors thrown by the SDK extend `EcodrixError`, so a single
2631
- * `catch` block can handle them all, while still allowing granular
2632
- * differentiation between auth failures, rate limits, and generic API errors.
2633
- *
2634
- * @example
2635
- * ```typescript
2636
- * import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
2637
- *
2638
- * try {
2639
- * await ecod.crm.leads.retrieve("invalid_id");
2640
- * } catch (err) {
2641
- * if (err instanceof AuthenticationError) {
2642
- * console.error("Invalid API key or client code.");
2643
- * } else if (err instanceof RateLimitError) {
2644
- * console.warn("Slow down — rate limit hit.");
2645
- * } else if (err instanceof APIError) {
2646
- * console.error(`API error ${err.status}: ${err.message}`);
2647
- * }
2648
- * }
2649
- * ```
2650
- */
2651
- /** Base class for all ECODrIx SDK errors. */
2652
- declare class EcodrixError extends Error {
2653
- constructor(message: string);
2654
- }
2655
- /**
2656
- * Represents an error returned by the ECODrIx API.
2657
- * Carries the HTTP `status` code and an optional `code` string.
2658
- */
2659
- declare class APIError extends EcodrixError {
2660
- /** HTTP status code returned by the API (e.g. 400, 404, 500). */
2661
- status?: number;
2662
- /** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
2663
- code?: string;
2664
- constructor(message: string, status?: number, code?: string);
2665
- }
2666
- /**
2667
- * Thrown when the API key or client code is missing, invalid, or expired.
2668
- * HTTP 401.
2669
- */
2670
- declare class AuthenticationError extends APIError {
2671
- constructor(message?: string);
2672
- }
2673
- /**
2674
- * Thrown when the rate limit for the API key has been exceeded.
2675
- * HTTP 429. Implement exponential backoff before retrying.
2676
- */
2677
- declare class RateLimitError extends APIError {
2678
- constructor(message?: string);
2679
- }
2680
-
2681
- /**
2682
- * Validates and constructs webhook events sent by the ECODrIx platform.
2683
- * Ensures the payload has not been tampered with.
2684
- *
2685
- * @example
2686
- * ```typescript
2687
- * import { ecod } from "./services/ecodrix";
2688
- *
2689
- * app.post("/api/webhooks", async (req, res) => {
2690
- * try {
2691
- * const event = await ecod.webhooks.constructEvent(
2692
- * req.rawBody,
2693
- * req.headers["x-ecodrix-signature"],
2694
- * process.env.ECOD_WEBHOOK_SECRET
2695
- * );
2696
- * console.log("Verified event:", event.type);
2697
- * res.send({ received: true });
2698
- * } catch (err) {
2699
- * res.status(400).send(`Webhook Error: ${err.message}`);
2700
- * }
2701
- * });
2702
- * ```
2703
- */
2704
- declare class Webhooks {
2705
- /**
2706
- * Cryptographically validates a webhook payload.
2707
- * Note: This method dynamically imports Node's `crypto` module, meaning it will only execute gracefully in a Server environment.
2708
- *
2709
- * @param payload - The raw request body as a string or Buffer.
2710
- * @param signature - The `x-ecodrix-signature` header value.
2711
- * @param secret - The webhook signing secret for your tenant.
2712
- * @returns The parsed JSON object of the event if the signature is valid.
2713
- * @throws WebhookSignatureError if the validation fails.
2714
- */
2715
- constructEvent(payload: string | Buffer, signature: string | string[] | undefined, secret: string): Promise<any>;
2716
- }
2717
-
2718
- interface CreateBroadcastParams {
2719
- /** Optional name for the broadcast campaign */
2720
- name?: string;
2721
- /** Name of the Meta template to send */
2722
- templateName: string;
2723
- /** Language code (defaults to en_US) */
2724
- templateLanguage?: string;
2725
- /** List of recipients with their phone numbers and variable overrides */
2726
- recipients: {
2727
- phone: string;
2728
- variables?: string[];
2729
- }[];
2730
- }
2731
- declare class Broadcasts extends APIResource {
2732
- /**
2733
- * List past and active WhatsApp broadcast campaigns.
2734
- *
2735
- * @param params - Optional filter parameters (page, limit, status).
2736
- * @returns Paginated list of broadcast records.
2737
- * @example
2738
- * ```typescript
2739
- * const broadcasts = await erixClient.whatsapp.broadcasts.list({ limit: 10 });
2740
- * ```
2741
- */
2742
- list<T = any>(params?: Record<string, any>): Promise<T>;
2743
- /**
2744
- * Retrieve full details and real-time stats for a specific broadcast campaign.
2745
- *
2746
- * @param id - The unique identifier of the broadcast.
2747
- * @returns The broadcast record including sent/failed counts.
2748
- * @example
2749
- * ```typescript
2750
- * const stats = await erixClient.whatsapp.broadcasts.retrieve("bc_123");
2751
- * console.log(`Success Rate: ${(stats.sentCount / stats.totalRecipients) * 100}%`);
2752
- * ```
2753
- */
2754
- retrieve<T = any>(id: string): Promise<T>;
2755
- /**
2756
- * Create a new broadcast campaign to send template messages to multiple recipients.
2757
- *
2758
- * @param params - Broadcast configuration (name, templateName, recipients).
2759
- * @returns The newly created broadcast record.
2760
- * @example
2761
- * ```typescript
2762
- * await erixClient.whatsapp.broadcasts.create({
2763
- * name: "Spring Sale",
2764
- * templateName: "promo_code",
2765
- * recipients: [
2766
- * { phone: "+919876543210", variables: ["SAVE10"] }
2767
- * ]
2768
- * });
2769
- * ```
2770
- */
2771
- create<T = any>(params: CreateBroadcastParams): Promise<T>;
2772
- /**
2773
- * Update broadcast metadata, such as its name or administrative status.
2774
- *
2775
- * @param id - The unique ID of the broadcast.
2776
- * @param data - The fields to update (name, status).
2777
- * @example
2778
- * ```typescript
2779
- * await erixClient.whatsapp.broadcasts.update("bc_123", { name: "Revised Spring Sale" });
2780
- * ```
2781
- */
2782
- update<T = any>(id: string, data: {
2783
- name?: string;
2784
- status?: string;
2785
- }): Promise<T>;
2786
- /**
2787
- * Delete a broadcast campaign record.
2788
- * Note: This does not cancel messages already in flight but removes the record from the dashboard.
2789
- *
2790
- * @param id - The unique ID of the broadcast.
2791
- * @example
2792
- * ```typescript
2793
- * await erixClient.whatsapp.broadcasts.delete("bc_123");
2794
- * ```
2795
- */
2796
- delete<T = any>(id: string): Promise<T>;
2797
- }
2798
-
2799
- interface ListParams {
2800
- limit?: number;
2801
- before?: string;
2802
- after?: string;
2803
- status?: string;
2804
- }
2805
- declare class Conversations extends APIResource {
2806
- /**
2807
- * List conversations for the tenant.
2808
- * @deprecated Use `list` method from `ErixClient` instead.
2809
- * @param params - List parameters.
2810
- * @returns List of conversations.
2811
- * @example
2812
- * ```typescript
2813
- * import { ErixClient } from "erix-react";
2814
- * const erixClient = new ErixClient({ apiKey: "YOUR_API_KEY" });
2815
- * const conversations = await erixClient.whatsapp.conversations.list();
2816
- * ```
2817
- */
2818
- list<T = any>(params?: ListParams): Promise<T>;
2819
- /**
2820
- * Create a new conversation explicitly.
2821
- *
2822
- * @param params - Conversation details.
2823
- * @example
2824
- * ```typescript
2825
- * const conversation = await erixClient.whatsapp.conversations.create({
2826
- * phone: "+919876543210",
2827
- * name: "John Doe"
2828
- * });
2829
- * ```
2830
- */
2831
- create<T = any>(params: {
2832
- phone: string;
2833
- name?: string;
2834
- }): Promise<T>;
2835
- /**
2836
- * Retrieve details of a specific conversation.
2837
- *
2838
- * @param conversationId - The unique ID of the conversation.
2839
- * @example
2840
- * ```typescript
2841
- * const conversation = await erixClient.whatsapp.conversations.retrieve("conv_123");
2842
- * ```
2843
- */
2844
- retrieve<T = any>(conversationId: string): Promise<T>;
2845
- /**
2846
- * Get messages for a specific conversation.
2847
- *
2848
- * @param conversationId - The unique ID of the conversation.
2849
- * @param params - Pagination and filter parameters.
2850
- * @example
2851
- * ```typescript
2852
- * const messages = await erixClient.whatsapp.conversations.messages("conv_123", { limit: 50 });
2853
- * ```
2854
- */
2855
- messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
2856
- /**
2857
- * Link a conversation to a lead in the CRM.
2858
- *
2859
- * @param conversationId - The unique ID of the conversation.
2860
- * @param leadId - The unique ID of the lead to link.
2861
- * @param leadData - Optional additional lead metadata.
2862
- * @example
2863
- * ```typescript
2864
- * await erixClient.whatsapp.conversations.linkLead("conv_123", "lead_456");
2865
- * ```
2866
- */
2867
- linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
2868
- /**
2869
- * Mark a conversation as read (clear unread count).
2870
- *
2871
- * @param conversationId - The unique ID of the conversation.
2872
- * @example
2873
- * ```typescript
2874
- * await erixClient.whatsapp.conversations.markRead("conv_123");
2875
- * ```
2876
- */
2877
- markRead<T = any>(conversationId: string): Promise<T>;
2878
- /**
2879
- * Delete a conversation.
2880
- *
2881
- * @param conversationId - The unique ID of the conversation.
2882
- * @example
2883
- * ```typescript
2884
- * await erixClient.whatsapp.conversations.delete("conv_123");
2885
- * ```
2886
- */
2887
- delete(conversationId: string): Promise<unknown>;
2888
- /**
2889
- * Bulk delete conversations.
2890
- *
2891
- * @param ids - Array of conversation IDs to delete.
2892
- * @example
2893
- * ```typescript
2894
- * await erixClient.whatsapp.conversations.bulkDelete(["conv_1", "conv_2"]);
2895
- * ```
2896
- */
2897
- bulkDelete<T = any>(ids: string[]): Promise<T>;
2898
- }
2899
-
2900
- /**
2901
- * Parameters for sending a free-form WhatsApp message.
2902
- */
2903
- interface SendMessageParams {
2904
- /**
2905
- * Recipient's phone number in E.164 format.
2906
- * @example "+919876543210"
2907
- */
2908
- to?: string;
2909
- /**
2910
- * The unique ID of the conversation. If supplied, `to` is resolved automatically.
2911
- */
2912
- conversationId?: string;
2913
- /** Plain text body of the message. */
2914
- text?: string;
2915
- /** Public URL of the media asset to send. */
2916
- mediaUrl?: string;
2917
- /** MIME category of the media. */
2918
- mediaType?: "image" | "video" | "audio" | "document";
2919
- /** The `messageId` of the message to reply to (quoted replies). */
2920
- replyToId?: string;
2921
- /** Filename shown to the recipient (required for `document` type). */
2922
- filename?: string;
2923
- /** Arbitrary metadata stored with the message record. */
2924
- metadata?: Record<string, any>;
2925
- /** Template name for template messages. */
2926
- templateName?: string;
2927
- /** Template language for template messages. */
2928
- templateLanguage?: string;
2929
- /** Alternative language parameter. */
2930
- language?: string;
2931
- /** Template variables. */
2932
- variables?: string[];
2933
- }
2934
- /**
2935
- * Parameters for sending a pre-approved WhatsApp Business template.
2936
- */
2937
- interface SendTemplateParams {
2938
- /**
2939
- * Recipient's phone number in E.164 format.
2940
- * @example "+919876543210"
2941
- */
2942
- to?: string;
2943
- /**
2944
- * The unique ID of the conversation.
2945
- */
2946
- conversationId?: string;
2947
- /** The exact template name as approved in Meta Business Manager. */
2948
- templateName: string;
2949
- /**
2950
- * BCP-47 language code for the template.
2951
- * @default "en_US"
2952
- */
2953
- language?: string;
2954
- /**
2955
- * Ordered array of variable substitutions for template placeholders.
2956
- * @example ["Alice", "10 April 2026", "10:00 AM"]
2957
- */
2958
- variables?: string[];
2959
- /** Optional header media URL (for templates with media headers). */
2960
- mediaUrl?: string;
2961
- /** Media type for the header (e.g. "image", "document"). */
2962
- mediaType?: string;
2963
- /** User ID of the agent sending the message. */
2964
- userId?: string;
2965
- /** Optional filename for media headers. */
2966
- filename?: string;
2967
- /** Template language for template messages. */
2968
- templateLanguage?: string;
2969
- }
2970
- /**
2971
- * WhatsApp outbound messaging resource.
2972
- *
2973
- * Access via `ecod.whatsapp.messages`.
2974
- *
2975
- * @example
2976
- * ```typescript
2977
- * await ecod.whatsapp.messages.send({
2978
- * to: "+919876543210",
2979
- * text: "Your appointment is confirmed!",
2980
- * });
2981
- * ```
2982
- */
2983
- /**
2984
- * Resolved media metadata returned by any upload endpoint.
2985
- * `variants` is only present for raster images (JPEG, PNG, WebP, AVIF, GIF).
2986
- */
2987
- interface ChatMediaMeta {
2988
- /** Raw CDN URL — always present, all media types */
2989
- url: string;
2990
- /** Categorical type — "image" | "video" | "audio" | "document" */
2991
- type: "image" | "video" | "audio" | "document";
2992
- /** Cloudflare-optimised variant URLs. Only present for raster images. */
2993
- variants?: {
2994
- /** 150px WebP — use for list thumbnails and chat bubbles */
2995
- thumb: string;
2996
- /** 600px WebP — use for modal previews */
2997
- medium: string;
2998
- /** 1200px WebP — use for hero or full-screen views */
2999
- full: string;
3000
- /** Original CDN URL, no transformation */
3001
- raw: string;
3002
- };
3003
- /** Storage key within the tenant bucket */
3004
- key?: string;
3005
- /** Original filename */
3006
- fileName?: string;
3007
- }
3008
- declare class Messages extends APIResource {
3009
- /**
3010
- * Send a free-text or media message to a WhatsApp number.
3011
- *
3012
- * For text-only messages, supply `text`. For media, supply `mediaUrl`
3013
- * and `mediaType`. Both can be combined in a single message.
3014
- *
3015
- * @param params - Message parameters including recipient, text, and media.
3016
- * @returns The created message record from the database.
3017
- *
3018
- * @example Send a simple text message
3019
- * ```typescript
3020
- * await erixClient.whatsapp.messages.send({
3021
- * to: "+919876543210",
3022
- * text: "Hello from Ecodrix!",
3023
- * });
3024
- * ```
3025
- *
3026
- * @example Send an image with a caption
3027
- * ```typescript
3028
- * await erixClient.whatsapp.messages.send({
3029
- * to: "+919876543210",
3030
- * text: "Check out this flyer",
3031
- * mediaUrl: "https://example.com/flyer.jpg",
3032
- * mediaType: "image",
3033
- * });
3034
- * ```
3035
- */
3036
- send<T = any>(params: SendMessageParams): Promise<T>;
3037
- /**
3038
- * Send a pre-approved WhatsApp Business template message.
3039
- *
3040
- * Templates must be approved in Meta Business Manager before they can be sent.
3041
- * Variable placeholders (e.g., {{1}}, {{2}}) are replaced with values from the
3042
- * `variables` array in order.
3043
- *
3044
- * @param params - Template message configuration (name, language, variables).
3045
- * @returns The created message record.
3046
- *
3047
- * @example
3048
- * ```typescript
3049
- * await erixClient.whatsapp.messages.sendTemplate({
3050
- * to: "+919876543210",
3051
- * templateName: "welcome_user",
3052
- * language: "en_US",
3053
- * variables: ["Alice"], // Replaces {{1}} in template
3054
- * });
3055
- * ```
3056
- */
3057
- sendTemplate<T = any>(params: SendTemplateParams): Promise<T>;
3058
- /**
3059
- * Star or unstar a message.
3060
- *
3061
- * @param messageId - The ID of the message.
3062
- * @param isStarred - Boolean indicating whether to star or unstar.
3063
- */
3064
- star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
3065
- /**
3066
- * React to a message with an emoji.
3067
- *
3068
- * @param messageId - The ID of the message.
3069
- * @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
3070
- */
3071
- react<T = any>(messageId: string, reaction: string): Promise<T>;
3072
- /**
3073
- * Mark all messages in a conversation as read (double-tick).
3074
- *
3075
- * @param conversationId - The conversation to mark as read.
3076
- *
3077
- * @example
3078
- * ```typescript
3079
- * await ecod.whatsapp.messages.markRead("conv_64abc...");
3080
- * ```
3081
- */
3082
- markRead(conversationId: string): Promise<unknown>;
3083
- /**
3084
- * Upload a media file for WhatsApp chat.
3085
- *
3086
- * Works with any file type — image, video, audio, or document.
3087
- * For raster images the response includes Cloudflare-optimised `variants`
3088
- * (thumb 150px, medium 600px, full 1200px). Non-image types return only `url`.
3089
- *
3090
- * @param file - The file to upload (File, Blob, or Buffer).
3091
- * @returns Full media metadata `{ url, type, variants?, key, fileName }`.
3092
- *
3093
- * @example
3094
- * ```typescript
3095
- * const file = input.files[0];
3096
- * const { data } = await ecod.whatsapp.messages.upload(file);
3097
- * // For images: data.variants.thumb → 150px WebP from Cloudflare
3098
- * // For video/audio: use data.url directly in <video> or <audio>
3099
- * ```
3100
- */
3101
- upload(file: any): Promise<{
3102
- success: boolean;
3103
- data: ChatMediaMeta;
3104
- }>;
3105
- }
3106
-
3107
- interface TemplateMapping {
3108
- mappings: any[];
3109
- onEmptyVariable: string;
3110
- }
3111
- declare class Templates extends APIResource {
3112
- /**
3113
- * List all WhatsApp message templates in the tenant database.
3114
- *
3115
- * @param params - Optional filter parameters (status, mappingStatus, channel).
3116
- * @returns List of message templates.
3117
- * @example
3118
- * ```typescript
3119
- * const templates = await erixClient.whatsapp.templates.list({ status: "APPROVED" });
3120
- * ```
3121
- */
3122
- list<T = any>(params?: {
3123
- status?: string;
3124
- mappingStatus?: string;
3125
- channel?: string;
3126
- }): Promise<T>;
3127
- /**
3128
- * Synchronize templates from the Meta WhatsApp Business API.
3129
- * This updates the local database with the latest template status and content from Meta.
3130
- *
3131
- * @returns Success status of the sync operation.
3132
- * @example
3133
- * ```typescript
3134
- * await erixClient.whatsapp.templates.sync();
3135
- * ```
3136
- */
3137
- sync<T = any>(): Promise<T>;
3138
- /**
3139
- * Retrieve details of a specific WhatsApp template.
3140
- *
3141
- * @param templateIdentifier - The name or ID of the template.
3142
- * @returns Detailed template object including components and status.
3143
- * @example
3144
- * ```typescript
3145
- * const template = await erixClient.whatsapp.templates.retrieve("welcome_message");
3146
- * ```
3147
- */
3148
- retrieve<T = any>(templateIdentifier: string): Promise<T>;
3149
- /**
3150
- * Create a new WhatsApp template manually (Draft).
3151
- *
3152
- * @param payload - Template configuration (name, category, language, components).
3153
- * @example
3154
- * ```typescript
3155
- * await erixClient.whatsapp.templates.create({
3156
- * name: "new_promotion",
3157
- * category: "MARKETING",
3158
- * language: "en_US",
3159
- * components: [...]
3160
- * });
3161
- * ```
3162
- */
3163
- create<T = any>(payload: any): Promise<T>;
3164
- /**
3165
- * Update an existing WhatsApp template.
3166
- *
3167
- * @param templateId - The unique ID of the template.
3168
- * @param payload - Updated template configuration.
3169
- */
3170
- update<T = any>(templateId: string, payload: any): Promise<T>;
3171
- /**
3172
- * Delete a WhatsApp template from both the local database and Meta (if specified).
3173
- *
3174
- * @param templateName - The name of the template to delete.
3175
- * @param force - If true, attempts to delete from Meta API as well.
3176
- * @example
3177
- * ```typescript
3178
- * await erixClient.whatsapp.templates.deleteTemplate("old_template", true);
3179
- * ```
3180
- */
3181
- deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
3182
- /**
3183
- * List available configuration options for variable mapping.
3184
- *
3185
- * @example
3186
- * ```typescript
3187
- * const config = await erixClient.whatsapp.templates.mappingConfig();
3188
- * ```
3189
- */
3190
- mappingConfig<T = any>(): Promise<T>;
3191
- /**
3192
- * List CRM collections available for variable mapping (Leads, Deals, etc.).
3193
- */
3194
- collections<T = any>(): Promise<T>;
3195
- /**
3196
- * List fields for a specific CRM collection to be used in mapping.
3197
- *
3198
- * @param collectionName - The name of the CRM collection.
3199
- */
3200
- collectionFields<T = any>(collectionName: string): Promise<T>;
3201
- /**
3202
- * Update variable mappings for a template to automate personalization.
3203
- *
3204
- * @param templateName - Name of the template.
3205
- * @param payload - Mapping definitions.
3206
- */
3207
- updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
3208
- /**
3209
- * Validate if a template is ready for automated sending based on its mappings.
3210
- */
3211
- validate<T = any>(templateName: string): Promise<T>;
3212
- /**
3213
- * Preview a template resolution with sample data.
3214
- *
3215
- * @param templateName - Name of the template.
3216
- * @param context - Lead data or variable overrides for preview.
3217
- * @example
3218
- * ```typescript
3219
- * const preview = await erixClient.whatsapp.templates.preview("welcome", {
3220
- * lead: { firstName: "Alice" }
3221
- * });
3222
- * ```
3223
- */
3224
- preview<T = any>(templateName: string, context: {
3225
- lead?: any;
3226
- vars?: any;
3227
- }): Promise<T>;
3228
- /**
3229
- * Introspect a template and provide a manifest of its required variables.
3230
- *
3231
- * This is used by Erix React to build dynamic "Mapping Forms" where users
3232
- * can connect CRM fields to WhatsApp variables.
3233
- *
3234
- * @param templateIdentifier - The name or ID of the template.
3235
- */
3236
- getVariableManifest(templateIdentifier: string): Promise<ResourceManifest>;
3237
- /**
3238
- * Check which automations or sequences are currently using this template.
3239
- */
3240
- checkUsage<T = any>(templateName: string): Promise<T>;
3241
- }
3242
-
3243
- interface SendTemplatePayload {
3244
- /** Phone number in E.164 format. */
3245
- phone: string;
3246
- /** Name of the pre-approved WhatsApp template. */
3247
- templateName: string;
3248
- /** Language code (defaults to "en"). */
3249
- languageCode?: string;
3250
- /** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
3251
- variables?: Record<string, string>;
3252
- /** Explicitly resolved variables if bypassing the internal resolution engine. */
3253
- resolvedVariables?: any[];
3254
- }
3255
- declare class WhatsApp extends APIResource {
3256
- messages: Messages;
3257
- conversations: Conversations;
3258
- broadcasts: Broadcasts;
3259
- templates: Templates;
3260
- constructor(client: AxiosInstance);
3261
- /**
3262
- * Upload an asset directly to chat storage.
3263
- */
3264
- upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
3265
- /**
3266
- * Dispatch a WhatsApp template message directly to a specific phone number.
3267
- * Bypasses the automation queue for immediate high-priority delivery.
3268
- *
3269
- * @param payload - The template dispatch payload.
3270
- * @returns Information about the dispatched message.
3271
- */
3272
- sendTemplate(payload: SendTemplatePayload): Promise<{
3273
- success: boolean;
3274
- messageId?: string;
3275
- templateName?: string;
3276
- resolvedVariables?: any[];
3277
- }>;
3278
- }
3279
-
3280
- /**
3281
- * Configuration options for the ECODrIxAPI client.
3282
- *
3283
- * Minimum required: `apiKey` and `clientCode`.
3284
- * The backend URL is managed internally and should not need to be changed.
3285
- */
3286
- interface ECODrIxAPIOptions {
3287
- /**
3288
- * Your ECODrIx Platform API key.
3289
- * Obtain this from the ECODrIx dashboard under Settings → API Keys.
3290
- * @example "ecod_live_sk_..."
3291
- */
3292
- apiKey: string;
3293
- /**
3294
- * Your tenant ID (Client Code).
3295
- * This scopes all API requests to your specific organisation.
3296
- * @example "ERIX_CLNT_JHBJHF"
3297
- */
3298
- clientCode?: string;
3299
- /**
3300
- * Optional Core API Key for deep system-level bypasses.
3301
- * Only used by elevated internal SaaS modules like Nirvisham.
3302
- */
3303
- coreApiKey?: string;
3304
- /**
3305
- * @internal Override Socket.io URL for testing/staging.
3306
- * Not documented — internal use only.
3307
- */
3308
- socketUrl?: string;
3309
- /**
3310
- * @internal Override the backend API URL. Used by the CLI and internal tests only.
3311
- * Host projects must never set this — the production URL is hardcoded internally.
3312
- */
3313
- baseUrl?: string;
3314
- }
3315
- /**
3316
- * The primary entry point for the ECODrIx SDK.
3317
- *
3318
- * Initialise once with your credentials and use the namespaced resources
3319
- * to interact with every part of the platform.
3320
- *
3321
- * @example
3322
- * ```typescript
3323
- * import { ECODrIxAPI } from "@ecodrix/erix-api";
3324
- *
3325
- * const ecod = new ECODrIxAPI({
3326
- * apiKey: process.env.ECOD_API_KEY!,
3327
- * clientCode: "ERIX_CLNT_JHBJHF",
3328
- * });
3329
- *
3330
- * await ecod.whatsapp.messages.send({ to: "+91...", text: "Hello!" });
3331
- * const lead = await ecod.crm.leads.create({ firstName: "Alice", phone: "+91..." });
3332
- * ```
3333
- */
3334
- declare class ECODrIxAPI {
3335
- /**
3336
- * @internal Axios HTTP client for making API requests.
3337
- */
3338
- private readonly client;
3339
- /**
3340
- * @internal Socket.io client for real-time events.
3341
- */
3342
- private readonly socket;
3343
- /**
3344
- * The tenant client code this SDK instance is scoped to.
3345
- * Useful for components that need to read the clientCode back
3346
- * from a context-provided SDK instance.
3347
- */
3348
- readonly clientCode: string | undefined;
3349
- /** WhatsApp messaging and conversation management. */
3350
- readonly whatsapp: WhatsApp;
3351
- /** CRM resources — Leads and related sub-resources. */
3352
- readonly crm: CRM;
3353
- /** Cloudflare R2-backed media storage. */
3354
- readonly media: Media;
3355
- /** Google Meet appointment scheduling. */
3356
- readonly meet: Meetings;
3357
- /** Automation execution logs and provider webhook callbacks. */
3358
- readonly notifications: Notifications;
3359
- /** Outbound email marketing engine and template management. */
3360
- readonly email: Email;
3361
- /** Platform-wide execution logs and audit trails. */
3362
- readonly logs: Logs;
3363
- /** Lead events and workflow automation triggers. */
3364
- readonly events: EventsResource;
3365
- /** Cryptographic webhook signature verification. */
3366
- readonly webhooks: Webhooks;
3367
- /** Tenant Cloud Storage mapping. */
3368
- readonly storage: Storage;
3369
- /** Email and SMS Marketing Campaigns. */
3370
- readonly marketing: Marketing;
3371
- /** Platform and tenant health diagnostics. */
3372
- readonly health: Health;
3373
- /** Background job queue management. */
3374
- readonly queue: Queue;
3375
- /** White-Label Agency administration. */
3376
- readonly agency: Agency;
3377
- /** Multi-tenant Identity & Lifecycle services. */
3378
- readonly services: Services;
3379
- /** Tenant environment and provider settings. */
3380
- readonly settings: Settings;
3381
- /** Dynamic Cross-Origin Resource Sharing network policies. */
3382
- readonly cors: Cors;
3383
- /** ErixCheckout one-click checkout flow management. */
3384
- readonly checkout: Checkout;
3385
- constructor(options: ECODrIxAPIOptions);
3386
- /**
3387
- * Join a specific real-time room (e.g., a conversation or a lead).
3388
- *
3389
- * @param roomId - The unique identifier for the room.
3390
- */
3391
- joinRoom(roomId: string): void;
3392
- /**
3393
- * Leave a previously joined real-time room.
3394
- *
3395
- * @param roomId - The unique identifier for the room.
3396
- */
3397
- leaveRoom(roomId: string): void;
3398
- private setupSocket;
3399
- /**
3400
- * Subscribe to a real-time event emitted by the ECODrIx platform.
3401
- *
3402
- * The SDK maintains a persistent Socket.io connection. Events are
3403
- * scoped to your `clientCode` — you will only receive events for
3404
- * your own tenant.
3405
- *
3406
- * **Standard events:**
3407
- * - `new_message` — inbound WhatsApp message (includes conversation and message payload)
3408
- * - `message_sent` — outbound message successfully sent
3409
- * - `message_status_update` — WhatsApp message status change (delivered, read, failed)
3410
- * - `conversation_updated` — metadata change (unread count, last message, status)
3411
- * - `message_updated` — real-time updates for reactions or media processing
3412
- * - `notification:new` — new system or CRM notification
3413
- * - `workflow-run-update` — automation execution progress
3414
- * - `meet.scheduled` — Google Meet appointment booked
3415
- *
3416
- * @param event - The event name to subscribe to.
3417
- * @param callback - The handler function invoked when the event fires.
3418
- * @returns `this` for method chaining.
3419
- *
3420
- * @example
3421
- * ```typescript
3422
- * ecod
3423
- * .on("whatsapp.message_received", (msg) => console.log(msg.body))
3424
- * .on("automation.failed", (err) => alertTeam(err));
3425
- * ```
3426
- */
3427
- on(event: string, callback: (...args: any[]) => void): this;
3428
- /**
3429
- * Gracefully disconnect the real-time Socket.io connection.
3430
- * Call this when shutting down your server or when the client is
3431
- * no longer needed to free up resources.
3432
- *
3433
- * @example
3434
- * ```typescript
3435
- * process.on("SIGTERM", () => ecod.disconnect());
3436
- * ```
3437
- */
3438
- disconnect(): void;
3439
- /**
3440
- * Remove a previously registered event listener.
3441
- * Always call this in cleanup (e.g. React `useEffect` return) to prevent
3442
- * memory leaks and duplicate handlers after reconnections.
3443
- *
3444
- * @param event - The event name to unsubscribe from.
3445
- * @param callback - The exact handler reference passed to `.on()`.
3446
- * @returns `this` for method chaining.
3447
- */
3448
- off(event: string, callback: (...args: any[]) => void): this;
3449
- /**
3450
- * Raw Execution Escape-Hatch.
3451
- * Send an authenticated HTTP request directly to the ECODrIx backend from ANY external project.
3452
- *
3453
- * This is extremely powerful giving you full unrestricted access to make calls
3454
- * against new, experimental, or completely custom backend APIs while still benefitting
3455
- * from the SDK's built-in authentication and automatic `axios-retry` logic.
3456
- *
3457
- * @example
3458
- * ```typescript
3459
- * const { data } = await ecod.request("POST", "/api/saas/experimental-feature", { flag: true });
3460
- * console.log(data);
3461
- * ```
3462
- */
3463
- request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
3464
- }
3465
-
3466
- export { APIError, type ApplyCouponPayload, AuthenticationError, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type CreateOrderPayload, type CreateSessionPayload, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, EcodrixError, type FieldManifest, type FieldType, RateLimitError, type ResourceManifest, type VerifyPayload, ECODrIxAPI as default };