UNPKG

smartlead-mcp-by-leadmagic

Version:

💜 The Premier Model Context Protocol Server for SmartLead's Cold Email Automation Platform - Complete API coverage with 116+ tools for campaign management, lead tracking, smart delivery, and analytics. Beautiful purple-gradient installer, zero-config set

147 lines • 5.41 kB
/** * SmartLead Webhooks API Client * * Handles webhook management operations including: * - Webhook CRUD operations * - Event management and retry logic * - Campaign webhook integration * - Webhook analytics and monitoring */ import { BaseSmartLeadClient } from '../../client/base.js'; /** * Webhooks Client * * Provides methods for managing webhooks and webhook events * including creation, updates, testing, and analytics. */ export class WebhooksClient extends BaseSmartLeadClient { // ================================ // WEBHOOK MANAGEMENT METHODS // ================================ /** * Create a new webhook */ async createWebhook(params) { const response = await this.withRetry(() => this.apiClient.post('/webhooks', params), 'create webhook'); return response.data; } /** * Get all webhooks */ async getAllWebhooks(params) { const response = await this.withRetry(() => this.apiClient.get('/webhooks', { params }), 'get all webhooks'); return response.data; } /** * Get webhook by ID */ async getWebhookById(webhookId) { const response = await this.withRetry(() => this.apiClient.get(`/webhooks/${webhookId}`), 'get webhook by ID'); return response.data; } /** * Update webhook */ async updateWebhook(webhookId, params) { const response = await this.withRetry(() => this.apiClient.put(`/webhooks/${webhookId}`, params), 'update webhook'); return response.data; } /** * Delete webhook */ async deleteWebhook(webhookId) { const response = await this.withRetry(() => this.apiClient.delete(`/webhooks/${webhookId}`), 'delete webhook'); return response.data; } /** * Test webhook endpoint */ async testWebhook(webhookId, params) { const response = await this.withRetry(() => this.apiClient.post(`/webhooks/${webhookId}/test`, params), 'test webhook'); return response.data; } /** * Get webhook events */ async getWebhookEvents(webhookId, params) { const response = await this.withRetry(() => this.apiClient.get(`/webhooks/${webhookId}/events`, { params }), 'get webhook events'); return response.data; } /** * Get webhook event types */ async getWebhookEventTypes() { const response = await this.withRetry(() => this.apiClient.get('/webhooks/event-types'), 'get webhook event types'); return response.data; } /** * Retry failed webhook event */ async retryWebhookEvent(webhookId, eventId) { const response = await this.withRetry(() => this.apiClient.post(`/webhooks/${webhookId}/events/${eventId}/retry`), 'retry webhook event'); return response.data; } /** * Get webhook analytics */ async getWebhookAnalytics(webhookId, params) { const response = await this.withRetry(() => this.apiClient.get(`/webhooks/${webhookId}/analytics`, { params }), 'get webhook analytics'); return response.data; } /** * Enable/disable webhook */ async toggleWebhookStatus(webhookId, enabled) { const response = await this.withRetry(() => this.apiClient.patch(`/webhooks/${webhookId}/status`, { enabled }), 'toggle webhook status'); return response.data; } /** * Get webhook delivery logs */ async getWebhookDeliveryLogs(webhookId, params) { const response = await this.withRetry(() => this.apiClient.get(`/webhooks/${webhookId}/delivery-logs`, { params }), 'get webhook delivery logs'); return response.data; } // ================================ // CAMPAIGN WEBHOOK METHODS // ================================ /** * GET /campaigns/{campaign_id}/webhooks */ async getWebhooksByCampaignId(campaignId) { const response = await this.withRetry(() => this.apiClient.get(`/campaigns/${campaignId}/webhooks`), 'get webhooks by campaign ID'); return response.data; } /** * POST /campaigns/{campaign_id}/webhooks */ async addOrUpdateCampaignWebhook(campaignId, params) { const response = await this.withRetry(() => this.apiClient.post(`/campaigns/${campaignId}/webhooks`, params), 'add or update campaign webhook'); return response.data; } /** * DELETE /campaigns/{campaign_id}/webhooks/{webhook_id} */ async deleteCampaignWebhook(campaignId, webhookId) { const response = await this.withRetry(() => this.apiClient.delete(`/campaigns/${campaignId}/webhooks/${webhookId}`), 'delete campaign webhook'); return response.data; } // ================================ // WEBHOOK ANALYTICS & MONITORING // ================================ /** * GET /webhooks/publish-summary */ async getWebhooksPublishSummary() { const response = await this.withRetry(() => this.apiClient.get('/webhooks/publish-summary'), 'get webhooks publish summary'); return response.data; } /** * POST /webhooks/retrigger-failed-events */ async retriggerFailedEvents(params) { const response = await this.withRetry(() => this.apiClient.post('/webhooks/retrigger-failed-events', params), 'retrigger failed events'); return response.data; } } //# sourceMappingURL=client.js.map