@ecodrix/erix-api 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,315 +23,230 @@ declare abstract class APIResource {
23
23
  private handleError;
24
24
  }
25
25
 
26
- /**
27
- * Parameters for sending a free-form WhatsApp message.
28
- */
29
- interface SendMessageParams {
30
- /**
31
- * Recipient's phone number in E.164 format.
32
- * @example "+919876543210"
33
- */
34
- to: string;
35
- /** Plain text body of the message. */
36
- text?: string;
37
- /** Public URL of the media asset to send. */
38
- mediaUrl?: string;
39
- /** MIME category of the media. */
40
- mediaType?: "image" | "video" | "audio" | "document";
41
- /** The `messageId` of the message to reply to (quoted replies). */
42
- replyToId?: string;
43
- /** Filename shown to the recipient (required for `document` type). */
44
- filename?: string;
45
- /** Arbitrary metadata stored with the message record. */
26
+ interface LogActivityParams {
27
+ leadId: string;
28
+ type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
29
+ title: string;
30
+ body?: string;
46
31
  metadata?: Record<string, any>;
47
32
  }
48
- /**
49
- * Parameters for sending a pre-approved WhatsApp Business template.
50
- */
51
- interface SendTemplateParams {
33
+ interface LogCallParams {
34
+ durationMinutes: number;
35
+ summary: string;
36
+ outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
37
+ }
38
+ declare class Notes extends APIResource {
52
39
  /**
53
- * Recipient's phone number in E.164 format.
54
- * @example "+919876543210"
40
+ * List all notes for a specific lead.
55
41
  */
56
- to: string;
57
- /** The exact template name as approved in Meta Business Manager. */
58
- templateName: string;
42
+ list<T = any>(leadId: string): Promise<T>;
59
43
  /**
60
- * BCP-47 language code for the template.
61
- * @default "en_US"
44
+ * Add a note to a lead.
62
45
  */
63
- language?: string;
46
+ create<T = any>(leadId: string, params: {
47
+ content: string;
48
+ }): Promise<T>;
64
49
  /**
65
- * Ordered array of variable substitutions for template placeholders.
66
- * @example ["Alice", "10 April 2026", "10:00 AM"]
50
+ * Update an existing note.
67
51
  */
68
- variables?: string[];
69
- /** Optional header media URL (for templates with media headers). */
70
- mediaUrl?: string;
71
- /** Media type for the header (e.g. "image", "document"). */
72
- mediaType?: string;
73
- }
74
- /**
75
- * WhatsApp outbound messaging resource.
76
- *
77
- * Access via `ecod.whatsapp.messages`.
78
- *
79
- * @example
80
- * ```typescript
81
- * await ecod.whatsapp.messages.send({
82
- * to: "+919876543210",
83
- * text: "Your appointment is confirmed!",
84
- * });
85
- * ```
86
- */
87
- declare class Messages extends APIResource {
52
+ update<T = any>(noteId: string, content: string): Promise<T>;
88
53
  /**
89
- * Send a free-text or media message to a WhatsApp number.
90
- *
91
- * For text-only messages, supply `text`. For media, supply `mediaUrl`
92
- * and `mediaType`. Both can be combined.
93
- *
94
- * @param params - Message parameters.
95
- * @returns The created message record.
96
- *
97
- * @example Text message
98
- * ```typescript
99
- * await ecod.whatsapp.messages.send({
100
- * to: "+919876543210",
101
- * text: "Hello!",
102
- * });
103
- * ```
104
- *
105
- * @example Media message
106
- * ```typescript
107
- * await ecod.whatsapp.messages.send({
108
- * to: "+919876543210",
109
- * mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
110
- * mediaType: "document",
111
- * filename: "invoice.pdf",
112
- * });
113
- * ```
54
+ * Pin or unpin a note to the top of the feed.
114
55
  */
115
- send(params: SendMessageParams): Promise<unknown>;
56
+ pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
116
57
  /**
117
- * Send a pre-approved WhatsApp Business template message.
118
- *
119
- * Templates must be approved in Meta Business Manager before use.
120
- * Variable placeholders in the template body are filled left-to-right
121
- * from the `variables` array.
122
- *
123
- * @param params - Template message parameters.
124
- * @returns The created message record.
125
- *
126
- * @example
127
- * ```typescript
128
- * await ecod.whatsapp.messages.sendTemplate({
129
- * to: "+919876543210",
130
- * templateName: "appointment_reminder",
131
- * language: "en_US",
132
- * variables: ["Alice", "10 April", "10:00 AM"],
133
- * });
134
- * ```
58
+ * Delete a note.
135
59
  */
136
- sendTemplate(params: SendTemplateParams): Promise<unknown>;
60
+ delete(noteId: string): Promise<unknown>;
61
+ }
62
+ declare class Activities extends APIResource {
63
+ notes: Notes;
64
+ constructor(client: any);
137
65
  /**
138
- * Star or unstar a message.
139
- *
140
- * @param messageId - The ID of the message.
141
- * @param isStarred - Boolean indicating whether to star or unstar.
66
+ * Retrieve the complete chronological timeline for a lead.
142
67
  */
143
- star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
68
+ timeline<T = any>(leadId: string, params?: {
69
+ page?: number;
70
+ limit?: number;
71
+ }): Promise<T>;
144
72
  /**
145
- * React to a message with an emoji.
146
- *
147
- * @param messageId - The ID of the message.
148
- * @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
73
+ * List specific activities (filtered by type).
149
74
  */
150
- react<T = any>(messageId: string, reaction: string): Promise<T>;
75
+ list<T = any>(leadId: string, params?: {
76
+ type?: string;
77
+ page?: number;
78
+ limit?: number;
79
+ }): Promise<T>;
151
80
  /**
152
- * Mark all messages in a conversation as read (double-tick).
153
- *
154
- * @param conversationId - The conversation to mark as read.
155
- *
156
- * @example
157
- * ```typescript
158
- * await ecod.whatsapp.messages.markRead("conv_64abc...");
159
- * ```
81
+ * Generic method to log a business activity/event.
160
82
  */
161
- markRead(conversationId: string): Promise<unknown>;
83
+ log<T = any>(params: LogActivityParams): Promise<T>;
84
+ /**
85
+ * Specific method to log communication outcomes.
86
+ */
87
+ logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
162
88
  }
163
89
 
164
- interface ListParams {
165
- limit?: number;
166
- before?: string;
167
- after?: string;
168
- status?: string;
90
+ type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
91
+ interface AnalyticsParams {
92
+ range?: AnalyticsRange;
93
+ from?: string;
94
+ to?: string;
95
+ pipelineId?: string;
169
96
  }
170
- declare class Conversations extends APIResource {
97
+ declare class Analytics extends APIResource {
171
98
  /**
172
- * List conversations for the tenant.
99
+ * KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
173
100
  */
174
- list<T = any>(params?: ListParams): Promise<T>;
101
+ overview<T = any>(params?: AnalyticsParams): Promise<T>;
175
102
  /**
176
- * Create a new conversation explicitly.
177
- *
178
- * @param params - Conversation details.
103
+ * Stage-by-stage lead counts and conversion percentages.
179
104
  */
180
- create<T = any>(params: {
181
- phone: string;
182
- name?: string;
183
- }): Promise<T>;
105
+ funnel<T = any>(pipelineId: string): Promise<T>;
184
106
  /**
185
- * Retrieve details of a specific conversation.
107
+ * Revenue forecast: deal value × stage probability.
186
108
  */
187
- retrieve<T = any>(conversationId: string): Promise<T>;
109
+ forecast<T = any>(pipelineId?: string): Promise<T>;
188
110
  /**
189
- * Get messages for a specific conversation.
111
+ * Lead source breakdown: count, conversion rate, total value per source.
190
112
  */
191
- messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
113
+ sources<T = any>(params?: AnalyticsParams): Promise<T>;
192
114
  /**
193
- * Link a conversation to a lead.
115
+ * Team leaderboard: won deals, revenue, activity count, conversion rate per member.
194
116
  */
195
- linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
117
+ team<T = any>(params?: AnalyticsParams): Promise<T>;
196
118
  /**
197
- * Mark a conversation as read (clear unread count).
119
+ * Daily activity counts by type. For activity calendar.
198
120
  */
199
- markRead<T = any>(conversationId: string): Promise<T>;
121
+ heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
200
122
  /**
201
- * Delete a conversation.
123
+ * Score distribution: how many leads in each score bucket.
202
124
  */
203
- delete(conversationId: string): Promise<unknown>;
125
+ scores<T = any>(): Promise<T>;
204
126
  /**
205
- * Bulk delete conversations.
127
+ * Avg time leads spend in each stage. Helps find bottlenecks.
206
128
  */
207
- bulkDelete(ids: string[]): Promise<unknown>;
208
- }
209
-
210
- interface CreateBroadcastParams {
211
- /** Optional name for the broadcast campaign */
212
- name?: string;
213
- /** Name of the Meta template to send */
214
- templateName: string;
215
- /** Language code (defaults to en_US) */
216
- templateLanguage?: string;
217
- /** List of recipients with their phone numbers and variable overrides */
218
- recipients: {
219
- phone: string;
220
- variables?: string[];
221
- }[];
222
- }
223
- declare class Broadcasts extends APIResource {
129
+ stageTime<T = any>(pipelineId: string): Promise<T>;
224
130
  /**
225
- * List past and active broadcasts.
131
+ * Tiered Growth Report matching business sophistication.
226
132
  */
227
- list<T = any>(params?: Record<string, any>): Promise<T>;
133
+ tiered<T = any>(params?: AnalyticsParams): Promise<T>;
228
134
  /**
229
- * Create a new broadcast to send a template message to multiple recipients.
135
+ * Consolidated analytics including CRM overview and WhatsApp.
230
136
  */
231
- create<T = any>(params: CreateBroadcastParams): Promise<T>;
137
+ summary<T = any>(params?: AnalyticsParams): Promise<T>;
138
+ /**
139
+ * WhatsApp volume and delivery analytics.
140
+ */
141
+ whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
232
142
  }
233
143
 
234
- interface TemplateMapping {
235
- mappings: any[];
236
- onEmptyVariable: string;
237
- }
238
- declare class Templates extends APIResource {
144
+ declare class AutomationDashboard extends APIResource {
239
145
  /**
240
- * List all templates from the tenant database.
146
+ * Retrieve summary statistics for automation health.
241
147
  */
242
- list<T = any>(params?: {
243
- status?: string;
244
- mappingStatus?: string;
245
- channel?: string;
246
- }): Promise<T>;
148
+ stats<T = any>(): Promise<T>;
247
149
  /**
248
- * Synchronize templates from Meta API.
150
+ * List recent EventLog entries (automation logs).
249
151
  */
250
- sync<T = any>(): Promise<T>;
152
+ logs<T = any>(params?: {
153
+ limit?: number;
154
+ status?: string;
155
+ }): Promise<T>;
251
156
  /**
252
- * Get template details.
157
+ * Re-emit a failed event log to process its automations again.
253
158
  */
254
- retrieve<T = any>(templateIdentifier: string): Promise<T>;
159
+ retryFailedEvent<T = any>(logId: string): Promise<T>;
160
+ }
161
+
162
+ interface AutomationRulePayload {
163
+ name: string;
164
+ trigger: string;
165
+ isActive?: boolean;
166
+ nodes: any[];
167
+ edges: any[];
168
+ }
169
+ declare class Automations extends APIResource {
255
170
  /**
256
- * Create a new template manually.
171
+ * List all automation rules for the tenant.
257
172
  */
258
- create<T = any>(payload: any): Promise<T>;
173
+ list<T = any>(): Promise<T>;
259
174
  /**
260
- * Update an existing template.
175
+ * Create a new automation rule.
261
176
  */
262
- update<T = any>(templateId: string, payload: any): Promise<T>;
177
+ create<T = any>(payload: AutomationRulePayload): Promise<T>;
263
178
  /**
264
- * Delete a template.
179
+ * Update an existing automation rule.
265
180
  */
266
- deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
181
+ update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
267
182
  /**
268
- * List curated mapping config options.
183
+ * Enable or disable an automation rule.
269
184
  */
270
- mappingConfig<T = any>(): Promise<T>;
185
+ toggle<T = any>(ruleId: string): Promise<T>;
271
186
  /**
272
- * List CRM collections for variable mapping.
187
+ * Delete an automation rule.
273
188
  */
274
- collections<T = any>(): Promise<T>;
189
+ deleteRule<T = any>(ruleId: string): Promise<T>;
275
190
  /**
276
- * List CRM fields for a collection.
191
+ * Bulk delete rules.
277
192
  */
278
- collectionFields<T = any>(collectionName: string): Promise<T>;
193
+ bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
279
194
  /**
280
- * Update variable mappings for a template.
195
+ * Dry-run test an automation rule against a specific lead.
281
196
  */
282
- updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
197
+ test<T = any>(ruleId: string, leadId: string): Promise<T>;
283
198
  /**
284
- * Validate mapping readiness.
199
+ * Get available event triggers for automations.
285
200
  */
286
- validate<T = any>(templateName: string): Promise<T>;
201
+ getAvailableEvents<T = any>(): Promise<T>;
287
202
  /**
288
- * Preview a template resolution.
203
+ * List enrollments for a rule.
289
204
  */
290
- preview<T = any>(templateName: string, context: {
291
- lead?: any;
292
- vars?: any;
205
+ enrollments<T = any>(ruleId: string, params?: {
206
+ status?: string;
207
+ page?: number;
208
+ limit?: number;
209
+ startDate?: string;
210
+ endDate?: string;
293
211
  }): Promise<T>;
294
212
  /**
295
- * Check automation usage of a template.
213
+ * Get an enrollment detail.
296
214
  */
297
- checkUsage<T = any>(templateName: string): Promise<T>;
298
- }
299
-
300
- interface SendTemplatePayload {
301
- /** Phone number in E.164 format. */
302
- phone: string;
303
- /** Name of the pre-approved WhatsApp template. */
304
- templateName: string;
305
- /** Language code (defaults to "en"). */
306
- languageCode?: string;
307
- /** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
308
- variables?: Record<string, string>;
309
- /** Explicitly resolved variables if bypassing the internal resolution engine. */
310
- resolvedVariables?: any[];
311
- }
312
- declare class WhatsApp extends APIResource {
313
- messages: Messages;
314
- conversations: Conversations;
315
- broadcasts: Broadcasts;
316
- templates: Templates;
317
- constructor(client: AxiosInstance);
215
+ getEnrollment<T = any>(enrollmentId: string): Promise<T>;
318
216
  /**
319
- * Upload an asset directly to chat storage.
217
+ * Pause an enrollment.
320
218
  */
321
- upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
219
+ pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
322
220
  /**
323
- * Dispatch a WhatsApp template message directly to a specific phone number.
324
- * Bypasses the automation queue for immediate high-priority delivery.
221
+ * Resume an enrollment.
222
+ */
223
+ resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
224
+ /**
225
+ * List workflow runs.
226
+ */
227
+ runs<T = any>(ruleId: string): Promise<T>;
228
+ /**
229
+ * Get run details.
230
+ */
231
+ getRun<T = any>(runId: string): Promise<T>;
232
+ /**
233
+ * Resume a paused run.
234
+ */
235
+ resumeRun<T = any>(runId: string): Promise<T>;
236
+ /**
237
+ * Abort a running workflow.
238
+ */
239
+ abortRun<T = any>(runId: string): Promise<T>;
240
+ /**
241
+ * Emit an external webhook event to unlock a `wait_event` node inside a
242
+ * paused workflow run. Required when integrating third-party tools that
243
+ * need to resume a suspended automation.
325
244
  *
326
- * @param payload - The template dispatch payload.
327
- * @returns Information about the dispatched message.
245
+ * @param ruleId - The automation rule that contains the wait_event node.
246
+ * @param eventName - The event name that should match the node's condition.
247
+ * @param payload - Arbitrary data forwarded to the node context.
328
248
  */
329
- sendTemplate(payload: SendTemplatePayload): Promise<{
330
- success: boolean;
331
- messageId?: string;
332
- templateName?: string;
333
- resolvedVariables?: any[];
334
- }>;
249
+ webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
335
250
  }
336
251
 
337
252
  /**
@@ -551,6 +466,19 @@ declare class Leads extends APIResource {
551
466
  bulkDelete(ids: string[]): Promise<unknown>;
552
467
  }
553
468
 
469
+ declare class Payments extends APIResource {
470
+ /**
471
+ * Record an inbound payment against a lead or appointment.
472
+ */
473
+ capture<T = any>(payload: {
474
+ leadId: string;
475
+ amount: number;
476
+ currency?: string;
477
+ description?: string;
478
+ appointmentId?: string;
479
+ }): Promise<T>;
480
+ }
481
+
554
482
  interface CreatePipelineParams {
555
483
  name: string;
556
484
  isDefault?: boolean;
@@ -623,298 +551,368 @@ declare class Pipelines extends APIResource {
623
551
  deleteStage(stageId: string, moveLeadsToStageId?: string): Promise<unknown>;
624
552
  }
625
553
 
626
- interface LogActivityParams {
627
- leadId: string;
628
- type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
629
- title: string;
630
- body?: string;
631
- metadata?: Record<string, any>;
632
- }
633
- interface LogCallParams {
634
- durationMinutes: number;
635
- summary: string;
636
- outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
554
+ interface ScoringConfig {
555
+ decayDays: number;
556
+ thresholds: {
557
+ hot: number;
558
+ warm: number;
559
+ };
560
+ rules: any[];
637
561
  }
638
- declare class Notes extends APIResource {
639
- /**
640
- * List all notes for a specific lead.
641
- */
642
- list<T = any>(leadId: string): Promise<T>;
643
- /**
644
- * Add a note to a lead.
645
- */
646
- create<T = any>(leadId: string, params: {
647
- content: string;
648
- }): Promise<T>;
562
+ declare class Scoring extends APIResource {
649
563
  /**
650
- * Update an existing note.
564
+ * Retrieve the tenant's global lead scoring configuration.
651
565
  */
652
- update<T = any>(noteId: string, content: string): Promise<T>;
566
+ getConfig<T = any>(): Promise<T>;
653
567
  /**
654
- * Pin or unpin a note to the top of the feed.
568
+ * Update scoring configuration.
655
569
  */
656
- pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
570
+ updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
657
571
  /**
658
- * Delete a note.
572
+ * Force recalculate the score for a specific lead.
659
573
  */
660
- delete(noteId: string): Promise<unknown>;
574
+ recalculate<T = any>(leadId: string): Promise<T>;
661
575
  }
662
- declare class Activities extends APIResource {
663
- notes: Notes;
664
- constructor(client: any);
665
- /**
666
- * Retrieve the complete chronological timeline for a lead.
667
- */
668
- timeline<T = any>(leadId: string, params?: {
669
- page?: number;
670
- limit?: number;
671
- }): Promise<T>;
576
+
577
+ declare class Sequences extends APIResource {
672
578
  /**
673
- * List specific activities (filtered by type).
579
+ * Manually enroll a lead in a drip sequence (automation rule).
674
580
  */
675
- list<T = any>(leadId: string, params?: {
676
- type?: string;
677
- page?: number;
678
- limit?: number;
581
+ enroll<T = any>(payload: {
582
+ leadId: string;
583
+ ruleId: string;
584
+ variables?: Record<string, any>;
679
585
  }): Promise<T>;
680
586
  /**
681
- * Generic method to log a business activity/event.
587
+ * Unenroll a lead from a running sequence.
682
588
  */
683
- log<T = any>(params: LogActivityParams): Promise<T>;
589
+ unenroll<T = any>(enrollmentId: string): Promise<T>;
684
590
  /**
685
- * Specific method to log communication outcomes.
591
+ * List active sequence enrollments for a specific lead.
686
592
  */
687
- logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
593
+ listForLead<T = any>(leadId: string): Promise<T>;
688
594
  }
689
595
 
690
- type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
691
- interface AnalyticsParams {
692
- range?: AnalyticsRange;
693
- from?: string;
694
- to?: string;
695
- pipelineId?: string;
596
+ declare class CRM {
597
+ leads: Leads;
598
+ pipelines: Pipelines;
599
+ activities: Activities;
600
+ analytics: Analytics;
601
+ automations: Automations;
602
+ sequences: Sequences;
603
+ scoring: Scoring;
604
+ payments: Payments;
605
+ automationDashboard: AutomationDashboard;
606
+ constructor(client: AxiosInstance);
696
607
  }
697
- declare class Analytics extends APIResource {
608
+
609
+ /**
610
+ * Payload to send a high-throughput email campaign.
611
+ */
612
+ interface SendCampaignPayload {
613
+ /** Array of recipient email addresses. */
614
+ recipients: string[];
615
+ /** Subject line of the email. */
616
+ subject: string;
617
+ /** HTML body of the email. */
618
+ html: string;
619
+ }
620
+ /**
621
+ * Interface representing the result of a campaign dispatch.
622
+ */
623
+ interface CampaignResult {
624
+ success: boolean;
625
+ message?: string;
626
+ [key: string]: any;
627
+ }
628
+ declare class EmailResource extends APIResource {
698
629
  /**
699
- * KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
630
+ * Send an HTML email campaign to a list of recipients.
631
+ *
632
+ * @param payload - The campaign details (recipients, subject, html).
633
+ * @returns The dispatch result.
700
634
  */
701
- overview<T = any>(params?: AnalyticsParams): Promise<T>;
702
- /**
703
- * Stage-by-stage lead counts and conversion percentages.
704
- */
705
- funnel<T = any>(pipelineId: string): Promise<T>;
706
- /**
707
- * Revenue forecast: deal value × stage probability.
708
- */
709
- forecast<T = any>(pipelineId?: string): Promise<T>;
710
- /**
711
- * Lead source breakdown: count, conversion rate, total value per source.
712
- */
713
- sources<T = any>(params?: AnalyticsParams): Promise<T>;
714
- /**
715
- * Team leaderboard: won deals, revenue, activity count, conversion rate per member.
716
- */
717
- team<T = any>(params?: AnalyticsParams): Promise<T>;
718
- /**
719
- * Daily activity counts by type. For activity calendar.
720
- */
721
- heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
722
- /**
723
- * Score distribution: how many leads in each score bucket.
724
- */
725
- scores<T = any>(): Promise<T>;
726
- /**
727
- * Avg time leads spend in each stage. Helps find bottlenecks.
728
- */
729
- stageTime<T = any>(pipelineId: string): Promise<T>;
730
- /**
731
- * Tiered Growth Report matching business sophistication.
732
- */
733
- tiered<T = any>(params?: AnalyticsParams): Promise<T>;
734
- /**
735
- * Consolidated analytics including CRM overview and WhatsApp.
736
- */
737
- summary<T = any>(params?: AnalyticsParams): Promise<T>;
635
+ sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
738
636
  /**
739
- * WhatsApp volume and delivery analytics.
637
+ * Send a system verification/test email to validate SMTP configuration.
638
+ *
639
+ * @param to - The recipient's email address.
640
+ * @returns The dispatch result.
740
641
  */
741
- whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
642
+ sendTestEmail(to: string): Promise<CampaignResult>;
742
643
  }
743
644
 
744
- interface AutomationRulePayload {
645
+ /**
646
+ * Event definition representing an entry point capable of triggering automations.
647
+ */
648
+ interface EventDefinition {
649
+ name: string;
650
+ displayName: string;
651
+ description?: string;
652
+ pipelineId?: string;
653
+ stageId?: string;
654
+ defaultSource?: string;
655
+ [key: string]: any;
656
+ }
657
+ /**
658
+ * Payload to register/assign a new custom event definition.
659
+ */
660
+ interface AssignEventPayload {
661
+ /** The internal machine-readable name of the event (e.g. "webinar_joined") */
745
662
  name: string;
663
+ /** Human-readable display name */
664
+ displayName: string;
665
+ /** Event description */
666
+ description?: string;
667
+ /** ID of the pipeline to associate with matching leads */
668
+ pipelineId?: string;
669
+ /** ID of the stage within the pipeline */
670
+ stageId?: string;
671
+ /** Default source tag for leads created via this event */
672
+ defaultSource?: string;
673
+ }
674
+ /**
675
+ * Payload to programmatically trigger an event/workflow.
676
+ */
677
+ interface TriggerPayload {
678
+ /** The name of the event to fire (e.g., "webinar_joined") */
746
679
  trigger: string;
747
- isActive?: boolean;
748
- nodes: any[];
749
- edges: any[];
680
+ /** Phone number of the lead (E.164 format) */
681
+ phone: string;
682
+ /** Email of the lead */
683
+ email?: string;
684
+ /** Key-value pairs for string templates */
685
+ variables?: Record<string, string>;
686
+ /** Deep payload data mapping to the event */
687
+ data?: any;
688
+ /** URL to receive an acknowledgment callback when processing completes */
689
+ callbackUrl?: string;
690
+ /** Secret metadata passed back to the callback URL */
691
+ callbackMetadata?: any;
692
+ /** Auto-create lead if phone does not exist in CRM */
693
+ createLeadIfMissing?: boolean;
694
+ /** Pre-fill data if creating a new lead */
695
+ leadData?: {
696
+ firstName?: string;
697
+ lastName?: string;
698
+ source?: string;
699
+ };
700
+ /** Delay execution of matched workflows (in seconds) */
701
+ delaySeconds?: number;
702
+ /** Delay execution of matched workflows (in minutes) */
703
+ delayMinutes?: number;
704
+ /** Explicit ISO timestamp to trigger the workflow run */
705
+ runAt?: string;
706
+ /** Automatically generate a Google Meet appointment if matched actions require it */
707
+ requiresMeet?: boolean;
708
+ /** Configuration details for the generated Google Meet appointment */
709
+ meetConfig?: {
710
+ summary?: string;
711
+ description?: string;
712
+ startTime?: string;
713
+ duration?: number;
714
+ timezone?: string;
715
+ attendees?: string[];
716
+ };
750
717
  }
751
- declare class Automations extends APIResource {
752
- /**
753
- * List all automation rules for the tenant.
754
- */
755
- list<T = any>(): Promise<T>;
756
- /**
757
- * Create a new automation rule.
758
- */
759
- create<T = any>(payload: AutomationRulePayload): Promise<T>;
718
+ /**
719
+ * Response returned when triggering an event.
720
+ */
721
+ interface TriggerResponse {
722
+ success: boolean;
723
+ data?: {
724
+ eventLogId: string;
725
+ trigger: string;
726
+ leadId: string;
727
+ rulesMatched: number;
728
+ };
729
+ message?: string;
730
+ code?: string;
731
+ }
732
+ declare class EventsResource extends APIResource {
760
733
  /**
761
- * Update an existing automation rule.
734
+ * Retrieve all valid events (system + custom) that can be used as Automation Rule triggers.
762
735
  */
763
- update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
736
+ list(): Promise<{
737
+ success: boolean;
738
+ data: EventDefinition[];
739
+ }>;
764
740
  /**
765
- * Enable or disable an automation rule.
741
+ * Register a new custom event entry point into the CRM automation engine.
742
+ * Useful when introducing new granular triggers.
766
743
  */
767
- toggle<T = any>(ruleId: string): Promise<T>;
744
+ assign(payload: AssignEventPayload): Promise<{
745
+ success: boolean;
746
+ data: EventDefinition;
747
+ }>;
768
748
  /**
769
- * Delete an automation rule.
749
+ * Deactivate a custom event assignment by name.
770
750
  */
771
- deleteRule<T = any>(ruleId: string): Promise<T>;
751
+ unassign(name: string): Promise<{
752
+ success: boolean;
753
+ data: any;
754
+ }>;
772
755
  /**
773
- * Bulk delete rules.
756
+ * Deactivate multiple custom event assignments simultaneously.
774
757
  */
775
- bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
758
+ unassignBulk(names: string[]): Promise<{
759
+ success: boolean;
760
+ message: string;
761
+ }>;
776
762
  /**
777
- * Dry-run test an automation rule against a specific lead.
763
+ * Programmatically fire an event into the CRM automation engine.
764
+ * Emits to the internal EventBus to match with active Workflow Automation Rules.
778
765
  */
779
- test<T = any>(ruleId: string, leadId: string): Promise<T>;
766
+ trigger(payload: TriggerPayload): Promise<TriggerResponse>;
780
767
  /**
781
- * Get available event triggers for automations.
768
+ * List all custom event definitions.
782
769
  */
783
- getAvailableEvents<T = any>(): Promise<T>;
770
+ listCustomEvents<T = any>(): Promise<T>;
784
771
  /**
785
- * List enrollments for a rule.
772
+ * Create or upsert a custom event definition.
786
773
  */
787
- enrollments<T = any>(ruleId: string, params?: {
788
- status?: string;
789
- page?: number;
790
- limit?: number;
791
- startDate?: string;
792
- endDate?: string;
774
+ createCustomEvent<T = any>(payload: {
775
+ name: string;
776
+ displayName: string;
777
+ description?: string;
793
778
  }): Promise<T>;
794
779
  /**
795
- * Get an enrollment detail.
796
- */
797
- getEnrollment<T = any>(enrollmentId: string): Promise<T>;
798
- /**
799
- * Pause an enrollment.
780
+ * Delete a custom event definition.
800
781
  */
801
- pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
782
+ deleteCustomEvent<T = any>(id: string): Promise<T>;
802
783
  /**
803
- * Resume an enrollment.
784
+ * Manually emit a custom event to trigger workflows based on its definition.
804
785
  */
805
- resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
786
+ emit<T = any>(payload: {
787
+ eventName: string;
788
+ leadId: string;
789
+ data?: any;
790
+ }): Promise<T>;
791
+ }
792
+
793
+ interface SystemHealth {
794
+ status: string;
795
+ version: string;
796
+ env: string;
797
+ uptime: number;
798
+ db: string;
799
+ queueDepth: number;
800
+ timestamp: string;
801
+ }
802
+ interface ClientHealth {
803
+ clientCode: string;
804
+ services: {
805
+ whatsapp: "connected" | "not_configured";
806
+ email: "configured" | "not_configured";
807
+ googleMeet: "configured" | "not_configured";
808
+ };
809
+ activeAutomations: number;
810
+ queueDepth: number;
811
+ timestamp: string;
812
+ }
813
+ interface JobStatus {
814
+ jobId: string;
815
+ status: string;
816
+ attempts: number;
817
+ maxAttempts: number;
818
+ lastError: any;
819
+ runAt: string;
820
+ completedAt: string | null;
821
+ failedAt: string | null;
822
+ createdAt: string;
823
+ }
824
+ declare class Health extends APIResource {
806
825
  /**
807
- * List workflow runs.
826
+ * Global platform health check.
808
827
  */
809
- runs<T = any>(ruleId: string): Promise<T>;
828
+ system(): Promise<SystemHealth>;
810
829
  /**
811
- * Get run details.
830
+ * Tenant-specific health check. Identifies configured services.
812
831
  */
813
- getRun<T = any>(runId: string): Promise<T>;
832
+ clientHealth(): Promise<ClientHealth>;
814
833
  /**
815
- * Resume a paused run.
834
+ * Job execution status lookup.
816
835
  */
817
- resumeRun<T = any>(runId: string): Promise<T>;
836
+ jobStatus(jobId: string): Promise<JobStatus>;
837
+ }
838
+
839
+ interface SendCampaignParams {
840
+ recipients: string[];
841
+ subject: string;
842
+ html: string;
843
+ }
844
+ declare class Emails extends APIResource {
818
845
  /**
819
- * Abort a running workflow.
846
+ * Dispatch a bulk email campaign.
820
847
  */
821
- abortRun<T = any>(runId: string): Promise<T>;
848
+ sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
822
849
  /**
823
- * Emit an external webhook event to unlock a `wait_event` node inside a
824
- * paused workflow run. Required when integrating third-party tools that
825
- * need to resume a suspended automation.
826
- *
827
- * @param ruleId - The automation rule that contains the wait_event node.
828
- * @param eventName - The event name that should match the node's condition.
829
- * @param payload - Arbitrary data forwarded to the node context.
850
+ * Send a test verification email (used to verify SMTP functionality).
830
851
  */
831
- webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
852
+ sendTest<T = any>(to: string): Promise<T>;
832
853
  }
833
-
834
- declare class Sequences extends APIResource {
854
+ declare class Campaigns extends APIResource {
835
855
  /**
836
- * Manually enroll a lead in a drip sequence (automation rule).
856
+ * List email and SMS marketing campaigns.
837
857
  */
838
- enroll<T = any>(payload: {
839
- leadId: string;
840
- ruleId: string;
841
- variables?: Record<string, any>;
858
+ list<T = any>(params?: {
859
+ status?: string;
860
+ limit?: number;
842
861
  }): Promise<T>;
843
862
  /**
844
- * Unenroll a lead from a running sequence.
845
- */
846
- unenroll<T = any>(enrollmentId: string): Promise<T>;
847
- /**
848
- * List active sequence enrollments for a specific lead.
863
+ * Create a new campaign.
849
864
  */
850
- listForLead<T = any>(leadId: string): Promise<T>;
851
- }
852
-
853
- interface ScoringConfig {
854
- decayDays: number;
855
- thresholds: {
856
- hot: number;
857
- warm: number;
858
- };
859
- rules: any[];
860
- }
861
- declare class Scoring extends APIResource {
865
+ create<T = any>(payload: {
866
+ name: string;
867
+ type: string;
868
+ subject?: string;
869
+ html?: string;
870
+ templateId?: string;
871
+ recipients?: string[];
872
+ }): Promise<T>;
862
873
  /**
863
- * Retrieve the tenant's global lead scoring configuration.
874
+ * Retrieve campaign details.
864
875
  */
865
- getConfig<T = any>(): Promise<T>;
876
+ retrieve<T = any>(campaignId: string): Promise<T>;
866
877
  /**
867
- * Update scoring configuration.
878
+ * Update a campaign.
868
879
  */
869
- updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
880
+ update<T = any>(campaignId: string, payload: any): Promise<T>;
870
881
  /**
871
- * Force recalculate the score for a specific lead.
882
+ * Delete a campaign.
872
883
  */
873
- recalculate<T = any>(leadId: string): Promise<T>;
874
- }
875
-
876
- declare class Payments extends APIResource {
884
+ delete<T = any>(campaignId: string): Promise<T>;
877
885
  /**
878
- * Record an inbound payment against a lead or appointment.
886
+ * Send or schedule a campaign.
879
887
  */
880
- capture<T = any>(payload: {
881
- leadId: string;
882
- amount: number;
883
- currency?: string;
884
- description?: string;
885
- appointmentId?: string;
888
+ send<T = any>(campaignId: string, payload?: {
889
+ scheduledAt?: string;
886
890
  }): Promise<T>;
887
- }
888
-
889
- declare class AutomationDashboard extends APIResource {
890
891
  /**
891
- * Retrieve summary statistics for automation health.
892
+ * Get campaign stats (opens, clicks, bounces).
892
893
  */
893
- stats<T = any>(): Promise<T>;
894
+ stats<T = any>(campaignId: string): Promise<T>;
895
+ }
896
+ declare class WhatsAppMarketing extends APIResource {
894
897
  /**
895
- * List recent EventLog entries (automation logs).
898
+ * Dispatch a template-based WhatsApp message with CRM-integrated variable resolution.
899
+ *
900
+ * Unlike direct WhatsApp sending, this endpoint automatically pulls data from the CRM
901
+ * based on the provided variables mapping.
896
902
  */
897
- logs<T = any>(params?: {
898
- limit?: number;
899
- status?: string;
903
+ sendTemplate<T = any>(params: {
904
+ phone: string;
905
+ templateName: string;
906
+ languageCode?: string;
907
+ variables?: Record<string, string>;
908
+ resolvedVariables?: Record<string, string>;
900
909
  }): Promise<T>;
901
- /**
902
- * Re-emit a failed event log to process its automations again.
903
- */
904
- retryFailedEvent<T = any>(logId: string): Promise<T>;
905
910
  }
906
-
907
- declare class CRM {
908
- leads: Leads;
909
- pipelines: Pipelines;
910
- activities: Activities;
911
- analytics: Analytics;
912
- automations: Automations;
913
- sequences: Sequences;
914
- scoring: Scoring;
915
- payments: Payments;
916
- automationDashboard: AutomationDashboard;
917
- constructor(client: AxiosInstance);
911
+ declare class Marketing extends APIResource {
912
+ emails: Emails;
913
+ campaigns: Campaigns;
914
+ whatsapp: WhatsAppMarketing;
915
+ constructor(client: any);
918
916
  }
919
917
 
920
918
  /**
@@ -1334,192 +1332,86 @@ declare class Notifications extends APIResource {
1334
1332
  clearAllAlerts<T = any>(): Promise<T>;
1335
1333
  /**
1336
1334
  * Retry an action from a notification (e.g. failed send).
1337
- */
1338
- retryAction<T = any>(notificationId: string): Promise<T>;
1339
- }
1340
-
1341
- /**
1342
- * Payload to send a high-throughput email campaign.
1343
- */
1344
- interface SendCampaignPayload {
1345
- /** Array of recipient email addresses. */
1346
- recipients: string[];
1347
- /** Subject line of the email. */
1348
- subject: string;
1349
- /** HTML body of the email. */
1350
- html: string;
1351
- }
1352
- /**
1353
- * Interface representing the result of a campaign dispatch.
1354
- */
1355
- interface CampaignResult {
1356
- success: boolean;
1357
- message?: string;
1358
- [key: string]: any;
1359
- }
1360
- declare class EmailResource extends APIResource {
1361
- /**
1362
- * Send an HTML email campaign to a list of recipients.
1363
- *
1364
- * @param payload - The campaign details (recipients, subject, html).
1365
- * @returns The dispatch result.
1366
- */
1367
- sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
1368
- /**
1369
- * Send a system verification/test email to validate SMTP configuration.
1370
- *
1371
- * @param to - The recipient's email address.
1372
- * @returns The dispatch result.
1373
- */
1374
- sendTestEmail(to: string): Promise<CampaignResult>;
1375
- }
1376
-
1377
- /**
1378
- * Event definition representing an entry point capable of triggering automations.
1379
- */
1380
- interface EventDefinition {
1381
- name: string;
1382
- displayName: string;
1383
- description?: string;
1384
- pipelineId?: string;
1385
- stageId?: string;
1386
- defaultSource?: string;
1387
- [key: string]: any;
1388
- }
1389
- /**
1390
- * Payload to register/assign a new custom event definition.
1391
- */
1392
- interface AssignEventPayload {
1393
- /** The internal machine-readable name of the event (e.g. "webinar_joined") */
1394
- name: string;
1395
- /** Human-readable display name */
1396
- displayName: string;
1397
- /** Event description */
1398
- description?: string;
1399
- /** ID of the pipeline to associate with matching leads */
1400
- pipelineId?: string;
1401
- /** ID of the stage within the pipeline */
1402
- stageId?: string;
1403
- /** Default source tag for leads created via this event */
1404
- defaultSource?: string;
1405
- }
1406
- /**
1407
- * Payload to programmatically trigger an event/workflow.
1408
- */
1409
- interface TriggerPayload {
1410
- /** The name of the event to fire (e.g., "webinar_joined") */
1411
- trigger: string;
1412
- /** Phone number of the lead (E.164 format) */
1413
- phone: string;
1414
- /** Email of the lead */
1415
- email?: string;
1416
- /** Key-value pairs for string templates */
1417
- variables?: Record<string, string>;
1418
- /** Deep payload data mapping to the event */
1419
- data?: any;
1420
- /** URL to receive an acknowledgment callback when processing completes */
1421
- callbackUrl?: string;
1422
- /** Secret metadata passed back to the callback URL */
1423
- callbackMetadata?: any;
1424
- /** Auto-create lead if phone does not exist in CRM */
1425
- createLeadIfMissing?: boolean;
1426
- /** Pre-fill data if creating a new lead */
1427
- leadData?: {
1428
- firstName?: string;
1429
- lastName?: string;
1430
- source?: string;
1431
- };
1432
- /** Delay execution of matched workflows (in seconds) */
1433
- delaySeconds?: number;
1434
- /** Delay execution of matched workflows (in minutes) */
1435
- delayMinutes?: number;
1436
- /** Explicit ISO timestamp to trigger the workflow run */
1437
- runAt?: string;
1438
- /** Automatically generate a Google Meet appointment if matched actions require it */
1439
- requiresMeet?: boolean;
1440
- /** Configuration details for the generated Google Meet appointment */
1441
- meetConfig?: {
1442
- summary?: string;
1443
- description?: string;
1444
- startTime?: string;
1445
- duration?: number;
1446
- timezone?: string;
1447
- attendees?: string[];
1448
- };
1335
+ */
1336
+ retryAction<T = any>(notificationId: string): Promise<T>;
1449
1337
  }
1450
- /**
1451
- * Response returned when triggering an event.
1452
- */
1453
- interface TriggerResponse {
1454
- success: boolean;
1455
- data?: {
1456
- eventLogId: string;
1457
- trigger: string;
1458
- leadId: string;
1459
- rulesMatched: number;
1460
- };
1461
- message?: string;
1462
- code?: string;
1338
+
1339
+ interface JobStats {
1340
+ waiting: number;
1341
+ active: number;
1342
+ completed: number;
1343
+ failed: number;
1344
+ delayed: number;
1463
1345
  }
1464
- declare class EventsResource extends APIResource {
1346
+ declare class Queue extends APIResource {
1465
1347
  /**
1466
- * Retrieve all valid events (system + custom) that can be used as Automation Rule triggers.
1348
+ * List all failed jobs.
1467
1349
  */
1468
- list(): Promise<{
1469
- success: boolean;
1470
- data: EventDefinition[];
1471
- }>;
1350
+ listFailed<T = any>(): Promise<T>;
1472
1351
  /**
1473
- * Register a new custom event entry point into the CRM automation engine.
1474
- * Useful when introducing new granular triggers.
1352
+ * Get queue health statistics.
1475
1353
  */
1476
- assign(payload: AssignEventPayload): Promise<{
1477
- success: boolean;
1478
- data: EventDefinition;
1479
- }>;
1354
+ getStats<T = JobStats>(): Promise<T>;
1480
1355
  /**
1481
- * Deactivate a custom event assignment by name.
1356
+ * Retry a failed job.
1482
1357
  */
1483
- unassign(name: string): Promise<{
1484
- success: boolean;
1485
- data: any;
1486
- }>;
1358
+ retryJob<T = any>(jobId: string): Promise<T>;
1487
1359
  /**
1488
- * Deactivate multiple custom event assignments simultaneously.
1360
+ * Remove a job from the queue.
1489
1361
  */
1490
- unassignBulk(names: string[]): Promise<{
1491
- success: boolean;
1492
- message: string;
1493
- }>;
1362
+ deleteJob<T = any>(jobId: string): Promise<T>;
1363
+ }
1364
+
1365
+ declare class Folders extends APIResource {
1494
1366
  /**
1495
- * Programmatically fire an event into the CRM automation engine.
1496
- * Emits to the internal EventBus to match with active Workflow Automation Rules.
1367
+ * Create a new folder.
1497
1368
  */
1498
- trigger(payload: TriggerPayload): Promise<TriggerResponse>;
1369
+ create<T = any>(name: string): Promise<T>;
1499
1370
  /**
1500
- * List all custom event definitions.
1371
+ * Delete a folder and its contents.
1501
1372
  */
1502
- listCustomEvents<T = any>(): Promise<T>;
1373
+ delete<T = any>(folderPath: string): Promise<T>;
1374
+ }
1375
+ declare class Files extends APIResource {
1503
1376
  /**
1504
- * Create or upsert a custom event definition.
1377
+ * List files in a folder.
1505
1378
  */
1506
- createCustomEvent<T = any>(payload: {
1507
- name: string;
1508
- displayName: string;
1509
- description?: string;
1379
+ list<T = any>(folder: string, params?: {
1380
+ year?: string;
1381
+ month?: string;
1510
1382
  }): Promise<T>;
1511
1383
  /**
1512
- * Delete a custom event definition.
1384
+ * Get a presigned upload URL for direct-to-cloud browser uploads.
1513
1385
  */
1514
- deleteCustomEvent<T = any>(id: string): Promise<T>;
1386
+ getUploadUrl<T = any>(params: {
1387
+ folder: string;
1388
+ filename: string;
1389
+ contentType: string;
1390
+ }): Promise<T>;
1515
1391
  /**
1516
- * Manually emit a custom event to trigger workflows based on its definition.
1392
+ * Notify backend after a successful direct browser upload.
1517
1393
  */
1518
- emit<T = any>(payload: {
1519
- eventName: string;
1520
- leadId: string;
1521
- data?: any;
1394
+ confirmUpload<T = any>(params: {
1395
+ key: string;
1396
+ sizeBytes: number;
1522
1397
  }): Promise<T>;
1398
+ /**
1399
+ * Get a presigned download URL for an R2 key.
1400
+ */
1401
+ getDownloadUrl<T = any>(key: string): Promise<T>;
1402
+ /**
1403
+ * Delete a file by key.
1404
+ */
1405
+ delete(key: string): Promise<unknown>;
1406
+ }
1407
+ declare class Storage extends APIResource {
1408
+ folders: Folders;
1409
+ files: Files;
1410
+ constructor(client: any);
1411
+ /**
1412
+ * Get tenant storage usage and quota limitations.
1413
+ */
1414
+ usage<T = any>(): Promise<T>;
1523
1415
  }
1524
1416
 
1525
1417
  /**
@@ -1616,207 +1508,315 @@ declare class Webhooks {
1616
1508
  constructEvent(payload: string | Buffer, signature: string | string[] | undefined, secret: string): Promise<any>;
1617
1509
  }
1618
1510
 
1619
- declare class Folders extends APIResource {
1511
+ interface CreateBroadcastParams {
1512
+ /** Optional name for the broadcast campaign */
1513
+ name?: string;
1514
+ /** Name of the Meta template to send */
1515
+ templateName: string;
1516
+ /** Language code (defaults to en_US) */
1517
+ templateLanguage?: string;
1518
+ /** List of recipients with their phone numbers and variable overrides */
1519
+ recipients: {
1520
+ phone: string;
1521
+ variables?: string[];
1522
+ }[];
1523
+ }
1524
+ declare class Broadcasts extends APIResource {
1620
1525
  /**
1621
- * Create a new folder.
1526
+ * List past and active broadcasts.
1622
1527
  */
1623
- create<T = any>(name: string): Promise<T>;
1528
+ list<T = any>(params?: Record<string, any>): Promise<T>;
1624
1529
  /**
1625
- * Delete a folder and its contents.
1530
+ * Create a new broadcast to send a template message to multiple recipients.
1626
1531
  */
1627
- delete<T = any>(folderPath: string): Promise<T>;
1532
+ create<T = any>(params: CreateBroadcastParams): Promise<T>;
1628
1533
  }
1629
- declare class Files extends APIResource {
1534
+
1535
+ interface ListParams {
1536
+ limit?: number;
1537
+ before?: string;
1538
+ after?: string;
1539
+ status?: string;
1540
+ }
1541
+ declare class Conversations extends APIResource {
1630
1542
  /**
1631
- * List files in a folder.
1543
+ * List conversations for the tenant.
1632
1544
  */
1633
- list<T = any>(folder: string, params?: {
1634
- year?: string;
1635
- month?: string;
1545
+ list<T = any>(params?: ListParams): Promise<T>;
1546
+ /**
1547
+ * Create a new conversation explicitly.
1548
+ *
1549
+ * @param params - Conversation details.
1550
+ */
1551
+ create<T = any>(params: {
1552
+ phone: string;
1553
+ name?: string;
1636
1554
  }): Promise<T>;
1637
1555
  /**
1638
- * Get a presigned upload URL for direct-to-cloud browser uploads.
1556
+ * Retrieve details of a specific conversation.
1557
+ */
1558
+ retrieve<T = any>(conversationId: string): Promise<T>;
1559
+ /**
1560
+ * Get messages for a specific conversation.
1561
+ */
1562
+ messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
1563
+ /**
1564
+ * Link a conversation to a lead.
1565
+ */
1566
+ linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
1567
+ /**
1568
+ * Mark a conversation as read (clear unread count).
1569
+ */
1570
+ markRead<T = any>(conversationId: string): Promise<T>;
1571
+ /**
1572
+ * Delete a conversation.
1573
+ */
1574
+ delete(conversationId: string): Promise<unknown>;
1575
+ /**
1576
+ * Bulk delete conversations.
1577
+ */
1578
+ bulkDelete(ids: string[]): Promise<unknown>;
1579
+ }
1580
+
1581
+ /**
1582
+ * Parameters for sending a free-form WhatsApp message.
1583
+ */
1584
+ interface SendMessageParams {
1585
+ /**
1586
+ * Recipient's phone number in E.164 format.
1587
+ * @example "+919876543210"
1588
+ */
1589
+ to: string;
1590
+ /** Plain text body of the message. */
1591
+ text?: string;
1592
+ /** Public URL of the media asset to send. */
1593
+ mediaUrl?: string;
1594
+ /** MIME category of the media. */
1595
+ mediaType?: "image" | "video" | "audio" | "document";
1596
+ /** The `messageId` of the message to reply to (quoted replies). */
1597
+ replyToId?: string;
1598
+ /** Filename shown to the recipient (required for `document` type). */
1599
+ filename?: string;
1600
+ /** Arbitrary metadata stored with the message record. */
1601
+ metadata?: Record<string, any>;
1602
+ }
1603
+ /**
1604
+ * Parameters for sending a pre-approved WhatsApp Business template.
1605
+ */
1606
+ interface SendTemplateParams {
1607
+ /**
1608
+ * Recipient's phone number in E.164 format.
1609
+ * @example "+919876543210"
1610
+ */
1611
+ to: string;
1612
+ /** The exact template name as approved in Meta Business Manager. */
1613
+ templateName: string;
1614
+ /**
1615
+ * BCP-47 language code for the template.
1616
+ * @default "en_US"
1617
+ */
1618
+ language?: string;
1619
+ /**
1620
+ * Ordered array of variable substitutions for template placeholders.
1621
+ * @example ["Alice", "10 April 2026", "10:00 AM"]
1622
+ */
1623
+ variables?: string[];
1624
+ /** Optional header media URL (for templates with media headers). */
1625
+ mediaUrl?: string;
1626
+ /** Media type for the header (e.g. "image", "document"). */
1627
+ mediaType?: string;
1628
+ }
1629
+ /**
1630
+ * WhatsApp outbound messaging resource.
1631
+ *
1632
+ * Access via `ecod.whatsapp.messages`.
1633
+ *
1634
+ * @example
1635
+ * ```typescript
1636
+ * await ecod.whatsapp.messages.send({
1637
+ * to: "+919876543210",
1638
+ * text: "Your appointment is confirmed!",
1639
+ * });
1640
+ * ```
1641
+ */
1642
+ declare class Messages extends APIResource {
1643
+ /**
1644
+ * Send a free-text or media message to a WhatsApp number.
1645
+ *
1646
+ * For text-only messages, supply `text`. For media, supply `mediaUrl`
1647
+ * and `mediaType`. Both can be combined.
1648
+ *
1649
+ * @param params - Message parameters.
1650
+ * @returns The created message record.
1651
+ *
1652
+ * @example Text message
1653
+ * ```typescript
1654
+ * await ecod.whatsapp.messages.send({
1655
+ * to: "+919876543210",
1656
+ * text: "Hello!",
1657
+ * });
1658
+ * ```
1659
+ *
1660
+ * @example Media message
1661
+ * ```typescript
1662
+ * await ecod.whatsapp.messages.send({
1663
+ * to: "+919876543210",
1664
+ * mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
1665
+ * mediaType: "document",
1666
+ * filename: "invoice.pdf",
1667
+ * });
1668
+ * ```
1639
1669
  */
1640
- getUploadUrl<T = any>(params: {
1641
- folder: string;
1642
- filename: string;
1643
- contentType: string;
1644
- }): Promise<T>;
1670
+ send(params: SendMessageParams): Promise<unknown>;
1645
1671
  /**
1646
- * Notify backend after a successful direct browser upload.
1672
+ * Send a pre-approved WhatsApp Business template message.
1673
+ *
1674
+ * Templates must be approved in Meta Business Manager before use.
1675
+ * Variable placeholders in the template body are filled left-to-right
1676
+ * from the `variables` array.
1677
+ *
1678
+ * @param params - Template message parameters.
1679
+ * @returns The created message record.
1680
+ *
1681
+ * @example
1682
+ * ```typescript
1683
+ * await ecod.whatsapp.messages.sendTemplate({
1684
+ * to: "+919876543210",
1685
+ * templateName: "appointment_reminder",
1686
+ * language: "en_US",
1687
+ * variables: ["Alice", "10 April", "10:00 AM"],
1688
+ * });
1689
+ * ```
1647
1690
  */
1648
- confirmUpload<T = any>(params: {
1649
- key: string;
1650
- sizeBytes: number;
1651
- }): Promise<T>;
1691
+ sendTemplate(params: SendTemplateParams): Promise<unknown>;
1652
1692
  /**
1653
- * Get a presigned download URL for an R2 key.
1693
+ * Star or unstar a message.
1694
+ *
1695
+ * @param messageId - The ID of the message.
1696
+ * @param isStarred - Boolean indicating whether to star or unstar.
1654
1697
  */
1655
- getDownloadUrl<T = any>(key: string): Promise<T>;
1698
+ star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
1656
1699
  /**
1657
- * Delete a file by key.
1700
+ * React to a message with an emoji.
1701
+ *
1702
+ * @param messageId - The ID of the message.
1703
+ * @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
1658
1704
  */
1659
- delete(key: string): Promise<unknown>;
1660
- }
1661
- declare class Storage extends APIResource {
1662
- folders: Folders;
1663
- files: Files;
1664
- constructor(client: any);
1705
+ react<T = any>(messageId: string, reaction: string): Promise<T>;
1665
1706
  /**
1666
- * Get tenant storage usage and quota limitations.
1707
+ * Mark all messages in a conversation as read (double-tick).
1708
+ *
1709
+ * @param conversationId - The conversation to mark as read.
1710
+ *
1711
+ * @example
1712
+ * ```typescript
1713
+ * await ecod.whatsapp.messages.markRead("conv_64abc...");
1714
+ * ```
1667
1715
  */
1668
- usage<T = any>(): Promise<T>;
1716
+ markRead(conversationId: string): Promise<unknown>;
1669
1717
  }
1670
1718
 
1671
- interface SendCampaignParams {
1672
- recipients: string[];
1673
- subject: string;
1674
- html: string;
1675
- }
1676
- declare class Emails extends APIResource {
1677
- /**
1678
- * Dispatch a bulk email campaign.
1679
- */
1680
- sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
1681
- /**
1682
- * Send a test verification email (used to verify SMTP functionality).
1683
- */
1684
- sendTest<T = any>(to: string): Promise<T>;
1719
+ interface TemplateMapping {
1720
+ mappings: any[];
1721
+ onEmptyVariable: string;
1685
1722
  }
1686
- declare class Campaigns extends APIResource {
1723
+ declare class Templates extends APIResource {
1687
1724
  /**
1688
- * List email and SMS marketing campaigns.
1725
+ * List all templates from the tenant database.
1689
1726
  */
1690
1727
  list<T = any>(params?: {
1691
1728
  status?: string;
1692
- limit?: number;
1729
+ mappingStatus?: string;
1730
+ channel?: string;
1693
1731
  }): Promise<T>;
1694
1732
  /**
1695
- * Create a new campaign.
1733
+ * Synchronize templates from Meta API.
1696
1734
  */
1697
- create<T = any>(payload: {
1698
- name: string;
1699
- type: string;
1700
- subject?: string;
1701
- html?: string;
1702
- templateId?: string;
1703
- recipients?: string[];
1704
- }): Promise<T>;
1735
+ sync<T = any>(): Promise<T>;
1705
1736
  /**
1706
- * Retrieve campaign details.
1737
+ * Get template details.
1707
1738
  */
1708
- retrieve<T = any>(campaignId: string): Promise<T>;
1739
+ retrieve<T = any>(templateIdentifier: string): Promise<T>;
1709
1740
  /**
1710
- * Update a campaign.
1741
+ * Create a new template manually.
1711
1742
  */
1712
- update<T = any>(campaignId: string, payload: any): Promise<T>;
1743
+ create<T = any>(payload: any): Promise<T>;
1713
1744
  /**
1714
- * Delete a campaign.
1745
+ * Update an existing template.
1715
1746
  */
1716
- delete<T = any>(campaignId: string): Promise<T>;
1747
+ update<T = any>(templateId: string, payload: any): Promise<T>;
1717
1748
  /**
1718
- * Send or schedule a campaign.
1749
+ * Delete a template.
1719
1750
  */
1720
- send<T = any>(campaignId: string, payload?: {
1721
- scheduledAt?: string;
1722
- }): Promise<T>;
1751
+ deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
1723
1752
  /**
1724
- * Get campaign stats (opens, clicks, bounces).
1753
+ * List curated mapping config options.
1725
1754
  */
1726
- stats<T = any>(campaignId: string): Promise<T>;
1727
- }
1728
- declare class WhatsAppMarketing extends APIResource {
1755
+ mappingConfig<T = any>(): Promise<T>;
1729
1756
  /**
1730
- * Dispatch a template-based WhatsApp message with CRM-integrated variable resolution.
1731
- *
1732
- * Unlike direct WhatsApp sending, this endpoint automatically pulls data from the CRM
1733
- * based on the provided variables mapping.
1757
+ * List CRM collections for variable mapping.
1734
1758
  */
1735
- sendTemplate<T = any>(params: {
1736
- phone: string;
1737
- templateName: string;
1738
- languageCode?: string;
1739
- variables?: Record<string, string>;
1740
- resolvedVariables?: Record<string, string>;
1741
- }): Promise<T>;
1742
- }
1743
- declare class Marketing extends APIResource {
1744
- emails: Emails;
1745
- campaigns: Campaigns;
1746
- whatsapp: WhatsAppMarketing;
1747
- constructor(client: any);
1748
- }
1749
-
1750
- interface SystemHealth {
1751
- status: string;
1752
- version: string;
1753
- env: string;
1754
- uptime: number;
1755
- db: string;
1756
- queueDepth: number;
1757
- timestamp: string;
1758
- }
1759
- interface ClientHealth {
1760
- clientCode: string;
1761
- services: {
1762
- whatsapp: "connected" | "not_configured";
1763
- email: "configured" | "not_configured";
1764
- googleMeet: "configured" | "not_configured";
1765
- };
1766
- activeAutomations: number;
1767
- queueDepth: number;
1768
- timestamp: string;
1769
- }
1770
- interface JobStatus {
1771
- jobId: string;
1772
- status: string;
1773
- attempts: number;
1774
- maxAttempts: number;
1775
- lastError: any;
1776
- runAt: string;
1777
- completedAt: string | null;
1778
- failedAt: string | null;
1779
- createdAt: string;
1780
- }
1781
- declare class Health extends APIResource {
1759
+ collections<T = any>(): Promise<T>;
1782
1760
  /**
1783
- * Global platform health check.
1761
+ * List CRM fields for a collection.
1784
1762
  */
1785
- system(): Promise<SystemHealth>;
1763
+ collectionFields<T = any>(collectionName: string): Promise<T>;
1786
1764
  /**
1787
- * Tenant-specific health check. Identifies configured services.
1765
+ * Update variable mappings for a template.
1788
1766
  */
1789
- clientHealth(): Promise<ClientHealth>;
1767
+ updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
1790
1768
  /**
1791
- * Job execution status lookup.
1769
+ * Validate mapping readiness.
1792
1770
  */
1793
- jobStatus(jobId: string): Promise<JobStatus>;
1794
- }
1795
-
1796
- interface JobStats {
1797
- waiting: number;
1798
- active: number;
1799
- completed: number;
1800
- failed: number;
1801
- delayed: number;
1802
- }
1803
- declare class Queue extends APIResource {
1771
+ validate<T = any>(templateName: string): Promise<T>;
1804
1772
  /**
1805
- * List all failed jobs.
1773
+ * Preview a template resolution.
1806
1774
  */
1807
- listFailed<T = any>(): Promise<T>;
1775
+ preview<T = any>(templateName: string, context: {
1776
+ lead?: any;
1777
+ vars?: any;
1778
+ }): Promise<T>;
1808
1779
  /**
1809
- * Get queue health statistics.
1780
+ * Check automation usage of a template.
1810
1781
  */
1811
- getStats<T = JobStats>(): Promise<T>;
1782
+ checkUsage<T = any>(templateName: string): Promise<T>;
1783
+ }
1784
+
1785
+ interface SendTemplatePayload {
1786
+ /** Phone number in E.164 format. */
1787
+ phone: string;
1788
+ /** Name of the pre-approved WhatsApp template. */
1789
+ templateName: string;
1790
+ /** Language code (defaults to "en"). */
1791
+ languageCode?: string;
1792
+ /** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
1793
+ variables?: Record<string, string>;
1794
+ /** Explicitly resolved variables if bypassing the internal resolution engine. */
1795
+ resolvedVariables?: any[];
1796
+ }
1797
+ declare class WhatsApp extends APIResource {
1798
+ messages: Messages;
1799
+ conversations: Conversations;
1800
+ broadcasts: Broadcasts;
1801
+ templates: Templates;
1802
+ constructor(client: AxiosInstance);
1812
1803
  /**
1813
- * Retry a failed job.
1804
+ * Upload an asset directly to chat storage.
1814
1805
  */
1815
- retryJob<T = any>(jobId: string): Promise<T>;
1806
+ upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
1816
1807
  /**
1817
- * Remove a job from the queue.
1808
+ * Dispatch a WhatsApp template message directly to a specific phone number.
1809
+ * Bypasses the automation queue for immediate high-priority delivery.
1810
+ *
1811
+ * @param payload - The template dispatch payload.
1812
+ * @returns Information about the dispatched message.
1818
1813
  */
1819
- deleteJob<T = any>(jobId: string): Promise<T>;
1814
+ sendTemplate(payload: SendTemplatePayload): Promise<{
1815
+ success: boolean;
1816
+ messageId?: string;
1817
+ templateName?: string;
1818
+ resolvedVariables?: any[];
1819
+ }>;
1820
1820
  }
1821
1821
 
1822
1822
  /**