@workbenchcrm/sdk 1.0.3 → 1.1.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.
package/dist/index.d.mts CHANGED
@@ -98,9 +98,13 @@ interface ApiError {
98
98
  meta: ResponseMeta;
99
99
  }
100
100
  /**
101
- * Client status values
101
+ * Client status values (lifecycle status)
102
102
  */
103
- type ClientStatus = 'active' | 'inactive' | 'lead' | 'prospect' | 'archived';
103
+ type ClientStatus = 'active' | 'inactive' | 'archived';
104
+ /**
105
+ * Lead status values (pipeline stage for leads)
106
+ */
107
+ type LeadStatus = 'new' | 'contacted' | 'qualified' | 'proposal' | 'negotiation' | 'won' | 'lost';
104
108
  /**
105
109
  * Client record
106
110
  */
@@ -113,6 +117,8 @@ interface Client {
113
117
  email: string | null;
114
118
  phone: string | null;
115
119
  status: ClientStatus;
120
+ /** Lead pipeline stage */
121
+ lead_status: LeadStatus | null;
116
122
  source: string | null;
117
123
  notes: string | null;
118
124
  /** Internal notes visible only to business users */
@@ -132,7 +138,10 @@ interface CreateClientOptions {
132
138
  company?: string | null;
133
139
  email?: string | null;
134
140
  phone?: string | null;
141
+ /** Client lifecycle status (defaults to 'active') */
135
142
  status?: ClientStatus;
143
+ /** Lead pipeline stage (defaults to 'new') */
144
+ lead_status?: LeadStatus | null;
136
145
  source?: string | null;
137
146
  notes?: string | null;
138
147
  internal_notes?: string | null;
@@ -150,6 +159,7 @@ interface UpdateClientOptions extends Partial<CreateClientOptions> {
150
159
  */
151
160
  interface ListClientsOptions extends ListOptions {
152
161
  status?: ClientStatus;
162
+ lead_status?: LeadStatus;
153
163
  }
154
164
  /**
155
165
  * Invoice status values
@@ -519,6 +529,89 @@ interface WebhookEventTypeInfo {
519
529
  description: string;
520
530
  category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
521
531
  }
532
+ /**
533
+ * Notification type - who receives the notification
534
+ */
535
+ type NotificationType = 'CLIENT' | 'BUSINESS';
536
+ /**
537
+ * Notification events supported by the SDK
538
+ * - sdk_client_created: Welcome notification for new clients
539
+ * - sdk_request_created: New service request notification
540
+ * - sdk_quote_created: Quote sent notification
541
+ * - sdk_invoice_created: Invoice sent notification
542
+ * - sdk_job_created: Job scheduled notification
543
+ * - sdk_custom: Custom notification (requires subject/html overrides)
544
+ */
545
+ type NotificationEvent = 'sdk_client_created' | 'sdk_request_created' | 'sdk_quote_created' | 'sdk_invoice_created' | 'sdk_job_created' | 'sdk_custom';
546
+ /**
547
+ * Business user roles for BUSINESS notifications
548
+ */
549
+ type BusinessUserRole = 'owner' | 'admin' | 'manager' | 'member';
550
+ /**
551
+ * Base options for sending notifications
552
+ */
553
+ interface SendNotificationBaseOptions {
554
+ /** Template data for variable interpolation (e.g., client_name, quote_total) */
555
+ templateData?: Record<string, string | number>;
556
+ /** Custom subject line (overrides template) */
557
+ subjectOverride?: string;
558
+ /** Custom HTML body (overrides template) */
559
+ htmlOverride?: string;
560
+ /** Entity type for audit logging (e.g., 'client', 'invoice') */
561
+ entityType?: string;
562
+ /** Entity ID for audit logging */
563
+ entityId?: string;
564
+ }
565
+ /**
566
+ * Options for sending a notification to a client
567
+ */
568
+ interface SendToClientOptions extends SendNotificationBaseOptions {
569
+ /** Client ID to send the notification to */
570
+ clientId: string;
571
+ /** Event type for template selection */
572
+ event: NotificationEvent;
573
+ }
574
+ /**
575
+ * Options for sending a notification to business team members
576
+ */
577
+ interface SendToTeamOptions extends SendNotificationBaseOptions {
578
+ /** Event type for template selection */
579
+ event: NotificationEvent;
580
+ /** Roles to notify (defaults to all if not specified) */
581
+ roles?: BusinessUserRole[];
582
+ }
583
+ /**
584
+ * Options for sending a custom notification
585
+ */
586
+ interface SendCustomNotificationOptions extends SendNotificationBaseOptions {
587
+ /** Notification type - CLIENT or BUSINESS */
588
+ type: NotificationType;
589
+ /** Client ID (required for CLIENT type) */
590
+ clientId?: string;
591
+ /** Roles to notify (for BUSINESS type) */
592
+ roles?: BusinessUserRole[];
593
+ /** Required: Custom subject line */
594
+ subject: string;
595
+ /** Required: Custom HTML body */
596
+ html: string;
597
+ }
598
+ /**
599
+ * Result of sending notifications
600
+ */
601
+ interface NotificationResult {
602
+ /** Whether at least one notification was sent successfully */
603
+ success: boolean;
604
+ /** Unique ID for this notification batch */
605
+ notification_id: string;
606
+ /** Total number of recipients */
607
+ recipients_count: number;
608
+ /** Number of successful email sends */
609
+ sent_count: number;
610
+ /** Number of failed email sends */
611
+ failed_count: number;
612
+ /** Error messages if any failures occurred */
613
+ errors?: string[];
614
+ }
522
615
 
523
616
  /**
524
617
  * @file resources/clients.ts
@@ -1386,6 +1479,156 @@ declare class WebhooksResource {
1386
1479
  listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
1387
1480
  }
1388
1481
 
1482
+ /**
1483
+ * Notifications Resource
1484
+ *
1485
+ * Provides methods for sending email notifications to clients and
1486
+ * business team members via the Workbench API.
1487
+ *
1488
+ * @module resources/notifications
1489
+ *
1490
+ * @example
1491
+ * // Send a welcome notification to a new client
1492
+ * await workbench.notifications.sendToClient({
1493
+ * clientId: 'client-uuid',
1494
+ * event: 'sdk_client_created',
1495
+ * templateData: { client_name: 'John Doe' }
1496
+ * });
1497
+ *
1498
+ * @example
1499
+ * // Notify business admins about a new request
1500
+ * await workbench.notifications.sendToTeam({
1501
+ * event: 'sdk_request_created',
1502
+ * roles: ['owner', 'admin'],
1503
+ * templateData: { request_title: 'AC Repair', client_name: 'John' }
1504
+ * });
1505
+ *
1506
+ * @example
1507
+ * // Send a custom notification
1508
+ * await workbench.notifications.sendCustom({
1509
+ * type: 'CLIENT',
1510
+ * clientId: 'client-uuid',
1511
+ * subject: 'Your appointment is confirmed!',
1512
+ * html: '<h1>Confirmed!</h1><p>See you tomorrow at 10am.</p>'
1513
+ * });
1514
+ */
1515
+
1516
+ /**
1517
+ * Notifications resource for sending email notifications via the SDK
1518
+ */
1519
+ declare class NotificationsResource {
1520
+ private readonly client;
1521
+ constructor(client: WorkbenchClient);
1522
+ /**
1523
+ * Send a notification to a specific client
1524
+ *
1525
+ * Sends an email notification to a client using a predefined template
1526
+ * or custom content. The client must have a valid email address.
1527
+ *
1528
+ * @param options - Notification options
1529
+ * @returns Notification result with delivery statistics
1530
+ *
1531
+ * @example
1532
+ * // Welcome a new client
1533
+ * const result = await workbench.notifications.sendToClient({
1534
+ * clientId: 'client-uuid',
1535
+ * event: 'sdk_client_created',
1536
+ * templateData: {
1537
+ * client_name: 'John Doe'
1538
+ * }
1539
+ * });
1540
+ * console.log(`Sent to ${result.data.sent_count} recipient(s)`);
1541
+ *
1542
+ * @example
1543
+ * // Notify client about a new quote with custom subject
1544
+ * const result = await workbench.notifications.sendToClient({
1545
+ * clientId: 'client-uuid',
1546
+ * event: 'sdk_quote_created',
1547
+ * templateData: {
1548
+ * client_name: 'John',
1549
+ * quote_number: 'Q-001',
1550
+ * quote_total: '$1,500.00'
1551
+ * },
1552
+ * subjectOverride: 'Your custom quote is ready!'
1553
+ * });
1554
+ */
1555
+ sendToClient(options: SendToClientOptions): Promise<ApiResponse<NotificationResult>>;
1556
+ /**
1557
+ * Send a notification to business team members
1558
+ *
1559
+ * Sends an email notification to team members, optionally filtered
1560
+ * by their role in the business.
1561
+ *
1562
+ * @param options - Notification options
1563
+ * @returns Notification result with delivery statistics
1564
+ *
1565
+ * @example
1566
+ * // Notify all team members about a new service request
1567
+ * const result = await workbench.notifications.sendToTeam({
1568
+ * event: 'sdk_request_created',
1569
+ * templateData: {
1570
+ * request_title: 'Emergency AC Repair',
1571
+ * client_name: 'John Doe',
1572
+ * request_description: 'AC not cooling, needs urgent attention'
1573
+ * }
1574
+ * });
1575
+ *
1576
+ * @example
1577
+ * // Notify only owners and admins
1578
+ * const result = await workbench.notifications.sendToTeam({
1579
+ * event: 'sdk_invoice_created',
1580
+ * roles: ['owner', 'admin'],
1581
+ * templateData: {
1582
+ * invoice_number: 'INV-001',
1583
+ * invoice_total: '$2,500.00',
1584
+ * client_name: 'Acme Corp'
1585
+ * }
1586
+ * });
1587
+ */
1588
+ sendToTeam(options: SendToTeamOptions): Promise<ApiResponse<NotificationResult>>;
1589
+ /**
1590
+ * Send a custom notification
1591
+ *
1592
+ * Sends a notification with fully custom subject and HTML content.
1593
+ * Can be sent to either a client or business team members.
1594
+ *
1595
+ * @param options - Custom notification options
1596
+ * @returns Notification result with delivery statistics
1597
+ *
1598
+ * @example
1599
+ * // Send custom appointment confirmation to client
1600
+ * const result = await workbench.notifications.sendCustom({
1601
+ * type: 'CLIENT',
1602
+ * clientId: 'client-uuid',
1603
+ * subject: 'Your appointment is confirmed for tomorrow!',
1604
+ * html: `
1605
+ * <h1>Appointment Confirmed</h1>
1606
+ * <p>Hi John,</p>
1607
+ * <p>Your appointment has been confirmed:</p>
1608
+ * <ul>
1609
+ * <li><strong>Date:</strong> January 23, 2026</li>
1610
+ * <li><strong>Time:</strong> 10:00 AM</li>
1611
+ * <li><strong>Service:</strong> AC Maintenance</li>
1612
+ * </ul>
1613
+ * <p>See you tomorrow!</p>
1614
+ * `
1615
+ * });
1616
+ *
1617
+ * @example
1618
+ * // Send custom alert to admins
1619
+ * const result = await workbench.notifications.sendCustom({
1620
+ * type: 'BUSINESS',
1621
+ * roles: ['owner', 'admin'],
1622
+ * subject: 'High-value quote approved!',
1623
+ * html: '<p>Quote Q-001 for $10,000 has been approved by Acme Corp.</p>',
1624
+ * templateData: {
1625
+ * quote_number: 'Q-001'
1626
+ * }
1627
+ * });
1628
+ */
1629
+ sendCustom(options: SendCustomNotificationOptions): Promise<ApiResponse<NotificationResult>>;
1630
+ }
1631
+
1389
1632
  /**
1390
1633
  * @file client.ts
1391
1634
  * @description Main Workbench API client class
@@ -1474,6 +1717,8 @@ declare class WorkbenchClient {
1474
1717
  readonly serviceRequests: ServiceRequestsResource;
1475
1718
  /** Webhooks resource */
1476
1719
  readonly webhooks: WebhooksResource;
1720
+ /** Notifications resource */
1721
+ readonly notifications: NotificationsResource;
1477
1722
  /**
1478
1723
  * Create a new Workbench client
1479
1724
  *
@@ -1655,4 +1900,4 @@ declare function constructWebhookEvent<T = Record<string, unknown>>(payload: str
1655
1900
  timestamp: string;
1656
1901
  };
1657
1902
 
1658
- export { type ApiError, type ApiResponse, type Client, type ClientStatus, ClientsResource, type CreateClientOptions, type CreateInvoiceOptions, type CreateJobOptions, type CreateQuoteOptions, type CreateServiceRequestOptions, type CreateWebhookOptions, type Invoice, type InvoiceItem, type InvoiceStatus, InvoicesResource, type Job, type JobPriority, type JobStatus, JobsResource, type ListClientsOptions, type ListInvoicesOptions, type ListJobsOptions, type ListOptions, type ListQuotesOptions, type ListResponse, type ListServiceRequestsOptions, type ListWebhookDeliveriesOptions, type Pagination, type Quote, type QuoteItem, type QuoteStatus, QuotesResource, type RequestOptions, type ResponseMeta, type ServiceRequest, type ServiceRequestPriority, type ServiceRequestStatus, ServiceRequestsResource, type UpdateClientOptions, type UpdateInvoiceOptions, type UpdateJobOptions, type UpdateQuoteOptions, type UpdateServiceRequestOptions, type UpdateWebhookOptions, type VerifyOptions, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookSignature, WebhookVerificationError, WebhooksResource, WorkbenchClient, type WorkbenchConfig, WorkbenchError, computeSignature, constructWebhookEvent, parseSignatureHeader, verifyWebhookSignature };
1903
+ export { type ApiError, type ApiResponse, type BusinessUserRole, type Client, type ClientStatus, ClientsResource, type CreateClientOptions, type CreateInvoiceOptions, type CreateJobOptions, type CreateQuoteOptions, type CreateServiceRequestOptions, type CreateWebhookOptions, type Invoice, type InvoiceItem, type InvoiceStatus, InvoicesResource, type Job, type JobPriority, type JobStatus, JobsResource, type ListClientsOptions, type ListInvoicesOptions, type ListJobsOptions, type ListOptions, type ListQuotesOptions, type ListResponse, type ListServiceRequestsOptions, type ListWebhookDeliveriesOptions, type NotificationEvent, type NotificationResult, type NotificationType, NotificationsResource, type Pagination, type Quote, type QuoteItem, type QuoteStatus, QuotesResource, type RequestOptions, type ResponseMeta, type SendCustomNotificationOptions, type SendToClientOptions, type SendToTeamOptions, type ServiceRequest, type ServiceRequestPriority, type ServiceRequestStatus, ServiceRequestsResource, type UpdateClientOptions, type UpdateInvoiceOptions, type UpdateJobOptions, type UpdateQuoteOptions, type UpdateServiceRequestOptions, type UpdateWebhookOptions, type VerifyOptions, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookSignature, WebhookVerificationError, WebhooksResource, WorkbenchClient, type WorkbenchConfig, WorkbenchError, computeSignature, constructWebhookEvent, parseSignatureHeader, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -98,9 +98,13 @@ interface ApiError {
98
98
  meta: ResponseMeta;
99
99
  }
100
100
  /**
101
- * Client status values
101
+ * Client status values (lifecycle status)
102
102
  */
103
- type ClientStatus = 'active' | 'inactive' | 'lead' | 'prospect' | 'archived';
103
+ type ClientStatus = 'active' | 'inactive' | 'archived';
104
+ /**
105
+ * Lead status values (pipeline stage for leads)
106
+ */
107
+ type LeadStatus = 'new' | 'contacted' | 'qualified' | 'proposal' | 'negotiation' | 'won' | 'lost';
104
108
  /**
105
109
  * Client record
106
110
  */
@@ -113,6 +117,8 @@ interface Client {
113
117
  email: string | null;
114
118
  phone: string | null;
115
119
  status: ClientStatus;
120
+ /** Lead pipeline stage */
121
+ lead_status: LeadStatus | null;
116
122
  source: string | null;
117
123
  notes: string | null;
118
124
  /** Internal notes visible only to business users */
@@ -132,7 +138,10 @@ interface CreateClientOptions {
132
138
  company?: string | null;
133
139
  email?: string | null;
134
140
  phone?: string | null;
141
+ /** Client lifecycle status (defaults to 'active') */
135
142
  status?: ClientStatus;
143
+ /** Lead pipeline stage (defaults to 'new') */
144
+ lead_status?: LeadStatus | null;
136
145
  source?: string | null;
137
146
  notes?: string | null;
138
147
  internal_notes?: string | null;
@@ -150,6 +159,7 @@ interface UpdateClientOptions extends Partial<CreateClientOptions> {
150
159
  */
151
160
  interface ListClientsOptions extends ListOptions {
152
161
  status?: ClientStatus;
162
+ lead_status?: LeadStatus;
153
163
  }
154
164
  /**
155
165
  * Invoice status values
@@ -519,6 +529,89 @@ interface WebhookEventTypeInfo {
519
529
  description: string;
520
530
  category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
521
531
  }
532
+ /**
533
+ * Notification type - who receives the notification
534
+ */
535
+ type NotificationType = 'CLIENT' | 'BUSINESS';
536
+ /**
537
+ * Notification events supported by the SDK
538
+ * - sdk_client_created: Welcome notification for new clients
539
+ * - sdk_request_created: New service request notification
540
+ * - sdk_quote_created: Quote sent notification
541
+ * - sdk_invoice_created: Invoice sent notification
542
+ * - sdk_job_created: Job scheduled notification
543
+ * - sdk_custom: Custom notification (requires subject/html overrides)
544
+ */
545
+ type NotificationEvent = 'sdk_client_created' | 'sdk_request_created' | 'sdk_quote_created' | 'sdk_invoice_created' | 'sdk_job_created' | 'sdk_custom';
546
+ /**
547
+ * Business user roles for BUSINESS notifications
548
+ */
549
+ type BusinessUserRole = 'owner' | 'admin' | 'manager' | 'member';
550
+ /**
551
+ * Base options for sending notifications
552
+ */
553
+ interface SendNotificationBaseOptions {
554
+ /** Template data for variable interpolation (e.g., client_name, quote_total) */
555
+ templateData?: Record<string, string | number>;
556
+ /** Custom subject line (overrides template) */
557
+ subjectOverride?: string;
558
+ /** Custom HTML body (overrides template) */
559
+ htmlOverride?: string;
560
+ /** Entity type for audit logging (e.g., 'client', 'invoice') */
561
+ entityType?: string;
562
+ /** Entity ID for audit logging */
563
+ entityId?: string;
564
+ }
565
+ /**
566
+ * Options for sending a notification to a client
567
+ */
568
+ interface SendToClientOptions extends SendNotificationBaseOptions {
569
+ /** Client ID to send the notification to */
570
+ clientId: string;
571
+ /** Event type for template selection */
572
+ event: NotificationEvent;
573
+ }
574
+ /**
575
+ * Options for sending a notification to business team members
576
+ */
577
+ interface SendToTeamOptions extends SendNotificationBaseOptions {
578
+ /** Event type for template selection */
579
+ event: NotificationEvent;
580
+ /** Roles to notify (defaults to all if not specified) */
581
+ roles?: BusinessUserRole[];
582
+ }
583
+ /**
584
+ * Options for sending a custom notification
585
+ */
586
+ interface SendCustomNotificationOptions extends SendNotificationBaseOptions {
587
+ /** Notification type - CLIENT or BUSINESS */
588
+ type: NotificationType;
589
+ /** Client ID (required for CLIENT type) */
590
+ clientId?: string;
591
+ /** Roles to notify (for BUSINESS type) */
592
+ roles?: BusinessUserRole[];
593
+ /** Required: Custom subject line */
594
+ subject: string;
595
+ /** Required: Custom HTML body */
596
+ html: string;
597
+ }
598
+ /**
599
+ * Result of sending notifications
600
+ */
601
+ interface NotificationResult {
602
+ /** Whether at least one notification was sent successfully */
603
+ success: boolean;
604
+ /** Unique ID for this notification batch */
605
+ notification_id: string;
606
+ /** Total number of recipients */
607
+ recipients_count: number;
608
+ /** Number of successful email sends */
609
+ sent_count: number;
610
+ /** Number of failed email sends */
611
+ failed_count: number;
612
+ /** Error messages if any failures occurred */
613
+ errors?: string[];
614
+ }
522
615
 
523
616
  /**
524
617
  * @file resources/clients.ts
@@ -1386,6 +1479,156 @@ declare class WebhooksResource {
1386
1479
  listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
1387
1480
  }
1388
1481
 
1482
+ /**
1483
+ * Notifications Resource
1484
+ *
1485
+ * Provides methods for sending email notifications to clients and
1486
+ * business team members via the Workbench API.
1487
+ *
1488
+ * @module resources/notifications
1489
+ *
1490
+ * @example
1491
+ * // Send a welcome notification to a new client
1492
+ * await workbench.notifications.sendToClient({
1493
+ * clientId: 'client-uuid',
1494
+ * event: 'sdk_client_created',
1495
+ * templateData: { client_name: 'John Doe' }
1496
+ * });
1497
+ *
1498
+ * @example
1499
+ * // Notify business admins about a new request
1500
+ * await workbench.notifications.sendToTeam({
1501
+ * event: 'sdk_request_created',
1502
+ * roles: ['owner', 'admin'],
1503
+ * templateData: { request_title: 'AC Repair', client_name: 'John' }
1504
+ * });
1505
+ *
1506
+ * @example
1507
+ * // Send a custom notification
1508
+ * await workbench.notifications.sendCustom({
1509
+ * type: 'CLIENT',
1510
+ * clientId: 'client-uuid',
1511
+ * subject: 'Your appointment is confirmed!',
1512
+ * html: '<h1>Confirmed!</h1><p>See you tomorrow at 10am.</p>'
1513
+ * });
1514
+ */
1515
+
1516
+ /**
1517
+ * Notifications resource for sending email notifications via the SDK
1518
+ */
1519
+ declare class NotificationsResource {
1520
+ private readonly client;
1521
+ constructor(client: WorkbenchClient);
1522
+ /**
1523
+ * Send a notification to a specific client
1524
+ *
1525
+ * Sends an email notification to a client using a predefined template
1526
+ * or custom content. The client must have a valid email address.
1527
+ *
1528
+ * @param options - Notification options
1529
+ * @returns Notification result with delivery statistics
1530
+ *
1531
+ * @example
1532
+ * // Welcome a new client
1533
+ * const result = await workbench.notifications.sendToClient({
1534
+ * clientId: 'client-uuid',
1535
+ * event: 'sdk_client_created',
1536
+ * templateData: {
1537
+ * client_name: 'John Doe'
1538
+ * }
1539
+ * });
1540
+ * console.log(`Sent to ${result.data.sent_count} recipient(s)`);
1541
+ *
1542
+ * @example
1543
+ * // Notify client about a new quote with custom subject
1544
+ * const result = await workbench.notifications.sendToClient({
1545
+ * clientId: 'client-uuid',
1546
+ * event: 'sdk_quote_created',
1547
+ * templateData: {
1548
+ * client_name: 'John',
1549
+ * quote_number: 'Q-001',
1550
+ * quote_total: '$1,500.00'
1551
+ * },
1552
+ * subjectOverride: 'Your custom quote is ready!'
1553
+ * });
1554
+ */
1555
+ sendToClient(options: SendToClientOptions): Promise<ApiResponse<NotificationResult>>;
1556
+ /**
1557
+ * Send a notification to business team members
1558
+ *
1559
+ * Sends an email notification to team members, optionally filtered
1560
+ * by their role in the business.
1561
+ *
1562
+ * @param options - Notification options
1563
+ * @returns Notification result with delivery statistics
1564
+ *
1565
+ * @example
1566
+ * // Notify all team members about a new service request
1567
+ * const result = await workbench.notifications.sendToTeam({
1568
+ * event: 'sdk_request_created',
1569
+ * templateData: {
1570
+ * request_title: 'Emergency AC Repair',
1571
+ * client_name: 'John Doe',
1572
+ * request_description: 'AC not cooling, needs urgent attention'
1573
+ * }
1574
+ * });
1575
+ *
1576
+ * @example
1577
+ * // Notify only owners and admins
1578
+ * const result = await workbench.notifications.sendToTeam({
1579
+ * event: 'sdk_invoice_created',
1580
+ * roles: ['owner', 'admin'],
1581
+ * templateData: {
1582
+ * invoice_number: 'INV-001',
1583
+ * invoice_total: '$2,500.00',
1584
+ * client_name: 'Acme Corp'
1585
+ * }
1586
+ * });
1587
+ */
1588
+ sendToTeam(options: SendToTeamOptions): Promise<ApiResponse<NotificationResult>>;
1589
+ /**
1590
+ * Send a custom notification
1591
+ *
1592
+ * Sends a notification with fully custom subject and HTML content.
1593
+ * Can be sent to either a client or business team members.
1594
+ *
1595
+ * @param options - Custom notification options
1596
+ * @returns Notification result with delivery statistics
1597
+ *
1598
+ * @example
1599
+ * // Send custom appointment confirmation to client
1600
+ * const result = await workbench.notifications.sendCustom({
1601
+ * type: 'CLIENT',
1602
+ * clientId: 'client-uuid',
1603
+ * subject: 'Your appointment is confirmed for tomorrow!',
1604
+ * html: `
1605
+ * <h1>Appointment Confirmed</h1>
1606
+ * <p>Hi John,</p>
1607
+ * <p>Your appointment has been confirmed:</p>
1608
+ * <ul>
1609
+ * <li><strong>Date:</strong> January 23, 2026</li>
1610
+ * <li><strong>Time:</strong> 10:00 AM</li>
1611
+ * <li><strong>Service:</strong> AC Maintenance</li>
1612
+ * </ul>
1613
+ * <p>See you tomorrow!</p>
1614
+ * `
1615
+ * });
1616
+ *
1617
+ * @example
1618
+ * // Send custom alert to admins
1619
+ * const result = await workbench.notifications.sendCustom({
1620
+ * type: 'BUSINESS',
1621
+ * roles: ['owner', 'admin'],
1622
+ * subject: 'High-value quote approved!',
1623
+ * html: '<p>Quote Q-001 for $10,000 has been approved by Acme Corp.</p>',
1624
+ * templateData: {
1625
+ * quote_number: 'Q-001'
1626
+ * }
1627
+ * });
1628
+ */
1629
+ sendCustom(options: SendCustomNotificationOptions): Promise<ApiResponse<NotificationResult>>;
1630
+ }
1631
+
1389
1632
  /**
1390
1633
  * @file client.ts
1391
1634
  * @description Main Workbench API client class
@@ -1474,6 +1717,8 @@ declare class WorkbenchClient {
1474
1717
  readonly serviceRequests: ServiceRequestsResource;
1475
1718
  /** Webhooks resource */
1476
1719
  readonly webhooks: WebhooksResource;
1720
+ /** Notifications resource */
1721
+ readonly notifications: NotificationsResource;
1477
1722
  /**
1478
1723
  * Create a new Workbench client
1479
1724
  *
@@ -1655,4 +1900,4 @@ declare function constructWebhookEvent<T = Record<string, unknown>>(payload: str
1655
1900
  timestamp: string;
1656
1901
  };
1657
1902
 
1658
- export { type ApiError, type ApiResponse, type Client, type ClientStatus, ClientsResource, type CreateClientOptions, type CreateInvoiceOptions, type CreateJobOptions, type CreateQuoteOptions, type CreateServiceRequestOptions, type CreateWebhookOptions, type Invoice, type InvoiceItem, type InvoiceStatus, InvoicesResource, type Job, type JobPriority, type JobStatus, JobsResource, type ListClientsOptions, type ListInvoicesOptions, type ListJobsOptions, type ListOptions, type ListQuotesOptions, type ListResponse, type ListServiceRequestsOptions, type ListWebhookDeliveriesOptions, type Pagination, type Quote, type QuoteItem, type QuoteStatus, QuotesResource, type RequestOptions, type ResponseMeta, type ServiceRequest, type ServiceRequestPriority, type ServiceRequestStatus, ServiceRequestsResource, type UpdateClientOptions, type UpdateInvoiceOptions, type UpdateJobOptions, type UpdateQuoteOptions, type UpdateServiceRequestOptions, type UpdateWebhookOptions, type VerifyOptions, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookSignature, WebhookVerificationError, WebhooksResource, WorkbenchClient, type WorkbenchConfig, WorkbenchError, computeSignature, constructWebhookEvent, parseSignatureHeader, verifyWebhookSignature };
1903
+ export { type ApiError, type ApiResponse, type BusinessUserRole, type Client, type ClientStatus, ClientsResource, type CreateClientOptions, type CreateInvoiceOptions, type CreateJobOptions, type CreateQuoteOptions, type CreateServiceRequestOptions, type CreateWebhookOptions, type Invoice, type InvoiceItem, type InvoiceStatus, InvoicesResource, type Job, type JobPriority, type JobStatus, JobsResource, type ListClientsOptions, type ListInvoicesOptions, type ListJobsOptions, type ListOptions, type ListQuotesOptions, type ListResponse, type ListServiceRequestsOptions, type ListWebhookDeliveriesOptions, type NotificationEvent, type NotificationResult, type NotificationType, NotificationsResource, type Pagination, type Quote, type QuoteItem, type QuoteStatus, QuotesResource, type RequestOptions, type ResponseMeta, type SendCustomNotificationOptions, type SendToClientOptions, type SendToTeamOptions, type ServiceRequest, type ServiceRequestPriority, type ServiceRequestStatus, ServiceRequestsResource, type UpdateClientOptions, type UpdateInvoiceOptions, type UpdateJobOptions, type UpdateQuoteOptions, type UpdateServiceRequestOptions, type UpdateWebhookOptions, type VerifyOptions, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookSignature, WebhookVerificationError, WebhooksResource, WorkbenchClient, type WorkbenchConfig, WorkbenchError, computeSignature, constructWebhookEvent, parseSignatureHeader, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  ClientsResource: () => ClientsResource,
24
24
  InvoicesResource: () => InvoicesResource,
25
25
  JobsResource: () => JobsResource,
26
+ NotificationsResource: () => NotificationsResource,
26
27
  QuotesResource: () => QuotesResource,
27
28
  ServiceRequestsResource: () => ServiceRequestsResource,
28
29
  WebhookVerificationError: () => WebhookVerificationError,
@@ -859,6 +860,159 @@ var WebhooksResource = class {
859
860
  }
860
861
  };
861
862
 
863
+ // src/resources/notifications.ts
864
+ var NotificationsResource = class {
865
+ client;
866
+ constructor(client) {
867
+ this.client = client;
868
+ }
869
+ /**
870
+ * Send a notification to a specific client
871
+ *
872
+ * Sends an email notification to a client using a predefined template
873
+ * or custom content. The client must have a valid email address.
874
+ *
875
+ * @param options - Notification options
876
+ * @returns Notification result with delivery statistics
877
+ *
878
+ * @example
879
+ * // Welcome a new client
880
+ * const result = await workbench.notifications.sendToClient({
881
+ * clientId: 'client-uuid',
882
+ * event: 'sdk_client_created',
883
+ * templateData: {
884
+ * client_name: 'John Doe'
885
+ * }
886
+ * });
887
+ * console.log(`Sent to ${result.data.sent_count} recipient(s)`);
888
+ *
889
+ * @example
890
+ * // Notify client about a new quote with custom subject
891
+ * const result = await workbench.notifications.sendToClient({
892
+ * clientId: 'client-uuid',
893
+ * event: 'sdk_quote_created',
894
+ * templateData: {
895
+ * client_name: 'John',
896
+ * quote_number: 'Q-001',
897
+ * quote_total: '$1,500.00'
898
+ * },
899
+ * subjectOverride: 'Your custom quote is ready!'
900
+ * });
901
+ */
902
+ async sendToClient(options) {
903
+ const body = {
904
+ type: "CLIENT",
905
+ event: options.event,
906
+ client_id: options.clientId,
907
+ template_data: options.templateData,
908
+ subject_override: options.subjectOverride,
909
+ html_override: options.htmlOverride,
910
+ entity_type: options.entityType,
911
+ entity_id: options.entityId
912
+ };
913
+ return this.client.post("/v1/notifications", body);
914
+ }
915
+ /**
916
+ * Send a notification to business team members
917
+ *
918
+ * Sends an email notification to team members, optionally filtered
919
+ * by their role in the business.
920
+ *
921
+ * @param options - Notification options
922
+ * @returns Notification result with delivery statistics
923
+ *
924
+ * @example
925
+ * // Notify all team members about a new service request
926
+ * const result = await workbench.notifications.sendToTeam({
927
+ * event: 'sdk_request_created',
928
+ * templateData: {
929
+ * request_title: 'Emergency AC Repair',
930
+ * client_name: 'John Doe',
931
+ * request_description: 'AC not cooling, needs urgent attention'
932
+ * }
933
+ * });
934
+ *
935
+ * @example
936
+ * // Notify only owners and admins
937
+ * const result = await workbench.notifications.sendToTeam({
938
+ * event: 'sdk_invoice_created',
939
+ * roles: ['owner', 'admin'],
940
+ * templateData: {
941
+ * invoice_number: 'INV-001',
942
+ * invoice_total: '$2,500.00',
943
+ * client_name: 'Acme Corp'
944
+ * }
945
+ * });
946
+ */
947
+ async sendToTeam(options) {
948
+ const body = {
949
+ type: "BUSINESS",
950
+ event: options.event,
951
+ roles: options.roles,
952
+ template_data: options.templateData,
953
+ subject_override: options.subjectOverride,
954
+ html_override: options.htmlOverride,
955
+ entity_type: options.entityType,
956
+ entity_id: options.entityId
957
+ };
958
+ return this.client.post("/v1/notifications", body);
959
+ }
960
+ /**
961
+ * Send a custom notification
962
+ *
963
+ * Sends a notification with fully custom subject and HTML content.
964
+ * Can be sent to either a client or business team members.
965
+ *
966
+ * @param options - Custom notification options
967
+ * @returns Notification result with delivery statistics
968
+ *
969
+ * @example
970
+ * // Send custom appointment confirmation to client
971
+ * const result = await workbench.notifications.sendCustom({
972
+ * type: 'CLIENT',
973
+ * clientId: 'client-uuid',
974
+ * subject: 'Your appointment is confirmed for tomorrow!',
975
+ * html: `
976
+ * <h1>Appointment Confirmed</h1>
977
+ * <p>Hi John,</p>
978
+ * <p>Your appointment has been confirmed:</p>
979
+ * <ul>
980
+ * <li><strong>Date:</strong> January 23, 2026</li>
981
+ * <li><strong>Time:</strong> 10:00 AM</li>
982
+ * <li><strong>Service:</strong> AC Maintenance</li>
983
+ * </ul>
984
+ * <p>See you tomorrow!</p>
985
+ * `
986
+ * });
987
+ *
988
+ * @example
989
+ * // Send custom alert to admins
990
+ * const result = await workbench.notifications.sendCustom({
991
+ * type: 'BUSINESS',
992
+ * roles: ['owner', 'admin'],
993
+ * subject: 'High-value quote approved!',
994
+ * html: '<p>Quote Q-001 for $10,000 has been approved by Acme Corp.</p>',
995
+ * templateData: {
996
+ * quote_number: 'Q-001'
997
+ * }
998
+ * });
999
+ */
1000
+ async sendCustom(options) {
1001
+ const body = {
1002
+ type: options.type,
1003
+ event: "sdk_custom",
1004
+ client_id: options.clientId,
1005
+ roles: options.roles,
1006
+ template_data: options.templateData,
1007
+ subject_override: options.subject,
1008
+ html_override: options.html,
1009
+ entity_type: options.entityType,
1010
+ entity_id: options.entityId
1011
+ };
1012
+ return this.client.post("/v1/notifications", body);
1013
+ }
1014
+ };
1015
+
862
1016
  // src/client.ts
863
1017
  var DEFAULT_BASE_URL = "https://api.tryworkbench.app";
864
1018
  var DEFAULT_TIMEOUT = 3e4;
@@ -898,6 +1052,8 @@ var WorkbenchClient = class {
898
1052
  serviceRequests;
899
1053
  /** Webhooks resource */
900
1054
  webhooks;
1055
+ /** Notifications resource */
1056
+ notifications;
901
1057
  /**
902
1058
  * Create a new Workbench client
903
1059
  *
@@ -919,6 +1075,7 @@ var WorkbenchClient = class {
919
1075
  this.jobs = new JobsResource(this);
920
1076
  this.serviceRequests = new ServiceRequestsResource(this);
921
1077
  this.webhooks = new WebhooksResource(this);
1078
+ this.notifications = new NotificationsResource(this);
922
1079
  }
923
1080
  /**
924
1081
  * Build URL with query parameters
@@ -1133,6 +1290,7 @@ function constructWebhookEvent(payload, signature, secret, options = {}) {
1133
1290
  ClientsResource,
1134
1291
  InvoicesResource,
1135
1292
  JobsResource,
1293
+ NotificationsResource,
1136
1294
  QuotesResource,
1137
1295
  ServiceRequestsResource,
1138
1296
  WebhookVerificationError,
package/dist/index.mjs CHANGED
@@ -821,6 +821,159 @@ var WebhooksResource = class {
821
821
  }
822
822
  };
823
823
 
824
+ // src/resources/notifications.ts
825
+ var NotificationsResource = class {
826
+ client;
827
+ constructor(client) {
828
+ this.client = client;
829
+ }
830
+ /**
831
+ * Send a notification to a specific client
832
+ *
833
+ * Sends an email notification to a client using a predefined template
834
+ * or custom content. The client must have a valid email address.
835
+ *
836
+ * @param options - Notification options
837
+ * @returns Notification result with delivery statistics
838
+ *
839
+ * @example
840
+ * // Welcome a new client
841
+ * const result = await workbench.notifications.sendToClient({
842
+ * clientId: 'client-uuid',
843
+ * event: 'sdk_client_created',
844
+ * templateData: {
845
+ * client_name: 'John Doe'
846
+ * }
847
+ * });
848
+ * console.log(`Sent to ${result.data.sent_count} recipient(s)`);
849
+ *
850
+ * @example
851
+ * // Notify client about a new quote with custom subject
852
+ * const result = await workbench.notifications.sendToClient({
853
+ * clientId: 'client-uuid',
854
+ * event: 'sdk_quote_created',
855
+ * templateData: {
856
+ * client_name: 'John',
857
+ * quote_number: 'Q-001',
858
+ * quote_total: '$1,500.00'
859
+ * },
860
+ * subjectOverride: 'Your custom quote is ready!'
861
+ * });
862
+ */
863
+ async sendToClient(options) {
864
+ const body = {
865
+ type: "CLIENT",
866
+ event: options.event,
867
+ client_id: options.clientId,
868
+ template_data: options.templateData,
869
+ subject_override: options.subjectOverride,
870
+ html_override: options.htmlOverride,
871
+ entity_type: options.entityType,
872
+ entity_id: options.entityId
873
+ };
874
+ return this.client.post("/v1/notifications", body);
875
+ }
876
+ /**
877
+ * Send a notification to business team members
878
+ *
879
+ * Sends an email notification to team members, optionally filtered
880
+ * by their role in the business.
881
+ *
882
+ * @param options - Notification options
883
+ * @returns Notification result with delivery statistics
884
+ *
885
+ * @example
886
+ * // Notify all team members about a new service request
887
+ * const result = await workbench.notifications.sendToTeam({
888
+ * event: 'sdk_request_created',
889
+ * templateData: {
890
+ * request_title: 'Emergency AC Repair',
891
+ * client_name: 'John Doe',
892
+ * request_description: 'AC not cooling, needs urgent attention'
893
+ * }
894
+ * });
895
+ *
896
+ * @example
897
+ * // Notify only owners and admins
898
+ * const result = await workbench.notifications.sendToTeam({
899
+ * event: 'sdk_invoice_created',
900
+ * roles: ['owner', 'admin'],
901
+ * templateData: {
902
+ * invoice_number: 'INV-001',
903
+ * invoice_total: '$2,500.00',
904
+ * client_name: 'Acme Corp'
905
+ * }
906
+ * });
907
+ */
908
+ async sendToTeam(options) {
909
+ const body = {
910
+ type: "BUSINESS",
911
+ event: options.event,
912
+ roles: options.roles,
913
+ template_data: options.templateData,
914
+ subject_override: options.subjectOverride,
915
+ html_override: options.htmlOverride,
916
+ entity_type: options.entityType,
917
+ entity_id: options.entityId
918
+ };
919
+ return this.client.post("/v1/notifications", body);
920
+ }
921
+ /**
922
+ * Send a custom notification
923
+ *
924
+ * Sends a notification with fully custom subject and HTML content.
925
+ * Can be sent to either a client or business team members.
926
+ *
927
+ * @param options - Custom notification options
928
+ * @returns Notification result with delivery statistics
929
+ *
930
+ * @example
931
+ * // Send custom appointment confirmation to client
932
+ * const result = await workbench.notifications.sendCustom({
933
+ * type: 'CLIENT',
934
+ * clientId: 'client-uuid',
935
+ * subject: 'Your appointment is confirmed for tomorrow!',
936
+ * html: `
937
+ * <h1>Appointment Confirmed</h1>
938
+ * <p>Hi John,</p>
939
+ * <p>Your appointment has been confirmed:</p>
940
+ * <ul>
941
+ * <li><strong>Date:</strong> January 23, 2026</li>
942
+ * <li><strong>Time:</strong> 10:00 AM</li>
943
+ * <li><strong>Service:</strong> AC Maintenance</li>
944
+ * </ul>
945
+ * <p>See you tomorrow!</p>
946
+ * `
947
+ * });
948
+ *
949
+ * @example
950
+ * // Send custom alert to admins
951
+ * const result = await workbench.notifications.sendCustom({
952
+ * type: 'BUSINESS',
953
+ * roles: ['owner', 'admin'],
954
+ * subject: 'High-value quote approved!',
955
+ * html: '<p>Quote Q-001 for $10,000 has been approved by Acme Corp.</p>',
956
+ * templateData: {
957
+ * quote_number: 'Q-001'
958
+ * }
959
+ * });
960
+ */
961
+ async sendCustom(options) {
962
+ const body = {
963
+ type: options.type,
964
+ event: "sdk_custom",
965
+ client_id: options.clientId,
966
+ roles: options.roles,
967
+ template_data: options.templateData,
968
+ subject_override: options.subject,
969
+ html_override: options.html,
970
+ entity_type: options.entityType,
971
+ entity_id: options.entityId
972
+ };
973
+ return this.client.post("/v1/notifications", body);
974
+ }
975
+ };
976
+
824
977
  // src/client.ts
825
978
  var DEFAULT_BASE_URL = "https://api.tryworkbench.app";
826
979
  var DEFAULT_TIMEOUT = 3e4;
@@ -860,6 +1013,8 @@ var WorkbenchClient = class {
860
1013
  serviceRequests;
861
1014
  /** Webhooks resource */
862
1015
  webhooks;
1016
+ /** Notifications resource */
1017
+ notifications;
863
1018
  /**
864
1019
  * Create a new Workbench client
865
1020
  *
@@ -881,6 +1036,7 @@ var WorkbenchClient = class {
881
1036
  this.jobs = new JobsResource(this);
882
1037
  this.serviceRequests = new ServiceRequestsResource(this);
883
1038
  this.webhooks = new WebhooksResource(this);
1039
+ this.notifications = new NotificationsResource(this);
884
1040
  }
885
1041
  /**
886
1042
  * Build URL with query parameters
@@ -1094,6 +1250,7 @@ export {
1094
1250
  ClientsResource,
1095
1251
  InvoicesResource,
1096
1252
  JobsResource,
1253
+ NotificationsResource,
1097
1254
  QuotesResource,
1098
1255
  ServiceRequestsResource,
1099
1256
  WebhookVerificationError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workbenchcrm/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Official Node.js SDK for the Workbench CRM API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",