@ecodrix/erix-api 2.1.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,235 +256,6 @@ declare class Analytics extends APIResource {
256
256
  retention<T = any>(): Promise<T>;
257
257
  }
258
258
 
259
- declare class AutomationDashboard extends APIResource {
260
- /**
261
- * Retrieve summary statistics for automation health (total, success, failed).
262
- *
263
- * @returns Stats object.
264
- * @example
265
- * ```typescript
266
- * const stats = await erixClient.crm.automationDashboard.stats();
267
- * ```
268
- */
269
- stats<T = any>(): Promise<T>;
270
- /**
271
- * List recent EventLog entries representing automation executions.
272
- *
273
- * @param params - Optional filters (limit, status).
274
- * @example
275
- * ```typescript
276
- * const logs = await erixClient.crm.automationDashboard.logs({ status: "failed" });
277
- * ```
278
- */
279
- logs<T = any>(params?: {
280
- limit?: number;
281
- status?: string;
282
- }): Promise<T>;
283
- /**
284
- * Re-emit a failed event log to re-trigger its associated automation rules.
285
- *
286
- * @param logId - The unique ID of the failed event log.
287
- * @example
288
- * ```typescript
289
- * await erixClient.crm.automationDashboard.retryFailedEvent("log_123");
290
- * ```
291
- */
292
- retryFailedEvent<T = any>(logId: string): Promise<T>;
293
- }
294
-
295
- interface AutomationRulePayload {
296
- name: string;
297
- trigger: string;
298
- isActive?: boolean;
299
- nodes: any[];
300
- edges: any[];
301
- }
302
- declare class Automations extends APIResource {
303
- /**
304
- * List all automation rules (workflows) configured for the tenant.
305
- *
306
- * @returns Array of automation rule objects.
307
- * @example
308
- * ```typescript
309
- * const rules = await erixClient.crm.automations.list();
310
- * ```
311
- */
312
- list<T = any>(): Promise<T>;
313
- /**
314
- * Create a new automation rule with triggers and workflow nodes.
315
- *
316
- * @param payload - The automation rule definition (trigger, nodes, edges).
317
- * @returns The created automation rule.
318
- * @example
319
- * ```typescript
320
- * await erixClient.crm.automations.create({
321
- * name: "Welcome Email Workflow",
322
- * trigger: "contact_created",
323
- * nodes: [...],
324
- * edges: [...]
325
- * });
326
- * ```
327
- */
328
- create<T = any>(payload: AutomationRulePayload): Promise<T>;
329
- /**
330
- * Update an existing automation rule.
331
- */
332
- update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
333
- /**
334
- * Enable or disable an automation rule.
335
- */
336
- toggle<T = any>(ruleId: string): Promise<T>;
337
- /**
338
- * Delete an automation rule.
339
- */
340
- delete<T = any>(ruleId: string): Promise<unknown>;
341
- /**
342
- * Bulk delete rules.
343
- */
344
- bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
345
- /**
346
- * Dry-run test an automation rule against a specific lead to verify logic.
347
- *
348
- * @param ruleId - The ID of the rule to test.
349
- * @param leadId - The ID of the lead to run the test against.
350
- * @example
351
- * ```typescript
352
- * await erixClient.crm.automations.test("rule_123", "lead_456");
353
- * ```
354
- */
355
- test<T = any>(ruleId: string, leadId: string): Promise<T>;
356
- /**
357
- * Get available event triggers for automations.
358
- */
359
- getAvailableEvents<T = any>(): Promise<T>;
360
- /**
361
- * List enrollments for a rule.
362
- */
363
- enrollments<T = any>(ruleId: string, params?: {
364
- status?: string;
365
- page?: number;
366
- limit?: number;
367
- startDate?: string;
368
- endDate?: string;
369
- }): Promise<T>;
370
- /**
371
- * Get an enrollment detail.
372
- */
373
- getEnrollment<T = any>(enrollmentId: string): Promise<T>;
374
- /**
375
- * Pause an enrollment.
376
- */
377
- pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
378
- /**
379
- * Resume an enrollment.
380
- */
381
- resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
382
- /**
383
- * List workflow runs.
384
- */
385
- runs<T = any>(ruleId: string): Promise<T>;
386
- /**
387
- * Get run details.
388
- */
389
- getRun<T = any>(runId: string): Promise<T>;
390
- /**
391
- * Resume a paused run.
392
- */
393
- resumeRun<T = any>(runId: string): Promise<T>;
394
- /**
395
- * Abort a running workflow.
396
- */
397
- abortRun<T = any>(runId: string): Promise<T>;
398
- /**
399
- * Emit an external webhook event to unlock a `wait_event` node inside a
400
- * paused workflow run. Required when integrating third-party tools that
401
- * need to resume a suspended automation.
402
- *
403
- * @param ruleId - The automation rule that contains the wait_event node.
404
- * @param eventName - The event name that should match the node's condition.
405
- * @param payload - Arbitrary data forwarded to the node context.
406
- */
407
- webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
408
- /**
409
- * Fire a CRM automation trigger for a given phone number.
410
- *
411
- * @param params - Trigger payload (trigger name, phone, variables, etc.)
412
- */
413
- trigger<T = any>(params: {
414
- trigger: string;
415
- phone: string;
416
- email?: string;
417
- variables?: Record<string, string>;
418
- createLeadIfMissing?: boolean;
419
- leadData?: any;
420
- delayMinutes?: number;
421
- runAt?: Date | string;
422
- }): Promise<T>;
423
- }
424
-
425
- /**
426
- * CRM Campaigns — broadcast campaigns with A/B testing.
427
- *
428
- * @example
429
- * ```typescript
430
- * const campaigns = await ecod.crm.campaigns.list();
431
- * const analytics = await ecod.crm.campaigns.analytics("campaign-id");
432
- * const ab = await ecod.crm.campaigns.createAB({ channel: "email", ... });
433
- * ```
434
- */
435
- declare class CRMCampaigns extends APIResource {
436
- /**
437
- * List campaigns with metrics.
438
- */
439
- list<T = any>(params?: {
440
- status?: string;
441
- startDate?: string;
442
- endDate?: string;
443
- page?: number;
444
- limit?: number;
445
- }): Promise<T>;
446
- /**
447
- * Get analytics for a specific campaign.
448
- */
449
- analytics<T = any>(campaignId: string): Promise<T>;
450
- /**
451
- * Create and send a campaign.
452
- */
453
- create<T = any>(payload: {
454
- channel: "email" | "whatsapp";
455
- recipients: Array<string | {
456
- email?: string;
457
- phone?: string;
458
- name?: string;
459
- }>;
460
- subject?: string;
461
- html?: string;
462
- templateName?: string;
463
- languageCode?: string;
464
- variables?: Record<string, unknown>;
465
- }): Promise<T>;
466
- /**
467
- * Create an A/B split test campaign.
468
- */
469
- createAB<T = any>(payload: {
470
- channel: "email" | "whatsapp";
471
- recipients: Array<string | {
472
- email?: string;
473
- phone?: string;
474
- name?: string;
475
- }>;
476
- variants: Array<{
477
- name: string;
478
- subject?: string;
479
- html?: string;
480
- templateName?: string;
481
- }>;
482
- testPercent?: number;
483
- waitHours?: number;
484
- winnerMetric?: "open" | "click" | "reply" | "delivered";
485
- }): Promise<T>;
486
- }
487
-
488
259
  /**
489
260
  * CRM Documents — document checklist management per lead.
490
261
  *
@@ -768,6 +539,14 @@ interface UpsertLeadParams {
768
539
  phone: string;
769
540
  name?: string;
770
541
  };
542
+ /**
543
+ * Generic, tenant-agnostic cross-reference map ({ refKey: refValue }) the
544
+ * caller controls — e.g. `{ orderId: "..." }`, `{ appointmentId: "..." }`,
545
+ * or any custom key. Merged into the lead's `metadata.refs`. Preferred over
546
+ * the deprecated `moduleInfo`.
547
+ */
548
+ refs?: Record<string, string>;
549
+ /** @deprecated Use `refs` instead. Retained for backward compatibility. */
771
550
  moduleInfo?: any;
772
551
  trigger?: string;
773
552
  pipelineId?: string;
@@ -1049,9 +828,10 @@ declare class Leads extends APIResource {
1049
828
  */
1050
829
  meetings<T = any>(leadId: string): Promise<T>;
1051
830
  /**
1052
- * List sequence enrollments for this lead.
831
+ * List automation history for this lead as Flow runs. Flow is the automation
832
+ * engine — this returns the workflow runs triggered for the lead.
1053
833
  */
1054
- sequences<T = any>(leadId: string): Promise<T>;
834
+ flowRuns<T = any>(leadId: string): Promise<T>;
1055
835
  /**
1056
836
  * Merge two duplicate leads. Primary survives, secondary's data is merged in
1057
837
  * (conversations, activities, tags) and the secondary is deleted.
@@ -1301,516 +1081,116 @@ declare class Scoring extends APIResource {
1301
1081
  preview<T = any>(leadId: string): Promise<T>;
1302
1082
  }
1303
1083
 
1304
- declare class Sequences extends APIResource {
1305
- /**
1306
- * Manually enroll a lead into a specific automation drip sequence (Workflow).
1307
- *
1308
- * @param payload - Enrollment details (leadId, ruleId, and custom variables).
1309
- * @example
1310
- * ```typescript
1311
- * await erixClient.crm.sequences.enroll({
1312
- * leadId: "lead_123",
1313
- * ruleId: "rule_456",
1314
- * variables: { start_date: "2026-05-01" }
1315
- * });
1316
- * ```
1317
- */
1318
- enroll<T = any>(payload: {
1319
- leadId: string;
1320
- ruleId: string;
1321
- variables?: Record<string, any>;
1322
- }): Promise<T>;
1323
- /**
1324
- * Unenroll a lead from a currently running automation sequence.
1325
- *
1326
- * @param enrollmentId - The unique ID of the sequence enrollment.
1327
- * @example
1328
- * ```typescript
1329
- * await erixClient.crm.sequences.unenroll("enroll_123");
1330
- * ```
1331
- */
1332
- unenroll<T = any>(enrollmentId: string): Promise<unknown>;
1333
- /**
1334
- * List all active and completed sequence enrollments for a specific lead.
1335
- *
1336
- * @param leadId - The unique ID of the lead.
1337
- * @returns Array of enrollment records.
1338
- * @example
1339
- * ```typescript
1340
- * const enrollments = await erixClient.crm.sequences.listForLead("lead_123");
1341
- * ```
1342
- */
1343
- listForLead<T = any>(leadId: string): Promise<T>;
1344
- }
1345
-
1346
- /**
1347
- * Broadcast campaign entity returned by `/product/erix/chat/broadcasts`.
1348
- *
1349
- * Tracks the lifecycle of a bulk WhatsApp send and its delivery counters.
1350
- */
1351
- interface Broadcast {
1352
- _id: string;
1353
- name: string;
1354
- templateName: string;
1355
- status: "draft" | "scheduled" | "sending" | "completed" | "failed";
1356
- recipientCount: number;
1357
- sentCount: number;
1358
- deliveredCount: number;
1359
- readCount: number;
1360
- createdAt: string;
1361
- scheduledAt?: string;
1362
- completedAt?: string;
1363
- }
1364
- interface CreateBroadcastParams {
1365
- /** Optional name for the broadcast campaign */
1366
- name?: string;
1367
- /** Name of the Meta template to send */
1368
- templateName: string;
1369
- /** Language code (defaults to en_US) */
1370
- templateLanguage?: string;
1371
- /** List of recipients with their phone numbers and variable overrides */
1372
- recipients: {
1373
- phone: string;
1374
- variables?: string[];
1375
- }[];
1376
- }
1377
- declare class Broadcasts extends APIResource {
1378
- /**
1379
- * List past and active WhatsApp broadcast campaigns.
1380
- *
1381
- * @param params - Optional filter parameters (page, limit, status).
1382
- * @returns Paginated list of broadcast records.
1383
- * @example
1384
- * ```typescript
1385
- * const broadcasts = await erixClient.whatsapp.broadcasts.list({ limit: 10 });
1386
- * ```
1387
- */
1388
- list<T = any>(params?: Record<string, any>): Promise<T>;
1389
- /**
1390
- * Retrieve full details and real-time stats for a specific broadcast campaign.
1391
- *
1392
- * @param id - The unique identifier of the broadcast.
1393
- * @returns The broadcast record including sent/failed counts.
1394
- * @example
1395
- * ```typescript
1396
- * const stats = await erixClient.whatsapp.broadcasts.retrieve("bc_123");
1397
- * console.log(`Success Rate: ${(stats.sentCount / stats.totalRecipients) * 100}%`);
1398
- * ```
1399
- */
1400
- retrieve<T = any>(id: string): Promise<T>;
1401
- /**
1402
- * Create a new broadcast campaign to send template messages to multiple recipients.
1403
- *
1404
- * @param params - Broadcast configuration (name, templateName, recipients).
1405
- * @returns The newly created broadcast record.
1406
- * @example
1407
- * ```typescript
1408
- * await erixClient.whatsapp.broadcasts.create({
1409
- * name: "Spring Sale",
1410
- * templateName: "promo_code",
1411
- * recipients: [
1412
- * { phone: "+919876543210", variables: ["SAVE10"] }
1413
- * ]
1414
- * });
1415
- * ```
1416
- */
1417
- create<T = any>(params: CreateBroadcastParams): Promise<T>;
1418
- /**
1419
- * Update broadcast metadata, such as its name or administrative status.
1420
- *
1421
- * @param id - The unique ID of the broadcast.
1422
- * @param data - The fields to update (name, status).
1423
- * @example
1424
- * ```typescript
1425
- * await erixClient.whatsapp.broadcasts.update("bc_123", { name: "Revised Spring Sale" });
1426
- * ```
1427
- */
1428
- update<T = any>(id: string, data: {
1429
- name?: string;
1430
- status?: string;
1431
- }): Promise<T>;
1432
- /**
1433
- * Delete a broadcast campaign record.
1434
- * Note: This does not cancel messages already in flight but removes the record from the dashboard.
1435
- *
1436
- * @param id - The unique ID of the broadcast.
1437
- * @example
1438
- * ```typescript
1439
- * await erixClient.whatsapp.broadcasts.delete("bc_123");
1440
- * ```
1441
- */
1442
- delete<T = any>(id: string): Promise<T>;
1443
- }
1444
-
1445
- /**
1446
- * Conversation entity returned by `/product/erix/chat/conversations`.
1447
- *
1448
- * Represents a single WhatsApp thread between the workspace and an
1449
- * external phone number. `status` is the conversation lifecycle (open
1450
- * vs resolved) — distinct from `LeadStatus` on the linked lead.
1451
- */
1084
+ /** Channels the platform inbox carries. */
1085
+ type InboxChannel = "whatsapp" | "instagram" | "facebook" | "telegram" | "email" | "webchat";
1086
+ /** One inbox thread (any channel) — served by `/platform/inbox`. */
1452
1087
  interface Conversation {
1453
- _id: string;
1088
+ id: string;
1089
+ leadId: string | null;
1090
+ channel: InboxChannel;
1091
+ /** The contact's address on that channel (phone, IG id, chat id…). */
1454
1092
  phone: string;
1455
- contactName?: string;
1456
- lastMessage?: {
1457
- body: string;
1458
- timestamp: string;
1459
- direction: "inbound" | "outbound";
1460
- };
1093
+ userName: string | null;
1094
+ profilePicture: string | null;
1095
+ lastMessage: string | null;
1096
+ lastMessageAt: string | null;
1461
1097
  unreadCount: number;
1462
- status: "open" | "resolved";
1463
- assignedTo?: string;
1464
- leadId?: string;
1465
- updatedAt: string;
1098
+ status: string;
1099
+ updatedAt: string | null;
1466
1100
  }
1467
1101
  interface ListParams {
1468
- limit?: number;
1469
- before?: string;
1470
- after?: string;
1102
+ channel?: InboxChannel;
1471
1103
  status?: string;
1104
+ search?: string;
1105
+ limit?: number;
1106
+ offset?: number;
1472
1107
  }
1108
+ /**
1109
+ * The unified inbox (WhatsApp, Instagram, Facebook, Telegram, email, webchat)
1110
+ * — one set of threads for every channel.
1111
+ */
1473
1112
  declare class Conversations extends APIResource {
1474
- /**
1475
- * List conversations for the tenant.
1476
- * @deprecated Use `list` method from `ErixClient` instead.
1477
- * @param params - List parameters.
1478
- * @returns List of conversations.
1479
- * @example
1480
- * ```typescript
1481
- * import { ErixClient } from "erix-react";
1482
- * const erixClient = new ErixClient({ apiKey: "YOUR_API_KEY" });
1483
- * const conversations = await erixClient.whatsapp.conversations.list();
1484
- * ```
1485
- */
1113
+ /** Threads, newest first. Response: `{ success, data, total }`. */
1486
1114
  list<T = any>(params?: ListParams): Promise<T>;
1487
- /**
1488
- * Create a new conversation explicitly.
1489
- *
1490
- * @param params - Conversation details.
1491
- * @example
1492
- * ```typescript
1493
- * const conversation = await erixClient.whatsapp.conversations.create({
1494
- * phone: "+919876543210",
1495
- * name: "John Doe"
1496
- * });
1497
- * ```
1498
- */
1115
+ /** Find or open the thread for a contact (defaults to WhatsApp). */
1499
1116
  create<T = any>(params: {
1500
1117
  phone: string;
1501
1118
  name?: string;
1119
+ channel?: InboxChannel;
1502
1120
  }): Promise<T>;
1503
- /**
1504
- * Retrieve details of a specific conversation.
1505
- *
1506
- * @param conversationId - The unique ID of the conversation.
1507
- * @example
1508
- * ```typescript
1509
- * const conversation = await erixClient.whatsapp.conversations.retrieve("conv_123");
1510
- * ```
1511
- */
1121
+ /** Link the thread to one of your CRM leads (e.g. after creating it). */
1122
+ linkLead<T = any>(conversationId: string, leadId: string): Promise<T>;
1512
1123
  retrieve<T = any>(conversationId: string): Promise<T>;
1513
1124
  /**
1514
- * Get messages for a specific conversation.
1515
- *
1516
- * @param conversationId - The unique ID of the conversation.
1517
- * @param params - Pagination and filter parameters.
1518
- * @example
1519
- * ```typescript
1520
- * const messages = await erixClient.whatsapp.conversations.messages("conv_123", { limit: 50 });
1521
- * ```
1522
- */
1523
- messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
1524
- /**
1525
- * Link a conversation to a lead in the CRM.
1526
- *
1527
- * @param conversationId - The unique ID of the conversation.
1528
- * @param leadId - The unique ID of the lead to link.
1529
- * @param leadData - Optional additional lead metadata.
1530
- * @example
1531
- * ```typescript
1532
- * await erixClient.whatsapp.conversations.linkLead("conv_123", "lead_456");
1533
- * ```
1534
- */
1535
- linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
1536
- /**
1537
- * Mark a conversation as read (clear unread count).
1538
- *
1539
- * @param conversationId - The unique ID of the conversation.
1540
- * @example
1541
- * ```typescript
1542
- * await erixClient.whatsapp.conversations.markRead("conv_123");
1543
- * ```
1125
+ * Messages of a thread, newest page first. Page back with `before` = the
1126
+ * oldest message's `createdAt` you have. Response: `{ data, hasMore }`.
1544
1127
  */
1128
+ messages<T = any>(conversationId: string, params?: {
1129
+ limit?: number;
1130
+ before?: string;
1131
+ }): Promise<T>;
1545
1132
  markRead<T = any>(conversationId: string): Promise<T>;
1546
- /**
1547
- * Delete a conversation.
1548
- *
1549
- * @param conversationId - The unique ID of the conversation.
1550
- * @example
1551
- * ```typescript
1552
- * await erixClient.whatsapp.conversations.delete("conv_123");
1553
- * ```
1554
- */
1555
1133
  delete(conversationId: string): Promise<unknown>;
1556
- /**
1557
- * Bulk delete conversations.
1558
- *
1559
- * @param ids - Array of conversation IDs to delete.
1560
- * @example
1561
- * ```typescript
1562
- * await erixClient.whatsapp.conversations.bulkDelete(["conv_1", "conv_2"]);
1563
- * ```
1564
- */
1134
+ /** Delete 1–100 threads. */
1565
1135
  bulkDelete<T = any>(ids: string[]): Promise<T>;
1566
1136
  }
1567
1137
 
1568
- /**
1569
- * A single chat message inside a `Conversation`.
1570
- */
1138
+ /** One inbox message (any channel). */
1571
1139
  interface Message {
1572
- _id: string;
1140
+ id: string;
1573
1141
  conversationId: string;
1574
- body?: string;
1575
- mediaUrl?: string;
1576
- mediaType?: "image" | "video" | "audio" | "document";
1577
1142
  direction: "inbound" | "outbound";
1578
- status: "sent" | "delivered" | "read" | "failed";
1579
- timestamp: string;
1580
- replyToId?: string;
1143
+ messageType: string;
1144
+ text: string | null;
1145
+ mediaUrl: string | null;
1146
+ mediaType: string | null;
1147
+ caption: string | null;
1148
+ status: string;
1149
+ isStarred: boolean;
1150
+ createdAt?: string;
1151
+ }
1152
+ /** A file already uploaded to YOUR tenant storage (see {@link Messages.upload}). */
1153
+ interface OutboundMedia {
1154
+ key: string;
1155
+ mimeType: string;
1156
+ fileName?: string;
1581
1157
  }
1582
- /**
1583
- * Parameters for sending a free-form WhatsApp message.
1584
- */
1585
1158
  interface SendMessageParams {
1586
- /**
1587
- * Recipient's phone number in E.164 format.
1588
- * @example "+919876543210"
1589
- */
1590
- to?: string;
1591
- /**
1592
- * The unique ID of the conversation. If supplied, `to` is resolved automatically.
1593
- */
1159
+ /** Reply in an existing inbox thread (any channel). */
1594
1160
  conversationId?: string;
1595
- /** Plain text body of the message. */
1161
+ /** …or message a WhatsApp number directly (free text needs an open 24h window). */
1162
+ to?: string;
1596
1163
  text?: string;
1597
- /** Public URL of the media asset to send. */
1598
- mediaUrl?: string;
1599
- /** MIME category of the media. */
1600
- mediaType?: "image" | "video" | "audio" | "document";
1601
- /** The `messageId` of the message to reply to (quoted replies). */
1602
- replyToId?: string;
1603
- /** Filename shown to the recipient (required for `document` type). */
1604
- filename?: string;
1605
- /** Arbitrary metadata stored with the message record. */
1606
- metadata?: Record<string, any>;
1607
- /** Template name for template messages. */
1608
- templateName?: string;
1609
- /** Template language for template messages. */
1610
- templateLanguage?: string;
1611
- /** Alternative language parameter. */
1612
- language?: string;
1613
- /** Template variables. */
1614
- variables?: string[];
1164
+ /** An uploaded file — inbox threads only (WhatsApp today). */
1165
+ media?: OutboundMedia;
1615
1166
  }
1616
- /**
1617
- * Parameters for sending a pre-approved WhatsApp Business template.
1618
- */
1619
1167
  interface SendTemplateParams {
1620
- /**
1621
- * Recipient's phone number in E.164 format.
1622
- * @example "+919876543210"
1623
- */
1624
- to?: string;
1625
- /**
1626
- * The unique ID of the conversation.
1627
- */
1628
- conversationId?: string;
1629
- /** The exact template name as approved in Meta Business Manager. */
1168
+ /** Recipient phone (E.164). */
1169
+ to: string;
1170
+ /** Template name as approved in Meta Business Manager. */
1630
1171
  templateName: string;
1631
- /**
1632
- * BCP-47 language code for the template.
1633
- * @default "en_US"
1634
- */
1635
1172
  language?: string;
1636
- /**
1637
- * Ordered array of variable substitutions for template placeholders.
1638
- * @example ["Alice", "10 April 2026", "10:00 AM"]
1639
- */
1640
1173
  variables?: string[];
1641
- /** Optional header media URL (for templates with media headers). */
1642
- mediaUrl?: string;
1643
- /** Media type for the header (e.g. "image", "document"). */
1644
- mediaType?: string;
1645
- /** User ID of the agent sending the message. */
1646
- userId?: string;
1647
- /** Optional filename for media headers. */
1648
- filename?: string;
1649
- /** Template language for template messages. */
1650
- templateLanguage?: string;
1651
- }
1652
- /**
1653
- * WhatsApp outbound messaging resource.
1654
- *
1655
- * Access via `ecod.whatsapp.messages`.
1656
- *
1657
- * @example
1658
- * ```typescript
1659
- * await ecod.whatsapp.messages.send({
1660
- * to: "+919876543210",
1661
- * text: "Your appointment is confirmed!",
1662
- * });
1663
- * ```
1664
- */
1665
- /**
1666
- * Resolved media metadata returned by any upload endpoint.
1667
- * `variants` is only present for raster images (JPEG, PNG, WebP, AVIF, GIF).
1668
- */
1669
- interface ChatMediaMeta {
1670
- /** Raw CDN URL — always present, all media types */
1671
- url: string;
1672
- /** Categorical type — "image" | "video" | "audio" | "document" */
1673
- type: "image" | "video" | "audio" | "document";
1674
- /** Cloudflare-optimised variant URLs. Only present for raster images. */
1675
- variants?: {
1676
- /** 150px WebP — use for list thumbnails and chat bubbles */
1677
- thumb: string;
1678
- /** 600px WebP — use for modal previews */
1679
- medium: string;
1680
- /** 1200px WebP — use for hero or full-screen views */
1681
- full: string;
1682
- /** Original CDN URL, no transformation */
1683
- raw: string;
1684
- };
1685
- /** Storage key within the tenant bucket */
1686
- key?: string;
1687
- /** Original filename */
1688
- fileName?: string;
1689
1174
  }
1690
1175
  declare class Messages extends APIResource {
1691
1176
  /**
1692
- * Send a free-text or media message to a WhatsApp number.
1693
- *
1694
- * For text-only messages, supply `text`. For media, supply `mediaUrl`
1695
- * and `mediaType`. Both can be combined in a single message.
1696
- *
1697
- * @param params - Message parameters including recipient, text, and media.
1698
- * @returns The created message record from the database.
1699
- *
1700
- * @example Send a simple text message
1701
- * ```typescript
1702
- * await erixClient.whatsapp.messages.send({
1703
- * to: "+919876543210",
1704
- * text: "Hello from Ecodrix!",
1705
- * });
1706
- * ```
1707
- *
1708
- * @example Send an image with a caption
1709
- * ```typescript
1710
- * await erixClient.whatsapp.messages.send({
1711
- * to: "+919876543210",
1712
- * text: "Check out this flyer",
1713
- * mediaUrl: "https://example.com/flyer.jpg",
1714
- * mediaType: "image",
1715
- * });
1716
- * ```
1177
+ * Send a message. With `conversationId` it goes through the unified inbox
1178
+ * (text and/or `media`); with `to` it's a direct WhatsApp text.
1717
1179
  */
1718
1180
  send<T = any>(params: SendMessageParams): Promise<T>;
1719
- /**
1720
- * Send a pre-approved WhatsApp Business template message.
1721
- *
1722
- * Templates must be approved in Meta Business Manager before they can be sent.
1723
- * Variable placeholders (e.g., {{1}}, {{2}}) are replaced with values from the
1724
- * `variables` array in order.
1725
- *
1726
- * @param params - Template message configuration (name, language, variables).
1727
- * @returns The created message record.
1728
- *
1729
- * @example
1730
- * ```typescript
1731
- * await erixClient.whatsapp.messages.sendTemplate({
1732
- * to: "+919876543210",
1733
- * templateName: "welcome_user",
1734
- * language: "en_US",
1735
- * variables: ["Alice"], // Replaces {{1}} in template
1736
- * });
1737
- * ```
1738
- */
1181
+ /** Send an approved WhatsApp template (opens a conversation). */
1739
1182
  sendTemplate<T = any>(params: SendTemplateParams): Promise<T>;
1740
- /**
1741
- * Star or unstar a message.
1742
- *
1743
- * @param messageId - The ID of the message.
1744
- * @param isStarred - Boolean indicating whether to star or unstar.
1745
- */
1746
1183
  star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
1747
- /**
1748
- * React to a message with an emoji.
1749
- *
1750
- * @param messageId - The ID of the message.
1751
- * @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
1752
- */
1753
- react<T = any>(messageId: string, reaction: string): Promise<T>;
1754
- /**
1755
- * Mark all messages in a conversation as read (double-tick).
1756
- *
1757
- * @param conversationId - The conversation to mark as read.
1758
- *
1759
- * @example
1760
- * ```typescript
1761
- * await ecod.whatsapp.messages.markRead("conv_64abc...");
1762
- * ```
1763
- */
1764
1184
  markRead(conversationId: string): Promise<unknown>;
1765
1185
  /**
1766
- * Upload a media file for WhatsApp chat.
1767
- *
1768
- * Works with any file type — image, video, audio, or document.
1769
- * For raster images the response includes Cloudflare-optimised `variants`
1770
- * (thumb 150px, medium 600px, full 1200px). Non-image types return only `url`.
1771
- *
1772
- * @param file - The file to upload (File, Blob, or Buffer).
1773
- * @returns Full media metadata `{ url, type, variants?, key, fileName }`.
1774
- *
1775
- * @example
1776
- * ```typescript
1777
- * const file = input.files[0];
1778
- * const { data } = await ecod.whatsapp.messages.upload(file);
1779
- * // For images: data.variants.thumb → 150px WebP from Cloudflare
1780
- * // For video/audio: use data.url directly in <video> or <audio>
1781
- * ```
1782
- */
1783
- upload(file: any): Promise<{
1784
- success: boolean;
1785
- data: ChatMediaMeta;
1786
- }>;
1787
- }
1788
-
1789
- /**
1790
- * Channel-agnostic marketing campaigns (email / SMS / WhatsApp) owned by
1791
- * ERIX-CRM. Mounted at `/product/erix/crm/campaigns`.
1792
- *
1793
- * Access via `ecod.product.erix.campaigns`.
1794
- */
1795
- declare class Campaigns extends APIResource {
1796
- /**
1797
- * List campaigns with optional status filtering.
1798
- */
1799
- list<T = any>(params?: {
1800
- status?: string;
1801
- limit?: number;
1802
- page?: number;
1803
- startDate?: string;
1804
- endDate?: string;
1805
- }): Promise<T>;
1806
- /**
1807
- * Create a campaign.
1186
+ * Upload a file to your tenant storage for sending as `media`:
1187
+ * presign → PUT straight to storage → confirm (counts usage). Your API key
1188
+ * never goes to the storage host.
1808
1189
  */
1809
- create<T = any>(payload: Record<string, unknown>): Promise<T>;
1810
- /**
1811
- * Delivery + engagement analytics for a campaign (opens, clicks, bounces).
1812
- */
1813
- stats<T = any>(campaignId: string): Promise<T>;
1190
+ upload(file: Blob, opts?: {
1191
+ fileName?: string;
1192
+ folder?: string;
1193
+ }): Promise<OutboundMedia>;
1814
1194
  }
1815
1195
 
1816
1196
  interface CheckoutProduct {
@@ -1917,9 +1297,15 @@ declare class Checkout extends APIResource {
1917
1297
  interface TriggerPayload {
1918
1298
  /** The name of the event to fire (e.g., "webinar_joined") */
1919
1299
  trigger: string;
1920
- /** Phone number of the lead (E.164 format) */
1921
- phone: string;
1922
- /** Email of the lead */
1300
+ /**
1301
+ * Phone number of the lead (E.164 format). Phone OR email is required —
1302
+ * at least one of `phone`/`email` must be provided (enforced server-side).
1303
+ */
1304
+ phone?: string;
1305
+ /**
1306
+ * Email of the lead. Phone OR email is required — at least one of
1307
+ * `phone`/`email` must be provided (enforced server-side).
1308
+ */
1923
1309
  email?: string;
1924
1310
  /** Key-value pairs for string templates */
1925
1311
  variables?: Record<string, string>;
@@ -1964,18 +1350,18 @@ interface TriggerResponse {
1964
1350
  eventLogId: string;
1965
1351
  trigger: string;
1966
1352
  leadId: string;
1967
- rulesMatched: number;
1968
1353
  };
1969
1354
  message?: string;
1970
1355
  code?: string;
1971
1356
  }
1972
1357
  declare class EventsResource extends APIResource {
1973
1358
  /**
1974
- * Programmatically trigger an automation workflow by firing a specific event.
1975
- * This matches the event against active Automation Rules and executes linked actions.
1359
+ * Programmatically trigger an automation by firing a specific event.
1360
+ * This matches the event against active Flows (Flow is the automation
1361
+ * engine) and starts each flow whose declared trigger matches.
1976
1362
  *
1977
1363
  * @param payload - The trigger details (event name, lead phone/email, variables).
1978
- * @returns Trigger response with diagnostic info (eventLogId, matched rules).
1364
+ * @returns Trigger response with diagnostic info (eventLogId, trigger, leadId).
1979
1365
  * @example
1980
1366
  * ```typescript
1981
1367
  * await erixClient.events.trigger({
@@ -1988,7 +1374,8 @@ declare class EventsResource extends APIResource {
1988
1374
  */
1989
1375
  trigger(payload: TriggerPayload): Promise<TriggerResponse>;
1990
1376
  /**
1991
- * List all custom event definitions.
1377
+ * Every trigger a flow can start on: built-ins plus your custom events.
1378
+ * Response: `{ success, data: { triggers } }`.
1992
1379
  */
1993
1380
  listCustomEvents<T = any>(): Promise<T>;
1994
1381
  /**
@@ -2039,10 +1426,8 @@ declare class Invoices extends APIResource {
2039
1426
  * Update an invoice.
2040
1427
  */
2041
1428
  update<T = any>(id: string, payload: Record<string, unknown>): Promise<T>;
2042
- /**
2043
- * Delete an invoice.
2044
- */
2045
- delete<T = any>(id: string): Promise<T>;
1429
+ /** Void an invoice (invoices are never deleted — GST records stay). */
1430
+ void<T = any>(id: string): Promise<T>;
2046
1431
  /**
2047
1432
  * Send an invoice via WhatsApp to the linked lead.
2048
1433
  */
@@ -2057,89 +1442,6 @@ declare class Invoices extends APIResource {
2057
1442
  updateSettings<T = any>(payload: Record<string, unknown>): Promise<T>;
2058
1443
  }
2059
1444
 
2060
- interface LogPaginationQuery {
2061
- page?: number;
2062
- limit?: number;
2063
- trigger?: string;
2064
- status?: "received" | "processing" | "completed" | "partial" | "failed";
2065
- from?: string;
2066
- to?: string;
2067
- }
2068
- interface EventLog {
2069
- id: string;
2070
- trigger: string;
2071
- phone?: string;
2072
- email?: string;
2073
- status: "received" | "processing" | "completed" | "partial" | "failed";
2074
- rulesMatched: number;
2075
- jobsCreated: number;
2076
- meetLink?: string;
2077
- callbackUrl?: string;
2078
- callbackStatus: "not_required" | "sent" | "failed";
2079
- payload: any;
2080
- error?: string;
2081
- idempotencyKey?: string;
2082
- processedAt?: string;
2083
- createdAt: string;
2084
- updatedAt: string;
2085
- }
2086
- interface CallbackLog {
2087
- id: string;
2088
- callbackUrl: string;
2089
- method: string;
2090
- payload: any;
2091
- jobId?: string;
2092
- enrollmentId?: string;
2093
- responseStatus: number;
2094
- responseBody: string;
2095
- status: "sent" | "failed" | "pending_retry";
2096
- attempts: number;
2097
- lastAttemptAt?: string;
2098
- signature?: string;
2099
- createdAt: string;
2100
- }
2101
- interface LogResponse<T> {
2102
- success: boolean;
2103
- data: T[];
2104
- pagination: {
2105
- total: number;
2106
- page: number;
2107
- limit: number;
2108
- pages: number;
2109
- };
2110
- }
2111
- /**
2112
- * Audit and execution logs for platform events and webhooks.
2113
- *
2114
- * Access via `ecod.logs`.
2115
- */
2116
- declare class Logs extends APIResource {
2117
- /**
2118
- * List event execution logs with optional filtering.
2119
- *
2120
- * Use this to audit automation triggers and debug workflow execution.
2121
- */
2122
- listEventLogs(query?: LogPaginationQuery): Promise<LogResponse<EventLog>>;
2123
- /**
2124
- * Get detailed information for a single event execution.
2125
- */
2126
- getEventLog(id: string): Promise<{
2127
- success: boolean;
2128
- data: EventLog;
2129
- }>;
2130
- /**
2131
- * List webhook callback logs (outbound responses from ECODrIx to your system).
2132
- */
2133
- listCallbackLogs(query?: LogPaginationQuery): Promise<LogResponse<CallbackLog>>;
2134
- /**
2135
- * Get high-level execution statistics for the tenant.
2136
- */
2137
- getStats(): Promise<{
2138
- success: boolean;
2139
- data: any;
2140
- }>;
2141
- }
2142
-
2143
1445
  /**
2144
1446
  * Niche Resources — Workflow packs + WhatsApp template suggestions.
2145
1447
  *
@@ -2170,41 +1472,6 @@ declare class NicheResources extends APIResource {
2170
1472
  templateSuggestions<T = any>(): Promise<T>;
2171
1473
  }
2172
1474
 
2173
- /**
2174
- * Portal Inbox — team-side unified inbox for portal conversations.
2175
- *
2176
- * Lists all projects with active client threads, retrieves messages,
2177
- * and posts replies. Mounted at `/product/erix/portal-inbox`.
2178
- *
2179
- * @example
2180
- * ```typescript
2181
- * const threads = await ecod.portalInbox.conversations();
2182
- * const messages = await ecod.portalInbox.messages(projectId);
2183
- * await ecod.portalInbox.reply(projectId, { body: "We'll get back to you!" });
2184
- * ```
2185
- */
2186
- declare class PortalInbox extends APIResource {
2187
- /**
2188
- * List all projects with active portal conversation threads.
2189
- * Returns projectId, projectName, lastMessageAt, lastBody, lastSender, unreadCount.
2190
- */
2191
- conversations<T = any>(): Promise<T>;
2192
- /**
2193
- * Get paginated messages for a project's portal thread.
2194
- */
2195
- messages<T = any>(projectId: string): Promise<T>;
2196
- /**
2197
- * Post a reply from the team to a project's portal thread.
2198
- */
2199
- reply<T = any>(projectId: string, payload: {
2200
- body: string;
2201
- attachments?: Array<{
2202
- name: string;
2203
- url: string;
2204
- }>;
2205
- }): Promise<T>;
2206
- }
2207
-
2208
1475
  /**
2209
1476
  * Project Documents + E-Sign — document management and digital signatures
2210
1477
  * for CRM projects.
@@ -2343,6 +1610,16 @@ declare class Connect extends APIResource {
2343
1610
  module: "crm" | "flow" | "laie";
2344
1611
  enabled: boolean;
2345
1612
  }): Promise<T>;
1613
+ /**
1614
+ * One-click Google OAuth: the consent-popup URL for the signed-in tenant.
1615
+ * It carries a short-lived (5 min) ticket, so open it right away.
1616
+ */
1617
+ googleConnectUrl(): Promise<{
1618
+ success: boolean;
1619
+ data: {
1620
+ url: string;
1621
+ };
1622
+ }>;
2346
1623
  /**
2347
1624
  * Create a payment link on the tenant's OWN connected gateway
2348
1625
  * (Razorpay / Stripe). Tenant-scoped; requires the `payments` provider to be
@@ -2967,10 +2244,6 @@ declare class Templates extends APIResource {
2967
2244
  * @param templateIdentifier - The name or ID of the template.
2968
2245
  */
2969
2246
  getVariableManifest(templateIdentifier: string): Promise<ResourceManifest>;
2970
- /**
2971
- * Check which automations or sequences are currently using this template.
2972
- */
2973
- checkUsage<T = any>(templateName: string): Promise<T>;
2974
2247
  }
2975
2248
 
2976
2249
  /**
@@ -3154,10 +2427,6 @@ declare class Folders extends APIResource {
3154
2427
  * ```
3155
2428
  */
3156
2429
  create<T = any>(name: string): Promise<T>;
3157
- /**
3158
- * Delete a folder and its contents.
3159
- */
3160
- delete<T = any>(folderPath: string): Promise<T>;
3161
2430
  }
3162
2431
  declare class Files extends APIResource {
3163
2432
  /**
@@ -3211,66 +2480,143 @@ declare class Files extends APIResource {
3211
2480
  delete(key: string): Promise<unknown>;
3212
2481
  }
3213
2482
 
3214
- /**
3215
- * Adaptive Onboarding type definitions.
3216
- *
3217
- * These types mirror the Postgres data shapes from the
3218
- * `adaptive-onboarding-ai-persona` spec — see
3219
- * `.kiro/specs/adaptive-onboarding-ai-persona/design.md` §"Data Models" and
3220
- * §"Onboarding engine".
3221
- *
3222
- * NO RUNTIME CODE. Types only. Both saas (Next.js) and server (Express)
3223
- * import from here so the wire shape stays in lockstep.
3224
- */
3225
- /**
3226
- * Renderable step kinds. The saas selects the appropriate React component
3227
- * from `components/onboarding/steps/*` based on this discriminator.
3228
- */
3229
- type OnboardingStepType = "single_choice" | "multi_choice" | "text_input" | "ai_summary_confirm" | "feature_preview" | "completion";
3230
- /**
3231
- * One selectable answer option in a `single_choice` / `multi_choice` step.
3232
- */
3233
- interface OnboardingOption {
3234
- /** Internal value persisted in `session.answers[stepId]`. */
3235
- value: string;
3236
- /** Human-readable label shown to the user. */
3237
- label: string;
3238
- /** Optional short description rendered under the label. */
3239
- description?: string;
3240
- /** Optional icon identifier (Lucide name, image URL, or emoji). */
3241
- icon?: string;
2483
+ interface SystemHealth {
2484
+ status: string;
2485
+ version: string;
2486
+ env: string;
2487
+ uptime: number;
2488
+ db: string;
2489
+ queueDepth: number;
2490
+ timestamp: string;
3242
2491
  }
3243
2492
  /**
3244
- * Declares which persona field a step's answer writes to.
2493
+ * Platform health diagnostics.
3245
2494
  *
3246
- * Engine flow: when the step is answered, the value is written to
3247
- * `session.draftPersona.<targetField>`, optionally passed through a named
3248
- * transformation. On `complete()` the draft persona is upserted to
3249
- * `ecodrix_ai_personas`.
2495
+ * Access via `ecod.platform.health`.
3250
2496
  */
3251
- interface OnboardingMemoryMapping {
3252
- /**
3253
- * Dot-path into the persona document, e.g.
3254
- * `"identity.nicheSubtype"` or `"behaviorRules.outreachTone"`.
3255
- */
3256
- targetField: string;
2497
+ declare class Health extends APIResource {
3257
2498
  /**
3258
- * Optional named transformation applied to the raw answer before write.
3259
- * Engine-defined (`"map_to_niche_config"`, `"lowercase"`, `"split_csv"`,
3260
- * etc.).
2499
+ * Global platform health check — verifies the core API is operational.
2500
+ * Public endpoint: `GET /health`.
3261
2501
  */
3262
- transformation?: string;
2502
+ system(): Promise<SystemHealth>;
3263
2503
  }
2504
+
3264
2505
  /**
3265
- * A single step in an `OnboardingConfig`.
2506
+ * Automation event log and provider callback resource.
3266
2507
  *
3267
- * Branching is via `showIf` / `skipIf` JsonLogic expressions evaluated
3268
- * against `session.answers`. The engine never reaches an undefined step —
3269
- * a missing `nextStepId` terminates the flow.
3270
- */
3271
- interface OnboardingStep {
3272
- /** Stable identifier referenced by branch expressions and analytics. */
3273
- stepId: string;
2508
+ * Access via `ecod.notifications`.
2509
+ *
2510
+ * This resource is **read-only**. It exposes platform audit trails — useful
2511
+ * for debugging automation failures, monitoring webhook callbacks, and
2512
+ * building internal ops dashboards.
2513
+ *
2514
+ * @example
2515
+ * ```typescript
2516
+ * // Find failed automations in April
2517
+ * const { data } = await ecod.notifications.listLogs({
2518
+ * status: "failed",
2519
+ * startDate: "2026-04-01",
2520
+ * endDate: "2026-04-30",
2521
+ * });
2522
+ * ```
2523
+ */
2524
+ declare class Notifications extends APIResource {
2525
+ /**
2526
+ * List unread CRM notifications and alerts (e.g., lead assignments, system alerts).
2527
+ *
2528
+ * @param params - Optional filters (limit, unreadOnly).
2529
+ * @returns Paginated list of notification objects.
2530
+ * @example
2531
+ * ```typescript
2532
+ * const alerts = await erixClient.notifications.listAlerts({ unreadOnly: true });
2533
+ * ```
2534
+ */
2535
+ listAlerts<T = any>(params?: {
2536
+ limit?: number;
2537
+ unreadOnly?: boolean;
2538
+ }): Promise<T>;
2539
+ /**
2540
+ * Dismiss/mark a specific notification alert as read.
2541
+ *
2542
+ * @param notificationId - The unique ID of the notification.
2543
+ * @example
2544
+ * ```typescript
2545
+ * await erixClient.notifications.dismissAlert("alert_123");
2546
+ * ```
2547
+ */
2548
+ dismissAlert<T = any>(notificationId: string): Promise<T>;
2549
+ /**
2550
+ * Clear all notifications for the current tenant immediately.
2551
+ *
2552
+ * @example
2553
+ * ```typescript
2554
+ * await erixClient.notifications.clearAllAlerts();
2555
+ * ```
2556
+ */
2557
+ clearAllAlerts<T = any>(): Promise<T>;
2558
+ }
2559
+
2560
+ /**
2561
+ * Adaptive Onboarding type definitions.
2562
+ *
2563
+ * These types mirror the Postgres data shapes from the
2564
+ * `adaptive-onboarding-ai-persona` spec — see
2565
+ * `.kiro/specs/adaptive-onboarding-ai-persona/design.md` §"Data Models" and
2566
+ * §"Onboarding engine".
2567
+ *
2568
+ * NO RUNTIME CODE. Types only. Both saas (Next.js) and server (Express)
2569
+ * import from here so the wire shape stays in lockstep.
2570
+ */
2571
+ /**
2572
+ * Renderable step kinds. The saas selects the appropriate React component
2573
+ * from `components/onboarding/steps/*` based on this discriminator.
2574
+ */
2575
+ type OnboardingStepType = "single_choice" | "multi_choice" | "text_input" | "ai_summary_confirm" | "feature_preview" | "completion";
2576
+ /**
2577
+ * One selectable answer option in a `single_choice` / `multi_choice` step.
2578
+ */
2579
+ interface OnboardingOption {
2580
+ /** Internal value persisted in `session.answers[stepId]`. */
2581
+ value: string;
2582
+ /** Human-readable label shown to the user. */
2583
+ label: string;
2584
+ /** Optional short description rendered under the label. */
2585
+ description?: string;
2586
+ /** Optional icon identifier (Lucide name, image URL, or emoji). */
2587
+ icon?: string;
2588
+ }
2589
+ /**
2590
+ * Declares which persona field a step's answer writes to.
2591
+ *
2592
+ * Engine flow: when the step is answered, the value is written to
2593
+ * `session.draftPersona.<targetField>`, optionally passed through a named
2594
+ * transformation. On `complete()` the draft persona is upserted to
2595
+ * `ecodrix_ai_personas`.
2596
+ */
2597
+ interface OnboardingMemoryMapping {
2598
+ /**
2599
+ * Dot-path into the persona document, e.g.
2600
+ * `"identity.nicheSubtype"` or `"behaviorRules.outreachTone"`.
2601
+ */
2602
+ targetField: string;
2603
+ /**
2604
+ * Optional named transformation applied to the raw answer before write.
2605
+ * Engine-defined (`"map_to_niche_config"`, `"lowercase"`, `"split_csv"`,
2606
+ * etc.).
2607
+ */
2608
+ transformation?: string;
2609
+ }
2610
+ /**
2611
+ * A single step in an `OnboardingConfig`.
2612
+ *
2613
+ * Branching is via `showIf` / `skipIf` JsonLogic expressions evaluated
2614
+ * against `session.answers`. The engine never reaches an undefined step —
2615
+ * a missing `nextStepId` terminates the flow.
2616
+ */
2617
+ interface OnboardingStep {
2618
+ /** Stable identifier referenced by branch expressions and analytics. */
2619
+ stepId: string;
3274
2620
  /** Title rendered above the question. */
3275
2621
  title: string;
3276
2622
  /** Optional secondary line under the title. */
@@ -3645,6 +2991,135 @@ interface NichePack {
3645
2991
  researchConfig?: NichePackResearchConfig;
3646
2992
  }
3647
2993
 
2994
+ /**
2995
+ * Body of `POST /platform/tenants/onboarding/global` — the four-question signup form.
2996
+ *
2997
+ * Fields land directly on `ecodrix_organizations.*` columns (workspace
2998
+ * name, timezone) and `service_config -> 'global'` (primary product,
2999
+ * adaptive flag). See REQ-001.
3000
+ */
3001
+ interface GlobalOnboardingPayload {
3002
+ /** Workspace / org display name. Persisted to `ecodrix_organizations.name`. */
3003
+ workspaceName: string;
3004
+ /** Personal display name of the signing-up user. */
3005
+ displayName: string;
3006
+ /** IANA timezone, e.g. `"Asia/Kolkata"`. Persisted to `organizations.timezone`. */
3007
+ timezone: string;
3008
+ /**
3009
+ * The product the user wants to start with. `"not_sure"` defers
3010
+ * per-product onboarding to first product open.
3011
+ */
3012
+ primaryProduct: "crm" | "laie" | "flow" | "not_sure";
3013
+ }
3014
+ /**
3015
+ * Body of `POST /platform/tenants/onboarding/${productId}/start` — opens a per-product onboarding
3016
+ * session. Triggered by the explicit "Enable {Product}" click on
3017
+ * `/products/<productId>` (REQ-002).
3018
+ */
3019
+ interface StartOnboardingPayload {
3020
+ productId: "crm" | "laie" | "flow";
3021
+ }
3022
+ /**
3023
+ * Body of `POST /platform/tenants/onboarding/${productId}/answer` — records one step's answer and
3024
+ * advances the engine. The saas calls this on every step submit (and as
3025
+ * a debounced PATCH for resumability).
3026
+ */
3027
+ interface AnswerOnboardingPayload {
3028
+ sessionId: string;
3029
+ stepId: string;
3030
+ /** Shape depends on the step type — string, string[], boolean, etc. */
3031
+ answer: unknown;
3032
+ }
3033
+ /**
3034
+ * Body of `POST /platform/tenants/onboarding/complete` — terminates the session,
3035
+ * upserts the persona, and materializes the workspace defaults.
3036
+ */
3037
+ interface CompleteOnboardingPayload {
3038
+ sessionId: string;
3039
+ }
3040
+ /**
3041
+ * Body of `POST /platform/tenants/onboarding/${productId}/edit` — post-completion edit of a single
3042
+ * answer from `/settings/onboarding`. Triggers a `persona_recomputed`
3043
+ * event (REQ-010).
3044
+ */
3045
+ interface EditOnboardingPayload {
3046
+ stepId: string;
3047
+ answer: unknown;
3048
+ }
3049
+ /**
3050
+ * Result of `POST /platform/tenants/onboarding/${productId}/start`.
3051
+ */
3052
+ interface StartOnboardingResponse {
3053
+ sessionId: string;
3054
+ firstStep: OnboardingStep;
3055
+ }
3056
+ /**
3057
+ * Result of `POST /platform/tenants/onboarding/${productId}/answer`.
3058
+ */
3059
+ interface AnswerOnboardingResponse {
3060
+ /** `null` when the engine has reached the final step. */
3061
+ nextStep: OnboardingStep | null;
3062
+ draftPersona: Record<string, unknown>;
3063
+ }
3064
+ /**
3065
+ * Result of `GET /platform/tenants/onboarding/${productId}/state`. Returns the active session
3066
+ * (status `"active"`) for `(userId, productId)`, plus the step the
3067
+ * renderer should currently show.
3068
+ */
3069
+ interface OnboardingStateResponse {
3070
+ session: OnboardingSession | null;
3071
+ currentStep: OnboardingStep | null;
3072
+ }
3073
+ /**
3074
+ * Result of `POST /platform/tenants/onboarding/complete`.
3075
+ */
3076
+ interface CompleteOnboardingResponse {
3077
+ /** Opaque persona document — full type lives in `resources/persona.ts`. */
3078
+ persona: Record<string, unknown>;
3079
+ workspaceProfile: WorkspaceProfile;
3080
+ }
3081
+ /**
3082
+ * Result of `POST /platform/tenants/onboarding/${productId}/edit`.
3083
+ */
3084
+ interface EditOnboardingResponse {
3085
+ persona: Record<string, unknown>;
3086
+ /** RFC 6902 JSON Patch describing what changed in the persona. */
3087
+ diff: Array<Record<string, unknown>>;
3088
+ }
3089
+ /**
3090
+ * Adaptive onboarding resource.
3091
+ *
3092
+ * Mounted on the main client as `ecod.onboarding`. Mirrors the seven
3093
+ * tenant-facing routes documented in `design.md` § "API surface".
3094
+ *
3095
+ * @example
3096
+ * ```typescript
3097
+ * await ecod.onboarding.global({
3098
+ * workspaceName: "Acme Health",
3099
+ * displayName: "Alice",
3100
+ * timezone: "Asia/Kolkata",
3101
+ * primaryProduct: "crm",
3102
+ * });
3103
+ *
3104
+ * const { sessionId, firstStep } = await ecod.onboarding.start({ productId: "crm" });
3105
+ * await ecod.onboarding.answer({ sessionId, stepId: firstStep.stepId, answer: "healthcare" });
3106
+ * await ecod.onboarding.complete({ sessionId });
3107
+ * ```
3108
+ */
3109
+ declare class Onboarding extends APIResource {
3110
+ /**
3111
+ * Submit the four-question global onboarding form (REQ-001).
3112
+ * Updates `ecodrix_organizations.*` columns and
3113
+ * `service_config.global.primaryProduct`.
3114
+ */
3115
+ global<T = unknown>(payload: GlobalOnboardingPayload): Promise<T>;
3116
+ /**
3117
+ * Finalise the session, upsert the persona, and materialize the
3118
+ * niche-tuned workspace defaults.
3119
+ */
3120
+ complete(payload: CompleteOnboardingPayload): Promise<CompleteOnboardingResponse>;
3121
+ }
3122
+
3648
3123
  /**
3649
3124
  * Identity block — who the user is, what they sell, where they operate.
3650
3125
  * Stored at `ecodrix_ai_personas.identity` (JSONB).
@@ -4262,2450 +3737,581 @@ declare class Persona extends APIResource {
4262
3737
  }
4263
3738
 
4264
3739
  /**
4265
- * Admin-side onboarding resource.
4266
- *
4267
- * Mounted on the main client as `ecod.adminOnboarding`. Mirrors the
4268
- * platform-admin endpoints under `/platform/admin/onboarding/*`
4269
- * documented in `server/src/platform/routes/admin/onboarding.routes.ts`.
4270
- *
4271
- * Auth: every method requires the elevated platform `coreApiKey`. The
4272
- * SDK forwards it as `x-core-api-key`; admin server-side callers should
4273
- * always construct a client with `coreApiKey` set (see
4274
- * `admin/src/lib/client/erix-admin.ts`).
4275
- *
4276
- * Endpoints covered in this build (task 4.1.1 — list page):
4277
- *
4278
- * - GET /platform/admin/onboarding/niche-packs list
4279
- * - GET /platform/admin/onboarding/niche-packs/:slug fetch one
4280
- * - POST /platform/admin/onboarding/niche-packs create
4281
- * - PATCH /platform/admin/onboarding/niche-packs/:slug update
4282
- * - POST /platform/admin/onboarding/niche-packs/:slug/publish publish
4283
- * - POST /platform/admin/onboarding/niche-packs/:slug/unpublish back to draft
4284
- * - POST /platform/admin/onboarding/niche-packs/:slug/fork new draft copy
4285
- * - GET /platform/admin/onboarding/configs list configs
4286
- * - POST /platform/admin/onboarding/configs create config
4287
- * - PATCH /platform/admin/onboarding/configs/:productId/:version update
4288
- * - POST /platform/admin/onboarding/configs/:productId/:version/publish publish
4289
- *
4290
- * Endpoints for A/B onboarding experiments (task 4.2.2):
4291
- *
4292
- * - GET /platform/admin/onboarding/experiments list
4293
- * - GET /platform/admin/onboarding/experiments/:slug fetch one
4294
- * - POST /platform/admin/onboarding/experiments create draft
4295
- * - PATCH /platform/admin/onboarding/experiments/:slug partial update
4296
- * - DELETE /platform/admin/onboarding/experiments/:slug hard-delete
3740
+ * Copilot resource — synchronous chat, confirmation, and session management.
4297
3741
  *
4298
- * Successive admin tasks (4.1.2–4.1.5) layer richer editor / fork /
4299
- * publish flows on top of these primitives.
3742
+ * Access via `ecod.platform.ai.copilot`.
4300
3743
  */
4301
-
4302
- /** Niche pack row as returned by the admin list endpoint. */
4303
- interface NichePackSummary {
4304
- id: string;
4305
- slug: string;
4306
- productId: NichePack["productId"];
4307
- version: string;
4308
- status: NichePackStatus;
4309
- /** ISO 8601 — creation timestamp (server clock). */
4310
- createdAt: string;
4311
- /** ISO 8601 — last edit timestamp. */
4312
- updatedAt: string;
4313
- /** ISO 8601 — first time `status` flipped to `published`. */
4314
- publishedAt?: string | null;
4315
- /** Admin staff id who created this version. */
4316
- createdBy?: string | null;
4317
- }
4318
- /** Filters accepted by `adminOnboarding.listNichePacks`. */
4319
- interface ListNichePacksParams {
4320
- /** Restrict to a single product family. */
4321
- productId?: NichePack["productId"];
4322
- /** Restrict to one lifecycle status. */
4323
- status?: NichePackStatus;
4324
- /**
4325
- * Free-form fuzzy search. Matched (case-insensitive) against `slug`
4326
- * and `productId`. Whitespace is trimmed.
4327
- */
4328
- search?: string;
4329
- /** Page size — server clamps to 1..100, default 25. */
4330
- limit?: number;
4331
- /** Pagination offset, default 0. */
4332
- offset?: number;
4333
- }
4334
- /** Body accepted by the create-pack endpoint. */
4335
- interface CreateNichePackPayload {
4336
- slug: string;
4337
- productId: NichePack["productId"];
4338
- /** Defaults to `"1.0.0"` server-side. */
4339
- version?: string;
4340
- onboardingConfig?: Record<string, unknown>;
4341
- workspaceProfile?: Record<string, unknown>;
4342
- researchConfig?: Record<string, unknown>;
4343
- }
4344
- /** Body accepted by the update-pack endpoint. At least one field required. */
4345
- interface UpdateNichePackPayload {
4346
- status?: NichePackStatus;
4347
- onboardingConfig?: Record<string, unknown>;
4348
- workspaceProfile?: Record<string, unknown>;
4349
- researchConfig?: Record<string, unknown>;
4350
- }
4351
- /** Body accepted by the fork-pack endpoint. */
4352
- interface ForkNichePackPayload {
4353
- /** Source version to clone; defaults to the latest row for the slug. */
4354
- fromVersion?: string;
4355
- /** Target version for the new draft; defaults to a server-side bump. */
4356
- version?: string;
4357
- }
4358
- /**
4359
- * Body accepted by `adminOnboarding.smokeTestNichePack` (task 4.1.5).
4360
- *
4361
- * Both fields are optional:
4362
- *
4363
- * - `fromVersion` pins a specific row for the slug; without it the
4364
- * server picks the most recent (typically the latest draft).
4365
- * - `answers` is a `{ stepId: value }` map. When omitted (or missing
4366
- * keys for some steps) the in-memory runner auto-picks the first
4367
- * option of `single_choice` / `multi_choice` steps and uses a
4368
- * placeholder for `text_input`.
4369
- */
4370
- interface SmokeTestNichePackPayload {
4371
- fromVersion?: string;
4372
- answers?: Record<string, unknown>;
4373
- }
4374
- /**
4375
- * One materializer action the live `workspaceShaper.materialize` call
4376
- * WOULD perform if the smoke-tested pack were used in a real
4377
- * onboarding-complete flow. The summary string is what the admin
4378
- * panel renders verbatim ("Would create pipeline 'Patient Journey'
4379
- * with 5 stages").
4380
- */
4381
- type SmokeTestMaterializerAction = {
4382
- kind: "pipeline";
4383
- name: string;
4384
- stageCount: number;
4385
- isDefault: boolean;
4386
- summary: string;
4387
- } | {
4388
- kind: "field";
4389
- key: string;
4390
- label: string;
4391
- type: string;
4392
- required: boolean;
4393
- summary: string;
4394
- } | {
4395
- kind: "automation";
4396
- name: string;
4397
- trigger: string;
4398
- enabled: boolean;
4399
- summary: string;
4400
- };
4401
- /**
4402
- * Result envelope returned by `adminOnboarding.smokeTestNichePack`.
4403
- *
4404
- * Mirrors `SmokeTestResult` in
4405
- * `server/src/erix/services/onboarding/smokeTestRunner.ts`.
4406
- */
4407
- interface SmokeTestResult {
4408
- /** In-memory `OnboardingSession` produced by the simulator. */
4409
- session: OnboardingSession;
4410
- /** Persona shaped from the answers + memory mappings. */
4411
- persona: AIPersona;
4412
- /** Workspace profile produced by `workspaceShaper.produce`. */
4413
- workspaceProfile: WorkspaceProfile;
4414
- /** Actions the live materializer would perform. */
4415
- materializerActions: SmokeTestMaterializerAction[];
4416
- /** Wall-clock duration (millis) of the simulation. */
4417
- durationMs: number;
4418
- /** Step ids the engine visited (in order). */
4419
- visitedStepIds: string[];
4420
- /** Step ids the engine skipped via branching predicates. */
4421
- skippedStepIds: string[];
4422
- /** Whether the runner had to auto-pick at least one answer. */
4423
- autoPicked: boolean;
4424
- }
4425
- /** Standard `{ success, data }` envelope used by every admin endpoint. */
4426
- interface ApiEnvelope<T> {
4427
- success: boolean;
4428
- data: T;
4429
- }
4430
- /** Envelope returned by `GET /platform/admin/onboarding/niche-packs`. */
4431
- interface ListNichePacksResponse extends ApiEnvelope<NichePackSummary[]> {
4432
- /**
4433
- * Total niche-pack rows matching the current filter set, ignoring
4434
- * the page window. Drives the saas-side paginator. Falls back to
4435
- * `data.length` when the server can't compute a true count.
4436
- */
4437
- total: number;
4438
- }
4439
- /** Envelope returned by single-pack endpoints (get / create / update / fork). */
4440
- type NichePackResponse = ApiEnvelope<NichePack & NichePackSummary>;
4441
- /** Filters accepted by `adminOnboarding.listOnboardingConfigs`. */
4442
- interface ListOnboardingConfigsParams {
4443
- productId?: OnboardingConfig["productId"];
4444
- status?: NichePackStatus;
4445
- }
4446
- /** Body accepted by the create-config endpoint. */
4447
- interface CreateOnboardingConfigPayload {
4448
- productId: OnboardingConfig["productId"];
4449
- version?: string;
4450
- config?: Record<string, unknown>;
4451
- }
4452
- /** Body accepted by the update-config endpoint. */
4453
- interface UpdateOnboardingConfigPayload {
4454
- status?: NichePackStatus;
4455
- config?: Record<string, unknown>;
4456
- }
4457
- /** Filters accepted by `adminOnboarding.listOnboardingExperiments`. */
4458
- interface ListOnboardingExperimentsParams {
4459
- productId?: OnboardingExperiment["productId"];
4460
- status?: OnboardingExperimentStatus;
4461
- /** Page size — server clamps to 1..100, default 25. */
4462
- limit?: number;
4463
- /** Pagination offset, default 0. */
4464
- offset?: number;
4465
- } /** Body accepted by the create-experiment endpoint. */
4466
- interface CreateOnboardingExperimentPayload {
4467
- /** Admin-facing handle; unique platform-wide. */
4468
- slug: string;
4469
- productId: OnboardingExperiment["productId"];
4470
- /** Display name shown in the admin panel. */
4471
- name: string;
4472
- description?: string;
4473
- /** Defaults to `"draft"` server-side. */
4474
- status?: OnboardingExperimentStatus;
4475
- /**
4476
- * Variant routing table — may be empty for a freshly created
4477
- * draft. Variants whose `cohortRange` overlaps are rejected with
4478
- * `OVERLAPPING_VARIANTS`.
4479
- */
4480
- variants?: OnboardingExperimentVariant[];
4481
- /** Fallback config version when no variant matches the user's bucket. */
4482
- controlConfigVersion?: string | null;
4483
- }
4484
- /** Body accepted by the patch-experiment endpoint. */
4485
- interface UpdateOnboardingExperimentPayload {
4486
- name?: string;
4487
- description?: string | null;
4488
- status?: OnboardingExperimentStatus;
4489
- variants?: OnboardingExperimentVariant[];
4490
- controlConfigVersion?: string | null;
4491
- }
4492
- /** Envelope returned by `GET /platform/admin/onboarding/experiments`. */
4493
- interface ListOnboardingExperimentsResponse extends ApiEnvelope<OnboardingExperiment[]> {
4494
- /**
4495
- * Total experiments matching the current filter set, ignoring the
4496
- * page window. Drives the saas-side paginator. Falls back to
4497
- * `data.length` when the server can't compute a true count.
4498
- */
4499
- total: number;
4500
- }
4501
- /** Envelope returned by single-experiment endpoints. */
4502
- type OnboardingExperimentResponse = ApiEnvelope<OnboardingExperiment>;
4503
- /**
4504
- * Filters accepted by every analytics endpoint
4505
- * (`getOnboardingFunnel`, `getOnboardingTimeOnStep`,
4506
- * `getOnboardingAbandonment`).
4507
- *
4508
- * `productId` constrains by product family, `nicheSubtype` by the
4509
- * `nichePackSlug` recorded on the originating session row. `fromDate`
4510
- * / `toDate` are wire-side ISO 8601 strings (the server coerces them
4511
- * via Zod's `z.coerce.date()`); when omitted, the server defaults to
4512
- * the trailing 30 days. The server hard-caps the requested window at
4513
- * 180 days and rejects `fromDate >= toDate` with 400 INVALID_FIELD.
4514
- */
4515
- interface OnboardingAnalyticsFiltersParams {
4516
- productId?: "crm" | "laie" | "flow" | string;
4517
- nicheSubtype?: string;
4518
- /** ISO 8601 datetime, e.g. `"2025-01-01T00:00:00.000Z"`. */
4519
- fromDate?: string;
4520
- /** ISO 8601 datetime. */
4521
- toDate?: string;
4522
- }
4523
- /** One funnel row — distinct sessions that reached `stepId`. */
4524
- interface OnboardingFunnelStep {
4525
- productId: string;
4526
- nichePackSlug: string | null;
4527
- stepId: string;
4528
- /** Distinct sessions that emitted at least one event for this step. */
4529
- sessions: number;
4530
- /**
4531
- * Fraction `[0, 1]` of sessions that reached this step relative to
4532
- * the first step in the same `(productId, nichePackSlug)` flow.
4533
- * The first step always has `conversionRate = 1`.
4534
- */
4535
- conversionRate: number;
4536
- }
4537
- /** Result envelope for `getOnboardingFunnel`. */
4538
- interface OnboardingFunnelResult {
4539
- /** Flat list, ordered by `(productId, nichePackSlug, sessions DESC)`. */
4540
- funnel: OnboardingFunnelStep[];
4541
- /** Distinct sessions across all rows in the window. */
4542
- totalSessions: number;
4543
- }
4544
- /** One time-on-step row — per `(productId, nichePackSlug, stepId)`. */
4545
- interface OnboardingTimeOnStepRow {
4546
- productId: string;
4547
- nichePackSlug: string | null;
4548
- stepId: string;
4549
- /** Median (p50) milliseconds from `stepId` first event → next step. */
4550
- medianMs: number;
4551
- /** p95 milliseconds. */
4552
- p95Ms: number;
4553
- /** Number of (session, step) pairs that contributed a delta. */
4554
- sampleSize: number;
4555
- }
4556
- /** Result envelope for `getOnboardingTimeOnStep`. */
4557
- interface OnboardingTimeOnStepResult {
4558
- rows: OnboardingTimeOnStepRow[];
4559
- }
4560
- /** One abandonment bucket — abandoned sessions whose last seen step was `stepId`. */
4561
- interface OnboardingAbandonmentRow {
4562
- productId: string;
4563
- nichePackSlug: string | null;
4564
- stepId: string;
4565
- abandonedSessions: number;
4566
- }
4567
- /** Result envelope for `getOnboardingAbandonment`. */
4568
- interface OnboardingAbandonmentResult {
4569
- rows: OnboardingAbandonmentRow[];
4570
- totalAbandoned: number;
4571
- }
4572
- /** `{ success, data: OnboardingFunnelResult }`. */
4573
- type OnboardingFunnelResponse = ApiEnvelope<OnboardingFunnelResult>;
4574
- /** `{ success, data: OnboardingTimeOnStepResult }`. */
4575
- type OnboardingTimeOnStepResponse = ApiEnvelope<OnboardingTimeOnStepResult>;
4576
- /** `{ success, data: OnboardingAbandonmentResult }`. */
4577
- type OnboardingAbandonmentResponse = ApiEnvelope<OnboardingAbandonmentResult>;
4578
- /**
4579
- * Admin-side onboarding control plane.
4580
- *
4581
- * @example
4582
- * ```typescript
4583
- * const { data, total } = await ecod.adminOnboarding.listNichePacks({
4584
- * productId: "crm",
4585
- * status: "published",
4586
- * search: "clinic",
4587
- * limit: 25,
4588
- * offset: 0,
4589
- * });
4590
- * ```
4591
- */
4592
- declare class AdminOnboarding extends APIResource {
4593
- /**
4594
- * List niche packs with optional filtering, search, and pagination.
4595
- * Server response shape: `{ success, data, total }`.
4596
- */
4597
- listNichePacks(params?: ListNichePacksParams): Promise<ListNichePacksResponse>;
4598
- /** Fetch a single niche pack by slug. Without `version` returns the latest. */
4599
- getNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4600
- /** Create a new niche pack draft. */
4601
- createNichePack(payload: CreateNichePackPayload): Promise<NichePackResponse>;
4602
- /** Patch a draft niche pack. Server enforces "at least one field". */
4603
- updateNichePack(slug: string, payload: UpdateNichePackPayload, version?: string): Promise<NichePackResponse>;
4604
- /** Flip a niche pack to `published`. */
4605
- publishNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4606
- /** Flip a niche pack back to `draft`. */
4607
- unpublishNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4608
- /** Fork an existing niche pack into a new draft version. */
4609
- forkNichePack(slug: string, payload?: ForkNichePackPayload): Promise<NichePackResponse>;
4610
- /**
4611
- * Run an in-memory smoke test against a niche pack (task 4.1.5).
4612
- *
4613
- * The server resolves the pack row, walks its `onboardingConfig`
4614
- * with the supplied (or auto-picked) answers, shapes a persona
4615
- * + workspace profile, and returns the result without writing
4616
- * anything. Useful for admins to validate a draft pack before
4617
- * publishing.
4618
- *
4619
- * @param slug - Niche pack slug.
4620
- * @param payload - Optional `{ fromVersion?, answers? }`. Both
4621
- * fields are independently optional; `version` (the legacy
4622
- * query-string equivalent) is also supported as a third
4623
- * argument for parity with the other slug-keyed methods.
4624
- * @param version - Optional version override applied as a
4625
- * `?version=` query param (kept for callers that already
4626
- * thread version through the URL).
4627
- */
4628
- smokeTestNichePack(slug: string, payload?: SmokeTestNichePackPayload, version?: string): Promise<ApiEnvelope<SmokeTestResult>>;
4629
- listOnboardingConfigs(params?: ListOnboardingConfigsParams): Promise<ApiEnvelope<unknown[]>>;
4630
- createOnboardingConfig(payload: CreateOnboardingConfigPayload): Promise<ApiEnvelope<unknown>>;
4631
- updateOnboardingConfig(productId: OnboardingConfig["productId"], version: string, payload: UpdateOnboardingConfigPayload): Promise<ApiEnvelope<unknown>>;
4632
- publishOnboardingConfig(productId: OnboardingConfig["productId"], version: string): Promise<ApiEnvelope<unknown>>;
4633
- /**
4634
- * List onboarding A/B experiments with optional filters and
4635
- * pagination. Server response shape: `{ success, data, total }`.
4636
- */
4637
- listOnboardingExperiments(params?: ListOnboardingExperimentsParams): Promise<ListOnboardingExperimentsResponse>;
4638
- /** Fetch a single experiment by its slug. 404 when absent. */
4639
- getOnboardingExperiment(slug: string): Promise<OnboardingExperimentResponse>;
4640
- /**
4641
- * Create a draft experiment. The server enforces:
4642
- *
4643
- * - `slug` non-empty + globally unique.
4644
- * - `productId ∈ {crm, laie, flow}`.
4645
- * - `variants` is an array (may be empty for a draft).
4646
- * - Each variant's `cohortRange.from < cohortRange.to`, both in
4647
- * `[0, 100]`.
4648
- * - Variants don't overlap (returns 400 `OVERLAPPING_VARIANTS`).
4649
- */
4650
- createOnboardingExperiment(payload: CreateOnboardingExperimentPayload): Promise<OnboardingExperimentResponse>;
4651
- /**
4652
- * Patch an experiment. At least one of `name | description |
4653
- * status | variants | controlConfigVersion` must be supplied —
4654
- * the server returns 400 `NO_UPDATES` for an empty body. When
4655
- * `variants` is supplied the overlap validator re-runs.
4656
- */
4657
- updateOnboardingExperiment(slug: string, payload: UpdateOnboardingExperimentPayload): Promise<OnboardingExperimentResponse>;
4658
- /**
4659
- * Hard-delete an experiment. Returns the deleted row in `data` for
4660
- * audit-log convenience. Admin-only — no soft-delete column.
4661
- */
4662
- deleteOnboardingExperiment(slug: string): Promise<OnboardingExperimentResponse>;
4663
- /**
4664
- * Funnel-by-step counts for `(productId, nichePackSlug)`, plus
4665
- * conversion rates relative to each flow's first step.
4666
- *
4667
- * Server-side filters: `productId`, `nicheSubtype` (the niche pack
4668
- * slug — UI-friendly alias of the column name), `fromDate`,
4669
- * `toDate`. Both date bounds default to the trailing 30 days. The
4670
- * server clamps the window at 180 days and rejects
4671
- * `fromDate >= toDate` with 400 INVALID_FIELD.
4672
- *
4673
- * Powers the admin Sankey + per-step bar chart in Task 4.3.2.
4674
- */
4675
- getOnboardingFunnel(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingFunnelResponse>;
4676
- /**
4677
- * Median + p95 milliseconds spent on each step (per
4678
- * `(productId, nichePackSlug, stepId)`), computed via
4679
- * `LEAD(created_at) OVER (PARTITION BY session_id …)` on the event
4680
- * stream. Sample size accompanies each row so the saas can
4681
- * grey-out under-sampled buckets.
4682
- */
4683
- getOnboardingTimeOnStep(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingTimeOnStepResponse>;
4684
- /**
4685
- * Histogram of `stepId` values where sessions went inactive — i.e.
4686
- * `status = 'abandoned'` OR (active for >24h with no further
4687
- * events). The server also tallies a `totalAbandoned` aggregate so
4688
- * the saas can render a percentage column without re-summing.
4689
- */
4690
- getOnboardingAbandonment(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingAbandonmentResponse>;
4691
- }
4692
-
4693
- interface CorsOriginCreatePayload {
4694
- url: string;
4695
- name?: string;
4696
- allowedHeaders?: string[];
4697
- allowedMethods?: string[];
4698
- }
4699
- interface CorsOriginUpdatePayload {
4700
- url?: string;
4701
- name?: string;
4702
- allowedHeaders?: string[];
4703
- allowedMethods?: string[];
4704
- isActive?: boolean;
4705
- }
4706
- declare class Cors extends APIResource {
4707
- /**
4708
- * List all dynamic cross-origin policies.
4709
- */
4710
- list<T = any>(): Promise<T>;
4711
- /**
4712
- * Register a new cross-origin client for the SaaS API network dynamically.
4713
- */
4714
- create<T = any>(payload: CorsOriginCreatePayload): Promise<T>;
4715
- /**
4716
- * Adjust active states or configurations for an existing origin policy.
4717
- */
4718
- update<T = any>(id: string, payload: CorsOriginUpdatePayload): Promise<T>;
4719
- /**
4720
- * Irreversibly drop support for a cross-origin client URL policy permanently.
4721
- */
4722
- delete<T = any>(id: string): Promise<T>;
4723
- }
4724
-
4725
- interface SystemHealth {
4726
- status: string;
4727
- version: string;
4728
- env: string;
4729
- uptime: number;
4730
- db: string;
4731
- queueDepth: number;
4732
- timestamp: string;
4733
- }
4734
- /**
4735
- * Platform health diagnostics.
4736
- *
4737
- * Access via `ecod.platform.health`.
4738
- */
4739
- declare class Health extends APIResource {
4740
- /**
4741
- * Global platform health check — verifies the core API is operational.
4742
- * Public endpoint: `GET /health`.
4743
- */
4744
- system(): Promise<SystemHealth>;
4745
- }
4746
-
4747
- /**
4748
- * Filters for querying event and automation execution logs.
4749
- */
4750
- interface LogFilter {
4751
- /** Page number for pagination (1-indexed). */
4752
- page?: number;
4753
- /** Maximum number of records to return per page. */
4754
- limit?: number;
4755
- /**
4756
- * Filter by automation trigger name.
4757
- * @example "lead_created" | "appointment_booked"
4758
- */
4759
- trigger?: string;
4760
- /**
4761
- * Filter by execution status.
4762
- * @example "success" | "failed" | "pending"
4763
- */
4764
- status?: string;
4765
- /** Filter logs associated with a specific phone number. */
4766
- phone?: string;
4767
- /** Start of the date range (inclusive). ISO 8601 or Date object. */
4768
- startDate?: string | Date;
4769
- /** End of the date range (inclusive). ISO 8601 or Date object. */
4770
- endDate?: string | Date;
4771
- }
4772
- /**
4773
- * Automation event log and provider callback resource.
4774
- *
4775
- * Access via `ecod.notifications`.
4776
- *
4777
- * This resource is **read-only**. It exposes platform audit trails — useful
4778
- * for debugging automation failures, monitoring webhook callbacks, and
4779
- * building internal ops dashboards.
4780
- *
4781
- * @example
4782
- * ```typescript
4783
- * // Find failed automations in April
4784
- * const { data } = await ecod.notifications.listLogs({
4785
- * status: "failed",
4786
- * startDate: "2026-04-01",
4787
- * endDate: "2026-04-30",
4788
- * });
4789
- * ```
4790
- */
4791
- declare class Notifications extends APIResource {
4792
- /**
4793
- * List automation execution logs with optional filtering.
4794
- *
4795
- * Each log entry represents one automation run triggered by a platform event.
4796
- * Filter by `status: "failed"` to build a failure alerting pipeline.
4797
- *
4798
- * @param params - Optional filter criteria.
4799
- * @returns Paginated list of event log objects.
4800
- *
4801
- * @example
4802
- * ```typescript
4803
- * const { data: failed } = await ecod.notifications.listLogs({
4804
- * status: "failed",
4805
- * trigger: "lead_created",
4806
- * limit: 50,
4807
- * });
4808
- * ```
4809
- */
4810
- listLogs(params?: LogFilter): Promise<unknown>;
4811
- /**
4812
- * Retrieve the full details for a single automation event log entry.
4813
- *
4814
- * @param logId - The unique log ID.
4815
- * @returns A single event log document including the payload and error trace.
4816
- *
4817
- * @example
4818
- * ```typescript
4819
- * const { data } = await ecod.notifications.retrieveLog("log_64abc...");
4820
- * console.log(data.error); // → "Provider timeout after 30s"
4821
- * ```
4822
- */
4823
- retrieveLog(logId: string): Promise<unknown>;
4824
- /**
4825
- * Get a summary statistics object for automation event execution.
4826
- *
4827
- * @param params - Optional date range for the summary window.
4828
- * @returns `{ total, success, failed, pending }` counts.
4829
- *
4830
- * @example
4831
- * ```typescript
4832
- * const { data: stats } = await ecod.notifications.getStats({
4833
- * startDate: "2026-04-01",
4834
- * endDate: "2026-04-30",
4835
- * });
4836
- * console.log(`Failed: ${stats.failed} / ${stats.total}`);
4837
- * ```
4838
- */
4839
- getStats(params?: {
4840
- startDate?: string;
4841
- endDate?: string;
4842
- }): Promise<unknown>;
4843
- /**
4844
- * List external provider webhook callback logs.
4845
- *
4846
- * These are inbound HTTP callbacks from third-party providers
4847
- * (payment gateways, email services, etc.) stored for audit purposes.
4848
- *
4849
- * @param params - Pagination and date filter options.
4850
- * @returns Paginated list of callback log records.
4851
- *
4852
- * @example
4853
- * ```typescript
4854
- * const { data } = await ecod.notifications.listCallbacks({ limit: 20 });
4855
- * ```
4856
- */
4857
- listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
4858
- /**
4859
- * List unread CRM notifications and alerts (e.g., lead assignments, system alerts).
4860
- *
4861
- * @param params - Optional filters (limit, unreadOnly).
4862
- * @returns Paginated list of notification objects.
4863
- * @example
4864
- * ```typescript
4865
- * const alerts = await erixClient.notifications.listAlerts({ unreadOnly: true });
4866
- * ```
4867
- */
4868
- listAlerts<T = any>(params?: {
4869
- limit?: number;
4870
- unreadOnly?: boolean;
4871
- }): Promise<T>;
4872
- /**
4873
- * Dismiss/mark a specific notification alert as read.
4874
- *
4875
- * @param notificationId - The unique ID of the notification.
4876
- * @example
4877
- * ```typescript
4878
- * await erixClient.notifications.dismissAlert("alert_123");
4879
- * ```
4880
- */
4881
- dismissAlert<T = any>(notificationId: string): Promise<T>;
4882
- /**
4883
- * Clear all notifications for the current tenant immediately.
4884
- *
4885
- * @example
4886
- * ```typescript
4887
- * await erixClient.notifications.clearAllAlerts();
4888
- * ```
4889
- */
4890
- clearAllAlerts<T = any>(): Promise<T>;
4891
- /**
4892
- * Retry an action from a notification (e.g. failed automation send).
4893
- *
4894
- * @param notificationId - The unique ID of the notification.
4895
- * @example
4896
- * ```typescript
4897
- * await erixClient.notifications.retryAction("alert_123");
4898
- * ```
4899
- */
4900
- retryAction<T = any>(notificationId: string): Promise<T>;
4901
- }
4902
-
4903
- /**
4904
- * Body of `POST /platform/tenants/onboarding/global` — the four-question signup form.
4905
- *
4906
- * Fields land directly on `ecodrix_organizations.*` columns (workspace
4907
- * name, timezone) and `service_config -> 'global'` (primary product,
4908
- * adaptive flag). See REQ-001.
4909
- */
4910
- interface GlobalOnboardingPayload {
4911
- /** Workspace / org display name. Persisted to `ecodrix_organizations.name`. */
4912
- workspaceName: string;
4913
- /** Personal display name of the signing-up user. */
4914
- displayName: string;
4915
- /** IANA timezone, e.g. `"Asia/Kolkata"`. Persisted to `organizations.timezone`. */
4916
- timezone: string;
4917
- /**
4918
- * The product the user wants to start with. `"not_sure"` defers
4919
- * per-product onboarding to first product open.
4920
- */
4921
- primaryProduct: "crm" | "laie" | "flow" | "not_sure";
4922
- }
4923
- /**
4924
- * Body of `POST /platform/tenants/onboarding/${productId}/start` — opens a per-product onboarding
4925
- * session. Triggered by the explicit "Enable {Product}" click on
4926
- * `/products/<productId>` (REQ-002).
4927
- */
4928
- interface StartOnboardingPayload {
4929
- productId: "crm" | "laie" | "flow";
4930
- }
4931
- /**
4932
- * Body of `POST /platform/tenants/onboarding/${productId}/answer` — records one step's answer and
4933
- * advances the engine. The saas calls this on every step submit (and as
4934
- * a debounced PATCH for resumability).
4935
- */
4936
- interface AnswerOnboardingPayload {
4937
- sessionId: string;
4938
- stepId: string;
4939
- /** Shape depends on the step type — string, string[], boolean, etc. */
4940
- answer: unknown;
4941
- }
4942
- /**
4943
- * Body of `POST /platform/tenants/onboarding/complete` — terminates the session,
4944
- * upserts the persona, and materializes the workspace defaults.
4945
- */
4946
- interface CompleteOnboardingPayload {
4947
- sessionId: string;
4948
- }
4949
- /**
4950
- * Body of `POST /platform/tenants/onboarding/${productId}/edit` — post-completion edit of a single
4951
- * answer from `/settings/onboarding`. Triggers a `persona_recomputed`
4952
- * event (REQ-010).
4953
- */
4954
- interface EditOnboardingPayload {
4955
- stepId: string;
4956
- answer: unknown;
4957
- }
4958
- /**
4959
- * Result of `POST /platform/tenants/onboarding/${productId}/start`.
4960
- */
4961
- interface StartOnboardingResponse {
4962
- sessionId: string;
4963
- firstStep: OnboardingStep;
4964
- }
4965
- /**
4966
- * Result of `POST /platform/tenants/onboarding/${productId}/answer`.
4967
- */
4968
- interface AnswerOnboardingResponse {
4969
- /** `null` when the engine has reached the final step. */
4970
- nextStep: OnboardingStep | null;
4971
- draftPersona: Record<string, unknown>;
4972
- }
4973
- /**
4974
- * Result of `GET /platform/tenants/onboarding/${productId}/state`. Returns the active session
4975
- * (status `"active"`) for `(userId, productId)`, plus the step the
4976
- * renderer should currently show.
4977
- */
4978
- interface OnboardingStateResponse {
4979
- session: OnboardingSession | null;
4980
- currentStep: OnboardingStep | null;
4981
- }
4982
- /**
4983
- * Result of `POST /platform/tenants/onboarding/complete`.
4984
- */
4985
- interface CompleteOnboardingResponse {
4986
- /** Opaque persona document — full type lives in `resources/persona.ts`. */
4987
- persona: Record<string, unknown>;
4988
- workspaceProfile: WorkspaceProfile;
4989
- }
4990
- /**
4991
- * Result of `POST /platform/tenants/onboarding/${productId}/edit`.
4992
- */
4993
- interface EditOnboardingResponse {
4994
- persona: Record<string, unknown>;
4995
- /** RFC 6902 JSON Patch describing what changed in the persona. */
4996
- diff: Array<Record<string, unknown>>;
4997
- }
4998
- /**
4999
- * Adaptive onboarding resource.
5000
- *
5001
- * Mounted on the main client as `ecod.onboarding`. Mirrors the seven
5002
- * tenant-facing routes documented in `design.md` § "API surface".
5003
- *
5004
- * @example
5005
- * ```typescript
5006
- * await ecod.onboarding.global({
5007
- * workspaceName: "Acme Health",
5008
- * displayName: "Alice",
5009
- * timezone: "Asia/Kolkata",
5010
- * primaryProduct: "crm",
5011
- * });
5012
- *
5013
- * const { sessionId, firstStep } = await ecod.onboarding.start({ productId: "crm" });
5014
- * await ecod.onboarding.answer({ sessionId, stepId: firstStep.stepId, answer: "healthcare" });
5015
- * await ecod.onboarding.complete({ sessionId });
5016
- * ```
5017
- */
5018
- declare class Onboarding extends APIResource {
5019
- /**
5020
- * Submit the four-question global onboarding form (REQ-001).
5021
- * Updates `ecodrix_organizations.*` columns and
5022
- * `service_config.global.primaryProduct`.
5023
- */
5024
- global<T = unknown>(payload: GlobalOnboardingPayload): Promise<T>;
5025
- /**
5026
- * Open a per-product onboarding session. Called when the user clicks
5027
- * "Enable {Product}" on `/products/<productId>` (REQ-002).
5028
- */
5029
- start(payload: StartOnboardingPayload): Promise<StartOnboardingResponse>;
5030
- /**
5031
- * Record one step's answer and advance the engine. Returns the next
5032
- * step (or `null` at the end) and the in-progress draft persona.
5033
- */
5034
- answer(payload: AnswerOnboardingPayload): Promise<AnswerOnboardingResponse>;
5035
- /**
5036
- * Load the active session for the calling user + product. Used on
5037
- * page mount + every revisit to support resumability (REQ-010).
5038
- */
5039
- state(productId: string): Promise<OnboardingStateResponse>;
5040
- /**
5041
- * Finalise the session, upsert the persona, and materialize the
5042
- * niche-tuned workspace defaults.
5043
- */
5044
- complete(payload: CompleteOnboardingPayload): Promise<CompleteOnboardingResponse>;
5045
- /**
5046
- * Edit a previously-answered step from `/settings/onboarding`. The
5047
- * server emits a `persona_recomputed` event so the workspace and
5048
- * persona update in-session (REQ-010).
5049
- */
5050
- edit(payload: EditOnboardingPayload): Promise<EditOnboardingResponse>;
5051
- /**
5052
- * Preview the workspace profile that would be materialized if the
5053
- * session completed right now. Used by the `feature_preview` step.
5054
- */
5055
- previewWorkspace(sessionId: string): Promise<WorkspaceProfile>;
5056
- }
5057
-
5058
- declare class Clients extends APIResource {
5059
- /**
5060
- * List all clients in the ecosystem.
5061
- */
5062
- list<T = any>(): Promise<T>;
5063
- /**
5064
- * Get client count and auto-generate a unique code.
5065
- */
5066
- getCountAndGenerateCode<T = any>(): Promise<T>;
5067
- /**
5068
- * Retrieve a single client by client code.
5069
- */
5070
- retrieve<T = any>(clientCode: string): Promise<T>;
5071
- /**
5072
- * Get API Key for a specific client (Admin Only).
5073
- */
5074
- getApiKey<T = any>(clientCode: string): Promise<T>;
5075
- /**
5076
- * Generate or rotate API Key for a specific client (Admin Only).
5077
- */
5078
- rotateApiKey<T = any>(clientCode: string): Promise<T>;
5079
- /**
5080
- * Create a new client identity and provision initial resources.
5081
- */
5082
- create<T = any>(payload: {
5083
- name: string;
5084
- clientCode: string;
5085
- business?: any;
5086
- plan?: any;
5087
- }): Promise<T>;
5088
- /**
5089
- * Get active service configuration for a specific client.
5090
- */
5091
- getConfig<T = any>(clientCode: string): Promise<T>;
5092
- /**
5093
- * Update active service configuration for a specific client.
5094
- */
5095
- updateConfig<T = any>(clientCode: string, payload: any): Promise<T>;
5096
- /**
5097
- * List a client's ERIX-Connect connections (masked status + per-module
5098
- * grants). Replaces the legacy `getSecrets` — credentials are never returned
5099
- * in plaintext.
5100
- */
5101
- getConnections<T = any>(clientCode: string): Promise<T>;
5102
- /**
5103
- * List the ERIX-Connect provider registry (cards + methods + field metadata).
5104
- */
5105
- getConnectProviders<T = any>(clientCode: string): Promise<T>;
5106
- /**
5107
- * Connect a provider for a client via a chosen method.
5108
- */
5109
- connectProvider<T = any>(clientCode: string, providerId: string, payload: {
5110
- method: string;
5111
- config: Record<string, unknown>;
5112
- }): Promise<T>;
5113
- /**
5114
- * Update an already-connected provider's configuration.
5115
- */
5116
- configureProvider<T = any>(clientCode: string, providerId: string, payload: {
5117
- method: string;
5118
- config: Record<string, unknown>;
5119
- }): Promise<T>;
5120
- /**
5121
- * Disconnect a provider for a client.
5122
- */
5123
- disconnectProvider<T = any>(clientCode: string, providerId: string): Promise<T>;
5124
- /**
5125
- * Reveal a client's DECRYPTED credentials for a provider (admin/agency).
5126
- */
5127
- revealConnection<T = any>(clientCode: string, providerId: string): Promise<T>;
5128
- /**
5129
- * Toggle a per-module access grant (crm | flow | laie) for a client's
5130
- * connector.
5131
- */
5132
- setConnectionAccess<T = any>(clientCode: string, providerId: string, payload: {
5133
- module: "crm" | "flow" | "laie";
5134
- enabled: boolean;
5135
- }): Promise<T>;
5136
- /**
5137
- * Retrieve Data Source connection metadata.
5138
- */
5139
- getDataSource<T = any>(clientCode: string): Promise<T>;
5140
- /**
5141
- * Configure Data Source metadata.
5142
- */
5143
- manageDataSource<T = any>(clientCode: string, payload: any): Promise<T>;
5144
- /**
5145
- * Update Client Identity and perform cascading updates if required.
5146
- */
5147
- updateIdentity<T = any>(id: string, payload: any): Promise<T>;
5148
- /**
5149
- * Initiate Google Re-authentication for OAuth tokens.
5150
- */
5151
- googleReauth<T = any>(clientCode: string, payload?: {
5152
- authCode?: string;
5153
- }): Promise<T>;
5154
- /**
5155
- * Delete a client and perform cascading cleanup.
5156
- */
5157
- delete<T = any>(id: string): Promise<T>;
5158
- }
5159
- declare class Blogs extends APIResource {
5160
- /**
5161
- * Retrieve public corporate blogs/news.
5162
- */
5163
- list<T = any>(): Promise<T>;
5164
- }
5165
- declare class GlobalLeads extends APIResource {
5166
- /**
5167
- * Add a corporate lead capture entry.
5168
- */
5169
- add<T = any>(payload: any): Promise<T>;
5170
- }
5171
- declare class Services extends APIResource {
5172
- clients: Clients;
5173
- blogs: Blogs;
5174
- globalLeads: GlobalLeads;
5175
- constructor(client: any);
5176
- }
5177
-
5178
- /**
5179
- * Copilot resource — synchronous chat, confirmation, and session management.
5180
- *
5181
- * Access via `ecod.platform.ai.copilot`.
5182
- */
5183
- declare class Copilot extends APIResource {
5184
- /**
5185
- * Send a synchronous (non-streaming) chat message to the copilot.
5186
- */
5187
- chatSync<T = any>(body: Record<string, unknown>): Promise<T>;
5188
- /**
5189
- * Confirm a pending copilot action.
5190
- */
5191
- confirm<T = any>(body: Record<string, unknown>): Promise<T>;
5192
- /**
5193
- * List all copilot sessions.
5194
- */
5195
- listSessions<T = any>(): Promise<T>;
5196
- /**
5197
- * Retrieve a single copilot session by its ID.
5198
- *
5199
- * @param id - The session ID.
5200
- */
5201
- getSession<T = any>(id: string): Promise<T>;
5202
- /**
5203
- * Delete a copilot session by its ID.
5204
- *
5205
- * @param id - The session ID.
5206
- */
5207
- deleteSession<T = any>(id: string): Promise<T>;
5208
- /**
5209
- * Returns the version-relative path for the copilot chat streaming
5210
- * endpoint (`POST /platform/ai/copilot/chat`).
5211
- *
5212
- * NOTE: This endpoint is a Server-Sent-Events (SSE) stream. The axios
5213
- * client is not used for streaming, so SSE consumption must be handled by
5214
- * the caller (e.g. using `fetch` with a `ReadableStream` reader or an
5215
- * `EventSource`-compatible client). This method intentionally does not
5216
- * perform the request or implement streaming.
5217
- *
5218
- * @returns The version-relative SSE endpoint path.
5219
- */
5220
- chatStreamUrl(): string;
5221
- }
5222
- /**
5223
- * Platform AI container — groups the `copilot` sub-resource.
5224
- *
5225
- * Access via `ecod.platform.ai`.
5226
- */
5227
- declare class PlatformAI {
5228
- readonly copilot: Copilot;
5229
- constructor(client: AxiosInstance);
5230
- }
5231
-
5232
- /**
5233
- * Platform authentication resource — registration, login, sessions,
5234
- * password management, OAuth linking, and organization invitations.
5235
- *
5236
- * Access via `ecod.platform.auth`.
5237
- */
5238
- declare class Auth extends APIResource {
5239
- /**
5240
- * Register a new platform user / organization.
5241
- */
5242
- register<T = any>(body: Record<string, unknown>): Promise<T>;
5243
- /**
5244
- * Authenticate a user and establish a session.
5245
- */
5246
- login<T = any>(body: Record<string, unknown>): Promise<T>;
5247
- /**
5248
- * Log out of the current session.
5249
- */
5250
- logout<T = any>(body: Record<string, unknown>): Promise<T>;
5251
- /**
5252
- * Log out of every active session for the current user.
5253
- */
5254
- logoutAll<T = any>(body: Record<string, unknown>): Promise<T>;
5255
- /**
5256
- * Validate the current session token.
5257
- */
5258
- validateSession<T = any>(body: Record<string, unknown>): Promise<T>;
5259
- /**
5260
- * List all active sessions for the current user.
5261
- */
5262
- listSessions<T = any>(): Promise<T>;
5263
- /**
5264
- * Revoke a specific session by its ID.
5265
- *
5266
- * @param id - The session ID to revoke.
5267
- */
5268
- revokeSession<T = any>(id: string): Promise<T>;
5269
- /**
5270
- * Request a one-time password (OTP) to set or change a password.
5271
- */
5272
- requestPasswordOtp<T = any>(body: Record<string, unknown>): Promise<T>;
5273
- /**
5274
- * Set a password for the current user.
5275
- */
5276
- setPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5277
- /**
5278
- * Change the current user's password.
5279
- */
5280
- changePassword<T = any>(body: Record<string, unknown>): Promise<T>;
5281
- /**
5282
- * Begin the forgot-password flow.
5283
- */
5284
- forgotPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5285
- /**
5286
- * Reset a password using a reset token.
5287
- */
5288
- resetPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5289
- /**
5290
- * Link an OAuth identity to the current user.
5291
- */
5292
- linkOAuth<T = any>(body: Record<string, unknown>): Promise<T>;
5293
- /**
5294
- * Retrieve details about an organization invitation by token.
5295
- *
5296
- * @param token - The invitation token.
5297
- */
5298
- getInvitation<T = any>(token: string): Promise<T>;
5299
- /**
5300
- * Accept an organization invitation by token.
5301
- *
5302
- * @param token - The invitation token.
5303
- * @param body - Optional acceptance payload.
5304
- */
5305
- acceptInvitation<T = any>(token: string, body?: Record<string, unknown>): Promise<T>;
5306
- }
5307
-
5308
- /**
5309
- * Entitlements resource — read current plan entitlements and usage.
5310
- *
5311
- * Access via `ecod.platform.billing.entitlements`.
5312
- */
5313
- declare class Entitlements extends APIResource {
5314
- /**
5315
- * Retrieve the current organization's entitlements.
5316
- */
5317
- get<T = any>(): Promise<T>;
5318
- /**
5319
- * Retrieve current usage against entitlements.
5320
- */
5321
- usage<T = any>(): Promise<T>;
5322
- }
5323
- /**
5324
- * Subscriptions resource — manage plan upgrades, downgrades, cancellations,
5325
- * and add-ons.
5326
- *
5327
- * Access via `ecod.platform.billing.subscriptions`.
5328
- */
5329
- declare class Subscriptions extends APIResource {
5330
- /**
5331
- * Upgrade the current subscription plan.
5332
- */
5333
- upgrade<T = any>(body: Record<string, unknown>): Promise<T>;
5334
- /**
5335
- * Downgrade the current subscription plan.
5336
- */
5337
- downgrade<T = any>(body: Record<string, unknown>): Promise<T>;
5338
- /**
5339
- * Cancel the current subscription.
5340
- */
5341
- cancel<T = any>(body: Record<string, unknown>): Promise<T>;
5342
- /**
5343
- * Purchase an add-on for the current subscription.
5344
- */
5345
- purchaseAddon<T = any>(body: Record<string, unknown>): Promise<T>;
5346
- /**
5347
- * Cancel a previously purchased add-on.
5348
- */
5349
- cancelAddon<T = any>(body: Record<string, unknown>): Promise<T>;
5350
- }
5351
- /**
5352
- * Plans resource — read publicly available plans.
5353
- *
5354
- * Access via `ecod.platform.billing.plans`.
5355
- */
5356
- declare class Plans extends APIResource {
5357
- /**
5358
- * List all publicly available plans.
5359
- */
5360
- listPublic<T = any>(): Promise<T>;
5361
- }
5362
- /**
5363
- * Billing checkout resource — plan selection, subscription, verification,
5364
- * and synchronization.
5365
- *
5366
- * Access via `ecod.platform.billing.checkout`.
5367
- */
5368
- declare class BillingCheckout extends APIResource {
5369
- /**
5370
- * List plans available at checkout.
5371
- */
5372
- plans<T = any>(): Promise<T>;
5373
- /**
5374
- * Subscribe to a plan via checkout.
5375
- */
5376
- subscribe<T = any>(body: Record<string, unknown>): Promise<T>;
5377
- /**
5378
- * Verify a checkout payment.
5379
- */
5380
- verify<T = any>(body: Record<string, unknown>): Promise<T>;
5381
- /**
5382
- * Cancel an in-progress checkout.
5383
- */
5384
- cancel<T = any>(body: Record<string, unknown>): Promise<T>;
5385
- /**
5386
- * Retrieve the current checkout status.
5387
- */
5388
- status<T = any>(): Promise<T>;
5389
- /**
5390
- * Synchronize the checkout plan state with the provider.
5391
- */
5392
- syncPlan<T = any>(body: Record<string, unknown>): Promise<T>;
5393
- }
5394
- /**
5395
- * Billing user resource — transactions, subscription, and disputes for the
5396
- * current user.
5397
- *
5398
- * Access via `ecod.platform.billing.user`.
5399
- */
5400
- declare class BillingUser extends APIResource {
5401
- /**
5402
- * List the current user's billing transactions.
5403
- */
5404
- transactions<T = any>(): Promise<T>;
5405
- /**
5406
- * Retrieve the current user's subscription.
5407
- */
5408
- subscription<T = any>(): Promise<T>;
5409
- /**
5410
- * Raise a billing dispute.
5411
- */
5412
- raiseDispute<T = any>(body: Record<string, unknown>): Promise<T>;
5413
- /**
5414
- * List the current user's billing disputes.
5415
- */
5416
- disputes<T = any>(): Promise<T>;
5417
- }
5418
- /**
5419
- * Credits resource — balance, transactions, packs, and top-ups.
5420
- *
5421
- * Access via `ecod.platform.billing.credits`.
5422
- */
5423
- declare class Credits extends APIResource {
5424
- /**
5425
- * Retrieve the current credit balance.
5426
- */
5427
- balance<T = any>(): Promise<T>;
5428
- /**
5429
- * List credit transactions.
5430
- */
5431
- transactions<T = any>(): Promise<T>;
5432
- /**
5433
- * List available credit packs.
5434
- */
5435
- packs<T = any>(): Promise<T>;
5436
- /**
5437
- * Create a credit top-up order.
5438
- */
5439
- topupOrder<T = any>(body: Record<string, unknown>): Promise<T>;
5440
- /**
5441
- * Verify a credit top-up payment.
5442
- */
5443
- verifyTopup<T = any>(body: Record<string, unknown>): Promise<T>;
5444
- /**
5445
- * Configure automatic credit top-ups.
5446
- */
5447
- setAutoTopup<T = any>(body: Record<string, unknown>): Promise<T>;
5448
- /**
5449
- * Configure the daily spend cap (cost control).
5450
- * Body: `{ dailyCap: number | null, alertPct?: number }`.
5451
- */
5452
- setSpendCap<T = any>(body: Record<string, unknown>): Promise<T>;
5453
- }
5454
- /**
5455
- * Platform billing container — groups the `entitlements`, `subscriptions`,
5456
- * `plans`, `checkout`, `user`, and `credits` sub-resources.
5457
- *
5458
- * Access via `ecod.platform.billing`.
5459
- */
5460
- declare class Billing {
5461
- readonly entitlements: Entitlements;
5462
- readonly subscriptions: Subscriptions;
5463
- readonly plans: Plans;
5464
- readonly checkout: BillingCheckout;
5465
- readonly user: BillingUser;
5466
- readonly credits: Credits;
5467
- constructor(client: AxiosInstance);
5468
- }
5469
-
5470
- /**
5471
- * Platform support resource — categories and support ticket lifecycle.
5472
- *
5473
- * Access via `ecod.platform.support`.
5474
- */
5475
- declare class Support extends APIResource {
5476
- /**
5477
- * List available support categories.
5478
- */
5479
- categories<T = any>(): Promise<T>;
5480
- /**
5481
- * List support tickets with optional filtering.
5482
- *
5483
- * @param params - Optional query parameters (status, pagination, etc.).
5484
- */
5485
- listTickets<T = any>(params?: Record<string, unknown>): Promise<T>;
5486
- /**
5487
- * Create a new support ticket.
5488
- */
5489
- createTicket<T = any>(body: Record<string, unknown>): Promise<T>;
5490
- /**
5491
- * Retrieve a single support ticket by its ID.
5492
- *
5493
- * @param id - The support ticket ID.
5494
- */
5495
- getTicket<T = any>(id: string): Promise<T>;
5496
- /**
5497
- * Reply to an existing support ticket.
5498
- *
5499
- * @param id - The support ticket ID.
5500
- * @param body - The reply payload.
5501
- */
5502
- reply<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5503
- /**
5504
- * Close a support ticket.
5505
- *
5506
- * @param id - The support ticket ID.
5507
- */
5508
- close<T = any>(id: string): Promise<T>;
5509
- }
5510
-
5511
- /**
5512
- * Current-user ("me") resource — profile, organization, modules,
5513
- * workspaces, and active-org management.
5514
- *
5515
- * Access via `ecod.platform.users.me`.
5516
- */
5517
- declare class Me extends APIResource {
5518
- /**
5519
- * Retrieve the current authenticated user's profile.
5520
- */
5521
- get<T = any>(): Promise<T>;
5522
- /**
5523
- * Update the current user's profile.
5524
- */
5525
- update<T = any>(body: Record<string, unknown>): Promise<T>;
5526
- /**
5527
- * Update the current user's active organization details.
5528
- */
5529
- updateOrganization<T = any>(body: Record<string, unknown>): Promise<T>;
5530
- /**
5531
- * Toggle enabled modules for the current user / organization.
5532
- */
5533
- toggleModules<T = any>(body: Record<string, unknown>): Promise<T>;
5534
- /**
5535
- * List the workspaces available to the current user.
5536
- */
5537
- workspaces<T = any>(): Promise<T>;
5538
- /**
5539
- * Set the active organization for the current user.
5540
- */
5541
- setActiveOrg<T = any>(body: Record<string, unknown>): Promise<T>;
5542
- /**
5543
- * Dismiss the workspace setup prompt for the current user.
5544
- */
5545
- dismissWorkspaceSetup<T = any>(): Promise<T>;
5546
- }
5547
- /**
5548
- * Organization members resource — list, invite, and remove members.
5549
- *
5550
- * Access via `ecod.platform.users.members`.
5551
- */
5552
- declare class Members extends APIResource {
5553
- /**
5554
- * List all members of the current organization.
5555
- */
5556
- list<T = any>(): Promise<T>;
5557
- /**
5558
- * Invite a new member to the current organization.
5559
- */
5560
- invite<T = any>(body: Record<string, unknown>): Promise<T>;
5561
- /**
5562
- * Remove a member from the current organization.
5563
- *
5564
- * @param id - The member ID to remove.
5565
- */
5566
- remove<T = any>(id: string): Promise<T>;
5567
- }
5568
- /**
5569
- * User sessions resource — list and revoke sessions.
5570
- *
5571
- * Access via `ecod.platform.users.sessions`.
5572
- */
5573
- declare class Sessions extends APIResource {
5574
- /**
5575
- * List all sessions for the current user.
5576
- */
5577
- list<T = any>(): Promise<T>;
5578
- /**
5579
- * Revoke a specific session by its ID.
5580
- *
5581
- * @param id - The session ID to revoke.
5582
- */
5583
- revoke<T = any>(id: string): Promise<T>;
5584
- /**
5585
- * Revoke all sessions for the current user.
5586
- */
5587
- revokeAll<T = any>(): Promise<T>;
5588
- }
5589
-
5590
- /**
5591
- * Platform-admin activity logs resource — list and export activity logs.
5592
- *
5593
- * Access via `ecod.platform.admin.activityLogs`.
5594
- */
5595
- declare class AdminActivityLogs extends APIResource {
5596
- /**
5597
- * List activity logs.
5598
- */
5599
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5600
- /**
5601
- * Export activity logs.
5602
- */
5603
- export<T = any>(params?: Record<string, unknown>): Promise<T>;
5604
- }
5605
-
5606
- /**
5607
- * Platform-admin agency invoices resource — agency invoice settings and CRUD.
5608
- *
5609
- * NOTE: the doubled `admin/invoice-settings` / `admin/invoices` segments are
5610
- * intentional — a legacy router is mounted under the new prefix.
5611
- *
5612
- * Access via `ecod.platform.admin.agencyInvoices`.
5613
- */
5614
- declare class AdminAgencyInvoices extends APIResource {
5615
- /**
5616
- * Retrieve agency invoice settings.
5617
- */
5618
- getSettings<T = any>(): Promise<T>;
5619
- /**
5620
- * Update agency invoice settings.
5621
- */
5622
- updateSettings<T = any>(body: Record<string, unknown>): Promise<T>;
5623
- /**
5624
- * List agency invoices.
5625
- */
5626
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5627
- /**
5628
- * Create an agency invoice.
5629
- */
5630
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5631
- /**
5632
- * Retrieve a single agency invoice by ID.
5633
- */
5634
- retrieve<T = any>(id: string): Promise<T>;
5635
- /**
5636
- * Update an agency invoice.
5637
- */
5638
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5639
- /**
5640
- * Delete an agency invoice.
5641
- */
5642
- remove<T = any>(id: string): Promise<T>;
5643
- }
5644
-
5645
- /**
5646
- * Platform-admin agents resource — inspect and manage agents.
5647
- *
5648
- * Access via `ecod.platform.admin.agents`.
5649
- */
5650
- declare class AdminAgents extends APIResource {
5651
- /**
5652
- * Retrieve aggregate agent statistics.
5653
- */
5654
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5655
- /**
5656
- * List all agents.
5657
- */
5658
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5659
- /**
5660
- * Retrieve a single agent by ID.
5661
- */
5662
- retrieve<T = any>(id: string): Promise<T>;
5663
- /**
5664
- * Update an existing agent.
5665
- */
5666
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5667
- /**
5668
- * List runs for an agent.
5669
- */
5670
- runs<T = any>(id: string): Promise<T>;
5671
- }
5672
-
5673
- /**
5674
- * Platform-admin analytics resource — platform-wide analytics overviews.
5675
- *
5676
- * Access via `ecod.platform.admin.analytics`.
5677
- */
5678
- declare class AdminAnalytics extends APIResource {
5679
- /**
5680
- * Retrieve the analytics overview.
5681
- */
5682
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
5683
- /**
5684
- * Retrieve per-endpoint analytics.
5685
- */
5686
- endpoints<T = any>(params?: Record<string, unknown>): Promise<T>;
5687
- /**
5688
- * Retrieve error analytics.
5689
- */
5690
- errors<T = any>(params?: Record<string, unknown>): Promise<T>;
5691
- /**
5692
- * Retrieve per-tenant analytics.
5693
- */
5694
- tenants<T = any>(params?: Record<string, unknown>): Promise<T>;
5695
- }
5696
-
5697
- /**
5698
- * Platform-admin announcements resource — manage communications,
5699
- * broadcasts, maintenance windows, and changelog entries.
5700
- *
5701
- * Access via `ecod.platform.admin.announcements`.
5702
- */
5703
- declare class AdminAnnouncements extends APIResource {
5704
- /**
5705
- * List all communications.
5706
- */
5707
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5708
- /**
5709
- * Create a new communication.
5710
- */
5711
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5712
- /**
5713
- * Update an existing communication.
5714
- */
5715
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5716
- /**
5717
- * Delete a communication.
5718
- */
5719
- remove<T = any>(id: string): Promise<T>;
5720
- /**
5721
- * Publish a communication.
5722
- */
5723
- publish<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5724
- /**
5725
- * Broadcast a communication to recipients.
5726
- */
5727
- broadcast<T = any>(body: Record<string, unknown>): Promise<T>;
5728
- /**
5729
- * Set the maintenance window.
5730
- */
5731
- setMaintenance<T = any>(body: Record<string, unknown>): Promise<T>;
5732
- /**
5733
- * Retrieve the current maintenance window.
5734
- */
5735
- getMaintenance<T = any>(params?: Record<string, unknown>): Promise<T>;
5736
- /**
5737
- * Post a changelog entry.
5738
- */
5739
- changelog<T = any>(body: Record<string, unknown>): Promise<T>;
5740
- }
5741
-
5742
- /**
5743
- * Platform-admin audit logs resource — audit statistics, listing, and export.
5744
- *
5745
- * Access via `ecod.platform.admin.auditLogs`.
5746
- */
5747
- declare class AdminAuditLogs extends APIResource {
5748
- /**
5749
- * Retrieve aggregate audit statistics.
5750
- */
5751
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5752
- /**
5753
- * List audit log entries.
5754
- */
5755
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5756
- /**
5757
- * Export audit log entries.
5758
- */
5759
- export<T = any>(params?: Record<string, unknown>): Promise<T>;
5760
- }
5761
-
5762
- /**
5763
- * Platform-admin billing resource — billing events, trial extensions,
5764
- * grandfathering, and reconciliation.
5765
- *
5766
- * Access via `ecod.platform.admin.billing`.
5767
- */
5768
- declare class AdminBilling extends APIResource {
5769
- /**
5770
- * List all billing events.
5771
- */
5772
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
5773
- /**
5774
- * List billing events for a specific organization.
5775
- */
5776
- orgEvents<T = any>(orgId: string): Promise<T>;
5777
- /**
5778
- * List failed billing events.
5779
- */
5780
- failed<T = any>(params?: Record<string, unknown>): Promise<T>;
5781
- /**
5782
- * Record a billing event.
5783
- */
5784
- recordEvent<T = any>(body: Record<string, unknown>): Promise<T>;
5785
- /**
5786
- * Extend a trial period.
5787
- */
5788
- extendTrial<T = any>(body: Record<string, unknown>): Promise<T>;
5789
- /**
5790
- * Grandfather an organization onto legacy pricing.
5791
- */
5792
- grandfather<T = any>(body: Record<string, unknown>): Promise<T>;
5793
- /**
5794
- * Reconcile billing state with the provider.
5795
- */
5796
- reconcile<T = any>(params?: Record<string, unknown>): Promise<T>;
5797
- }
5798
-
5799
- /**
5800
- * Platform-admin blogs resource — blog content management.
5801
- *
5802
- * NOTE: the doubled `services/blogs` segments are intentional — a legacy
5803
- * router is mounted under the new prefix.
5804
- *
5805
- * Access via `ecod.platform.admin.blogs`.
5806
- */
5807
- declare class AdminBlogs extends APIResource {
5808
- /**
5809
- * List blog posts.
5810
- */
5811
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5812
- /**
5813
- * Retrieve a single blog post by slug or ID.
5814
- */
5815
- retrieve<T = any>(slugOrId: string): Promise<T>;
5816
- /**
5817
- * Create a blog post.
5818
- */
5819
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5820
- /**
5821
- * Update a blog post by slug or ID.
5822
- */
5823
- update<T = any>(slugOrId: string, body: Record<string, unknown>): Promise<T>;
5824
- /**
5825
- * Delete a blog post by slug or ID.
5826
- */
5827
- remove<T = any>(slugOrId: string): Promise<T>;
5828
- }
5829
-
5830
- /**
5831
- * Platform-admin compliance resource — manage compliance requests and
5832
- * organization data exports.
5833
- *
5834
- * Access via `ecod.platform.admin.compliance`.
5835
- */
5836
- declare class AdminCompliance extends APIResource {
5837
- /**
5838
- * List compliance requests.
5839
- */
5840
- requests<T = any>(params?: Record<string, unknown>): Promise<T>;
5841
- /**
5842
- * Create a new compliance request.
5843
- */
5844
- createRequest<T = any>(body: Record<string, unknown>): Promise<T>;
5845
- /**
5846
- * Update an existing compliance request.
5847
- */
5848
- updateRequest<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5849
- /**
5850
- * Export compliance data for an organization.
5851
- */
5852
- exportOrg<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
5853
- }
5854
-
5855
- /**
5856
- * Platform-admin credits resource — rate cards, credit packs, and wallets.
5857
- *
5858
- * Access via `ecod.platform.admin.credits`.
5859
- */
5860
- declare class AdminCredits extends APIResource {
5861
- /**
5862
- * Retrieve the credits rate card.
5863
- */
5864
- rateCard<T = any>(params?: Record<string, unknown>): Promise<T>;
5865
- /**
5866
- * List all credit packs.
5867
- */
5868
- packs<T = any>(params?: Record<string, unknown>): Promise<T>;
5869
- /**
5870
- * Create a new credit pack.
5871
- */
5872
- createPack<T = any>(body: Record<string, unknown>): Promise<T>;
5873
- /**
5874
- * Update an existing credit pack.
5875
- */
5876
- updatePack<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5877
- /**
5878
- * Delete a credit pack.
5879
- */
5880
- deletePack<T = any>(id: string): Promise<T>;
5881
- /**
5882
- * Retrieve the credit wallet for an organization.
5883
- */
5884
- wallet<T = any>(orgId: string): Promise<T>;
5885
- /**
5886
- * Adjust the credit wallet balance for an organization.
5887
- */
5888
- adjustWallet<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
5889
- }
5890
-
5891
- /**
5892
- * Platform-admin dashboard resource — admin dashboard statistics.
5893
- *
5894
- * Access via `ecod.platform.admin.dashboard`.
5895
- */
5896
- declare class AdminDashboard extends APIResource {
5897
- /**
5898
- * Retrieve admin dashboard statistics.
5899
- *
5900
- * NOTE: the doubled `admin/dashboard` segment is intentional — a legacy
5901
- * router is mounted under the new prefix.
5902
- */
5903
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5904
- }
5905
-
5906
- /**
5907
- * Platform-admin email monitor resource — cross-tenant email monitoring.
5908
- *
5909
- * Access via `ecod.platform.admin.email`.
5910
- */
5911
- declare class AdminEmail extends APIResource {
5912
- /**
5913
- * Retrieve the platform-wide email overview.
5914
- */
5915
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
5916
- /**
5917
- * List email campaigns across tenants.
5918
- */
5919
- campaigns<T = any>(params?: Record<string, unknown>): Promise<T>;
5920
- /**
5921
- * List email events (opens, clicks, bounces, etc.).
5922
- */
5923
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
5924
- /**
5925
- * Retrieve SES health metrics.
5926
- */
5927
- sesHealth<T = any>(params?: Record<string, unknown>): Promise<T>;
5928
- }
5929
-
5930
- /**
5931
- * Platform-admin Erix resource — Erix tenant provisioning and lifecycle.
5932
- *
5933
- * Access via `ecod.platform.admin.erix`.
5934
- */
5935
- declare class AdminErix extends APIResource {
5936
- /**
5937
- * Create a new Erix tenant.
5938
- */
5939
- createTenant<T = any>(body: Record<string, unknown>): Promise<T>;
5940
- /**
5941
- * List Erix tenants.
5942
- */
5943
- tenants<T = any>(params?: Record<string, unknown>): Promise<T>;
5944
- /**
5945
- * Retrieve a single Erix tenant by ID.
5946
- */
5947
- tenant<T = any>(id: string): Promise<T>;
5948
- /**
5949
- * Update the plan for an Erix tenant.
5950
- */
5951
- updatePlan<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5952
- /**
5953
- * Suspend an Erix tenant.
5954
- */
5955
- suspend<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5956
- /**
5957
- * Reactivate a suspended Erix tenant.
5958
- */
5959
- reactivate<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5960
- /**
5961
- * Rotate the API key for an Erix tenant.
5962
- */
5963
- rotateKey<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5964
- /**
5965
- * Retrieve usage metrics for an Erix tenant.
5966
- */
5967
- usage<T = any>(id: string): Promise<T>;
5968
- }
5969
-
5970
- /**
5971
- * Platform-admin feature flags resource — manage feature flags and their
5972
- * per-organization overrides.
5973
- *
5974
- * Access via `ecod.platform.admin.featureFlags`.
5975
- */
5976
- declare class AdminFeatureFlags extends APIResource {
5977
- /**
5978
- * List all feature flags.
5979
- */
5980
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5981
- /**
5982
- * Create a new feature flag.
5983
- */
5984
- create<T = any>(body: Record<string, unknown>): Promise<T>;
3744
+ declare class Copilot extends APIResource {
5985
3745
  /**
5986
- * Update an existing feature flag.
3746
+ * Send a synchronous (non-streaming) chat message to the copilot.
5987
3747
  */
5988
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
3748
+ chatSync<T = any>(body: Record<string, unknown>): Promise<T>;
5989
3749
  /**
5990
- * Delete a feature flag.
3750
+ * Confirm a pending copilot action.
5991
3751
  */
5992
- remove<T = any>(id: string): Promise<T>;
3752
+ confirm<T = any>(body: Record<string, unknown>): Promise<T>;
5993
3753
  /**
5994
- * List per-organization overrides for a feature flag.
3754
+ * List all copilot sessions.
5995
3755
  */
5996
- listOverrides<T = any>(id: string): Promise<T>;
3756
+ listSessions<T = any>(): Promise<T>;
5997
3757
  /**
5998
- * Add a per-organization override to a feature flag.
3758
+ * Retrieve a single copilot session by its ID.
3759
+ *
3760
+ * @param id - The session ID.
5999
3761
  */
6000
- addOverride<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
3762
+ getSession<T = any>(id: string): Promise<T>;
6001
3763
  /**
6002
- * Remove a per-organization override from a feature flag.
3764
+ * Delete a copilot session by its ID.
3765
+ *
3766
+ * @param id - The session ID.
6003
3767
  */
6004
- removeOverride<T = any>(id: string, orgId: string): Promise<T>;
3768
+ deleteSession<T = any>(id: string): Promise<T>;
6005
3769
  /**
6006
- * Retrieve resolved feature flags for a specific organization.
3770
+ * Returns the version-relative path for the copilot chat streaming
3771
+ * endpoint (`POST /platform/ai/copilot/chat`).
3772
+ *
3773
+ * NOTE: This endpoint is a Server-Sent-Events (SSE) stream. The axios
3774
+ * client is not used for streaming, so SSE consumption must be handled by
3775
+ * the caller (e.g. using `fetch` with a `ReadableStream` reader or an
3776
+ * `EventSource`-compatible client). This method intentionally does not
3777
+ * perform the request or implement streaming.
3778
+ *
3779
+ * @returns The version-relative SSE endpoint path.
6007
3780
  */
6008
- forOrg<T = any>(orgId: string): Promise<T>;
3781
+ chatStreamUrl(): string;
6009
3782
  }
6010
-
6011
3783
  /**
6012
- * Platform-admin flow monitor resource — cross-tenant flow run monitoring.
3784
+ * Platform AI container — groups the `copilot` sub-resource.
6013
3785
  *
6014
- * Access via `ecod.platform.admin.flow`.
3786
+ * Access via `ecod.platform.ai`.
6015
3787
  */
6016
- declare class AdminFlow extends APIResource {
6017
- /**
6018
- * Retrieve the platform-wide flow overview.
6019
- */
6020
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
6021
- /**
6022
- * List flow runs across tenants.
6023
- */
6024
- runs<T = any>(params?: Record<string, unknown>): Promise<T>;
6025
- /**
6026
- * List flow run failures.
6027
- */
6028
- failures<T = any>(params?: Record<string, unknown>): Promise<T>;
6029
- /**
6030
- * Retrieve a single flow run by ID.
6031
- */
6032
- run<T = any>(id: string): Promise<T>;
6033
- /**
6034
- * Retry a failed flow run.
6035
- */
6036
- retryRun<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
3788
+ declare class PlatformAI {
3789
+ readonly copilot: Copilot;
3790
+ constructor(client: AxiosInstance);
6037
3791
  }
6038
3792
 
6039
- /**
6040
- * Platform-admin integrations resource — per-tenant integration management.
6041
- *
6042
- * Access via `ecod.platform.admin.integrations`.
6043
- */
6044
- declare class AdminIntegrations extends APIResource {
6045
- /**
6046
- * List integrations for a tenant organization.
6047
- */
6048
- list<T = any>(orgId: string): Promise<T>;
6049
- /**
6050
- * Connect a provider integration for a tenant organization.
6051
- */
6052
- connect<T = any>(orgId: string, providerId: string, body?: Record<string, unknown>): Promise<T>;
6053
- /**
6054
- * Disconnect a provider integration for a tenant organization.
6055
- */
6056
- disconnect<T = any>(orgId: string, providerId: string): Promise<T>;
6057
- /**
6058
- * Test a provider integration for a tenant organization.
6059
- */
6060
- test<T = any>(orgId: string, providerId: string, body?: Record<string, unknown>): Promise<T>;
6061
- /**
6062
- * Send an integration invite for a tenant organization.
6063
- */
6064
- invite<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
3793
+ /** One thing the AI agent knows from: pasted text, a web page or a file. */
3794
+ interface KnowledgeSource {
3795
+ id: string;
3796
+ kind: "text" | "url" | "file";
3797
+ title: string;
3798
+ /** The URL (kind=url) or storage key (kind=file). */
3799
+ ref: string | null;
3800
+ mimeType: string | null;
3801
+ /** `pending` → `processing` → `ready` | `failed` (live: `knowledge.source_updated`). */
3802
+ status: "pending" | "processing" | "ready" | "failed";
3803
+ /** Why it failed, readable as-is. */
3804
+ error: string | null;
3805
+ chunkCount: number;
3806
+ createdAt: string;
3807
+ updatedAt: string;
6065
3808
  }
6066
-
6067
- /**
6068
- * Platform-admin LAIE control resource — LAIE overview, queue, proxies,
6069
- * credits, actors, enrichment config, and audits.
6070
- *
6071
- * Access via `ecod.platform.admin.laie`.
6072
- */
6073
- declare class AdminLaie extends APIResource {
6074
- /**
6075
- * Retrieve the LAIE platform overview.
6076
- */
6077
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
6078
- /**
6079
- * Retrieve the LAIE processing queue.
6080
- */
6081
- queue<T = any>(params?: Record<string, unknown>): Promise<T>;
6082
- /**
6083
- * List LAIE proxies.
6084
- */
6085
- proxies<T = any>(params?: Record<string, unknown>): Promise<T>;
6086
- /**
6087
- * Retrieve LAIE vault statistics.
6088
- */
6089
- vaultStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6090
- /**
6091
- * Retrieve LAIE credit usage.
6092
- */
6093
- credits<T = any>(params?: Record<string, unknown>): Promise<T>;
6094
- /**
6095
- * List LAIE actors.
6096
- */
6097
- actors<T = any>(params?: Record<string, unknown>): Promise<T>;
6098
- /**
6099
- * Retrieve the LAIE actor registry.
6100
- */
6101
- actorRegistry<T = any>(params?: Record<string, unknown>): Promise<T>;
6102
- /**
6103
- * Run a named LAIE actor.
6104
- */
6105
- runActor<T = any>(name: string, body?: Record<string, unknown>): Promise<T>;
6106
- /**
6107
- * Retrieve the LAIE enrichment configuration.
6108
- */
6109
- getEnrichmentConfig<T = any>(): Promise<T>;
6110
- /**
6111
- * Update the LAIE enrichment configuration.
6112
- */
6113
- setEnrichmentConfig<T = any>(body: Record<string, unknown>): Promise<T>;
6114
- /**
6115
- * List LAIE audit records.
6116
- */
6117
- audits<T = any>(params?: Record<string, unknown>): Promise<T>;
6118
- /**
6119
- * Retrieve a single LAIE audit record by ID.
6120
- */
6121
- audit<T = any>(id: string): Promise<T>;
3809
+ /** A passage the agent would use for a question. */
3810
+ interface KnowledgePassage {
3811
+ chunkId: string;
3812
+ sourceId: string;
3813
+ title: string;
3814
+ content: string;
3815
+ score: number;
6122
3816
  }
6123
-
3817
+ /** File types the knowledge base can read. */
3818
+ declare const KNOWLEDGE_FILE_TYPES: readonly ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown", "text/csv", "text/html", "image/png", "image/jpeg", "image/webp"];
3819
+ type Res<T> = {
3820
+ success: boolean;
3821
+ data: T;
3822
+ };
6124
3823
  /**
6125
- * Platform-admin LAIE runtime resource — live runtime stats for queue,
6126
- * proxies, browser pool, dead-letter queue, and runs.
6127
- *
6128
- * Access via `ecod.platform.admin.laieRuntime`.
3824
+ * The AI agent's knowledge base (RAG): what it answers from. Adding and
3825
+ * removing sources needs a workspace admin; reading and test-searching don't.
6129
3826
  */
6130
- declare class AdminLaieRuntime extends APIResource {
6131
- /**
6132
- * Retrieve LAIE runtime queue statistics.
6133
- */
6134
- queueStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6135
- /**
6136
- * Retrieve LAIE runtime proxy health.
6137
- */
6138
- proxyHealth<T = any>(params?: Record<string, unknown>): Promise<T>;
6139
- /**
6140
- * Retrieve LAIE runtime browser pool statistics.
6141
- */
6142
- browserPoolStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6143
- /**
6144
- * Replay the LAIE runtime dead-letter queue.
6145
- */
6146
- replayDlq<T = any>(body?: Record<string, unknown>): Promise<T>;
6147
- /**
6148
- * Retrieve LAIE runtime run statistics.
6149
- */
6150
- runStats<T = any>(params?: Record<string, unknown>): Promise<T>;
3827
+ declare class Knowledge extends APIResource {
3828
+ list(): Promise<Res<KnowledgeSource[]>>;
3829
+ /** Paste text — an FAQ, a price list, a policy. */
3830
+ addText(params: {
3831
+ title: string;
3832
+ content: string;
3833
+ }): Promise<Res<KnowledgeSource>>;
3834
+ /** A public web page (re-read it later with `reindex`). */
3835
+ addUrl(params: {
3836
+ url: string;
3837
+ title?: string;
3838
+ }): Promise<Res<KnowledgeSource>>;
3839
+ /** Upload a file (PDF, Word, text, image) to your storage and add it. */
3840
+ addFile(file: Blob, opts?: {
3841
+ title?: string;
3842
+ }): Promise<Res<KnowledgeSource>>;
3843
+ remove(id: string): Promise<{
3844
+ success: boolean;
3845
+ }>;
3846
+ /** Read the source again (e.g. the web page changed). */
3847
+ reindex(id: string): Promise<Res<KnowledgeSource>>;
3848
+ /** What the agent would retrieve for a question. */
3849
+ search(query: string, limit?: number): Promise<Res<KnowledgePassage[]>>;
6151
3850
  }
6152
3851
 
6153
- /**
6154
- * Platform-admin LAIE vault resource — LAIE vault overview.
6155
- *
6156
- * Access via `ecod.platform.admin.laieVault`.
6157
- */
6158
- declare class AdminLaieVault extends APIResource {
6159
- /**
6160
- * Retrieve the LAIE vault overview.
6161
- *
6162
- * NOTE: the doubled `admin/laie/vault` segment is intentional — a legacy
6163
- * router is mounted under the new prefix.
6164
- */
6165
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
3852
+ /** A tool the org can let its AI agent use (from the server's catalog). */
3853
+ interface AiAgentTool {
3854
+ id: string;
3855
+ label: string;
3856
+ description: string;
3857
+ /** True when it changes data (books, updates…). */
3858
+ sideEffect: boolean;
3859
+ }
3860
+ /** The org's AI agent (inbox auto-reply on WhatsApp, Instagram, Facebook, Telegram, email). */
3861
+ interface AiAgentSettings {
3862
+ aiAgentEnabled: boolean;
3863
+ /** The persona / instructions the agent follows. */
3864
+ aiAgentPrompt: string | null;
3865
+ /** Auto-send replies (otherwise they wait in the inbox as suggestions). */
3866
+ aiAutoReply: boolean;
3867
+ /** 0–1: below this, an auto-reply becomes a suggestion instead. */
3868
+ aiConfidenceThreshold: number;
3869
+ /** Ids from `availableTools` the agent may use. */
3870
+ aiAllowedTools: string[];
3871
+ /** Read-only: every tool that can be granted. */
3872
+ availableTools?: AiAgentTool[];
3873
+ /**
3874
+ * Returned by `updateSettings` when the agent is on: the channels whose
3875
+ * AI Auto-Reply flow is set up (connected channels only).
3876
+ */
3877
+ autoReplyChannels?: string[];
3878
+ }
3879
+ /** An AI draft waiting for a person in the inbox (kept up to 7 days). */
3880
+ interface AiSuggestion {
3881
+ id: string;
3882
+ conversationId: string;
3883
+ text: string;
3884
+ confidence: number;
3885
+ /** A data-changing step the agent proposed with the reply (approve to run). */
3886
+ pendingAction?: {
3887
+ action: string;
3888
+ input: Record<string, unknown>;
3889
+ };
3890
+ /** Knowledge sources the draft was grounded on. */
3891
+ sources?: {
3892
+ sourceId: string;
3893
+ title: string;
3894
+ }[];
3895
+ /** Set once a person approved `pendingAction`. */
3896
+ actionApprovedAt?: string;
3897
+ generatedAt: string;
6166
3898
  }
6167
-
6168
- /**
6169
- * Platform-admin leads resource — admin lead management, qualification,
6170
- * follow-ups, and notes.
6171
- *
6172
- * NOTE: the doubled `leads/leads` segments are intentional — a legacy router
6173
- * is mounted under the new prefix.
6174
- *
6175
- * Access via `ecod.platform.admin.leads`.
6176
- */
6177
- declare class AdminLeads extends APIResource {
6178
- /**
6179
- * Add a new lead.
6180
- */
6181
- addLead<T = any>(body: Record<string, unknown>): Promise<T>;
6182
- /**
6183
- * List leads.
6184
- */
6185
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
6186
- /**
6187
- * Retrieve a single lead by ID.
6188
- */
6189
- retrieve<T = any>(id: string): Promise<T>;
6190
- /**
6191
- * Update a lead.
6192
- */
6193
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6194
- /**
6195
- * Delete a lead.
6196
- */
6197
- remove<T = any>(id: string): Promise<T>;
6198
- /**
6199
- * Update a lead's status.
6200
- */
6201
- updateStatus<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6202
- /**
6203
- * Record a lead's qualification.
6204
- */
6205
- qualification<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6206
- /**
6207
- * Record a lead's first contact.
6208
- */
6209
- firstContact<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
6210
- /**
6211
- * Record a follow-up for a lead.
6212
- */
6213
- followup<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6214
- /**
6215
- * List notes for a lead.
6216
- */
6217
- notes<T = any>(id: string): Promise<T>;
6218
- /**
6219
- * Add a note to a lead.
6220
- */
6221
- addNote<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6222
- /**
6223
- * Update a lead note.
6224
- */
6225
- updateNote<T = any>(id: string, noteId: string, body: Record<string, unknown>): Promise<T>;
6226
- /**
6227
- * Delete a lead note.
6228
- */
6229
- deleteNote<T = any>(id: string, noteId: string): Promise<T>;
3899
+ /** A Flow run held at an approval step. */
3900
+ interface PausedRun {
3901
+ id: string;
3902
+ flowId: string;
3903
+ flowName: string;
3904
+ leadId: string | null;
3905
+ recordsHeld: number | null;
3906
+ startedAt: string | null;
3907
+ createdAt: string;
6230
3908
  }
6231
-
6232
3909
  /**
6233
- * Platform-admin OpenAPI resource — OpenAPI spec and health.
6234
- *
6235
- * Access via `ecod.platform.admin.openapi`.
3910
+ * The AI agent: its settings and the drafts it leaves in the inbox. Drafts
3911
+ * also arrive live on `ai_suggestion` and leave on `ai_suggestion.resolved`;
3912
+ * held runs change on `workflow-run-update`.
6236
3913
  */
6237
- declare class AdminOpenApi extends APIResource {
6238
- /**
6239
- * Retrieve the OpenAPI spec as JSON.
6240
- */
6241
- json<T = any>(): Promise<T>;
3914
+ declare class AiAgent extends APIResource {
3915
+ /** Settings plus `availableTools`. */
3916
+ settings(): Promise<{
3917
+ success: boolean;
3918
+ data: AiAgentSettings;
3919
+ }>;
3920
+ /** Change settings (workspace admins only). */
3921
+ updateSettings(patch: Partial<Omit<AiAgentSettings, "availableTools">>): Promise<{
3922
+ success: boolean;
3923
+ data: AiAgentSettings;
3924
+ }>;
3925
+ /** The draft waiting on a conversation (`data: null` when none). */
3926
+ suggestion(conversationId: string): Promise<{
3927
+ success: boolean;
3928
+ data: AiSuggestion | null;
3929
+ }>;
6242
3930
  /**
6243
- * Retrieve the Swagger UI HTML page.
3931
+ * Run the action the draft proposed (exactly the server's copy — once per
3932
+ * draft). Send the reply afterwards through the inbox as usual.
6244
3933
  */
6245
- docs<T = any>(): Promise<T>;
3934
+ approveAction(conversationId: string): Promise<{
3935
+ success: boolean;
3936
+ data: {
3937
+ action: string;
3938
+ output: unknown;
3939
+ };
3940
+ }>;
3941
+ /** Record that a person sent the draft (possibly edited) and clear it. */
3942
+ markSent(conversationId: string, text: string, confidence: number): Promise<unknown>;
3943
+ /** Discard the draft. */
3944
+ dismiss(conversationId: string): Promise<unknown>;
6246
3945
  /**
6247
- * Retrieve the OpenAPI health status.
3946
+ * Everything waiting on a person: AI drafts across every conversation, and
3947
+ * Flow runs held at an approval step.
6248
3948
  */
6249
- health<T = any>(): Promise<T>;
3949
+ approvals(): Promise<{
3950
+ success: boolean;
3951
+ data: {
3952
+ drafts: AiSuggestion[];
3953
+ runs: PausedRun[];
3954
+ };
3955
+ }>;
3956
+ /** Let a held run continue, or stop it. */
3957
+ decideRun(runId: string, decision: "approve" | "reject"): Promise<{
3958
+ success: boolean;
3959
+ decision: string;
3960
+ }>;
6250
3961
  }
6251
3962
 
6252
3963
  /**
6253
- * Platform-admin partners resource — manage partners and their referrals.
3964
+ * Platform authentication resource — registration, login, sessions,
3965
+ * password management, OAuth linking, and organization invitations.
6254
3966
  *
6255
- * Access via `ecod.platform.admin.partners`.
3967
+ * Access via `ecod.platform.auth`.
6256
3968
  */
6257
- declare class AdminPartners extends APIResource {
6258
- /**
6259
- * Retrieve aggregate partner statistics.
6260
- */
6261
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
6262
- /**
6263
- * List all partners.
6264
- */
6265
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
6266
- /**
6267
- * Create a new partner.
6268
- */
6269
- create<T = any>(body: Record<string, unknown>): Promise<T>;
6270
- /**
6271
- * Retrieve a single partner by ID.
6272
- */
6273
- retrieve<T = any>(id: string): Promise<T>;
6274
- /**
6275
- * Update an existing partner.
6276
- */
6277
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
3969
+ declare class Auth extends APIResource {
6278
3970
  /**
6279
- * Delete a partner.
3971
+ * Register a new platform user / organization.
6280
3972
  */
6281
- remove<T = any>(id: string): Promise<T>;
3973
+ register<T = any>(body: Record<string, unknown>): Promise<T>;
6282
3974
  /**
6283
- * List referrals for a partner.
3975
+ * Authenticate a user and establish a session.
6284
3976
  */
6285
- referrals<T = any>(id: string): Promise<T>;
3977
+ login<T = any>(body: Record<string, unknown>): Promise<T>;
6286
3978
  /**
6287
- * Update a specific referral for a partner.
3979
+ * Log out of the current session.
6288
3980
  */
6289
- updateReferral<T = any>(id: string, refId: string, body: Record<string, unknown>): Promise<T>;
6290
- }
6291
-
6292
- /**
6293
- * Platform-admin payment operations resource — refunds, payment validation,
6294
- * retries, timelines, and risk assessment.
6295
- *
6296
- * Access via `ecod.platform.admin.paymentOps`.
6297
- */
6298
- declare class AdminPaymentOps extends APIResource {
3981
+ logout<T = any>(body: Record<string, unknown>): Promise<T>;
6299
3982
  /**
6300
- * Issue a refund.
3983
+ * Log out of every active session for the current user.
6301
3984
  */
6302
- refund<T = any>(body: Record<string, unknown>): Promise<T>;
3985
+ logoutAll<T = any>(body: Record<string, unknown>): Promise<T>;
6303
3986
  /**
6304
- * Validate a payment by ID.
3987
+ * Validate the current session token.
6305
3988
  */
6306
- validate<T = any>(paymentId: string): Promise<T>;
3989
+ validateSession<T = any>(body: Record<string, unknown>): Promise<T>;
6307
3990
  /**
6308
- * Fetch a payment by ID.
3991
+ * List all active sessions for the current user.
6309
3992
  */
6310
- fetch<T = any>(paymentId: string): Promise<T>;
3993
+ listSessions<T = any>(): Promise<T>;
6311
3994
  /**
6312
- * Retrieve a subscription by ID.
3995
+ * Revoke a specific session by its ID.
3996
+ *
3997
+ * @param id - The session ID to revoke.
6313
3998
  */
6314
- subscription<T = any>(subId: string): Promise<T>;
3999
+ revokeSession<T = any>(id: string): Promise<T>;
6315
4000
  /**
6316
- * List failed payments.
4001
+ * Request a one-time password (OTP) to set or change a password.
6317
4002
  */
6318
- failed<T = any>(params?: Record<string, unknown>): Promise<T>;
4003
+ requestPasswordOtp<T = any>(body: Record<string, unknown>): Promise<T>;
6319
4004
  /**
6320
- * Retry failed payments for an organization.
4005
+ * Set a password for the current user.
6321
4006
  */
6322
- retry<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4007
+ setPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6323
4008
  /**
6324
- * Retrieve the payment timeline for an organization.
4009
+ * Change the current user's password.
6325
4010
  */
6326
- timeline<T = any>(orgId: string): Promise<T>;
4011
+ changePassword<T = any>(body: Record<string, unknown>): Promise<T>;
6327
4012
  /**
6328
- * Retrieve the payment risk assessment for an organization.
4013
+ * Begin the forgot-password flow.
6329
4014
  */
6330
- risk<T = any>(orgId: string): Promise<T>;
6331
- }
6332
-
6333
- /**
6334
- * Platform-admin persona history resource — inspect persona version history.
6335
- *
6336
- * Access via `ecod.platform.admin.personaHistory`.
6337
- */
6338
- declare class AdminPersonaHistory extends APIResource {
4015
+ forgotPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6339
4016
  /**
6340
- * Retrieve aggregate persona history statistics.
4017
+ * Reset a password using a reset token.
6341
4018
  */
6342
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4019
+ resetPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6343
4020
  /**
6344
- * List persona history entries.
4021
+ * Link an OAuth identity to the current user.
6345
4022
  */
6346
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4023
+ linkOAuth<T = any>(body: Record<string, unknown>): Promise<T>;
6347
4024
  /**
6348
- * Retrieve the history for a specific persona.
4025
+ * Retrieve details about an organization invitation by token.
4026
+ *
4027
+ * @param token - The invitation token.
6349
4028
  */
6350
- retrieve<T = any>(personaId: string): Promise<T>;
4029
+ getInvitation<T = any>(token: string): Promise<T>;
6351
4030
  /**
6352
- * Retrieve a specific version of a persona's history.
4031
+ * Accept an organization invitation by token.
4032
+ *
4033
+ * @param token - The invitation token.
4034
+ * @param body - Optional acceptance payload.
6353
4035
  */
6354
- version<T = any>(personaId: string, version: string): Promise<T>;
4036
+ acceptInvitation<T = any>(token: string, body?: Record<string, unknown>): Promise<T>;
6355
4037
  }
6356
4038
 
6357
4039
  /**
6358
- * Platform-admin pipelines resource — pipeline template management and
6359
- * provisioning.
4040
+ * Entitlements resource — read current plan entitlements and usage.
6360
4041
  *
6361
- * Access via `ecod.platform.admin.pipelines`.
4042
+ * Access via `ecod.platform.billing.entitlements`.
6362
4043
  */
6363
- declare class AdminPipelines extends APIResource {
6364
- /**
6365
- * List pipeline templates.
6366
- */
6367
- templates<T = any>(params?: Record<string, unknown>): Promise<T>;
6368
- /**
6369
- * Create a new pipeline template.
6370
- */
6371
- createTemplate<T = any>(body: Record<string, unknown>): Promise<T>;
6372
- /**
6373
- * Update an existing pipeline template.
6374
- */
6375
- updateTemplate<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6376
- /**
6377
- * Delete a pipeline template.
6378
- */
6379
- deleteTemplate<T = any>(id: string): Promise<T>;
4044
+ declare class Entitlements extends APIResource {
6380
4045
  /**
6381
- * Provision pipelines from templates.
4046
+ * Retrieve the current organization's entitlements.
6382
4047
  */
6383
- provision<T = any>(body: Record<string, unknown>): Promise<T>;
4048
+ get<T = any>(): Promise<T>;
6384
4049
  /**
6385
- * Retrieve the pipelines overview.
4050
+ * Retrieve current usage against entitlements.
6386
4051
  */
6387
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
4052
+ usage<T = any>(): Promise<T>;
6388
4053
  }
6389
-
6390
4054
  /**
6391
- * Platform-admin plans resource — manage billing plans.
4055
+ * Subscriptions resource — manage plan upgrades, downgrades, cancellations,
4056
+ * and add-ons.
6392
4057
  *
6393
- * Access via `ecod.platform.admin.plans`.
4058
+ * Access via `ecod.platform.billing.subscriptions`.
6394
4059
  */
6395
- declare class AdminPlans extends APIResource {
4060
+ declare class Subscriptions extends APIResource {
6396
4061
  /**
6397
- * List all plans.
4062
+ * Upgrade the current subscription plan.
6398
4063
  */
6399
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4064
+ upgrade<T = any>(body: Record<string, unknown>): Promise<T>;
6400
4065
  /**
6401
- * Create a new plan.
4066
+ * Downgrade the current subscription plan.
6402
4067
  */
6403
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4068
+ downgrade<T = any>(body: Record<string, unknown>): Promise<T>;
6404
4069
  /**
6405
- * Update an existing plan.
4070
+ * Cancel the current subscription.
6406
4071
  */
6407
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4072
+ cancel<T = any>(body: Record<string, unknown>): Promise<T>;
6408
4073
  /**
6409
- * Delete a plan.
4074
+ * Purchase an add-on for the current subscription.
6410
4075
  */
6411
- remove<T = any>(id: string): Promise<T>;
4076
+ purchaseAddon<T = any>(body: Record<string, unknown>): Promise<T>;
6412
4077
  /**
6413
- * List tenants subscribed to a plan.
4078
+ * Cancel a previously purchased add-on.
6414
4079
  */
6415
- tenants<T = any>(id: string): Promise<T>;
4080
+ cancelAddon<T = any>(body: Record<string, unknown>): Promise<T>;
6416
4081
  }
6417
-
6418
4082
  /**
6419
- * Platform-admin revenue resource — revenue summaries and snapshots.
4083
+ * Plans resource — read publicly available plans.
6420
4084
  *
6421
- * Access via `ecod.platform.admin.revenue`.
4085
+ * Access via `ecod.platform.billing.plans`.
6422
4086
  */
6423
- declare class AdminRevenue extends APIResource {
6424
- /**
6425
- * Retrieve the aggregated revenue summary.
6426
- */
6427
- summary<T = any>(params?: Record<string, unknown>): Promise<T>;
6428
- /**
6429
- * List historical revenue snapshots.
6430
- */
6431
- snapshots<T = any>(params?: Record<string, unknown>): Promise<T>;
4087
+ declare class Plans extends APIResource {
6432
4088
  /**
6433
- * Generate a new revenue snapshot.
4089
+ * List all publicly available plans.
6434
4090
  */
6435
- generateSnapshot<T = any>(body?: Record<string, unknown>): Promise<T>;
4091
+ listPublic<T = any>(): Promise<T>;
6436
4092
  }
6437
-
6438
4093
  /**
6439
- * Platform-admin staff resource — admin staff account management.
6440
- *
6441
- * NOTE: the doubled `admin/staff` segments are intentional — a legacy router
6442
- * is mounted under the new prefix.
4094
+ * Billing checkout resource — plan selection, subscription, verification,
4095
+ * and synchronization.
6443
4096
  *
6444
- * Access via `ecod.platform.admin.staff`.
4097
+ * Access via `ecod.platform.billing.checkout`.
6445
4098
  */
6446
- declare class AdminStaff extends APIResource {
4099
+ declare class BillingCheckout extends APIResource {
6447
4100
  /**
6448
- * Verify staff credentials.
4101
+ * List plans available at checkout.
6449
4102
  */
6450
- verifyCredentials<T = any>(body: Record<string, unknown>): Promise<T>;
4103
+ plans<T = any>(): Promise<T>;
6451
4104
  /**
6452
- * Find an existing staff account or create one.
4105
+ * Subscribe to a plan via checkout.
6453
4106
  */
6454
- findOrCreate<T = any>(body: Record<string, unknown>): Promise<T>;
4107
+ subscribe<T = any>(body: Record<string, unknown>): Promise<T>;
6455
4108
  /**
6456
- * List admin staff accounts.
4109
+ * Verify a checkout payment.
6457
4110
  */
6458
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4111
+ verify<T = any>(body: Record<string, unknown>): Promise<T>;
6459
4112
  /**
6460
- * Create an admin staff account.
4113
+ * Cancel an in-progress checkout.
6461
4114
  */
6462
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4115
+ cancel<T = any>(body: Record<string, unknown>): Promise<T>;
6463
4116
  /**
6464
- * Update an admin staff account.
4117
+ * Retrieve the current checkout status.
6465
4118
  */
6466
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4119
+ status<T = any>(): Promise<T>;
6467
4120
  /**
6468
- * Delete an admin staff account.
4121
+ * Synchronize the checkout plan state with the provider.
6469
4122
  */
6470
- remove<T = any>(id: string): Promise<T>;
4123
+ syncPlan<T = any>(body: Record<string, unknown>): Promise<T>;
6471
4124
  }
6472
-
6473
4125
  /**
6474
- * Platform-admin storage resource — storage statistics, events, and usage.
4126
+ * Billing user resource — transactions, subscription, and disputes for the
4127
+ * current user.
6475
4128
  *
6476
- * Access via `ecod.platform.admin.storage`.
4129
+ * Access via `ecod.platform.billing.user`.
6477
4130
  */
6478
- declare class AdminStorage extends APIResource {
4131
+ declare class BillingUser extends APIResource {
6479
4132
  /**
6480
- * Retrieve aggregate storage statistics.
4133
+ * List the current user's billing transactions.
6481
4134
  */
6482
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4135
+ transactions<T = any>(): Promise<T>;
6483
4136
  /**
6484
- * List storage events.
4137
+ * Retrieve the current user's subscription.
6485
4138
  */
6486
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
4139
+ subscription<T = any>(): Promise<T>;
6487
4140
  /**
6488
- * Retrieve storage usage.
4141
+ * Raise a billing dispute.
6489
4142
  */
6490
- usage<T = any>(params?: Record<string, unknown>): Promise<T>;
6491
- }
6492
-
6493
- /**
6494
- * Platform-admin system health resource — system health overview.
6495
- *
6496
- * Access via `ecod.platform.admin.health`.
6497
- */
6498
- declare class AdminHealth extends APIResource {
4143
+ raiseDispute<T = any>(body: Record<string, unknown>): Promise<T>;
6499
4144
  /**
6500
- * Retrieve the system health overview.
4145
+ * List the current user's billing disputes.
6501
4146
  */
6502
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
4147
+ disputes<T = any>(): Promise<T>;
6503
4148
  }
6504
-
6505
4149
  /**
6506
- * Platform-admin templates resource — manage templates, versions, and
6507
- * plan assignments.
4150
+ * Credits resource — balance, transactions, packs, and top-ups.
6508
4151
  *
6509
- * Access via `ecod.platform.admin.templates`.
4152
+ * Access via `ecod.platform.billing.credits`.
6510
4153
  */
6511
- declare class AdminTemplates extends APIResource {
6512
- /**
6513
- * List all templates.
6514
- */
6515
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4154
+ declare class Credits extends APIResource {
6516
4155
  /**
6517
- * Create a new template.
4156
+ * Retrieve the current credit balance.
6518
4157
  */
6519
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4158
+ balance<T = any>(): Promise<T>;
6520
4159
  /**
6521
- * Retrieve a single template by ID.
4160
+ * List credit transactions.
6522
4161
  */
6523
- retrieve<T = any>(id: string): Promise<T>;
4162
+ transactions<T = any>(): Promise<T>;
6524
4163
  /**
6525
- * Update an existing template.
4164
+ * List available credit packs.
6526
4165
  */
6527
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4166
+ packs<T = any>(): Promise<T>;
6528
4167
  /**
6529
- * Delete a template.
4168
+ * Create a credit top-up order.
6530
4169
  */
6531
- remove<T = any>(id: string): Promise<T>;
4170
+ topupOrder<T = any>(body: Record<string, unknown>): Promise<T>;
6532
4171
  /**
6533
- * Clone an existing template.
4172
+ * Verify a credit top-up payment.
6534
4173
  */
6535
- clone<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4174
+ verifyTopup<T = any>(body: Record<string, unknown>): Promise<T>;
6536
4175
  /**
6537
- * List versions of a template.
4176
+ * Configure automatic credit top-ups.
6538
4177
  */
6539
- versions<T = any>(id: string): Promise<T>;
4178
+ setAutoTopup<T = any>(body: Record<string, unknown>): Promise<T>;
6540
4179
  /**
6541
- * Assign plans to a template.
4180
+ * Configure the daily spend cap (cost control).
4181
+ * Body: `{ dailyCap: number | null, alertPct?: number }`.
6542
4182
  */
6543
- assignPlans<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4183
+ setSpendCap<T = any>(body: Record<string, unknown>): Promise<T>;
4184
+ }
4185
+ /**
4186
+ * Platform billing container — groups the `entitlements`, `subscriptions`,
4187
+ * `plans`, `checkout`, `user`, and `credits` sub-resources.
4188
+ *
4189
+ * Access via `ecod.platform.billing`.
4190
+ */
4191
+ declare class Billing {
4192
+ readonly entitlements: Entitlements;
4193
+ readonly subscriptions: Subscriptions;
4194
+ readonly plans: Plans;
4195
+ readonly checkout: BillingCheckout;
4196
+ readonly user: BillingUser;
4197
+ readonly credits: Credits;
4198
+ constructor(client: AxiosInstance);
6544
4199
  }
6545
4200
 
6546
4201
  /**
6547
- * Platform-admin tenants resource — deep tenant inspection and lifecycle control.
4202
+ * Platform support resource — categories and support ticket lifecycle.
6548
4203
  *
6549
- * Access via `ecod.platform.admin.tenants`.
4204
+ * Access via `ecod.platform.support`.
6550
4205
  */
6551
- declare class AdminTenants extends APIResource {
6552
- /**
6553
- * Retrieve a deep, fully-expanded view of a tenant organization.
6554
- */
6555
- deep<T = any>(orgId: string): Promise<T>;
6556
- /**
6557
- * Retrieve usage metrics for a tenant organization.
6558
- */
6559
- usage<T = any>(orgId: string): Promise<T>;
6560
- /**
6561
- * Retrieve the team/members for a tenant organization.
6562
- */
6563
- team<T = any>(orgId: string): Promise<T>;
6564
- /**
6565
- * Retrieve billing details for a tenant organization.
6566
- */
6567
- billing<T = any>(orgId: string): Promise<T>;
6568
- /**
6569
- * Retrieve WhatsApp configuration for a tenant organization.
6570
- */
6571
- whatsapp<T = any>(orgId: string): Promise<T>;
6572
- /**
6573
- * Retrieve automation flows for a tenant organization.
6574
- */
6575
- flows<T = any>(orgId: string): Promise<T>;
6576
- /**
6577
- * Retrieve CRM statistics for a tenant organization.
6578
- */
6579
- crmStats<T = any>(orgId: string): Promise<T>;
6580
- /**
6581
- * Impersonate a tenant organization.
6582
- */
6583
- impersonate<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4206
+ declare class Support extends APIResource {
6584
4207
  /**
6585
- * Suspend a tenant organization.
4208
+ * List available support categories.
6586
4209
  */
6587
- suspend<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4210
+ categories<T = any>(): Promise<T>;
6588
4211
  /**
6589
- * Reactivate a suspended tenant organization.
4212
+ * List support tickets with optional filtering.
4213
+ *
4214
+ * @param params - Optional query parameters (status, pagination, etc.).
6590
4215
  */
6591
- reactivate<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4216
+ listTickets<T = any>(params?: Record<string, unknown>): Promise<T>;
6592
4217
  /**
6593
- * Update the plan assigned to a tenant organization.
4218
+ * Create a new support ticket.
6594
4219
  */
6595
- updatePlan<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
4220
+ createTicket<T = any>(body: Record<string, unknown>): Promise<T>;
6596
4221
  /**
6597
- * Update usage limits for a tenant organization.
4222
+ * Retrieve a single support ticket by its ID.
4223
+ *
4224
+ * @param id - The support ticket ID.
6598
4225
  */
6599
- updateLimits<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
4226
+ getTicket<T = any>(id: string): Promise<T>;
6600
4227
  /**
6601
- * Bulk-assign a plan across multiple tenant organizations.
4228
+ * Reply to an existing support ticket.
4229
+ *
4230
+ * @param id - The support ticket ID.
4231
+ * @param body - The reply payload.
6602
4232
  */
6603
- bulkAssignPlan<T = any>(body: Record<string, unknown>): Promise<T>;
4233
+ reply<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6604
4234
  /**
6605
- * List tenant organizations that have no plan assigned.
4235
+ * Close a support ticket.
4236
+ *
4237
+ * @param id - The support ticket ID.
6606
4238
  */
6607
- unassigned<T = any>(): Promise<T>;
4239
+ close<T = any>(id: string): Promise<T>;
6608
4240
  }
6609
4241
 
6610
4242
  /**
6611
- * Platform-admin tickets resource — manage support tickets, messages, and
6612
- * lifecycle transitions.
4243
+ * Current-user ("me") resource — profile, organization, modules,
4244
+ * workspaces, and active-org management.
6613
4245
  *
6614
- * Access via `ecod.platform.admin.tickets`.
4246
+ * Access via `ecod.platform.users.me`.
6615
4247
  */
6616
- declare class AdminTickets extends APIResource {
6617
- /**
6618
- * Retrieve aggregate ticket statistics.
6619
- */
6620
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4248
+ declare class Me extends APIResource {
6621
4249
  /**
6622
- * List all tickets.
4250
+ * Retrieve the current authenticated user's profile.
6623
4251
  */
6624
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4252
+ get<T = any>(): Promise<T>;
6625
4253
  /**
6626
- * Create a new ticket.
4254
+ * Update the current user's profile.
6627
4255
  */
6628
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4256
+ update<T = any>(body: Record<string, unknown>): Promise<T>;
6629
4257
  /**
6630
- * Retrieve a single ticket by ID.
4258
+ * Update the current user's active organization details.
6631
4259
  */
6632
- retrieve<T = any>(id: string): Promise<T>;
4260
+ updateOrganization<T = any>(body: Record<string, unknown>): Promise<T>;
6633
4261
  /**
6634
- * Update an existing ticket.
4262
+ * Toggle enabled modules for the current user / organization.
6635
4263
  */
6636
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4264
+ toggleModules<T = any>(body: Record<string, unknown>): Promise<T>;
6637
4265
  /**
6638
- * Add a message to a ticket.
4266
+ * List the workspaces available to the current user.
6639
4267
  */
6640
- addMessage<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4268
+ workspaces<T = any>(): Promise<T>;
6641
4269
  /**
6642
- * Resolve a ticket.
4270
+ * Set the active organization for the current user.
6643
4271
  */
6644
- resolve<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4272
+ setActiveOrg<T = any>(body: Record<string, unknown>): Promise<T>;
6645
4273
  /**
6646
- * Close a ticket.
4274
+ * Dismiss the workspace setup prompt for the current user.
6647
4275
  */
6648
- close<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4276
+ dismissWorkspaceSetup<T = any>(): Promise<T>;
6649
4277
  }
6650
-
6651
4278
  /**
6652
- * Platform-admin waitlist resource — manage waitlist entries.
4279
+ * Organization members resource — list, invite, and remove members.
6653
4280
  *
6654
- * Access via `ecod.platform.admin.waitlist`.
4281
+ * Access via `ecod.platform.users.members`.
6655
4282
  */
6656
- declare class AdminWaitlist extends APIResource {
6657
- /**
6658
- * Retrieve aggregate waitlist statistics.
6659
- */
6660
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
6661
- /**
6662
- * List waitlist entries.
6663
- */
6664
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4283
+ declare class Members extends APIResource {
6665
4284
  /**
6666
- * Retrieve a single waitlist entry by ID.
4285
+ * List all members of the current organization.
6667
4286
  */
6668
- retrieve<T = any>(id: string): Promise<T>;
4287
+ list<T = any>(): Promise<T>;
6669
4288
  /**
6670
- * Update a waitlist entry.
4289
+ * Invite a new member to the current organization.
6671
4290
  */
6672
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4291
+ invite<T = any>(body: Record<string, unknown>): Promise<T>;
6673
4292
  /**
6674
- * Remove a waitlist entry.
4293
+ * Remove a member from the current organization.
4294
+ *
4295
+ * @param id - The member ID to remove.
6675
4296
  */
6676
4297
  remove<T = any>(id: string): Promise<T>;
6677
- /**
6678
- * Perform a bulk operation on waitlist entries.
6679
- */
6680
- bulk<T = any>(body: Record<string, unknown>): Promise<T>;
6681
4298
  }
6682
-
6683
4299
  /**
6684
- * Platform-admin WhatsApp control resource — cross-tenant WhatsApp monitoring.
4300
+ * User sessions resource — list and revoke sessions.
6685
4301
  *
6686
- * Access via `ecod.platform.admin.whatsapp`.
4302
+ * Access via `ecod.platform.users.sessions`.
6687
4303
  */
6688
- declare class AdminWhatsApp extends APIResource {
6689
- /**
6690
- * Retrieve the platform-wide WhatsApp overview.
6691
- */
6692
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
6693
- /**
6694
- * List all WhatsApp Business Accounts (WABAs).
6695
- */
6696
- wabas<T = any>(params?: Record<string, unknown>): Promise<T>;
6697
- /**
6698
- * List WhatsApp message templates across tenants.
6699
- */
6700
- templates<T = any>(params?: Record<string, unknown>): Promise<T>;
4304
+ declare class Sessions extends APIResource {
6701
4305
  /**
6702
- * Retrieve WhatsApp delivery metrics.
4306
+ * List all sessions for the current user.
6703
4307
  */
6704
- delivery<T = any>(params?: Record<string, unknown>): Promise<T>;
4308
+ list<T = any>(): Promise<T>;
6705
4309
  /**
6706
- * List WhatsApp webhook events.
4310
+ * Revoke a specific session by its ID.
4311
+ *
4312
+ * @param id - The session ID to revoke.
6707
4313
  */
6708
- webhooks<T = any>(params?: Record<string, unknown>): Promise<T>;
4314
+ revoke<T = any>(id: string): Promise<T>;
6709
4315
  }
6710
4316
 
6711
4317
  /**
@@ -6723,36 +4329,34 @@ declare class AdminWhatsApp extends APIResource {
6723
4329
  * mounted v1 endpoint are wired.
6724
4330
  */
6725
4331
 
6726
- /** WhatsApp/web chat inbox (`/v1/api/product/erix/chat/*`). */
4332
+ /**
4333
+ * The unified inbox (`/v1/api/platform/inbox/*`) — every channel's threads.
4334
+ * Bulk sends are Flow campaigns (a flow run over a CRM segment), not a raw
4335
+ * broadcast API.
4336
+ */
6727
4337
  declare class ErixChat {
6728
4338
  readonly messages: Messages;
6729
4339
  readonly conversations: Conversations;
6730
- readonly broadcasts: Broadcasts;
6731
4340
  constructor(client: AxiosInstance);
6732
4341
  }
6733
4342
  /** Every ERIX product resource (`/v1/api/product/erix/*`). */
6734
4343
  declare class ErixProduct {
6735
4344
  readonly leads: Leads;
6736
4345
  readonly pipelines: Pipelines;
6737
- readonly automations: Automations;
6738
4346
  readonly activities: Activities;
6739
4347
  readonly analytics: Analytics;
6740
4348
  readonly scoring: Scoring;
6741
4349
  readonly payments: Payments;
6742
- readonly sequences: Sequences;
6743
- readonly automationDashboard: AutomationDashboard;
6744
4350
  readonly chat: ErixChat;
6745
4351
  readonly events: EventsResource;
6746
- readonly eventLog: Logs;
6747
4352
  readonly invoices: Invoices;
6748
4353
  readonly checkout: Checkout;
6749
4354
  readonly projects: ProjectDocuments;
6750
- readonly campaigns: Campaigns;
6751
- readonly portalInbox: PortalInbox;
6752
4355
  readonly niche: NicheResources;
6753
4356
  readonly documents: CRMDocuments;
6754
4357
  readonly invoiceExport: CRMInvoiceExport;
6755
- readonly crmCampaigns: CRMCampaigns;
4358
+ /** The AI agent: settings + inbox drafts. */
4359
+ readonly ai: AiAgent;
6756
4360
  constructor(client: AxiosInstance);
6757
4361
  }
6758
4362
  /** Product domain root (`/v1/api/product/*`). */
@@ -6806,52 +4410,6 @@ declare class PlatformUsers {
6806
4410
  readonly notifications: Notifications;
6807
4411
  constructor(client: AxiosInstance);
6808
4412
  }
6809
- /**
6810
- * Admin control plane (`/platform/admin/*`) — requires the elevated
6811
- * `coreApiKey`. This is the full platform-admin console surface consumed by
6812
- * the `admin` app.
6813
- */
6814
- declare class PlatformAdmin {
6815
- readonly revenue: AdminRevenue;
6816
- readonly billing: AdminBilling;
6817
- readonly payments: AdminPaymentOps;
6818
- readonly credits: AdminCredits;
6819
- readonly plans: AdminPlans;
6820
- readonly agencyInvoices: AdminAgencyInvoices;
6821
- readonly flags: AdminFeatureFlags;
6822
- readonly activityLogs: AdminActivityLogs;
6823
- readonly auditLogs: AdminAuditLogs;
6824
- readonly analytics: AdminAnalytics;
6825
- readonly health: AdminHealth;
6826
- readonly storage: AdminStorage;
6827
- readonly announcements: AdminAnnouncements;
6828
- readonly compliance: AdminCompliance;
6829
- readonly tickets: AdminTickets;
6830
- readonly templates: AdminTemplates;
6831
- readonly agents: AdminAgents;
6832
- readonly personaHistory: AdminPersonaHistory;
6833
- readonly openapi: AdminOpenApi;
6834
- readonly staff: AdminStaff;
6835
- readonly tenants: AdminTenants;
6836
- readonly whatsapp: AdminWhatsApp;
6837
- readonly laie: AdminLaie;
6838
- readonly laieRuntime: AdminLaieRuntime;
6839
- readonly laieVault: AdminLaieVault;
6840
- readonly flow: AdminFlow;
6841
- readonly email: AdminEmail;
6842
- readonly pipelines: AdminPipelines;
6843
- readonly integrations: AdminIntegrations;
6844
- readonly erix: AdminErix;
6845
- readonly dashboard: AdminDashboard;
6846
- readonly partners: AdminPartners;
6847
- readonly waitlist: AdminWaitlist;
6848
- readonly blogs: AdminBlogs;
6849
- readonly leads: AdminLeads;
6850
- readonly onboarding: AdminOnboarding;
6851
- readonly cors: Cors;
6852
- readonly clients: Services;
6853
- constructor(client: AxiosInstance);
6854
- }
6855
4413
  /** Platform control plane (`/platform/*`). */
6856
4414
  declare class PlatformDomain {
6857
4415
  readonly auth: Auth;
@@ -6860,7 +4418,8 @@ declare class PlatformDomain {
6860
4418
  readonly billing: Billing;
6861
4419
  readonly support: Support;
6862
4420
  readonly ai: PlatformAI;
6863
- readonly admin: PlatformAdmin;
4421
+ /** The AI agent's knowledge base (RAG). */
4422
+ readonly knowledge: Knowledge;
6864
4423
  readonly health: Health;
6865
4424
  constructor(client: AxiosInstance);
6866
4425
  }
@@ -6959,7 +4518,8 @@ declare class Webhooks {
6959
4518
  /**
6960
4519
  * Configuration options for the ECODrIxAPI client.
6961
4520
  *
6962
- * Minimum required: `apiKey` and `clientCode`.
4521
+ * Server-side: `apiKey` and `clientCode`. In a browser use `proxy` instead —
4522
+ * a workspace key must never ship to a browser.
6963
4523
  * The backend URL is managed internally and should not need to be changed.
6964
4524
  */
6965
4525
  interface ECODrIxAPIOptions {
@@ -6968,18 +4528,13 @@ interface ECODrIxAPIOptions {
6968
4528
  * Obtain this from the ECODrIx dashboard under Settings → API Keys.
6969
4529
  * @example "ecod_live_sk_..."
6970
4530
  */
6971
- apiKey: string;
4531
+ apiKey?: string;
6972
4532
  /**
6973
4533
  * Your tenant ID (Client Code).
6974
4534
  * This scopes all API requests to your specific organisation.
6975
4535
  * @example "ERIX_CLNT_JHBJHF"
6976
4536
  */
6977
4537
  clientCode?: string;
6978
- /**
6979
- * Optional Core API Key for deep system-level bypasses.
6980
- * Only used by elevated internal SaaS modules like Nirvisham.
6981
- */
6982
- coreApiKey?: string;
6983
4538
  /**
6984
4539
  * API route version to target. This is the ONLY knob for moving the entire
6985
4540
  * SDK to a new server API version — every endpoint is issued relative to
@@ -7010,6 +4565,27 @@ interface ECODrIxAPIOptions {
7010
4565
  * caller forever). Defaults to 30000 (30s). Set 0 to disable.
7011
4566
  */
7012
4567
  timeout?: number;
4568
+ /**
4569
+ * Browser mode — no workspace key in the page. Requests go to YOUR server
4570
+ * route at `url` (it checks your signed-in user, adds `x-api-key` /
4571
+ * `x-client-code`, and forwards `<url>/<version>/api/*` to ECODrIx). For
4572
+ * realtime, `ticket` returns a short-lived socket ticket your server gets
4573
+ * from `POST /v1/api/platform/realtime/ticket`; without it no socket opens.
4574
+ *
4575
+ * @example
4576
+ * ```typescript
4577
+ * new ECODrIxAPI({
4578
+ * proxy: {
4579
+ * url: "/api/erix",
4580
+ * ticket: () => fetch("/api/erix/ticket").then((r) => r.text()),
4581
+ * },
4582
+ * });
4583
+ * ```
4584
+ */
4585
+ proxy?: {
4586
+ url: string;
4587
+ ticket?: () => Promise<string>;
4588
+ };
7013
4589
  }
7014
4590
  /**
7015
4591
  * The primary entry point for the ECODrIx SDK.
@@ -7081,6 +4657,8 @@ declare class ECODrIxAPI {
7081
4657
  * @param roomId - The unique identifier for the room.
7082
4658
  */
7083
4659
  leaveRoom(roomId: string): void;
4660
+ /** Highest event `seq` seen — sent on reconnect so missed events replay. */
4661
+ private lastSeq;
7084
4662
  private setupSocket;
7085
4663
  /**
7086
4664
  * Subscribe to a real-time event emitted by the ECODrIx platform.
@@ -7090,14 +4668,24 @@ declare class ECODrIxAPI {
7090
4668
  * your own tenant.
7091
4669
  *
7092
4670
  * **Standard events:**
7093
- * - `new_message` — inbound WhatsApp message (includes conversation and message payload)
7094
- * - `message_sent` — outbound message successfully sent
7095
- * - `message_status_update` — WhatsApp message status change (delivered, read, failed)
7096
- * - `conversation_updated` — metadata change (unread count, last message, status)
7097
- * - `message_updated` — real-time updates for reactions or media processing
7098
- * - `notification:new` — new system or CRM notification
4671
+ * - `inbox.message` — `{ conversationId, message }` for EVERY message the
4672
+ * inbox stores: any channel, inbound or outbound, sent by anyone
4673
+ * (customer, agent, Flow, the AI). The one event an inbox needs.
4674
+ * - `message_status_update` — `{ messageId, conversationId, status }`
4675
+ * (sent → delivered → read, or failed)
4676
+ * - `new_message` / `message_sent` / `conversation_updated` /
4677
+ * `message_updated` — WhatsApp-specific detail (reactions, media)
4678
+ * - `ai_suggestion` — an AI draft is waiting on a conversation
4679
+ * - `ai_handoff` — `{ conversationId, reason }`: the AI handed a chat to a person
4680
+ * - `platform:notification` / `platform:notification_count` — notifications
4681
+ * - `knowledge.source_updated` / `knowledge.source_removed` — knowledge base
7099
4682
  * - `workflow-run-update` — automation execution progress
7100
- * - `meet.scheduled` — Google Meet appointment booked
4683
+ * - `resync` — after a reconnect the server couldn't replay everything that
4684
+ * was missed (gap too old/large): refetch your data.
4685
+ *
4686
+ * Every event's last argument is `{ seq }` (plus `replay: true` when it was
4687
+ * re-sent after a reconnect). A replay can repeat an event you already got,
4688
+ * so make handlers idempotent (e.g. upsert by id).
7101
4689
  *
7102
4690
  * @param event - The event name to subscribe to.
7103
4691
  * @param callback - The handler function invoked when the event fires.
@@ -7121,6 +4709,7 @@ declare class ECODrIxAPI {
7121
4709
  * process.on("SIGTERM", () => ecod.disconnect());
7122
4710
  * ```
7123
4711
  */
4712
+ private closed;
7124
4713
  disconnect(): void;
7125
4714
  /**
7126
4715
  * Remove a previously registered event listener.
@@ -7513,4 +5102,4 @@ declare function getRetryConfig(error: any): {
7513
5102
  readonly reason: "Generic API errors may be transient and worth retrying";
7514
5103
  };
7515
5104
 
7516
- export { type AIPersona, APIError, AdminOnboarding, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, AuthenticationError, type BehaviorRules, type Broadcast, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateBroadcastParams, type CreateLeadParams, type CreateNichePackPayload, type CreateOnboardingConfigPayload, type CreateOnboardingExperimentPayload, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG, EcodrixError, type EditOnboardingPayload, type EditOnboardingResponse, type EmailConfig, EmailConnect, ErixChat, ErixProduct, type FieldConfig, type FieldDefinition, type FieldManifest, type FieldType, type FileConfig, type FilterOperator, type FilterRule, type ForkNichePackPayload, type FormulaConfig, type GlobalOnboardingPayload, HTTP_STATUS_ERROR_MAP, type ICP, InfraDomain, LEAD_STATUS_VALUES, type LayoutType, type Lead, type LeadPattern, type LeadSource, type LeadStatus, type LearningMemory, type ListLeadsParams, type ListNichePacksParams, type ListNichePacksResponse, type ListOnboardingConfigsParams, type ListOnboardingExperimentsParams, type ListOnboardingExperimentsResponse, type ManifestFieldType, type MappingField, type MappingPreviewResult, type MappingSources, type MappingValidationResult, type Message, type NichePack, type NichePackResearchConfig, type NichePackResponse, type NichePackStatus, type NichePackSummary, type NormalizedFieldValue, type NumberConfig, Onboarding, type OnboardingAbandonmentResponse, type OnboardingAbandonmentResult, type OnboardingAbandonmentRow, type OnboardingAnalyticsFiltersParams, type OnboardingCohortRange, type OnboardingConfig, type OnboardingExperiment, type OnboardingExperimentResponse, type OnboardingExperimentStatus, type OnboardingExperimentVariant, type OnboardingFunnelResponse, type OnboardingFunnelResult, type OnboardingFunnelStep, type OnboardingMemoryMapping, type OnboardingOption, type OnboardingSession, type OnboardingSessionStatus, type OnboardingStateResponse, type OnboardingStep, type OnboardingStepType, type OnboardingTimeOnStepResponse, type OnboardingTimeOnStepResult, type OnboardingTimeOnStepRow, type OutreachEdit, type PaginatedResponse, Persona, type PersonaFollowupQuestion, type PersonaFollowupsResponse, type PersonaIdentity, type PersonaTimelineEntry, type PersonaTimelineOptions, type PersonaTimelineResponse, type PhoneConfig, type Pipeline, type PipelineStage, type PipelineStageParams, PlatformAdmin, PlatformDomain, PlatformTenants, PlatformUsers, ProductDomain, type ProgressConfig, RateLimitError, type RatingConfig, type ReinforceResponse, type ReinforcementEvent, type RelationConfig, type RelationValue, type ResourceManifest, type SendMessageParams, type ServiceConfig, type ServiceConfigGlobal, type ServiceConfigPerProduct, type SmokeTestMaterializerAction, type SmokeTestNichePackPayload, type SmokeTestResult, type SortRule, type StartOnboardingPayload, type StartOnboardingResponse, StorageInfra, type StoredFieldValue, type SuggestionEvent, type TagsConfig, type Template, type TemplateApiResponse, type TemplateBinding, type TemplateBindingSource, type TemplateComponent, type TemplateEmptyPolicy, type TemplateMapping, type TextConfig, type UpdateNichePackPayload, type UpdateOnboardingConfigPayload, type UpdateOnboardingExperimentPayload, type UpsertLeadParams, type UrlConfig, type VerifyPayload, type ViewConfig, type Vocabulary, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError };
5105
+ export { type AIPersona, APIError, APIResource, AiAgent, type AiAgentSettings, type AiAgentTool, type AiSuggestion, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, AuthenticationError, type BehaviorRules, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateLeadParams, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG, EcodrixError, type EditOnboardingPayload, type EditOnboardingResponse, type EmailConfig, EmailConnect, ErixChat, ErixProduct, type FieldConfig, type FieldDefinition, type FieldManifest, type FieldType, type FileConfig, type FilterOperator, type FilterRule, type FormulaConfig, type GlobalOnboardingPayload, HTTP_STATUS_ERROR_MAP, type ICP, type InboxChannel, InfraDomain, KNOWLEDGE_FILE_TYPES, Knowledge, type KnowledgePassage, type KnowledgeSource, LEAD_STATUS_VALUES, type LayoutType, type Lead, type LeadPattern, type LeadSource, type LeadStatus, type LearningMemory, type ListLeadsParams, type ManifestFieldType, type MappingField, type MappingPreviewResult, type MappingSources, type MappingValidationResult, type Message, type NichePack, type NichePackResearchConfig, type NichePackStatus, type NormalizedFieldValue, type NumberConfig, Onboarding, type OnboardingCohortRange, type OnboardingConfig, type OnboardingExperiment, type OnboardingExperimentStatus, type OnboardingExperimentVariant, type OnboardingMemoryMapping, type OnboardingOption, type OnboardingSession, type OnboardingSessionStatus, type OnboardingStateResponse, type OnboardingStep, type OnboardingStepType, type OutboundMedia, type OutreachEdit, type PaginatedResponse, type PausedRun, Persona, type PersonaFollowupQuestion, type PersonaFollowupsResponse, type PersonaIdentity, type PersonaTimelineEntry, type PersonaTimelineOptions, type PersonaTimelineResponse, type PhoneConfig, type Pipeline, type PipelineStage, type PipelineStageParams, PlatformDomain, PlatformTenants, PlatformUsers, ProductDomain, type ProgressConfig, RateLimitError, type RatingConfig, type ReinforceResponse, type ReinforcementEvent, type RelationConfig, type RelationValue, type RequestOptions, type ResourceManifest, type SendMessageParams, type SendTemplateParams, type ServiceConfig, type ServiceConfigGlobal, type ServiceConfigPerProduct, type SortRule, type StartOnboardingPayload, type StartOnboardingResponse, StorageInfra, type StoredFieldValue, type SuggestionEvent, type TagsConfig, type Template, type TemplateApiResponse, type TemplateBinding, type TemplateBindingSource, type TemplateComponent, type TemplateEmptyPolicy, type TemplateMapping, type TextConfig, type UpsertLeadParams, type UrlConfig, type VerifyPayload, type ViewConfig, type Vocabulary, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError };