@ecodrix/erix-api 2.1.4 → 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
@@ -2789,9 +2066,65 @@ interface Template {
2789
2066
  status: "APPROVED" | "PENDING" | "REJECTED";
2790
2067
  components: TemplateComponent[];
2791
2068
  }
2069
+ type TemplateBindingSource = "crm" | "trigger" | "system" | "manual" | "static" | "computed";
2070
+ type TemplateEmptyPolicy = "use_fallback" | "error" | "empty_string";
2071
+ interface TemplateBinding {
2072
+ token?: string;
2073
+ position: number;
2074
+ source: TemplateBindingSource;
2075
+ collection?: string;
2076
+ field?: string;
2077
+ staticValue?: string;
2078
+ formula?: string;
2079
+ transform?: string;
2080
+ fallback?: string;
2081
+ required?: boolean;
2082
+ label?: string;
2083
+ componentType?: string;
2084
+ componentIndex?: number;
2085
+ originalIndex?: string | number;
2086
+ }
2792
2087
  interface TemplateMapping {
2793
- mappings: any[];
2794
- onEmptyVariable: string;
2088
+ mappings: TemplateBinding[];
2089
+ onEmptyVariable: TemplateEmptyPolicy;
2090
+ }
2091
+ interface MappingField {
2092
+ key: string;
2093
+ label: string;
2094
+ type?: string;
2095
+ dataType?: string;
2096
+ }
2097
+ interface MappingSources {
2098
+ collections: Array<{
2099
+ name: string;
2100
+ label: string;
2101
+ fields: MappingField[];
2102
+ }>;
2103
+ triggers: Array<{
2104
+ name: string;
2105
+ label: string;
2106
+ fields: MappingField[];
2107
+ }>;
2108
+ system: MappingField[];
2109
+ static: {
2110
+ hint: string;
2111
+ };
2112
+ }
2113
+ interface TemplateApiResponse<T> {
2114
+ success: boolean;
2115
+ data: T;
2116
+ message?: string;
2117
+ error?: string;
2118
+ }
2119
+ interface MappingValidationResult {
2120
+ isReady: boolean;
2121
+ mappingCount: number;
2122
+ }
2123
+ interface MappingPreviewResult {
2124
+ isReady: boolean;
2125
+ resolvedVariables: string[];
2126
+ previewText: string;
2127
+ contextSnapshot?: Record<string, unknown>;
2795
2128
  }
2796
2129
  declare class Templates extends APIResource {
2797
2130
  /**
@@ -2873,8 +2206,10 @@ declare class Templates extends APIResource {
2873
2206
  * ```
2874
2207
  */
2875
2208
  mappingConfig<T = any>(): Promise<T>;
2209
+ /** Tenant-scoped CRM, custom-field, automation, and system mapping sources. */
2210
+ mappingSources<T = MappingSources>(): Promise<TemplateApiResponse<T>>;
2876
2211
  /**
2877
- * List CRM collections available for variable mapping (Leads, Deals, etc.).
2212
+ * List CRM collections available for variable mapping (legacy).
2878
2213
  */
2879
2214
  collections<T = any>(): Promise<T>;
2880
2215
  /**
@@ -2889,27 +2224,17 @@ declare class Templates extends APIResource {
2889
2224
  * @param templateName - Name of the template.
2890
2225
  * @param payload - Mapping definitions.
2891
2226
  */
2892
- updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
2893
- /**
2894
- * Validate if a template is ready for automated sending based on its mappings.
2895
- */
2896
- validate<T = any>(templateName: string): Promise<T>;
2227
+ updateMapping<T = unknown>(templateName: string, payload: TemplateMapping): Promise<TemplateApiResponse<T>>;
2228
+ /** Validate a persisted mapping, or a draft mapping before saving. */
2229
+ validate<T = MappingValidationResult>(templateName: string, draft?: TemplateMapping): Promise<TemplateApiResponse<T>>;
2897
2230
  /**
2898
- * Preview a template resolution with sample data.
2899
- *
2900
- * @param templateName - Name of the template.
2901
- * @param context - Lead data or variable overrides for preview.
2902
- * @example
2903
- * ```typescript
2904
- * const preview = await erixClient.whatsapp.templates.preview("welcome", {
2905
- * lead: { firstName: "Alice" }
2906
- * });
2907
- * ```
2231
+ * Preview a template resolution with caller-provided sample data.
2232
+ * Draft mappings are validated server-side and are never persisted.
2908
2233
  */
2909
- preview<T = any>(templateName: string, context: {
2910
- lead?: any;
2911
- vars?: any;
2912
- }): Promise<T>;
2234
+ preview<T = MappingPreviewResult>(templateName: string, context: {
2235
+ lead?: Record<string, unknown>;
2236
+ vars?: Record<string, unknown>;
2237
+ }, mappings?: TemplateBinding[], onEmptyVariable?: TemplateEmptyPolicy): Promise<TemplateApiResponse<T>>;
2913
2238
  /**
2914
2239
  * Introspect a template and provide a manifest of its required variables.
2915
2240
  *
@@ -2919,10 +2244,6 @@ declare class Templates extends APIResource {
2919
2244
  * @param templateIdentifier - The name or ID of the template.
2920
2245
  */
2921
2246
  getVariableManifest(templateIdentifier: string): Promise<ResourceManifest>;
2922
- /**
2923
- * Check which automations or sequences are currently using this template.
2924
- */
2925
- checkUsage<T = any>(templateName: string): Promise<T>;
2926
2247
  }
2927
2248
 
2928
2249
  /**
@@ -3106,10 +2427,6 @@ declare class Folders extends APIResource {
3106
2427
  * ```
3107
2428
  */
3108
2429
  create<T = any>(name: string): Promise<T>;
3109
- /**
3110
- * Delete a folder and its contents.
3111
- */
3112
- delete<T = any>(folderPath: string): Promise<T>;
3113
2430
  }
3114
2431
  declare class Files extends APIResource {
3115
2432
  /**
@@ -3163,27 +2480,104 @@ declare class Files extends APIResource {
3163
2480
  delete(key: string): Promise<unknown>;
3164
2481
  }
3165
2482
 
2483
+ interface SystemHealth {
2484
+ status: string;
2485
+ version: string;
2486
+ env: string;
2487
+ uptime: number;
2488
+ db: string;
2489
+ queueDepth: number;
2490
+ timestamp: string;
2491
+ }
3166
2492
  /**
3167
- * Adaptive Onboarding type definitions.
3168
- *
3169
- * These types mirror the Postgres data shapes from the
3170
- * `adaptive-onboarding-ai-persona` spec — see
3171
- * `.kiro/specs/adaptive-onboarding-ai-persona/design.md` §"Data Models" and
3172
- * §"Onboarding engine".
2493
+ * Platform health diagnostics.
3173
2494
  *
3174
- * NO RUNTIME CODE. Types only. Both saas (Next.js) and server (Express)
3175
- * import from here so the wire shape stays in lockstep.
3176
- */
3177
- /**
3178
- * Renderable step kinds. The saas selects the appropriate React component
3179
- * from `components/onboarding/steps/*` based on this discriminator.
2495
+ * Access via `ecod.platform.health`.
3180
2496
  */
3181
- type OnboardingStepType = "single_choice" | "multi_choice" | "text_input" | "ai_summary_confirm" | "feature_preview" | "completion";
2497
+ declare class Health extends APIResource {
2498
+ /**
2499
+ * Global platform health check — verifies the core API is operational.
2500
+ * Public endpoint: `GET /health`.
2501
+ */
2502
+ system(): Promise<SystemHealth>;
2503
+ }
2504
+
3182
2505
  /**
3183
- * One selectable answer option in a `single_choice` / `multi_choice` step.
3184
- */
3185
- interface OnboardingOption {
3186
- /** Internal value persisted in `session.answers[stepId]`. */
2506
+ * Automation event log and provider callback resource.
2507
+ *
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]`. */
3187
2581
  value: string;
3188
2582
  /** Human-readable label shown to the user. */
3189
2583
  label: string;
@@ -3597,6 +2991,135 @@ interface NichePack {
3597
2991
  researchConfig?: NichePackResearchConfig;
3598
2992
  }
3599
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
+
3600
3123
  /**
3601
3124
  * Identity block — who the user is, what they sell, where they operate.
3602
3125
  * Stored at `ecodrix_ai_personas.identity` (JSONB).
@@ -4214,2450 +3737,581 @@ declare class Persona extends APIResource {
4214
3737
  }
4215
3738
 
4216
3739
  /**
4217
- * Admin-side onboarding resource.
4218
- *
4219
- * Mounted on the main client as `ecod.adminOnboarding`. Mirrors the
4220
- * platform-admin endpoints under `/platform/admin/onboarding/*`
4221
- * documented in `server/src/platform/routes/admin/onboarding.routes.ts`.
4222
- *
4223
- * Auth: every method requires the elevated platform `coreApiKey`. The
4224
- * SDK forwards it as `x-core-api-key`; admin server-side callers should
4225
- * always construct a client with `coreApiKey` set (see
4226
- * `admin/src/lib/client/erix-admin.ts`).
4227
- *
4228
- * Endpoints covered in this build (task 4.1.1 — list page):
4229
- *
4230
- * - GET /platform/admin/onboarding/niche-packs list
4231
- * - GET /platform/admin/onboarding/niche-packs/:slug fetch one
4232
- * - POST /platform/admin/onboarding/niche-packs create
4233
- * - PATCH /platform/admin/onboarding/niche-packs/:slug update
4234
- * - POST /platform/admin/onboarding/niche-packs/:slug/publish publish
4235
- * - POST /platform/admin/onboarding/niche-packs/:slug/unpublish back to draft
4236
- * - POST /platform/admin/onboarding/niche-packs/:slug/fork new draft copy
4237
- * - GET /platform/admin/onboarding/configs list configs
4238
- * - POST /platform/admin/onboarding/configs create config
4239
- * - PATCH /platform/admin/onboarding/configs/:productId/:version update
4240
- * - POST /platform/admin/onboarding/configs/:productId/:version/publish publish
4241
- *
4242
- * Endpoints for A/B onboarding experiments (task 4.2.2):
4243
- *
4244
- * - GET /platform/admin/onboarding/experiments list
4245
- * - GET /platform/admin/onboarding/experiments/:slug fetch one
4246
- * - POST /platform/admin/onboarding/experiments create draft
4247
- * - PATCH /platform/admin/onboarding/experiments/:slug partial update
4248
- * - DELETE /platform/admin/onboarding/experiments/:slug hard-delete
3740
+ * Copilot resource — synchronous chat, confirmation, and session management.
4249
3741
  *
4250
- * Successive admin tasks (4.1.2–4.1.5) layer richer editor / fork /
4251
- * publish flows on top of these primitives.
3742
+ * Access via `ecod.platform.ai.copilot`.
4252
3743
  */
4253
-
4254
- /** Niche pack row as returned by the admin list endpoint. */
4255
- interface NichePackSummary {
4256
- id: string;
4257
- slug: string;
4258
- productId: NichePack["productId"];
4259
- version: string;
4260
- status: NichePackStatus;
4261
- /** ISO 8601 — creation timestamp (server clock). */
4262
- createdAt: string;
4263
- /** ISO 8601 — last edit timestamp. */
4264
- updatedAt: string;
4265
- /** ISO 8601 — first time `status` flipped to `published`. */
4266
- publishedAt?: string | null;
4267
- /** Admin staff id who created this version. */
4268
- createdBy?: string | null;
4269
- }
4270
- /** Filters accepted by `adminOnboarding.listNichePacks`. */
4271
- interface ListNichePacksParams {
4272
- /** Restrict to a single product family. */
4273
- productId?: NichePack["productId"];
4274
- /** Restrict to one lifecycle status. */
4275
- status?: NichePackStatus;
3744
+ declare class Copilot extends APIResource {
4276
3745
  /**
4277
- * Free-form fuzzy search. Matched (case-insensitive) against `slug`
4278
- * and `productId`. Whitespace is trimmed.
3746
+ * Send a synchronous (non-streaming) chat message to the copilot.
4279
3747
  */
4280
- search?: string;
4281
- /** Page size — server clamps to 1..100, default 25. */
4282
- limit?: number;
4283
- /** Pagination offset, default 0. */
4284
- offset?: number;
4285
- }
4286
- /** Body accepted by the create-pack endpoint. */
4287
- interface CreateNichePackPayload {
4288
- slug: string;
4289
- productId: NichePack["productId"];
4290
- /** Defaults to `"1.0.0"` server-side. */
4291
- version?: string;
4292
- onboardingConfig?: Record<string, unknown>;
4293
- workspaceProfile?: Record<string, unknown>;
4294
- researchConfig?: Record<string, unknown>;
4295
- }
4296
- /** Body accepted by the update-pack endpoint. At least one field required. */
4297
- interface UpdateNichePackPayload {
4298
- status?: NichePackStatus;
4299
- onboardingConfig?: Record<string, unknown>;
4300
- workspaceProfile?: Record<string, unknown>;
4301
- researchConfig?: Record<string, unknown>;
4302
- }
4303
- /** Body accepted by the fork-pack endpoint. */
4304
- interface ForkNichePackPayload {
4305
- /** Source version to clone; defaults to the latest row for the slug. */
4306
- fromVersion?: string;
4307
- /** Target version for the new draft; defaults to a server-side bump. */
4308
- version?: string;
4309
- }
4310
- /**
4311
- * Body accepted by `adminOnboarding.smokeTestNichePack` (task 4.1.5).
4312
- *
4313
- * Both fields are optional:
4314
- *
4315
- * - `fromVersion` pins a specific row for the slug; without it the
4316
- * server picks the most recent (typically the latest draft).
4317
- * - `answers` is a `{ stepId: value }` map. When omitted (or missing
4318
- * keys for some steps) the in-memory runner auto-picks the first
4319
- * option of `single_choice` / `multi_choice` steps and uses a
4320
- * placeholder for `text_input`.
4321
- */
4322
- interface SmokeTestNichePackPayload {
4323
- fromVersion?: string;
4324
- answers?: Record<string, unknown>;
4325
- }
4326
- /**
4327
- * One materializer action the live `workspaceShaper.materialize` call
4328
- * WOULD perform if the smoke-tested pack were used in a real
4329
- * onboarding-complete flow. The summary string is what the admin
4330
- * panel renders verbatim ("Would create pipeline 'Patient Journey'
4331
- * with 5 stages").
4332
- */
4333
- type SmokeTestMaterializerAction = {
4334
- kind: "pipeline";
4335
- name: string;
4336
- stageCount: number;
4337
- isDefault: boolean;
4338
- summary: string;
4339
- } | {
4340
- kind: "field";
4341
- key: string;
4342
- label: string;
4343
- type: string;
4344
- required: boolean;
4345
- summary: string;
4346
- } | {
4347
- kind: "automation";
4348
- name: string;
4349
- trigger: string;
4350
- enabled: boolean;
4351
- summary: string;
4352
- };
4353
- /**
4354
- * Result envelope returned by `adminOnboarding.smokeTestNichePack`.
4355
- *
4356
- * Mirrors `SmokeTestResult` in
4357
- * `server/src/erix/services/onboarding/smokeTestRunner.ts`.
4358
- */
4359
- interface SmokeTestResult {
4360
- /** In-memory `OnboardingSession` produced by the simulator. */
4361
- session: OnboardingSession;
4362
- /** Persona shaped from the answers + memory mappings. */
4363
- persona: AIPersona;
4364
- /** Workspace profile produced by `workspaceShaper.produce`. */
4365
- workspaceProfile: WorkspaceProfile;
4366
- /** Actions the live materializer would perform. */
4367
- materializerActions: SmokeTestMaterializerAction[];
4368
- /** Wall-clock duration (millis) of the simulation. */
4369
- durationMs: number;
4370
- /** Step ids the engine visited (in order). */
4371
- visitedStepIds: string[];
4372
- /** Step ids the engine skipped via branching predicates. */
4373
- skippedStepIds: string[];
4374
- /** Whether the runner had to auto-pick at least one answer. */
4375
- autoPicked: boolean;
4376
- }
4377
- /** Standard `{ success, data }` envelope used by every admin endpoint. */
4378
- interface ApiEnvelope<T> {
4379
- success: boolean;
4380
- data: T;
4381
- }
4382
- /** Envelope returned by `GET /platform/admin/onboarding/niche-packs`. */
4383
- interface ListNichePacksResponse extends ApiEnvelope<NichePackSummary[]> {
3748
+ chatSync<T = any>(body: Record<string, unknown>): Promise<T>;
4384
3749
  /**
4385
- * Total niche-pack rows matching the current filter set, ignoring
4386
- * the page window. Drives the saas-side paginator. Falls back to
4387
- * `data.length` when the server can't compute a true count.
3750
+ * Confirm a pending copilot action.
4388
3751
  */
4389
- total: number;
4390
- }
4391
- /** Envelope returned by single-pack endpoints (get / create / update / fork). */
4392
- type NichePackResponse = ApiEnvelope<NichePack & NichePackSummary>;
4393
- /** Filters accepted by `adminOnboarding.listOnboardingConfigs`. */
4394
- interface ListOnboardingConfigsParams {
4395
- productId?: OnboardingConfig["productId"];
4396
- status?: NichePackStatus;
4397
- }
4398
- /** Body accepted by the create-config endpoint. */
4399
- interface CreateOnboardingConfigPayload {
4400
- productId: OnboardingConfig["productId"];
4401
- version?: string;
4402
- config?: Record<string, unknown>;
4403
- }
4404
- /** Body accepted by the update-config endpoint. */
4405
- interface UpdateOnboardingConfigPayload {
4406
- status?: NichePackStatus;
4407
- config?: Record<string, unknown>;
4408
- }
4409
- /** Filters accepted by `adminOnboarding.listOnboardingExperiments`. */
4410
- interface ListOnboardingExperimentsParams {
4411
- productId?: OnboardingExperiment["productId"];
4412
- status?: OnboardingExperimentStatus;
4413
- /** Page size — server clamps to 1..100, default 25. */
4414
- limit?: number;
4415
- /** Pagination offset, default 0. */
4416
- offset?: number;
4417
- } /** Body accepted by the create-experiment endpoint. */
4418
- interface CreateOnboardingExperimentPayload {
4419
- /** Admin-facing handle; unique platform-wide. */
4420
- slug: string;
4421
- productId: OnboardingExperiment["productId"];
4422
- /** Display name shown in the admin panel. */
4423
- name: string;
4424
- description?: string;
4425
- /** Defaults to `"draft"` server-side. */
4426
- status?: OnboardingExperimentStatus;
4427
- /**
4428
- * Variant routing table — may be empty for a freshly created
4429
- * draft. Variants whose `cohortRange` overlaps are rejected with
4430
- * `OVERLAPPING_VARIANTS`.
4431
- */
4432
- variants?: OnboardingExperimentVariant[];
4433
- /** Fallback config version when no variant matches the user's bucket. */
4434
- controlConfigVersion?: string | null;
4435
- }
4436
- /** Body accepted by the patch-experiment endpoint. */
4437
- interface UpdateOnboardingExperimentPayload {
4438
- name?: string;
4439
- description?: string | null;
4440
- status?: OnboardingExperimentStatus;
4441
- variants?: OnboardingExperimentVariant[];
4442
- controlConfigVersion?: string | null;
4443
- }
4444
- /** Envelope returned by `GET /platform/admin/onboarding/experiments`. */
4445
- interface ListOnboardingExperimentsResponse extends ApiEnvelope<OnboardingExperiment[]> {
4446
- /**
4447
- * Total experiments matching the current filter set, ignoring the
4448
- * page window. Drives the saas-side paginator. Falls back to
4449
- * `data.length` when the server can't compute a true count.
4450
- */
4451
- total: number;
4452
- }
4453
- /** Envelope returned by single-experiment endpoints. */
4454
- type OnboardingExperimentResponse = ApiEnvelope<OnboardingExperiment>;
4455
- /**
4456
- * Filters accepted by every analytics endpoint
4457
- * (`getOnboardingFunnel`, `getOnboardingTimeOnStep`,
4458
- * `getOnboardingAbandonment`).
4459
- *
4460
- * `productId` constrains by product family, `nicheSubtype` by the
4461
- * `nichePackSlug` recorded on the originating session row. `fromDate`
4462
- * / `toDate` are wire-side ISO 8601 strings (the server coerces them
4463
- * via Zod's `z.coerce.date()`); when omitted, the server defaults to
4464
- * the trailing 30 days. The server hard-caps the requested window at
4465
- * 180 days and rejects `fromDate >= toDate` with 400 INVALID_FIELD.
4466
- */
4467
- interface OnboardingAnalyticsFiltersParams {
4468
- productId?: "crm" | "laie" | "flow" | string;
4469
- nicheSubtype?: string;
4470
- /** ISO 8601 datetime, e.g. `"2025-01-01T00:00:00.000Z"`. */
4471
- fromDate?: string;
4472
- /** ISO 8601 datetime. */
4473
- toDate?: string;
4474
- }
4475
- /** One funnel row — distinct sessions that reached `stepId`. */
4476
- interface OnboardingFunnelStep {
4477
- productId: string;
4478
- nichePackSlug: string | null;
4479
- stepId: string;
4480
- /** Distinct sessions that emitted at least one event for this step. */
4481
- sessions: number;
4482
- /**
4483
- * Fraction `[0, 1]` of sessions that reached this step relative to
4484
- * the first step in the same `(productId, nichePackSlug)` flow.
4485
- * The first step always has `conversionRate = 1`.
4486
- */
4487
- conversionRate: number;
4488
- }
4489
- /** Result envelope for `getOnboardingFunnel`. */
4490
- interface OnboardingFunnelResult {
4491
- /** Flat list, ordered by `(productId, nichePackSlug, sessions DESC)`. */
4492
- funnel: OnboardingFunnelStep[];
4493
- /** Distinct sessions across all rows in the window. */
4494
- totalSessions: number;
4495
- }
4496
- /** One time-on-step row — per `(productId, nichePackSlug, stepId)`. */
4497
- interface OnboardingTimeOnStepRow {
4498
- productId: string;
4499
- nichePackSlug: string | null;
4500
- stepId: string;
4501
- /** Median (p50) milliseconds from `stepId` first event → next step. */
4502
- medianMs: number;
4503
- /** p95 milliseconds. */
4504
- p95Ms: number;
4505
- /** Number of (session, step) pairs that contributed a delta. */
4506
- sampleSize: number;
4507
- }
4508
- /** Result envelope for `getOnboardingTimeOnStep`. */
4509
- interface OnboardingTimeOnStepResult {
4510
- rows: OnboardingTimeOnStepRow[];
4511
- }
4512
- /** One abandonment bucket — abandoned sessions whose last seen step was `stepId`. */
4513
- interface OnboardingAbandonmentRow {
4514
- productId: string;
4515
- nichePackSlug: string | null;
4516
- stepId: string;
4517
- abandonedSessions: number;
4518
- }
4519
- /** Result envelope for `getOnboardingAbandonment`. */
4520
- interface OnboardingAbandonmentResult {
4521
- rows: OnboardingAbandonmentRow[];
4522
- totalAbandoned: number;
4523
- }
4524
- /** `{ success, data: OnboardingFunnelResult }`. */
4525
- type OnboardingFunnelResponse = ApiEnvelope<OnboardingFunnelResult>;
4526
- /** `{ success, data: OnboardingTimeOnStepResult }`. */
4527
- type OnboardingTimeOnStepResponse = ApiEnvelope<OnboardingTimeOnStepResult>;
4528
- /** `{ success, data: OnboardingAbandonmentResult }`. */
4529
- type OnboardingAbandonmentResponse = ApiEnvelope<OnboardingAbandonmentResult>;
4530
- /**
4531
- * Admin-side onboarding control plane.
4532
- *
4533
- * @example
4534
- * ```typescript
4535
- * const { data, total } = await ecod.adminOnboarding.listNichePacks({
4536
- * productId: "crm",
4537
- * status: "published",
4538
- * search: "clinic",
4539
- * limit: 25,
4540
- * offset: 0,
4541
- * });
4542
- * ```
4543
- */
4544
- declare class AdminOnboarding extends APIResource {
4545
- /**
4546
- * List niche packs with optional filtering, search, and pagination.
4547
- * Server response shape: `{ success, data, total }`.
4548
- */
4549
- listNichePacks(params?: ListNichePacksParams): Promise<ListNichePacksResponse>;
4550
- /** Fetch a single niche pack by slug. Without `version` returns the latest. */
4551
- getNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4552
- /** Create a new niche pack draft. */
4553
- createNichePack(payload: CreateNichePackPayload): Promise<NichePackResponse>;
4554
- /** Patch a draft niche pack. Server enforces "at least one field". */
4555
- updateNichePack(slug: string, payload: UpdateNichePackPayload, version?: string): Promise<NichePackResponse>;
4556
- /** Flip a niche pack to `published`. */
4557
- publishNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4558
- /** Flip a niche pack back to `draft`. */
4559
- unpublishNichePack(slug: string, version?: string): Promise<NichePackResponse>;
4560
- /** Fork an existing niche pack into a new draft version. */
4561
- forkNichePack(slug: string, payload?: ForkNichePackPayload): Promise<NichePackResponse>;
4562
- /**
4563
- * Run an in-memory smoke test against a niche pack (task 4.1.5).
4564
- *
4565
- * The server resolves the pack row, walks its `onboardingConfig`
4566
- * with the supplied (or auto-picked) answers, shapes a persona
4567
- * + workspace profile, and returns the result without writing
4568
- * anything. Useful for admins to validate a draft pack before
4569
- * publishing.
4570
- *
4571
- * @param slug - Niche pack slug.
4572
- * @param payload - Optional `{ fromVersion?, answers? }`. Both
4573
- * fields are independently optional; `version` (the legacy
4574
- * query-string equivalent) is also supported as a third
4575
- * argument for parity with the other slug-keyed methods.
4576
- * @param version - Optional version override applied as a
4577
- * `?version=` query param (kept for callers that already
4578
- * thread version through the URL).
4579
- */
4580
- smokeTestNichePack(slug: string, payload?: SmokeTestNichePackPayload, version?: string): Promise<ApiEnvelope<SmokeTestResult>>;
4581
- listOnboardingConfigs(params?: ListOnboardingConfigsParams): Promise<ApiEnvelope<unknown[]>>;
4582
- createOnboardingConfig(payload: CreateOnboardingConfigPayload): Promise<ApiEnvelope<unknown>>;
4583
- updateOnboardingConfig(productId: OnboardingConfig["productId"], version: string, payload: UpdateOnboardingConfigPayload): Promise<ApiEnvelope<unknown>>;
4584
- publishOnboardingConfig(productId: OnboardingConfig["productId"], version: string): Promise<ApiEnvelope<unknown>>;
4585
- /**
4586
- * List onboarding A/B experiments with optional filters and
4587
- * pagination. Server response shape: `{ success, data, total }`.
4588
- */
4589
- listOnboardingExperiments(params?: ListOnboardingExperimentsParams): Promise<ListOnboardingExperimentsResponse>;
4590
- /** Fetch a single experiment by its slug. 404 when absent. */
4591
- getOnboardingExperiment(slug: string): Promise<OnboardingExperimentResponse>;
4592
- /**
4593
- * Create a draft experiment. The server enforces:
4594
- *
4595
- * - `slug` non-empty + globally unique.
4596
- * - `productId ∈ {crm, laie, flow}`.
4597
- * - `variants` is an array (may be empty for a draft).
4598
- * - Each variant's `cohortRange.from < cohortRange.to`, both in
4599
- * `[0, 100]`.
4600
- * - Variants don't overlap (returns 400 `OVERLAPPING_VARIANTS`).
4601
- */
4602
- createOnboardingExperiment(payload: CreateOnboardingExperimentPayload): Promise<OnboardingExperimentResponse>;
4603
- /**
4604
- * Patch an experiment. At least one of `name | description |
4605
- * status | variants | controlConfigVersion` must be supplied —
4606
- * the server returns 400 `NO_UPDATES` for an empty body. When
4607
- * `variants` is supplied the overlap validator re-runs.
4608
- */
4609
- updateOnboardingExperiment(slug: string, payload: UpdateOnboardingExperimentPayload): Promise<OnboardingExperimentResponse>;
4610
- /**
4611
- * Hard-delete an experiment. Returns the deleted row in `data` for
4612
- * audit-log convenience. Admin-only — no soft-delete column.
4613
- */
4614
- deleteOnboardingExperiment(slug: string): Promise<OnboardingExperimentResponse>;
4615
- /**
4616
- * Funnel-by-step counts for `(productId, nichePackSlug)`, plus
4617
- * conversion rates relative to each flow's first step.
4618
- *
4619
- * Server-side filters: `productId`, `nicheSubtype` (the niche pack
4620
- * slug — UI-friendly alias of the column name), `fromDate`,
4621
- * `toDate`. Both date bounds default to the trailing 30 days. The
4622
- * server clamps the window at 180 days and rejects
4623
- * `fromDate >= toDate` with 400 INVALID_FIELD.
4624
- *
4625
- * Powers the admin Sankey + per-step bar chart in Task 4.3.2.
4626
- */
4627
- getOnboardingFunnel(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingFunnelResponse>;
4628
- /**
4629
- * Median + p95 milliseconds spent on each step (per
4630
- * `(productId, nichePackSlug, stepId)`), computed via
4631
- * `LEAD(created_at) OVER (PARTITION BY session_id …)` on the event
4632
- * stream. Sample size accompanies each row so the saas can
4633
- * grey-out under-sampled buckets.
4634
- */
4635
- getOnboardingTimeOnStep(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingTimeOnStepResponse>;
4636
- /**
4637
- * Histogram of `stepId` values where sessions went inactive — i.e.
4638
- * `status = 'abandoned'` OR (active for >24h with no further
4639
- * events). The server also tallies a `totalAbandoned` aggregate so
4640
- * the saas can render a percentage column without re-summing.
4641
- */
4642
- getOnboardingAbandonment(params?: OnboardingAnalyticsFiltersParams): Promise<OnboardingAbandonmentResponse>;
4643
- }
4644
-
4645
- interface CorsOriginCreatePayload {
4646
- url: string;
4647
- name?: string;
4648
- allowedHeaders?: string[];
4649
- allowedMethods?: string[];
4650
- }
4651
- interface CorsOriginUpdatePayload {
4652
- url?: string;
4653
- name?: string;
4654
- allowedHeaders?: string[];
4655
- allowedMethods?: string[];
4656
- isActive?: boolean;
4657
- }
4658
- declare class Cors extends APIResource {
4659
- /**
4660
- * List all dynamic cross-origin policies.
4661
- */
4662
- list<T = any>(): Promise<T>;
4663
- /**
4664
- * Register a new cross-origin client for the SaaS API network dynamically.
4665
- */
4666
- create<T = any>(payload: CorsOriginCreatePayload): Promise<T>;
4667
- /**
4668
- * Adjust active states or configurations for an existing origin policy.
4669
- */
4670
- update<T = any>(id: string, payload: CorsOriginUpdatePayload): Promise<T>;
4671
- /**
4672
- * Irreversibly drop support for a cross-origin client URL policy permanently.
4673
- */
4674
- delete<T = any>(id: string): Promise<T>;
4675
- }
4676
-
4677
- interface SystemHealth {
4678
- status: string;
4679
- version: string;
4680
- env: string;
4681
- uptime: number;
4682
- db: string;
4683
- queueDepth: number;
4684
- timestamp: string;
4685
- }
4686
- /**
4687
- * Platform health diagnostics.
4688
- *
4689
- * Access via `ecod.platform.health`.
4690
- */
4691
- declare class Health extends APIResource {
4692
- /**
4693
- * Global platform health check — verifies the core API is operational.
4694
- * Public endpoint: `GET /health`.
4695
- */
4696
- system(): Promise<SystemHealth>;
4697
- }
4698
-
4699
- /**
4700
- * Filters for querying event and automation execution logs.
4701
- */
4702
- interface LogFilter {
4703
- /** Page number for pagination (1-indexed). */
4704
- page?: number;
4705
- /** Maximum number of records to return per page. */
4706
- limit?: number;
4707
- /**
4708
- * Filter by automation trigger name.
4709
- * @example "lead_created" | "appointment_booked"
4710
- */
4711
- trigger?: string;
4712
- /**
4713
- * Filter by execution status.
4714
- * @example "success" | "failed" | "pending"
4715
- */
4716
- status?: string;
4717
- /** Filter logs associated with a specific phone number. */
4718
- phone?: string;
4719
- /** Start of the date range (inclusive). ISO 8601 or Date object. */
4720
- startDate?: string | Date;
4721
- /** End of the date range (inclusive). ISO 8601 or Date object. */
4722
- endDate?: string | Date;
4723
- }
4724
- /**
4725
- * Automation event log and provider callback resource.
4726
- *
4727
- * Access via `ecod.notifications`.
4728
- *
4729
- * This resource is **read-only**. It exposes platform audit trails — useful
4730
- * for debugging automation failures, monitoring webhook callbacks, and
4731
- * building internal ops dashboards.
4732
- *
4733
- * @example
4734
- * ```typescript
4735
- * // Find failed automations in April
4736
- * const { data } = await ecod.notifications.listLogs({
4737
- * status: "failed",
4738
- * startDate: "2026-04-01",
4739
- * endDate: "2026-04-30",
4740
- * });
4741
- * ```
4742
- */
4743
- declare class Notifications extends APIResource {
4744
- /**
4745
- * List automation execution logs with optional filtering.
4746
- *
4747
- * Each log entry represents one automation run triggered by a platform event.
4748
- * Filter by `status: "failed"` to build a failure alerting pipeline.
4749
- *
4750
- * @param params - Optional filter criteria.
4751
- * @returns Paginated list of event log objects.
4752
- *
4753
- * @example
4754
- * ```typescript
4755
- * const { data: failed } = await ecod.notifications.listLogs({
4756
- * status: "failed",
4757
- * trigger: "lead_created",
4758
- * limit: 50,
4759
- * });
4760
- * ```
4761
- */
4762
- listLogs(params?: LogFilter): Promise<unknown>;
4763
- /**
4764
- * Retrieve the full details for a single automation event log entry.
4765
- *
4766
- * @param logId - The unique log ID.
4767
- * @returns A single event log document including the payload and error trace.
4768
- *
4769
- * @example
4770
- * ```typescript
4771
- * const { data } = await ecod.notifications.retrieveLog("log_64abc...");
4772
- * console.log(data.error); // → "Provider timeout after 30s"
4773
- * ```
4774
- */
4775
- retrieveLog(logId: string): Promise<unknown>;
4776
- /**
4777
- * Get a summary statistics object for automation event execution.
4778
- *
4779
- * @param params - Optional date range for the summary window.
4780
- * @returns `{ total, success, failed, pending }` counts.
4781
- *
4782
- * @example
4783
- * ```typescript
4784
- * const { data: stats } = await ecod.notifications.getStats({
4785
- * startDate: "2026-04-01",
4786
- * endDate: "2026-04-30",
4787
- * });
4788
- * console.log(`Failed: ${stats.failed} / ${stats.total}`);
4789
- * ```
4790
- */
4791
- getStats(params?: {
4792
- startDate?: string;
4793
- endDate?: string;
4794
- }): Promise<unknown>;
4795
- /**
4796
- * List external provider webhook callback logs.
4797
- *
4798
- * These are inbound HTTP callbacks from third-party providers
4799
- * (payment gateways, email services, etc.) stored for audit purposes.
4800
- *
4801
- * @param params - Pagination and date filter options.
4802
- * @returns Paginated list of callback log records.
4803
- *
4804
- * @example
4805
- * ```typescript
4806
- * const { data } = await ecod.notifications.listCallbacks({ limit: 20 });
4807
- * ```
4808
- */
4809
- listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
4810
- /**
4811
- * List unread CRM notifications and alerts (e.g., lead assignments, system alerts).
4812
- *
4813
- * @param params - Optional filters (limit, unreadOnly).
4814
- * @returns Paginated list of notification objects.
4815
- * @example
4816
- * ```typescript
4817
- * const alerts = await erixClient.notifications.listAlerts({ unreadOnly: true });
4818
- * ```
4819
- */
4820
- listAlerts<T = any>(params?: {
4821
- limit?: number;
4822
- unreadOnly?: boolean;
4823
- }): Promise<T>;
4824
- /**
4825
- * Dismiss/mark a specific notification alert as read.
4826
- *
4827
- * @param notificationId - The unique ID of the notification.
4828
- * @example
4829
- * ```typescript
4830
- * await erixClient.notifications.dismissAlert("alert_123");
4831
- * ```
4832
- */
4833
- dismissAlert<T = any>(notificationId: string): Promise<T>;
4834
- /**
4835
- * Clear all notifications for the current tenant immediately.
4836
- *
4837
- * @example
4838
- * ```typescript
4839
- * await erixClient.notifications.clearAllAlerts();
4840
- * ```
4841
- */
4842
- clearAllAlerts<T = any>(): Promise<T>;
4843
- /**
4844
- * Retry an action from a notification (e.g. failed automation send).
4845
- *
4846
- * @param notificationId - The unique ID of the notification.
4847
- * @example
4848
- * ```typescript
4849
- * await erixClient.notifications.retryAction("alert_123");
4850
- * ```
4851
- */
4852
- retryAction<T = any>(notificationId: string): Promise<T>;
4853
- }
4854
-
4855
- /**
4856
- * Body of `POST /platform/tenants/onboarding/global` — the four-question signup form.
4857
- *
4858
- * Fields land directly on `ecodrix_organizations.*` columns (workspace
4859
- * name, timezone) and `service_config -> 'global'` (primary product,
4860
- * adaptive flag). See REQ-001.
4861
- */
4862
- interface GlobalOnboardingPayload {
4863
- /** Workspace / org display name. Persisted to `ecodrix_organizations.name`. */
4864
- workspaceName: string;
4865
- /** Personal display name of the signing-up user. */
4866
- displayName: string;
4867
- /** IANA timezone, e.g. `"Asia/Kolkata"`. Persisted to `organizations.timezone`. */
4868
- timezone: string;
4869
- /**
4870
- * The product the user wants to start with. `"not_sure"` defers
4871
- * per-product onboarding to first product open.
4872
- */
4873
- primaryProduct: "crm" | "laie" | "flow" | "not_sure";
4874
- }
4875
- /**
4876
- * Body of `POST /platform/tenants/onboarding/${productId}/start` — opens a per-product onboarding
4877
- * session. Triggered by the explicit "Enable {Product}" click on
4878
- * `/products/<productId>` (REQ-002).
4879
- */
4880
- interface StartOnboardingPayload {
4881
- productId: "crm" | "laie" | "flow";
4882
- }
4883
- /**
4884
- * Body of `POST /platform/tenants/onboarding/${productId}/answer` — records one step's answer and
4885
- * advances the engine. The saas calls this on every step submit (and as
4886
- * a debounced PATCH for resumability).
4887
- */
4888
- interface AnswerOnboardingPayload {
4889
- sessionId: string;
4890
- stepId: string;
4891
- /** Shape depends on the step type — string, string[], boolean, etc. */
4892
- answer: unknown;
4893
- }
4894
- /**
4895
- * Body of `POST /platform/tenants/onboarding/complete` — terminates the session,
4896
- * upserts the persona, and materializes the workspace defaults.
4897
- */
4898
- interface CompleteOnboardingPayload {
4899
- sessionId: string;
4900
- }
4901
- /**
4902
- * Body of `POST /platform/tenants/onboarding/${productId}/edit` — post-completion edit of a single
4903
- * answer from `/settings/onboarding`. Triggers a `persona_recomputed`
4904
- * event (REQ-010).
4905
- */
4906
- interface EditOnboardingPayload {
4907
- stepId: string;
4908
- answer: unknown;
4909
- }
4910
- /**
4911
- * Result of `POST /platform/tenants/onboarding/${productId}/start`.
4912
- */
4913
- interface StartOnboardingResponse {
4914
- sessionId: string;
4915
- firstStep: OnboardingStep;
4916
- }
4917
- /**
4918
- * Result of `POST /platform/tenants/onboarding/${productId}/answer`.
4919
- */
4920
- interface AnswerOnboardingResponse {
4921
- /** `null` when the engine has reached the final step. */
4922
- nextStep: OnboardingStep | null;
4923
- draftPersona: Record<string, unknown>;
4924
- }
4925
- /**
4926
- * Result of `GET /platform/tenants/onboarding/${productId}/state`. Returns the active session
4927
- * (status `"active"`) for `(userId, productId)`, plus the step the
4928
- * renderer should currently show.
4929
- */
4930
- interface OnboardingStateResponse {
4931
- session: OnboardingSession | null;
4932
- currentStep: OnboardingStep | null;
4933
- }
4934
- /**
4935
- * Result of `POST /platform/tenants/onboarding/complete`.
4936
- */
4937
- interface CompleteOnboardingResponse {
4938
- /** Opaque persona document — full type lives in `resources/persona.ts`. */
4939
- persona: Record<string, unknown>;
4940
- workspaceProfile: WorkspaceProfile;
4941
- }
4942
- /**
4943
- * Result of `POST /platform/tenants/onboarding/${productId}/edit`.
4944
- */
4945
- interface EditOnboardingResponse {
4946
- persona: Record<string, unknown>;
4947
- /** RFC 6902 JSON Patch describing what changed in the persona. */
4948
- diff: Array<Record<string, unknown>>;
4949
- }
4950
- /**
4951
- * Adaptive onboarding resource.
4952
- *
4953
- * Mounted on the main client as `ecod.onboarding`. Mirrors the seven
4954
- * tenant-facing routes documented in `design.md` § "API surface".
4955
- *
4956
- * @example
4957
- * ```typescript
4958
- * await ecod.onboarding.global({
4959
- * workspaceName: "Acme Health",
4960
- * displayName: "Alice",
4961
- * timezone: "Asia/Kolkata",
4962
- * primaryProduct: "crm",
4963
- * });
4964
- *
4965
- * const { sessionId, firstStep } = await ecod.onboarding.start({ productId: "crm" });
4966
- * await ecod.onboarding.answer({ sessionId, stepId: firstStep.stepId, answer: "healthcare" });
4967
- * await ecod.onboarding.complete({ sessionId });
4968
- * ```
4969
- */
4970
- declare class Onboarding extends APIResource {
4971
- /**
4972
- * Submit the four-question global onboarding form (REQ-001).
4973
- * Updates `ecodrix_organizations.*` columns and
4974
- * `service_config.global.primaryProduct`.
4975
- */
4976
- global<T = unknown>(payload: GlobalOnboardingPayload): Promise<T>;
4977
- /**
4978
- * Open a per-product onboarding session. Called when the user clicks
4979
- * "Enable {Product}" on `/products/<productId>` (REQ-002).
4980
- */
4981
- start(payload: StartOnboardingPayload): Promise<StartOnboardingResponse>;
4982
- /**
4983
- * Record one step's answer and advance the engine. Returns the next
4984
- * step (or `null` at the end) and the in-progress draft persona.
4985
- */
4986
- answer(payload: AnswerOnboardingPayload): Promise<AnswerOnboardingResponse>;
4987
- /**
4988
- * Load the active session for the calling user + product. Used on
4989
- * page mount + every revisit to support resumability (REQ-010).
4990
- */
4991
- state(productId: string): Promise<OnboardingStateResponse>;
4992
- /**
4993
- * Finalise the session, upsert the persona, and materialize the
4994
- * niche-tuned workspace defaults.
4995
- */
4996
- complete(payload: CompleteOnboardingPayload): Promise<CompleteOnboardingResponse>;
4997
- /**
4998
- * Edit a previously-answered step from `/settings/onboarding`. The
4999
- * server emits a `persona_recomputed` event so the workspace and
5000
- * persona update in-session (REQ-010).
5001
- */
5002
- edit(payload: EditOnboardingPayload): Promise<EditOnboardingResponse>;
5003
- /**
5004
- * Preview the workspace profile that would be materialized if the
5005
- * session completed right now. Used by the `feature_preview` step.
5006
- */
5007
- previewWorkspace(sessionId: string): Promise<WorkspaceProfile>;
5008
- }
5009
-
5010
- declare class Clients extends APIResource {
5011
- /**
5012
- * List all clients in the ecosystem.
5013
- */
5014
- list<T = any>(): Promise<T>;
5015
- /**
5016
- * Get client count and auto-generate a unique code.
5017
- */
5018
- getCountAndGenerateCode<T = any>(): Promise<T>;
5019
- /**
5020
- * Retrieve a single client by client code.
5021
- */
5022
- retrieve<T = any>(clientCode: string): Promise<T>;
5023
- /**
5024
- * Get API Key for a specific client (Admin Only).
5025
- */
5026
- getApiKey<T = any>(clientCode: string): Promise<T>;
5027
- /**
5028
- * Generate or rotate API Key for a specific client (Admin Only).
5029
- */
5030
- rotateApiKey<T = any>(clientCode: string): Promise<T>;
5031
- /**
5032
- * Create a new client identity and provision initial resources.
5033
- */
5034
- create<T = any>(payload: {
5035
- name: string;
5036
- clientCode: string;
5037
- business?: any;
5038
- plan?: any;
5039
- }): Promise<T>;
5040
- /**
5041
- * Get active service configuration for a specific client.
5042
- */
5043
- getConfig<T = any>(clientCode: string): Promise<T>;
5044
- /**
5045
- * Update active service configuration for a specific client.
5046
- */
5047
- updateConfig<T = any>(clientCode: string, payload: any): Promise<T>;
5048
- /**
5049
- * List a client's ERIX-Connect connections (masked status + per-module
5050
- * grants). Replaces the legacy `getSecrets` — credentials are never returned
5051
- * in plaintext.
5052
- */
5053
- getConnections<T = any>(clientCode: string): Promise<T>;
5054
- /**
5055
- * List the ERIX-Connect provider registry (cards + methods + field metadata).
5056
- */
5057
- getConnectProviders<T = any>(clientCode: string): Promise<T>;
5058
- /**
5059
- * Connect a provider for a client via a chosen method.
5060
- */
5061
- connectProvider<T = any>(clientCode: string, providerId: string, payload: {
5062
- method: string;
5063
- config: Record<string, unknown>;
5064
- }): Promise<T>;
5065
- /**
5066
- * Update an already-connected provider's configuration.
5067
- */
5068
- configureProvider<T = any>(clientCode: string, providerId: string, payload: {
5069
- method: string;
5070
- config: Record<string, unknown>;
5071
- }): Promise<T>;
5072
- /**
5073
- * Disconnect a provider for a client.
5074
- */
5075
- disconnectProvider<T = any>(clientCode: string, providerId: string): Promise<T>;
5076
- /**
5077
- * Reveal a client's DECRYPTED credentials for a provider (admin/agency).
5078
- */
5079
- revealConnection<T = any>(clientCode: string, providerId: string): Promise<T>;
5080
- /**
5081
- * Toggle a per-module access grant (crm | flow | laie) for a client's
5082
- * connector.
5083
- */
5084
- setConnectionAccess<T = any>(clientCode: string, providerId: string, payload: {
5085
- module: "crm" | "flow" | "laie";
5086
- enabled: boolean;
5087
- }): Promise<T>;
5088
- /**
5089
- * Retrieve Data Source connection metadata.
5090
- */
5091
- getDataSource<T = any>(clientCode: string): Promise<T>;
5092
- /**
5093
- * Configure Data Source metadata.
5094
- */
5095
- manageDataSource<T = any>(clientCode: string, payload: any): Promise<T>;
5096
- /**
5097
- * Update Client Identity and perform cascading updates if required.
5098
- */
5099
- updateIdentity<T = any>(id: string, payload: any): Promise<T>;
5100
- /**
5101
- * Initiate Google Re-authentication for OAuth tokens.
5102
- */
5103
- googleReauth<T = any>(clientCode: string, payload?: {
5104
- authCode?: string;
5105
- }): Promise<T>;
5106
- /**
5107
- * Delete a client and perform cascading cleanup.
5108
- */
5109
- delete<T = any>(id: string): Promise<T>;
5110
- }
5111
- declare class Blogs extends APIResource {
5112
- /**
5113
- * Retrieve public corporate blogs/news.
5114
- */
5115
- list<T = any>(): Promise<T>;
5116
- }
5117
- declare class GlobalLeads extends APIResource {
5118
- /**
5119
- * Add a corporate lead capture entry.
5120
- */
5121
- add<T = any>(payload: any): Promise<T>;
5122
- }
5123
- declare class Services extends APIResource {
5124
- clients: Clients;
5125
- blogs: Blogs;
5126
- globalLeads: GlobalLeads;
5127
- constructor(client: any);
5128
- }
5129
-
5130
- /**
5131
- * Copilot resource — synchronous chat, confirmation, and session management.
5132
- *
5133
- * Access via `ecod.platform.ai.copilot`.
5134
- */
5135
- declare class Copilot extends APIResource {
5136
- /**
5137
- * Send a synchronous (non-streaming) chat message to the copilot.
5138
- */
5139
- chatSync<T = any>(body: Record<string, unknown>): Promise<T>;
5140
- /**
5141
- * Confirm a pending copilot action.
5142
- */
5143
- confirm<T = any>(body: Record<string, unknown>): Promise<T>;
5144
- /**
5145
- * List all copilot sessions.
5146
- */
5147
- listSessions<T = any>(): Promise<T>;
5148
- /**
5149
- * Retrieve a single copilot session by its ID.
5150
- *
5151
- * @param id - The session ID.
5152
- */
5153
- getSession<T = any>(id: string): Promise<T>;
5154
- /**
5155
- * Delete a copilot session by its ID.
5156
- *
5157
- * @param id - The session ID.
5158
- */
5159
- deleteSession<T = any>(id: string): Promise<T>;
5160
- /**
5161
- * Returns the version-relative path for the copilot chat streaming
5162
- * endpoint (`POST /platform/ai/copilot/chat`).
5163
- *
5164
- * NOTE: This endpoint is a Server-Sent-Events (SSE) stream. The axios
5165
- * client is not used for streaming, so SSE consumption must be handled by
5166
- * the caller (e.g. using `fetch` with a `ReadableStream` reader or an
5167
- * `EventSource`-compatible client). This method intentionally does not
5168
- * perform the request or implement streaming.
5169
- *
5170
- * @returns The version-relative SSE endpoint path.
5171
- */
5172
- chatStreamUrl(): string;
5173
- }
5174
- /**
5175
- * Platform AI container — groups the `copilot` sub-resource.
5176
- *
5177
- * Access via `ecod.platform.ai`.
5178
- */
5179
- declare class PlatformAI {
5180
- readonly copilot: Copilot;
5181
- constructor(client: AxiosInstance);
5182
- }
5183
-
5184
- /**
5185
- * Platform authentication resource — registration, login, sessions,
5186
- * password management, OAuth linking, and organization invitations.
5187
- *
5188
- * Access via `ecod.platform.auth`.
5189
- */
5190
- declare class Auth extends APIResource {
5191
- /**
5192
- * Register a new platform user / organization.
5193
- */
5194
- register<T = any>(body: Record<string, unknown>): Promise<T>;
5195
- /**
5196
- * Authenticate a user and establish a session.
5197
- */
5198
- login<T = any>(body: Record<string, unknown>): Promise<T>;
5199
- /**
5200
- * Log out of the current session.
5201
- */
5202
- logout<T = any>(body: Record<string, unknown>): Promise<T>;
5203
- /**
5204
- * Log out of every active session for the current user.
5205
- */
5206
- logoutAll<T = any>(body: Record<string, unknown>): Promise<T>;
5207
- /**
5208
- * Validate the current session token.
5209
- */
5210
- validateSession<T = any>(body: Record<string, unknown>): Promise<T>;
5211
- /**
5212
- * List all active sessions for the current user.
5213
- */
5214
- listSessions<T = any>(): Promise<T>;
5215
- /**
5216
- * Revoke a specific session by its ID.
5217
- *
5218
- * @param id - The session ID to revoke.
5219
- */
5220
- revokeSession<T = any>(id: string): Promise<T>;
5221
- /**
5222
- * Request a one-time password (OTP) to set or change a password.
5223
- */
5224
- requestPasswordOtp<T = any>(body: Record<string, unknown>): Promise<T>;
5225
- /**
5226
- * Set a password for the current user.
5227
- */
5228
- setPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5229
- /**
5230
- * Change the current user's password.
5231
- */
5232
- changePassword<T = any>(body: Record<string, unknown>): Promise<T>;
5233
- /**
5234
- * Begin the forgot-password flow.
5235
- */
5236
- forgotPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5237
- /**
5238
- * Reset a password using a reset token.
5239
- */
5240
- resetPassword<T = any>(body: Record<string, unknown>): Promise<T>;
5241
- /**
5242
- * Link an OAuth identity to the current user.
5243
- */
5244
- linkOAuth<T = any>(body: Record<string, unknown>): Promise<T>;
5245
- /**
5246
- * Retrieve details about an organization invitation by token.
5247
- *
5248
- * @param token - The invitation token.
5249
- */
5250
- getInvitation<T = any>(token: string): Promise<T>;
5251
- /**
5252
- * Accept an organization invitation by token.
5253
- *
5254
- * @param token - The invitation token.
5255
- * @param body - Optional acceptance payload.
5256
- */
5257
- acceptInvitation<T = any>(token: string, body?: Record<string, unknown>): Promise<T>;
5258
- }
5259
-
5260
- /**
5261
- * Entitlements resource — read current plan entitlements and usage.
5262
- *
5263
- * Access via `ecod.platform.billing.entitlements`.
5264
- */
5265
- declare class Entitlements extends APIResource {
5266
- /**
5267
- * Retrieve the current organization's entitlements.
5268
- */
5269
- get<T = any>(): Promise<T>;
5270
- /**
5271
- * Retrieve current usage against entitlements.
5272
- */
5273
- usage<T = any>(): Promise<T>;
5274
- }
5275
- /**
5276
- * Subscriptions resource — manage plan upgrades, downgrades, cancellations,
5277
- * and add-ons.
5278
- *
5279
- * Access via `ecod.platform.billing.subscriptions`.
5280
- */
5281
- declare class Subscriptions extends APIResource {
5282
- /**
5283
- * Upgrade the current subscription plan.
5284
- */
5285
- upgrade<T = any>(body: Record<string, unknown>): Promise<T>;
5286
- /**
5287
- * Downgrade the current subscription plan.
5288
- */
5289
- downgrade<T = any>(body: Record<string, unknown>): Promise<T>;
5290
- /**
5291
- * Cancel the current subscription.
5292
- */
5293
- cancel<T = any>(body: Record<string, unknown>): Promise<T>;
5294
- /**
5295
- * Purchase an add-on for the current subscription.
5296
- */
5297
- purchaseAddon<T = any>(body: Record<string, unknown>): Promise<T>;
5298
- /**
5299
- * Cancel a previously purchased add-on.
5300
- */
5301
- cancelAddon<T = any>(body: Record<string, unknown>): Promise<T>;
5302
- }
5303
- /**
5304
- * Plans resource — read publicly available plans.
5305
- *
5306
- * Access via `ecod.platform.billing.plans`.
5307
- */
5308
- declare class Plans extends APIResource {
5309
- /**
5310
- * List all publicly available plans.
5311
- */
5312
- listPublic<T = any>(): Promise<T>;
5313
- }
5314
- /**
5315
- * Billing checkout resource — plan selection, subscription, verification,
5316
- * and synchronization.
5317
- *
5318
- * Access via `ecod.platform.billing.checkout`.
5319
- */
5320
- declare class BillingCheckout extends APIResource {
5321
- /**
5322
- * List plans available at checkout.
5323
- */
5324
- plans<T = any>(): Promise<T>;
5325
- /**
5326
- * Subscribe to a plan via checkout.
5327
- */
5328
- subscribe<T = any>(body: Record<string, unknown>): Promise<T>;
5329
- /**
5330
- * Verify a checkout payment.
5331
- */
5332
- verify<T = any>(body: Record<string, unknown>): Promise<T>;
5333
- /**
5334
- * Cancel an in-progress checkout.
5335
- */
5336
- cancel<T = any>(body: Record<string, unknown>): Promise<T>;
5337
- /**
5338
- * Retrieve the current checkout status.
5339
- */
5340
- status<T = any>(): Promise<T>;
5341
- /**
5342
- * Synchronize the checkout plan state with the provider.
5343
- */
5344
- syncPlan<T = any>(body: Record<string, unknown>): Promise<T>;
5345
- }
5346
- /**
5347
- * Billing user resource — transactions, subscription, and disputes for the
5348
- * current user.
5349
- *
5350
- * Access via `ecod.platform.billing.user`.
5351
- */
5352
- declare class BillingUser extends APIResource {
5353
- /**
5354
- * List the current user's billing transactions.
5355
- */
5356
- transactions<T = any>(): Promise<T>;
5357
- /**
5358
- * Retrieve the current user's subscription.
5359
- */
5360
- subscription<T = any>(): Promise<T>;
5361
- /**
5362
- * Raise a billing dispute.
5363
- */
5364
- raiseDispute<T = any>(body: Record<string, unknown>): Promise<T>;
5365
- /**
5366
- * List the current user's billing disputes.
5367
- */
5368
- disputes<T = any>(): Promise<T>;
5369
- }
5370
- /**
5371
- * Credits resource — balance, transactions, packs, and top-ups.
5372
- *
5373
- * Access via `ecod.platform.billing.credits`.
5374
- */
5375
- declare class Credits extends APIResource {
5376
- /**
5377
- * Retrieve the current credit balance.
5378
- */
5379
- balance<T = any>(): Promise<T>;
5380
- /**
5381
- * List credit transactions.
5382
- */
5383
- transactions<T = any>(): Promise<T>;
5384
- /**
5385
- * List available credit packs.
5386
- */
5387
- packs<T = any>(): Promise<T>;
5388
- /**
5389
- * Create a credit top-up order.
5390
- */
5391
- topupOrder<T = any>(body: Record<string, unknown>): Promise<T>;
5392
- /**
5393
- * Verify a credit top-up payment.
5394
- */
5395
- verifyTopup<T = any>(body: Record<string, unknown>): Promise<T>;
5396
- /**
5397
- * Configure automatic credit top-ups.
5398
- */
5399
- setAutoTopup<T = any>(body: Record<string, unknown>): Promise<T>;
5400
- /**
5401
- * Configure the daily spend cap (cost control).
5402
- * Body: `{ dailyCap: number | null, alertPct?: number }`.
5403
- */
5404
- setSpendCap<T = any>(body: Record<string, unknown>): Promise<T>;
5405
- }
5406
- /**
5407
- * Platform billing container — groups the `entitlements`, `subscriptions`,
5408
- * `plans`, `checkout`, `user`, and `credits` sub-resources.
5409
- *
5410
- * Access via `ecod.platform.billing`.
5411
- */
5412
- declare class Billing {
5413
- readonly entitlements: Entitlements;
5414
- readonly subscriptions: Subscriptions;
5415
- readonly plans: Plans;
5416
- readonly checkout: BillingCheckout;
5417
- readonly user: BillingUser;
5418
- readonly credits: Credits;
5419
- constructor(client: AxiosInstance);
5420
- }
5421
-
5422
- /**
5423
- * Platform support resource — categories and support ticket lifecycle.
5424
- *
5425
- * Access via `ecod.platform.support`.
5426
- */
5427
- declare class Support extends APIResource {
5428
- /**
5429
- * List available support categories.
5430
- */
5431
- categories<T = any>(): Promise<T>;
5432
- /**
5433
- * List support tickets with optional filtering.
5434
- *
5435
- * @param params - Optional query parameters (status, pagination, etc.).
5436
- */
5437
- listTickets<T = any>(params?: Record<string, unknown>): Promise<T>;
5438
- /**
5439
- * Create a new support ticket.
5440
- */
5441
- createTicket<T = any>(body: Record<string, unknown>): Promise<T>;
5442
- /**
5443
- * Retrieve a single support ticket by its ID.
5444
- *
5445
- * @param id - The support ticket ID.
5446
- */
5447
- getTicket<T = any>(id: string): Promise<T>;
5448
- /**
5449
- * Reply to an existing support ticket.
5450
- *
5451
- * @param id - The support ticket ID.
5452
- * @param body - The reply payload.
5453
- */
5454
- reply<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5455
- /**
5456
- * Close a support ticket.
5457
- *
5458
- * @param id - The support ticket ID.
5459
- */
5460
- close<T = any>(id: string): Promise<T>;
5461
- }
5462
-
5463
- /**
5464
- * Current-user ("me") resource — profile, organization, modules,
5465
- * workspaces, and active-org management.
5466
- *
5467
- * Access via `ecod.platform.users.me`.
5468
- */
5469
- declare class Me extends APIResource {
5470
- /**
5471
- * Retrieve the current authenticated user's profile.
5472
- */
5473
- get<T = any>(): Promise<T>;
5474
- /**
5475
- * Update the current user's profile.
5476
- */
5477
- update<T = any>(body: Record<string, unknown>): Promise<T>;
5478
- /**
5479
- * Update the current user's active organization details.
5480
- */
5481
- updateOrganization<T = any>(body: Record<string, unknown>): Promise<T>;
5482
- /**
5483
- * Toggle enabled modules for the current user / organization.
5484
- */
5485
- toggleModules<T = any>(body: Record<string, unknown>): Promise<T>;
5486
- /**
5487
- * List the workspaces available to the current user.
5488
- */
5489
- workspaces<T = any>(): Promise<T>;
5490
- /**
5491
- * Set the active organization for the current user.
5492
- */
5493
- setActiveOrg<T = any>(body: Record<string, unknown>): Promise<T>;
5494
- /**
5495
- * Dismiss the workspace setup prompt for the current user.
5496
- */
5497
- dismissWorkspaceSetup<T = any>(): Promise<T>;
5498
- }
5499
- /**
5500
- * Organization members resource — list, invite, and remove members.
5501
- *
5502
- * Access via `ecod.platform.users.members`.
5503
- */
5504
- declare class Members extends APIResource {
5505
- /**
5506
- * List all members of the current organization.
5507
- */
5508
- list<T = any>(): Promise<T>;
5509
- /**
5510
- * Invite a new member to the current organization.
5511
- */
5512
- invite<T = any>(body: Record<string, unknown>): Promise<T>;
5513
- /**
5514
- * Remove a member from the current organization.
5515
- *
5516
- * @param id - The member ID to remove.
5517
- */
5518
- remove<T = any>(id: string): Promise<T>;
5519
- }
5520
- /**
5521
- * User sessions resource — list and revoke sessions.
5522
- *
5523
- * Access via `ecod.platform.users.sessions`.
5524
- */
5525
- declare class Sessions extends APIResource {
5526
- /**
5527
- * List all sessions for the current user.
5528
- */
5529
- list<T = any>(): Promise<T>;
5530
- /**
5531
- * Revoke a specific session by its ID.
5532
- *
5533
- * @param id - The session ID to revoke.
5534
- */
5535
- revoke<T = any>(id: string): Promise<T>;
5536
- /**
5537
- * Revoke all sessions for the current user.
5538
- */
5539
- revokeAll<T = any>(): Promise<T>;
5540
- }
5541
-
5542
- /**
5543
- * Platform-admin activity logs resource — list and export activity logs.
5544
- *
5545
- * Access via `ecod.platform.admin.activityLogs`.
5546
- */
5547
- declare class AdminActivityLogs extends APIResource {
5548
- /**
5549
- * List activity logs.
5550
- */
5551
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5552
- /**
5553
- * Export activity logs.
5554
- */
5555
- export<T = any>(params?: Record<string, unknown>): Promise<T>;
5556
- }
5557
-
5558
- /**
5559
- * Platform-admin agency invoices resource — agency invoice settings and CRUD.
5560
- *
5561
- * NOTE: the doubled `admin/invoice-settings` / `admin/invoices` segments are
5562
- * intentional — a legacy router is mounted under the new prefix.
5563
- *
5564
- * Access via `ecod.platform.admin.agencyInvoices`.
5565
- */
5566
- declare class AdminAgencyInvoices extends APIResource {
5567
- /**
5568
- * Retrieve agency invoice settings.
5569
- */
5570
- getSettings<T = any>(): Promise<T>;
5571
- /**
5572
- * Update agency invoice settings.
5573
- */
5574
- updateSettings<T = any>(body: Record<string, unknown>): Promise<T>;
5575
- /**
5576
- * List agency invoices.
5577
- */
5578
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5579
- /**
5580
- * Create an agency invoice.
5581
- */
5582
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5583
- /**
5584
- * Retrieve a single agency invoice by ID.
5585
- */
5586
- retrieve<T = any>(id: string): Promise<T>;
5587
- /**
5588
- * Update an agency invoice.
5589
- */
5590
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5591
- /**
5592
- * Delete an agency invoice.
5593
- */
5594
- remove<T = any>(id: string): Promise<T>;
5595
- }
5596
-
5597
- /**
5598
- * Platform-admin agents resource — inspect and manage agents.
5599
- *
5600
- * Access via `ecod.platform.admin.agents`.
5601
- */
5602
- declare class AdminAgents extends APIResource {
5603
- /**
5604
- * Retrieve aggregate agent statistics.
5605
- */
5606
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5607
- /**
5608
- * List all agents.
5609
- */
5610
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5611
- /**
5612
- * Retrieve a single agent by ID.
5613
- */
5614
- retrieve<T = any>(id: string): Promise<T>;
5615
- /**
5616
- * Update an existing agent.
5617
- */
5618
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5619
- /**
5620
- * List runs for an agent.
5621
- */
5622
- runs<T = any>(id: string): Promise<T>;
5623
- }
5624
-
5625
- /**
5626
- * Platform-admin analytics resource — platform-wide analytics overviews.
5627
- *
5628
- * Access via `ecod.platform.admin.analytics`.
5629
- */
5630
- declare class AdminAnalytics extends APIResource {
5631
- /**
5632
- * Retrieve the analytics overview.
5633
- */
5634
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
5635
- /**
5636
- * Retrieve per-endpoint analytics.
5637
- */
5638
- endpoints<T = any>(params?: Record<string, unknown>): Promise<T>;
5639
- /**
5640
- * Retrieve error analytics.
5641
- */
5642
- errors<T = any>(params?: Record<string, unknown>): Promise<T>;
5643
- /**
5644
- * Retrieve per-tenant analytics.
5645
- */
5646
- tenants<T = any>(params?: Record<string, unknown>): Promise<T>;
5647
- }
5648
-
5649
- /**
5650
- * Platform-admin announcements resource — manage communications,
5651
- * broadcasts, maintenance windows, and changelog entries.
5652
- *
5653
- * Access via `ecod.platform.admin.announcements`.
5654
- */
5655
- declare class AdminAnnouncements extends APIResource {
5656
- /**
5657
- * List all communications.
5658
- */
5659
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5660
- /**
5661
- * Create a new communication.
5662
- */
5663
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5664
- /**
5665
- * Update an existing communication.
5666
- */
5667
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5668
- /**
5669
- * Delete a communication.
5670
- */
5671
- remove<T = any>(id: string): Promise<T>;
5672
- /**
5673
- * Publish a communication.
5674
- */
5675
- publish<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5676
- /**
5677
- * Broadcast a communication to recipients.
5678
- */
5679
- broadcast<T = any>(body: Record<string, unknown>): Promise<T>;
5680
- /**
5681
- * Set the maintenance window.
5682
- */
5683
- setMaintenance<T = any>(body: Record<string, unknown>): Promise<T>;
5684
- /**
5685
- * Retrieve the current maintenance window.
5686
- */
5687
- getMaintenance<T = any>(params?: Record<string, unknown>): Promise<T>;
5688
- /**
5689
- * Post a changelog entry.
5690
- */
5691
- changelog<T = any>(body: Record<string, unknown>): Promise<T>;
5692
- }
5693
-
5694
- /**
5695
- * Platform-admin audit logs resource — audit statistics, listing, and export.
5696
- *
5697
- * Access via `ecod.platform.admin.auditLogs`.
5698
- */
5699
- declare class AdminAuditLogs extends APIResource {
5700
- /**
5701
- * Retrieve aggregate audit statistics.
5702
- */
5703
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5704
- /**
5705
- * List audit log entries.
5706
- */
5707
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5708
- /**
5709
- * Export audit log entries.
5710
- */
5711
- export<T = any>(params?: Record<string, unknown>): Promise<T>;
5712
- }
5713
-
5714
- /**
5715
- * Platform-admin billing resource — billing events, trial extensions,
5716
- * grandfathering, and reconciliation.
5717
- *
5718
- * Access via `ecod.platform.admin.billing`.
5719
- */
5720
- declare class AdminBilling extends APIResource {
5721
- /**
5722
- * List all billing events.
5723
- */
5724
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
5725
- /**
5726
- * List billing events for a specific organization.
5727
- */
5728
- orgEvents<T = any>(orgId: string): Promise<T>;
5729
- /**
5730
- * List failed billing events.
5731
- */
5732
- failed<T = any>(params?: Record<string, unknown>): Promise<T>;
5733
- /**
5734
- * Record a billing event.
5735
- */
5736
- recordEvent<T = any>(body: Record<string, unknown>): Promise<T>;
5737
- /**
5738
- * Extend a trial period.
5739
- */
5740
- extendTrial<T = any>(body: Record<string, unknown>): Promise<T>;
5741
- /**
5742
- * Grandfather an organization onto legacy pricing.
5743
- */
5744
- grandfather<T = any>(body: Record<string, unknown>): Promise<T>;
5745
- /**
5746
- * Reconcile billing state with the provider.
5747
- */
5748
- reconcile<T = any>(params?: Record<string, unknown>): Promise<T>;
5749
- }
5750
-
5751
- /**
5752
- * Platform-admin blogs resource — blog content management.
5753
- *
5754
- * NOTE: the doubled `services/blogs` segments are intentional — a legacy
5755
- * router is mounted under the new prefix.
5756
- *
5757
- * Access via `ecod.platform.admin.blogs`.
5758
- */
5759
- declare class AdminBlogs extends APIResource {
5760
- /**
5761
- * List blog posts.
5762
- */
5763
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5764
- /**
5765
- * Retrieve a single blog post by slug or ID.
5766
- */
5767
- retrieve<T = any>(slugOrId: string): Promise<T>;
5768
- /**
5769
- * Create a blog post.
5770
- */
5771
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5772
- /**
5773
- * Update a blog post by slug or ID.
5774
- */
5775
- update<T = any>(slugOrId: string, body: Record<string, unknown>): Promise<T>;
5776
- /**
5777
- * Delete a blog post by slug or ID.
5778
- */
5779
- remove<T = any>(slugOrId: string): Promise<T>;
5780
- }
5781
-
5782
- /**
5783
- * Platform-admin compliance resource — manage compliance requests and
5784
- * organization data exports.
5785
- *
5786
- * Access via `ecod.platform.admin.compliance`.
5787
- */
5788
- declare class AdminCompliance extends APIResource {
5789
- /**
5790
- * List compliance requests.
5791
- */
5792
- requests<T = any>(params?: Record<string, unknown>): Promise<T>;
5793
- /**
5794
- * Create a new compliance request.
5795
- */
5796
- createRequest<T = any>(body: Record<string, unknown>): Promise<T>;
5797
- /**
5798
- * Update an existing compliance request.
5799
- */
5800
- updateRequest<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5801
- /**
5802
- * Export compliance data for an organization.
5803
- */
5804
- exportOrg<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
5805
- }
5806
-
5807
- /**
5808
- * Platform-admin credits resource — rate cards, credit packs, and wallets.
5809
- *
5810
- * Access via `ecod.platform.admin.credits`.
5811
- */
5812
- declare class AdminCredits extends APIResource {
5813
- /**
5814
- * Retrieve the credits rate card.
5815
- */
5816
- rateCard<T = any>(params?: Record<string, unknown>): Promise<T>;
5817
- /**
5818
- * List all credit packs.
5819
- */
5820
- packs<T = any>(params?: Record<string, unknown>): Promise<T>;
5821
- /**
5822
- * Create a new credit pack.
5823
- */
5824
- createPack<T = any>(body: Record<string, unknown>): Promise<T>;
5825
- /**
5826
- * Update an existing credit pack.
5827
- */
5828
- updatePack<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5829
- /**
5830
- * Delete a credit pack.
5831
- */
5832
- deletePack<T = any>(id: string): Promise<T>;
5833
- /**
5834
- * Retrieve the credit wallet for an organization.
5835
- */
5836
- wallet<T = any>(orgId: string): Promise<T>;
3752
+ confirm<T = any>(body: Record<string, unknown>): Promise<T>;
5837
3753
  /**
5838
- * Adjust the credit wallet balance for an organization.
3754
+ * List all copilot sessions.
5839
3755
  */
5840
- adjustWallet<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
5841
- }
5842
-
5843
- /**
5844
- * Platform-admin dashboard resource — admin dashboard statistics.
5845
- *
5846
- * Access via `ecod.platform.admin.dashboard`.
5847
- */
5848
- declare class AdminDashboard extends APIResource {
3756
+ listSessions<T = any>(): Promise<T>;
5849
3757
  /**
5850
- * Retrieve admin dashboard statistics.
3758
+ * Retrieve a single copilot session by its ID.
5851
3759
  *
5852
- * NOTE: the doubled `admin/dashboard` segment is intentional — a legacy
5853
- * router is mounted under the new prefix.
5854
- */
5855
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
5856
- }
5857
-
5858
- /**
5859
- * Platform-admin email monitor resource — cross-tenant email monitoring.
5860
- *
5861
- * Access via `ecod.platform.admin.email`.
5862
- */
5863
- declare class AdminEmail extends APIResource {
5864
- /**
5865
- * Retrieve the platform-wide email overview.
5866
- */
5867
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
5868
- /**
5869
- * List email campaigns across tenants.
5870
- */
5871
- campaigns<T = any>(params?: Record<string, unknown>): Promise<T>;
5872
- /**
5873
- * List email events (opens, clicks, bounces, etc.).
5874
- */
5875
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
5876
- /**
5877
- * Retrieve SES health metrics.
5878
- */
5879
- sesHealth<T = any>(params?: Record<string, unknown>): Promise<T>;
5880
- }
5881
-
5882
- /**
5883
- * Platform-admin Erix resource — Erix tenant provisioning and lifecycle.
5884
- *
5885
- * Access via `ecod.platform.admin.erix`.
5886
- */
5887
- declare class AdminErix extends APIResource {
5888
- /**
5889
- * Create a new Erix tenant.
5890
- */
5891
- createTenant<T = any>(body: Record<string, unknown>): Promise<T>;
5892
- /**
5893
- * List Erix tenants.
5894
- */
5895
- tenants<T = any>(params?: Record<string, unknown>): Promise<T>;
5896
- /**
5897
- * Retrieve a single Erix tenant by ID.
5898
- */
5899
- tenant<T = any>(id: string): Promise<T>;
5900
- /**
5901
- * Update the plan for an Erix tenant.
5902
- */
5903
- updatePlan<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5904
- /**
5905
- * Suspend an Erix tenant.
5906
- */
5907
- suspend<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5908
- /**
5909
- * Reactivate a suspended Erix tenant.
5910
- */
5911
- reactivate<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5912
- /**
5913
- * Rotate the API key for an Erix tenant.
5914
- */
5915
- rotateKey<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
5916
- /**
5917
- * Retrieve usage metrics for an Erix tenant.
5918
- */
5919
- usage<T = any>(id: string): Promise<T>;
5920
- }
5921
-
5922
- /**
5923
- * Platform-admin feature flags resource — manage feature flags and their
5924
- * per-organization overrides.
5925
- *
5926
- * Access via `ecod.platform.admin.featureFlags`.
5927
- */
5928
- declare class AdminFeatureFlags extends APIResource {
5929
- /**
5930
- * List all feature flags.
5931
- */
5932
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
5933
- /**
5934
- * Create a new feature flag.
5935
- */
5936
- create<T = any>(body: Record<string, unknown>): Promise<T>;
5937
- /**
5938
- * Update an existing feature flag.
5939
- */
5940
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
5941
- /**
5942
- * Delete a feature flag.
5943
- */
5944
- remove<T = any>(id: string): Promise<T>;
5945
- /**
5946
- * List per-organization overrides for a feature flag.
5947
- */
5948
- listOverrides<T = any>(id: string): Promise<T>;
5949
- /**
5950
- * Add a per-organization override to a feature flag.
3760
+ * @param id - The session ID.
5951
3761
  */
5952
- addOverride<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
3762
+ getSession<T = any>(id: string): Promise<T>;
5953
3763
  /**
5954
- * Remove a per-organization override from a feature flag.
3764
+ * Delete a copilot session by its ID.
3765
+ *
3766
+ * @param id - The session ID.
5955
3767
  */
5956
- removeOverride<T = any>(id: string, orgId: string): Promise<T>;
3768
+ deleteSession<T = any>(id: string): Promise<T>;
5957
3769
  /**
5958
- * 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.
5959
3780
  */
5960
- forOrg<T = any>(orgId: string): Promise<T>;
3781
+ chatStreamUrl(): string;
5961
3782
  }
5962
-
5963
3783
  /**
5964
- * Platform-admin flow monitor resource — cross-tenant flow run monitoring.
3784
+ * Platform AI container — groups the `copilot` sub-resource.
5965
3785
  *
5966
- * Access via `ecod.platform.admin.flow`.
3786
+ * Access via `ecod.platform.ai`.
5967
3787
  */
5968
- declare class AdminFlow extends APIResource {
5969
- /**
5970
- * Retrieve the platform-wide flow overview.
5971
- */
5972
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
5973
- /**
5974
- * List flow runs across tenants.
5975
- */
5976
- runs<T = any>(params?: Record<string, unknown>): Promise<T>;
5977
- /**
5978
- * List flow run failures.
5979
- */
5980
- failures<T = any>(params?: Record<string, unknown>): Promise<T>;
5981
- /**
5982
- * Retrieve a single flow run by ID.
5983
- */
5984
- run<T = any>(id: string): Promise<T>;
5985
- /**
5986
- * Retry a failed flow run.
5987
- */
5988
- retryRun<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
3788
+ declare class PlatformAI {
3789
+ readonly copilot: Copilot;
3790
+ constructor(client: AxiosInstance);
5989
3791
  }
5990
3792
 
5991
- /**
5992
- * Platform-admin integrations resource — per-tenant integration management.
5993
- *
5994
- * Access via `ecod.platform.admin.integrations`.
5995
- */
5996
- declare class AdminIntegrations extends APIResource {
5997
- /**
5998
- * List integrations for a tenant organization.
5999
- */
6000
- list<T = any>(orgId: string): Promise<T>;
6001
- /**
6002
- * Connect a provider integration for a tenant organization.
6003
- */
6004
- connect<T = any>(orgId: string, providerId: string, body?: Record<string, unknown>): Promise<T>;
6005
- /**
6006
- * Disconnect a provider integration for a tenant organization.
6007
- */
6008
- disconnect<T = any>(orgId: string, providerId: string): Promise<T>;
6009
- /**
6010
- * Test a provider integration for a tenant organization.
6011
- */
6012
- test<T = any>(orgId: string, providerId: string, body?: Record<string, unknown>): Promise<T>;
6013
- /**
6014
- * Send an integration invite for a tenant organization.
6015
- */
6016
- 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;
6017
3808
  }
6018
-
6019
- /**
6020
- * Platform-admin LAIE control resource — LAIE overview, queue, proxies,
6021
- * credits, actors, enrichment config, and audits.
6022
- *
6023
- * Access via `ecod.platform.admin.laie`.
6024
- */
6025
- declare class AdminLaie extends APIResource {
6026
- /**
6027
- * Retrieve the LAIE platform overview.
6028
- */
6029
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
6030
- /**
6031
- * Retrieve the LAIE processing queue.
6032
- */
6033
- queue<T = any>(params?: Record<string, unknown>): Promise<T>;
6034
- /**
6035
- * List LAIE proxies.
6036
- */
6037
- proxies<T = any>(params?: Record<string, unknown>): Promise<T>;
6038
- /**
6039
- * Retrieve LAIE vault statistics.
6040
- */
6041
- vaultStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6042
- /**
6043
- * Retrieve LAIE credit usage.
6044
- */
6045
- credits<T = any>(params?: Record<string, unknown>): Promise<T>;
6046
- /**
6047
- * List LAIE actors.
6048
- */
6049
- actors<T = any>(params?: Record<string, unknown>): Promise<T>;
6050
- /**
6051
- * Retrieve the LAIE actor registry.
6052
- */
6053
- actorRegistry<T = any>(params?: Record<string, unknown>): Promise<T>;
6054
- /**
6055
- * Run a named LAIE actor.
6056
- */
6057
- runActor<T = any>(name: string, body?: Record<string, unknown>): Promise<T>;
6058
- /**
6059
- * Retrieve the LAIE enrichment configuration.
6060
- */
6061
- getEnrichmentConfig<T = any>(): Promise<T>;
6062
- /**
6063
- * Update the LAIE enrichment configuration.
6064
- */
6065
- setEnrichmentConfig<T = any>(body: Record<string, unknown>): Promise<T>;
6066
- /**
6067
- * List LAIE audit records.
6068
- */
6069
- audits<T = any>(params?: Record<string, unknown>): Promise<T>;
6070
- /**
6071
- * Retrieve a single LAIE audit record by ID.
6072
- */
6073
- 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;
6074
3816
  }
6075
-
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
+ };
6076
3823
  /**
6077
- * Platform-admin LAIE runtime resource — live runtime stats for queue,
6078
- * proxies, browser pool, dead-letter queue, and runs.
6079
- *
6080
- * 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.
6081
3826
  */
6082
- declare class AdminLaieRuntime extends APIResource {
6083
- /**
6084
- * Retrieve LAIE runtime queue statistics.
6085
- */
6086
- queueStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6087
- /**
6088
- * Retrieve LAIE runtime proxy health.
6089
- */
6090
- proxyHealth<T = any>(params?: Record<string, unknown>): Promise<T>;
6091
- /**
6092
- * Retrieve LAIE runtime browser pool statistics.
6093
- */
6094
- browserPoolStats<T = any>(params?: Record<string, unknown>): Promise<T>;
6095
- /**
6096
- * Replay the LAIE runtime dead-letter queue.
6097
- */
6098
- replayDlq<T = any>(body?: Record<string, unknown>): Promise<T>;
6099
- /**
6100
- * Retrieve LAIE runtime run statistics.
6101
- */
6102
- 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[]>>;
6103
3850
  }
6104
3851
 
6105
- /**
6106
- * Platform-admin LAIE vault resource — LAIE vault overview.
6107
- *
6108
- * Access via `ecod.platform.admin.laieVault`.
6109
- */
6110
- declare class AdminLaieVault extends APIResource {
6111
- /**
6112
- * Retrieve the LAIE vault overview.
6113
- *
6114
- * NOTE: the doubled `admin/laie/vault` segment is intentional — a legacy
6115
- * router is mounted under the new prefix.
6116
- */
6117
- 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;
6118
3898
  }
6119
-
6120
- /**
6121
- * Platform-admin leads resource — admin lead management, qualification,
6122
- * follow-ups, and notes.
6123
- *
6124
- * NOTE: the doubled `leads/leads` segments are intentional — a legacy router
6125
- * is mounted under the new prefix.
6126
- *
6127
- * Access via `ecod.platform.admin.leads`.
6128
- */
6129
- declare class AdminLeads extends APIResource {
6130
- /**
6131
- * Add a new lead.
6132
- */
6133
- addLead<T = any>(body: Record<string, unknown>): Promise<T>;
6134
- /**
6135
- * List leads.
6136
- */
6137
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
6138
- /**
6139
- * Retrieve a single lead by ID.
6140
- */
6141
- retrieve<T = any>(id: string): Promise<T>;
6142
- /**
6143
- * Update a lead.
6144
- */
6145
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6146
- /**
6147
- * Delete a lead.
6148
- */
6149
- remove<T = any>(id: string): Promise<T>;
6150
- /**
6151
- * Update a lead's status.
6152
- */
6153
- updateStatus<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6154
- /**
6155
- * Record a lead's qualification.
6156
- */
6157
- qualification<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6158
- /**
6159
- * Record a lead's first contact.
6160
- */
6161
- firstContact<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
6162
- /**
6163
- * Record a follow-up for a lead.
6164
- */
6165
- followup<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6166
- /**
6167
- * List notes for a lead.
6168
- */
6169
- notes<T = any>(id: string): Promise<T>;
6170
- /**
6171
- * Add a note to a lead.
6172
- */
6173
- addNote<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6174
- /**
6175
- * Update a lead note.
6176
- */
6177
- updateNote<T = any>(id: string, noteId: string, body: Record<string, unknown>): Promise<T>;
6178
- /**
6179
- * Delete a lead note.
6180
- */
6181
- 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;
6182
3908
  }
6183
-
6184
3909
  /**
6185
- * Platform-admin OpenAPI resource — OpenAPI spec and health.
6186
- *
6187
- * 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`.
6188
3913
  */
6189
- declare class AdminOpenApi extends APIResource {
6190
- /**
6191
- * Retrieve the OpenAPI spec as JSON.
6192
- */
6193
- 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
+ }>;
6194
3930
  /**
6195
- * 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.
6196
3933
  */
6197
- 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>;
6198
3945
  /**
6199
- * 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.
6200
3948
  */
6201
- 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
+ }>;
6202
3961
  }
6203
3962
 
6204
3963
  /**
6205
- * Platform-admin partners resource — manage partners and their referrals.
3964
+ * Platform authentication resource — registration, login, sessions,
3965
+ * password management, OAuth linking, and organization invitations.
6206
3966
  *
6207
- * Access via `ecod.platform.admin.partners`.
3967
+ * Access via `ecod.platform.auth`.
6208
3968
  */
6209
- declare class AdminPartners extends APIResource {
6210
- /**
6211
- * Retrieve aggregate partner statistics.
6212
- */
6213
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
6214
- /**
6215
- * List all partners.
6216
- */
6217
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
6218
- /**
6219
- * Create a new partner.
6220
- */
6221
- create<T = any>(body: Record<string, unknown>): Promise<T>;
6222
- /**
6223
- * Retrieve a single partner by ID.
6224
- */
6225
- retrieve<T = any>(id: string): Promise<T>;
6226
- /**
6227
- * Update an existing partner.
6228
- */
6229
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
3969
+ declare class Auth extends APIResource {
6230
3970
  /**
6231
- * Delete a partner.
3971
+ * Register a new platform user / organization.
6232
3972
  */
6233
- remove<T = any>(id: string): Promise<T>;
3973
+ register<T = any>(body: Record<string, unknown>): Promise<T>;
6234
3974
  /**
6235
- * List referrals for a partner.
3975
+ * Authenticate a user and establish a session.
6236
3976
  */
6237
- referrals<T = any>(id: string): Promise<T>;
3977
+ login<T = any>(body: Record<string, unknown>): Promise<T>;
6238
3978
  /**
6239
- * Update a specific referral for a partner.
3979
+ * Log out of the current session.
6240
3980
  */
6241
- updateReferral<T = any>(id: string, refId: string, body: Record<string, unknown>): Promise<T>;
6242
- }
6243
-
6244
- /**
6245
- * Platform-admin payment operations resource — refunds, payment validation,
6246
- * retries, timelines, and risk assessment.
6247
- *
6248
- * Access via `ecod.platform.admin.paymentOps`.
6249
- */
6250
- declare class AdminPaymentOps extends APIResource {
3981
+ logout<T = any>(body: Record<string, unknown>): Promise<T>;
6251
3982
  /**
6252
- * Issue a refund.
3983
+ * Log out of every active session for the current user.
6253
3984
  */
6254
- refund<T = any>(body: Record<string, unknown>): Promise<T>;
3985
+ logoutAll<T = any>(body: Record<string, unknown>): Promise<T>;
6255
3986
  /**
6256
- * Validate a payment by ID.
3987
+ * Validate the current session token.
6257
3988
  */
6258
- validate<T = any>(paymentId: string): Promise<T>;
3989
+ validateSession<T = any>(body: Record<string, unknown>): Promise<T>;
6259
3990
  /**
6260
- * Fetch a payment by ID.
3991
+ * List all active sessions for the current user.
6261
3992
  */
6262
- fetch<T = any>(paymentId: string): Promise<T>;
3993
+ listSessions<T = any>(): Promise<T>;
6263
3994
  /**
6264
- * Retrieve a subscription by ID.
3995
+ * Revoke a specific session by its ID.
3996
+ *
3997
+ * @param id - The session ID to revoke.
6265
3998
  */
6266
- subscription<T = any>(subId: string): Promise<T>;
3999
+ revokeSession<T = any>(id: string): Promise<T>;
6267
4000
  /**
6268
- * List failed payments.
4001
+ * Request a one-time password (OTP) to set or change a password.
6269
4002
  */
6270
- failed<T = any>(params?: Record<string, unknown>): Promise<T>;
4003
+ requestPasswordOtp<T = any>(body: Record<string, unknown>): Promise<T>;
6271
4004
  /**
6272
- * Retry failed payments for an organization.
4005
+ * Set a password for the current user.
6273
4006
  */
6274
- retry<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4007
+ setPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6275
4008
  /**
6276
- * Retrieve the payment timeline for an organization.
4009
+ * Change the current user's password.
6277
4010
  */
6278
- timeline<T = any>(orgId: string): Promise<T>;
4011
+ changePassword<T = any>(body: Record<string, unknown>): Promise<T>;
6279
4012
  /**
6280
- * Retrieve the payment risk assessment for an organization.
4013
+ * Begin the forgot-password flow.
6281
4014
  */
6282
- risk<T = any>(orgId: string): Promise<T>;
6283
- }
6284
-
6285
- /**
6286
- * Platform-admin persona history resource — inspect persona version history.
6287
- *
6288
- * Access via `ecod.platform.admin.personaHistory`.
6289
- */
6290
- declare class AdminPersonaHistory extends APIResource {
4015
+ forgotPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6291
4016
  /**
6292
- * Retrieve aggregate persona history statistics.
4017
+ * Reset a password using a reset token.
6293
4018
  */
6294
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4019
+ resetPassword<T = any>(body: Record<string, unknown>): Promise<T>;
6295
4020
  /**
6296
- * List persona history entries.
4021
+ * Link an OAuth identity to the current user.
6297
4022
  */
6298
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4023
+ linkOAuth<T = any>(body: Record<string, unknown>): Promise<T>;
6299
4024
  /**
6300
- * Retrieve the history for a specific persona.
4025
+ * Retrieve details about an organization invitation by token.
4026
+ *
4027
+ * @param token - The invitation token.
6301
4028
  */
6302
- retrieve<T = any>(personaId: string): Promise<T>;
4029
+ getInvitation<T = any>(token: string): Promise<T>;
6303
4030
  /**
6304
- * 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.
6305
4035
  */
6306
- version<T = any>(personaId: string, version: string): Promise<T>;
4036
+ acceptInvitation<T = any>(token: string, body?: Record<string, unknown>): Promise<T>;
6307
4037
  }
6308
4038
 
6309
4039
  /**
6310
- * Platform-admin pipelines resource — pipeline template management and
6311
- * provisioning.
4040
+ * Entitlements resource — read current plan entitlements and usage.
6312
4041
  *
6313
- * Access via `ecod.platform.admin.pipelines`.
4042
+ * Access via `ecod.platform.billing.entitlements`.
6314
4043
  */
6315
- declare class AdminPipelines extends APIResource {
6316
- /**
6317
- * List pipeline templates.
6318
- */
6319
- templates<T = any>(params?: Record<string, unknown>): Promise<T>;
6320
- /**
6321
- * Create a new pipeline template.
6322
- */
6323
- createTemplate<T = any>(body: Record<string, unknown>): Promise<T>;
6324
- /**
6325
- * Update an existing pipeline template.
6326
- */
6327
- updateTemplate<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6328
- /**
6329
- * Delete a pipeline template.
6330
- */
6331
- deleteTemplate<T = any>(id: string): Promise<T>;
4044
+ declare class Entitlements extends APIResource {
6332
4045
  /**
6333
- * Provision pipelines from templates.
4046
+ * Retrieve the current organization's entitlements.
6334
4047
  */
6335
- provision<T = any>(body: Record<string, unknown>): Promise<T>;
4048
+ get<T = any>(): Promise<T>;
6336
4049
  /**
6337
- * Retrieve the pipelines overview.
4050
+ * Retrieve current usage against entitlements.
6338
4051
  */
6339
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
4052
+ usage<T = any>(): Promise<T>;
6340
4053
  }
6341
-
6342
4054
  /**
6343
- * Platform-admin plans resource — manage billing plans.
4055
+ * Subscriptions resource — manage plan upgrades, downgrades, cancellations,
4056
+ * and add-ons.
6344
4057
  *
6345
- * Access via `ecod.platform.admin.plans`.
4058
+ * Access via `ecod.platform.billing.subscriptions`.
6346
4059
  */
6347
- declare class AdminPlans extends APIResource {
4060
+ declare class Subscriptions extends APIResource {
6348
4061
  /**
6349
- * List all plans.
4062
+ * Upgrade the current subscription plan.
6350
4063
  */
6351
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4064
+ upgrade<T = any>(body: Record<string, unknown>): Promise<T>;
6352
4065
  /**
6353
- * Create a new plan.
4066
+ * Downgrade the current subscription plan.
6354
4067
  */
6355
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4068
+ downgrade<T = any>(body: Record<string, unknown>): Promise<T>;
6356
4069
  /**
6357
- * Update an existing plan.
4070
+ * Cancel the current subscription.
6358
4071
  */
6359
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4072
+ cancel<T = any>(body: Record<string, unknown>): Promise<T>;
6360
4073
  /**
6361
- * Delete a plan.
4074
+ * Purchase an add-on for the current subscription.
6362
4075
  */
6363
- remove<T = any>(id: string): Promise<T>;
4076
+ purchaseAddon<T = any>(body: Record<string, unknown>): Promise<T>;
6364
4077
  /**
6365
- * List tenants subscribed to a plan.
4078
+ * Cancel a previously purchased add-on.
6366
4079
  */
6367
- tenants<T = any>(id: string): Promise<T>;
4080
+ cancelAddon<T = any>(body: Record<string, unknown>): Promise<T>;
6368
4081
  }
6369
-
6370
4082
  /**
6371
- * Platform-admin revenue resource — revenue summaries and snapshots.
4083
+ * Plans resource — read publicly available plans.
6372
4084
  *
6373
- * Access via `ecod.platform.admin.revenue`.
4085
+ * Access via `ecod.platform.billing.plans`.
6374
4086
  */
6375
- declare class AdminRevenue extends APIResource {
6376
- /**
6377
- * Retrieve the aggregated revenue summary.
6378
- */
6379
- summary<T = any>(params?: Record<string, unknown>): Promise<T>;
6380
- /**
6381
- * List historical revenue snapshots.
6382
- */
6383
- snapshots<T = any>(params?: Record<string, unknown>): Promise<T>;
4087
+ declare class Plans extends APIResource {
6384
4088
  /**
6385
- * Generate a new revenue snapshot.
4089
+ * List all publicly available plans.
6386
4090
  */
6387
- generateSnapshot<T = any>(body?: Record<string, unknown>): Promise<T>;
4091
+ listPublic<T = any>(): Promise<T>;
6388
4092
  }
6389
-
6390
4093
  /**
6391
- * Platform-admin staff resource — admin staff account management.
6392
- *
6393
- * NOTE: the doubled `admin/staff` segments are intentional — a legacy router
6394
- * is mounted under the new prefix.
4094
+ * Billing checkout resource — plan selection, subscription, verification,
4095
+ * and synchronization.
6395
4096
  *
6396
- * Access via `ecod.platform.admin.staff`.
4097
+ * Access via `ecod.platform.billing.checkout`.
6397
4098
  */
6398
- declare class AdminStaff extends APIResource {
4099
+ declare class BillingCheckout extends APIResource {
6399
4100
  /**
6400
- * Verify staff credentials.
4101
+ * List plans available at checkout.
6401
4102
  */
6402
- verifyCredentials<T = any>(body: Record<string, unknown>): Promise<T>;
4103
+ plans<T = any>(): Promise<T>;
6403
4104
  /**
6404
- * Find an existing staff account or create one.
4105
+ * Subscribe to a plan via checkout.
6405
4106
  */
6406
- findOrCreate<T = any>(body: Record<string, unknown>): Promise<T>;
4107
+ subscribe<T = any>(body: Record<string, unknown>): Promise<T>;
6407
4108
  /**
6408
- * List admin staff accounts.
4109
+ * Verify a checkout payment.
6409
4110
  */
6410
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4111
+ verify<T = any>(body: Record<string, unknown>): Promise<T>;
6411
4112
  /**
6412
- * Create an admin staff account.
4113
+ * Cancel an in-progress checkout.
6413
4114
  */
6414
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4115
+ cancel<T = any>(body: Record<string, unknown>): Promise<T>;
6415
4116
  /**
6416
- * Update an admin staff account.
4117
+ * Retrieve the current checkout status.
6417
4118
  */
6418
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4119
+ status<T = any>(): Promise<T>;
6419
4120
  /**
6420
- * Delete an admin staff account.
4121
+ * Synchronize the checkout plan state with the provider.
6421
4122
  */
6422
- remove<T = any>(id: string): Promise<T>;
4123
+ syncPlan<T = any>(body: Record<string, unknown>): Promise<T>;
6423
4124
  }
6424
-
6425
4125
  /**
6426
- * Platform-admin storage resource — storage statistics, events, and usage.
4126
+ * Billing user resource — transactions, subscription, and disputes for the
4127
+ * current user.
6427
4128
  *
6428
- * Access via `ecod.platform.admin.storage`.
4129
+ * Access via `ecod.platform.billing.user`.
6429
4130
  */
6430
- declare class AdminStorage extends APIResource {
4131
+ declare class BillingUser extends APIResource {
6431
4132
  /**
6432
- * Retrieve aggregate storage statistics.
4133
+ * List the current user's billing transactions.
6433
4134
  */
6434
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4135
+ transactions<T = any>(): Promise<T>;
6435
4136
  /**
6436
- * List storage events.
4137
+ * Retrieve the current user's subscription.
6437
4138
  */
6438
- events<T = any>(params?: Record<string, unknown>): Promise<T>;
4139
+ subscription<T = any>(): Promise<T>;
6439
4140
  /**
6440
- * Retrieve storage usage.
4141
+ * Raise a billing dispute.
6441
4142
  */
6442
- usage<T = any>(params?: Record<string, unknown>): Promise<T>;
6443
- }
6444
-
6445
- /**
6446
- * Platform-admin system health resource — system health overview.
6447
- *
6448
- * Access via `ecod.platform.admin.health`.
6449
- */
6450
- declare class AdminHealth extends APIResource {
4143
+ raiseDispute<T = any>(body: Record<string, unknown>): Promise<T>;
6451
4144
  /**
6452
- * Retrieve the system health overview.
4145
+ * List the current user's billing disputes.
6453
4146
  */
6454
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
4147
+ disputes<T = any>(): Promise<T>;
6455
4148
  }
6456
-
6457
4149
  /**
6458
- * Platform-admin templates resource — manage templates, versions, and
6459
- * plan assignments.
4150
+ * Credits resource — balance, transactions, packs, and top-ups.
6460
4151
  *
6461
- * Access via `ecod.platform.admin.templates`.
4152
+ * Access via `ecod.platform.billing.credits`.
6462
4153
  */
6463
- declare class AdminTemplates extends APIResource {
6464
- /**
6465
- * List all templates.
6466
- */
6467
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4154
+ declare class Credits extends APIResource {
6468
4155
  /**
6469
- * Create a new template.
4156
+ * Retrieve the current credit balance.
6470
4157
  */
6471
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4158
+ balance<T = any>(): Promise<T>;
6472
4159
  /**
6473
- * Retrieve a single template by ID.
4160
+ * List credit transactions.
6474
4161
  */
6475
- retrieve<T = any>(id: string): Promise<T>;
4162
+ transactions<T = any>(): Promise<T>;
6476
4163
  /**
6477
- * Update an existing template.
4164
+ * List available credit packs.
6478
4165
  */
6479
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4166
+ packs<T = any>(): Promise<T>;
6480
4167
  /**
6481
- * Delete a template.
4168
+ * Create a credit top-up order.
6482
4169
  */
6483
- remove<T = any>(id: string): Promise<T>;
4170
+ topupOrder<T = any>(body: Record<string, unknown>): Promise<T>;
6484
4171
  /**
6485
- * Clone an existing template.
4172
+ * Verify a credit top-up payment.
6486
4173
  */
6487
- clone<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4174
+ verifyTopup<T = any>(body: Record<string, unknown>): Promise<T>;
6488
4175
  /**
6489
- * List versions of a template.
4176
+ * Configure automatic credit top-ups.
6490
4177
  */
6491
- versions<T = any>(id: string): Promise<T>;
4178
+ setAutoTopup<T = any>(body: Record<string, unknown>): Promise<T>;
6492
4179
  /**
6493
- * Assign plans to a template.
4180
+ * Configure the daily spend cap (cost control).
4181
+ * Body: `{ dailyCap: number | null, alertPct?: number }`.
6494
4182
  */
6495
- 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);
6496
4199
  }
6497
4200
 
6498
4201
  /**
6499
- * Platform-admin tenants resource — deep tenant inspection and lifecycle control.
4202
+ * Platform support resource — categories and support ticket lifecycle.
6500
4203
  *
6501
- * Access via `ecod.platform.admin.tenants`.
4204
+ * Access via `ecod.platform.support`.
6502
4205
  */
6503
- declare class AdminTenants extends APIResource {
6504
- /**
6505
- * Retrieve a deep, fully-expanded view of a tenant organization.
6506
- */
6507
- deep<T = any>(orgId: string): Promise<T>;
6508
- /**
6509
- * Retrieve usage metrics for a tenant organization.
6510
- */
6511
- usage<T = any>(orgId: string): Promise<T>;
6512
- /**
6513
- * Retrieve the team/members for a tenant organization.
6514
- */
6515
- team<T = any>(orgId: string): Promise<T>;
6516
- /**
6517
- * Retrieve billing details for a tenant organization.
6518
- */
6519
- billing<T = any>(orgId: string): Promise<T>;
6520
- /**
6521
- * Retrieve WhatsApp configuration for a tenant organization.
6522
- */
6523
- whatsapp<T = any>(orgId: string): Promise<T>;
6524
- /**
6525
- * Retrieve automation flows for a tenant organization.
6526
- */
6527
- flows<T = any>(orgId: string): Promise<T>;
6528
- /**
6529
- * Retrieve CRM statistics for a tenant organization.
6530
- */
6531
- crmStats<T = any>(orgId: string): Promise<T>;
6532
- /**
6533
- * Impersonate a tenant organization.
6534
- */
6535
- impersonate<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4206
+ declare class Support extends APIResource {
6536
4207
  /**
6537
- * Suspend a tenant organization.
4208
+ * List available support categories.
6538
4209
  */
6539
- suspend<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4210
+ categories<T = any>(): Promise<T>;
6540
4211
  /**
6541
- * Reactivate a suspended tenant organization.
4212
+ * List support tickets with optional filtering.
4213
+ *
4214
+ * @param params - Optional query parameters (status, pagination, etc.).
6542
4215
  */
6543
- reactivate<T = any>(orgId: string, body?: Record<string, unknown>): Promise<T>;
4216
+ listTickets<T = any>(params?: Record<string, unknown>): Promise<T>;
6544
4217
  /**
6545
- * Update the plan assigned to a tenant organization.
4218
+ * Create a new support ticket.
6546
4219
  */
6547
- updatePlan<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
4220
+ createTicket<T = any>(body: Record<string, unknown>): Promise<T>;
6548
4221
  /**
6549
- * Update usage limits for a tenant organization.
4222
+ * Retrieve a single support ticket by its ID.
4223
+ *
4224
+ * @param id - The support ticket ID.
6550
4225
  */
6551
- updateLimits<T = any>(orgId: string, body: Record<string, unknown>): Promise<T>;
4226
+ getTicket<T = any>(id: string): Promise<T>;
6552
4227
  /**
6553
- * 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.
6554
4232
  */
6555
- bulkAssignPlan<T = any>(body: Record<string, unknown>): Promise<T>;
4233
+ reply<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
6556
4234
  /**
6557
- * List tenant organizations that have no plan assigned.
4235
+ * Close a support ticket.
4236
+ *
4237
+ * @param id - The support ticket ID.
6558
4238
  */
6559
- unassigned<T = any>(): Promise<T>;
4239
+ close<T = any>(id: string): Promise<T>;
6560
4240
  }
6561
4241
 
6562
4242
  /**
6563
- * Platform-admin tickets resource — manage support tickets, messages, and
6564
- * lifecycle transitions.
4243
+ * Current-user ("me") resource — profile, organization, modules,
4244
+ * workspaces, and active-org management.
6565
4245
  *
6566
- * Access via `ecod.platform.admin.tickets`.
4246
+ * Access via `ecod.platform.users.me`.
6567
4247
  */
6568
- declare class AdminTickets extends APIResource {
6569
- /**
6570
- * Retrieve aggregate ticket statistics.
6571
- */
6572
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
4248
+ declare class Me extends APIResource {
6573
4249
  /**
6574
- * List all tickets.
4250
+ * Retrieve the current authenticated user's profile.
6575
4251
  */
6576
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4252
+ get<T = any>(): Promise<T>;
6577
4253
  /**
6578
- * Create a new ticket.
4254
+ * Update the current user's profile.
6579
4255
  */
6580
- create<T = any>(body: Record<string, unknown>): Promise<T>;
4256
+ update<T = any>(body: Record<string, unknown>): Promise<T>;
6581
4257
  /**
6582
- * Retrieve a single ticket by ID.
4258
+ * Update the current user's active organization details.
6583
4259
  */
6584
- retrieve<T = any>(id: string): Promise<T>;
4260
+ updateOrganization<T = any>(body: Record<string, unknown>): Promise<T>;
6585
4261
  /**
6586
- * Update an existing ticket.
4262
+ * Toggle enabled modules for the current user / organization.
6587
4263
  */
6588
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4264
+ toggleModules<T = any>(body: Record<string, unknown>): Promise<T>;
6589
4265
  /**
6590
- * Add a message to a ticket.
4266
+ * List the workspaces available to the current user.
6591
4267
  */
6592
- addMessage<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4268
+ workspaces<T = any>(): Promise<T>;
6593
4269
  /**
6594
- * Resolve a ticket.
4270
+ * Set the active organization for the current user.
6595
4271
  */
6596
- resolve<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4272
+ setActiveOrg<T = any>(body: Record<string, unknown>): Promise<T>;
6597
4273
  /**
6598
- * Close a ticket.
4274
+ * Dismiss the workspace setup prompt for the current user.
6599
4275
  */
6600
- close<T = any>(id: string, body?: Record<string, unknown>): Promise<T>;
4276
+ dismissWorkspaceSetup<T = any>(): Promise<T>;
6601
4277
  }
6602
-
6603
4278
  /**
6604
- * Platform-admin waitlist resource — manage waitlist entries.
4279
+ * Organization members resource — list, invite, and remove members.
6605
4280
  *
6606
- * Access via `ecod.platform.admin.waitlist`.
4281
+ * Access via `ecod.platform.users.members`.
6607
4282
  */
6608
- declare class AdminWaitlist extends APIResource {
6609
- /**
6610
- * Retrieve aggregate waitlist statistics.
6611
- */
6612
- stats<T = any>(params?: Record<string, unknown>): Promise<T>;
6613
- /**
6614
- * List waitlist entries.
6615
- */
6616
- list<T = any>(params?: Record<string, unknown>): Promise<T>;
4283
+ declare class Members extends APIResource {
6617
4284
  /**
6618
- * Retrieve a single waitlist entry by ID.
4285
+ * List all members of the current organization.
6619
4286
  */
6620
- retrieve<T = any>(id: string): Promise<T>;
4287
+ list<T = any>(): Promise<T>;
6621
4288
  /**
6622
- * Update a waitlist entry.
4289
+ * Invite a new member to the current organization.
6623
4290
  */
6624
- update<T = any>(id: string, body: Record<string, unknown>): Promise<T>;
4291
+ invite<T = any>(body: Record<string, unknown>): Promise<T>;
6625
4292
  /**
6626
- * Remove a waitlist entry.
4293
+ * Remove a member from the current organization.
4294
+ *
4295
+ * @param id - The member ID to remove.
6627
4296
  */
6628
4297
  remove<T = any>(id: string): Promise<T>;
6629
- /**
6630
- * Perform a bulk operation on waitlist entries.
6631
- */
6632
- bulk<T = any>(body: Record<string, unknown>): Promise<T>;
6633
4298
  }
6634
-
6635
4299
  /**
6636
- * Platform-admin WhatsApp control resource — cross-tenant WhatsApp monitoring.
4300
+ * User sessions resource — list and revoke sessions.
6637
4301
  *
6638
- * Access via `ecod.platform.admin.whatsapp`.
4302
+ * Access via `ecod.platform.users.sessions`.
6639
4303
  */
6640
- declare class AdminWhatsApp extends APIResource {
6641
- /**
6642
- * Retrieve the platform-wide WhatsApp overview.
6643
- */
6644
- overview<T = any>(params?: Record<string, unknown>): Promise<T>;
6645
- /**
6646
- * List all WhatsApp Business Accounts (WABAs).
6647
- */
6648
- wabas<T = any>(params?: Record<string, unknown>): Promise<T>;
6649
- /**
6650
- * List WhatsApp message templates across tenants.
6651
- */
6652
- templates<T = any>(params?: Record<string, unknown>): Promise<T>;
4304
+ declare class Sessions extends APIResource {
6653
4305
  /**
6654
- * Retrieve WhatsApp delivery metrics.
4306
+ * List all sessions for the current user.
6655
4307
  */
6656
- delivery<T = any>(params?: Record<string, unknown>): Promise<T>;
4308
+ list<T = any>(): Promise<T>;
6657
4309
  /**
6658
- * List WhatsApp webhook events.
4310
+ * Revoke a specific session by its ID.
4311
+ *
4312
+ * @param id - The session ID to revoke.
6659
4313
  */
6660
- webhooks<T = any>(params?: Record<string, unknown>): Promise<T>;
4314
+ revoke<T = any>(id: string): Promise<T>;
6661
4315
  }
6662
4316
 
6663
4317
  /**
@@ -6675,36 +4329,34 @@ declare class AdminWhatsApp extends APIResource {
6675
4329
  * mounted v1 endpoint are wired.
6676
4330
  */
6677
4331
 
6678
- /** 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
+ */
6679
4337
  declare class ErixChat {
6680
4338
  readonly messages: Messages;
6681
4339
  readonly conversations: Conversations;
6682
- readonly broadcasts: Broadcasts;
6683
4340
  constructor(client: AxiosInstance);
6684
4341
  }
6685
4342
  /** Every ERIX product resource (`/v1/api/product/erix/*`). */
6686
4343
  declare class ErixProduct {
6687
4344
  readonly leads: Leads;
6688
4345
  readonly pipelines: Pipelines;
6689
- readonly automations: Automations;
6690
4346
  readonly activities: Activities;
6691
4347
  readonly analytics: Analytics;
6692
4348
  readonly scoring: Scoring;
6693
4349
  readonly payments: Payments;
6694
- readonly sequences: Sequences;
6695
- readonly automationDashboard: AutomationDashboard;
6696
4350
  readonly chat: ErixChat;
6697
4351
  readonly events: EventsResource;
6698
- readonly eventLog: Logs;
6699
4352
  readonly invoices: Invoices;
6700
4353
  readonly checkout: Checkout;
6701
4354
  readonly projects: ProjectDocuments;
6702
- readonly campaigns: Campaigns;
6703
- readonly portalInbox: PortalInbox;
6704
4355
  readonly niche: NicheResources;
6705
4356
  readonly documents: CRMDocuments;
6706
4357
  readonly invoiceExport: CRMInvoiceExport;
6707
- readonly crmCampaigns: CRMCampaigns;
4358
+ /** The AI agent: settings + inbox drafts. */
4359
+ readonly ai: AiAgent;
6708
4360
  constructor(client: AxiosInstance);
6709
4361
  }
6710
4362
  /** Product domain root (`/v1/api/product/*`). */
@@ -6758,52 +4410,6 @@ declare class PlatformUsers {
6758
4410
  readonly notifications: Notifications;
6759
4411
  constructor(client: AxiosInstance);
6760
4412
  }
6761
- /**
6762
- * Admin control plane (`/platform/admin/*`) — requires the elevated
6763
- * `coreApiKey`. This is the full platform-admin console surface consumed by
6764
- * the `admin` app.
6765
- */
6766
- declare class PlatformAdmin {
6767
- readonly revenue: AdminRevenue;
6768
- readonly billing: AdminBilling;
6769
- readonly payments: AdminPaymentOps;
6770
- readonly credits: AdminCredits;
6771
- readonly plans: AdminPlans;
6772
- readonly agencyInvoices: AdminAgencyInvoices;
6773
- readonly flags: AdminFeatureFlags;
6774
- readonly activityLogs: AdminActivityLogs;
6775
- readonly auditLogs: AdminAuditLogs;
6776
- readonly analytics: AdminAnalytics;
6777
- readonly health: AdminHealth;
6778
- readonly storage: AdminStorage;
6779
- readonly announcements: AdminAnnouncements;
6780
- readonly compliance: AdminCompliance;
6781
- readonly tickets: AdminTickets;
6782
- readonly templates: AdminTemplates;
6783
- readonly agents: AdminAgents;
6784
- readonly personaHistory: AdminPersonaHistory;
6785
- readonly openapi: AdminOpenApi;
6786
- readonly staff: AdminStaff;
6787
- readonly tenants: AdminTenants;
6788
- readonly whatsapp: AdminWhatsApp;
6789
- readonly laie: AdminLaie;
6790
- readonly laieRuntime: AdminLaieRuntime;
6791
- readonly laieVault: AdminLaieVault;
6792
- readonly flow: AdminFlow;
6793
- readonly email: AdminEmail;
6794
- readonly pipelines: AdminPipelines;
6795
- readonly integrations: AdminIntegrations;
6796
- readonly erix: AdminErix;
6797
- readonly dashboard: AdminDashboard;
6798
- readonly partners: AdminPartners;
6799
- readonly waitlist: AdminWaitlist;
6800
- readonly blogs: AdminBlogs;
6801
- readonly leads: AdminLeads;
6802
- readonly onboarding: AdminOnboarding;
6803
- readonly cors: Cors;
6804
- readonly clients: Services;
6805
- constructor(client: AxiosInstance);
6806
- }
6807
4413
  /** Platform control plane (`/platform/*`). */
6808
4414
  declare class PlatformDomain {
6809
4415
  readonly auth: Auth;
@@ -6812,7 +4418,8 @@ declare class PlatformDomain {
6812
4418
  readonly billing: Billing;
6813
4419
  readonly support: Support;
6814
4420
  readonly ai: PlatformAI;
6815
- readonly admin: PlatformAdmin;
4421
+ /** The AI agent's knowledge base (RAG). */
4422
+ readonly knowledge: Knowledge;
6816
4423
  readonly health: Health;
6817
4424
  constructor(client: AxiosInstance);
6818
4425
  }
@@ -6911,7 +4518,8 @@ declare class Webhooks {
6911
4518
  /**
6912
4519
  * Configuration options for the ECODrIxAPI client.
6913
4520
  *
6914
- * 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.
6915
4523
  * The backend URL is managed internally and should not need to be changed.
6916
4524
  */
6917
4525
  interface ECODrIxAPIOptions {
@@ -6920,18 +4528,13 @@ interface ECODrIxAPIOptions {
6920
4528
  * Obtain this from the ECODrIx dashboard under Settings → API Keys.
6921
4529
  * @example "ecod_live_sk_..."
6922
4530
  */
6923
- apiKey: string;
4531
+ apiKey?: string;
6924
4532
  /**
6925
4533
  * Your tenant ID (Client Code).
6926
4534
  * This scopes all API requests to your specific organisation.
6927
4535
  * @example "ERIX_CLNT_JHBJHF"
6928
4536
  */
6929
4537
  clientCode?: string;
6930
- /**
6931
- * Optional Core API Key for deep system-level bypasses.
6932
- * Only used by elevated internal SaaS modules like Nirvisham.
6933
- */
6934
- coreApiKey?: string;
6935
4538
  /**
6936
4539
  * API route version to target. This is the ONLY knob for moving the entire
6937
4540
  * SDK to a new server API version — every endpoint is issued relative to
@@ -6962,6 +4565,27 @@ interface ECODrIxAPIOptions {
6962
4565
  * caller forever). Defaults to 30000 (30s). Set 0 to disable.
6963
4566
  */
6964
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
+ };
6965
4589
  }
6966
4590
  /**
6967
4591
  * The primary entry point for the ECODrIx SDK.
@@ -7033,6 +4657,8 @@ declare class ECODrIxAPI {
7033
4657
  * @param roomId - The unique identifier for the room.
7034
4658
  */
7035
4659
  leaveRoom(roomId: string): void;
4660
+ /** Highest event `seq` seen — sent on reconnect so missed events replay. */
4661
+ private lastSeq;
7036
4662
  private setupSocket;
7037
4663
  /**
7038
4664
  * Subscribe to a real-time event emitted by the ECODrIx platform.
@@ -7042,14 +4668,24 @@ declare class ECODrIxAPI {
7042
4668
  * your own tenant.
7043
4669
  *
7044
4670
  * **Standard events:**
7045
- * - `new_message` — inbound WhatsApp message (includes conversation and message payload)
7046
- * - `message_sent` — outbound message successfully sent
7047
- * - `message_status_update` — WhatsApp message status change (delivered, read, failed)
7048
- * - `conversation_updated` — metadata change (unread count, last message, status)
7049
- * - `message_updated` — real-time updates for reactions or media processing
7050
- * - `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
7051
4682
  * - `workflow-run-update` — automation execution progress
7052
- * - `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).
7053
4689
  *
7054
4690
  * @param event - The event name to subscribe to.
7055
4691
  * @param callback - The handler function invoked when the event fires.
@@ -7073,6 +4709,7 @@ declare class ECODrIxAPI {
7073
4709
  * process.on("SIGTERM", () => ecod.disconnect());
7074
4710
  * ```
7075
4711
  */
4712
+ private closed;
7076
4713
  disconnect(): void;
7077
4714
  /**
7078
4715
  * Remove a previously registered event listener.
@@ -7465,4 +5102,4 @@ declare function getRetryConfig(error: any): {
7465
5102
  readonly reason: "Generic API errors may be transient and worth retrying";
7466
5103
  };
7467
5104
 
7468
- 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 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 TemplateComponent, 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 };