smartlead_get_webhooks_publish_summary
Retrieve a summary of webhook publish events for a specific email campaign within a defined time period to monitor delivery and engagement data.
Instructions
Get a summary of webhook publish events (Private Beta feature).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to get webhook publish summary for | |
| fromTime | No | Start date/time in ISO 8601 format (e.g. 2025-03-21T00:00:00Z) | |
| toTime | No | End date/time in ISO 8601 format (e.g. 2025-04-04T23:59:59Z) |
Implementation Reference
- src/handlers/webhooks.ts:184-238 (handler)The core handler function that implements the tool logic: validates input parameters using isGetWebhooksPublishSummaryParams, constructs the SmartLead API endpoint /campaigns/{campaign_id}/webhooks/summary with optional fromTime and toTime query parameters, performs the GET request with retry logic, and returns the JSON response or formatted error.async function handleGetWebhooksPublishSummary( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isGetWebhooksPublishSummaryParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_get_webhooks_publish_summary' ); } try { const smartLeadClient = createSmartLeadClient(apiClient); const { campaign_id, fromTime, toTime } = args; let url = `/campaigns/${campaign_id}/webhooks/summary`; const queryParams = new URLSearchParams(); if (fromTime) { queryParams.append('fromTime', fromTime); } if (toTime) { queryParams.append('toTime', toTime); } if (queryParams.toString()) { url += `?${queryParams.toString()}`; } const response = await withRetry( async () => smartLeadClient.get(url), 'get webhooks publish summary' ); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `API Error: ${error.response?.data?.message || error.message}` }], isError: true, }; } }
- src/tools/webhooks.ts:83-105 (schema)Defines the MCP tool schema including name, description, category, and inputSchema for parameter validation in the MCP protocol.export const GET_WEBHOOKS_PUBLISH_SUMMARY_TOOL: CategoryTool = { name: 'smartlead_get_webhooks_publish_summary', description: 'Get a summary of webhook publish events (Private Beta feature).', category: ToolCategory.WEBHOOKS, inputSchema: { type: 'object', properties: { campaign_id: { type: 'string', description: 'ID of the campaign to get webhook publish summary for', }, fromTime: { type: 'string', description: 'Start date/time in ISO 8601 format (e.g. 2025-03-21T00:00:00Z)', }, toTime: { type: 'string', description: 'End date/time in ISO 8601 format (e.g. 2025-04-04T23:59:59Z)', }, }, required: ['campaign_id'], }, };
- src/index.ts:221-224 (registration)Registers the webhook tools (including smartlead_get_webhooks_publish_summary) to the tool registry if the webhooks category is enabled by license.// Register webhook tools if enabled if (enabledCategories.webhooks) { toolRegistry.registerMany(webhookTools); }
- src/types/webhooks.ts:91-101 (schema)Runtime type guard function for validating tool input parameters matching the schema.export function isGetWebhooksPublishSummaryParams(args: unknown): args is GetWebhooksPublishSummaryParams { if (typeof args !== 'object' || args === null) return false; const params = args as Partial<GetWebhooksPublishSummaryParams>; return ( typeof params.campaign_id === 'string' && (params.fromTime === undefined || typeof params.fromTime === 'string') && (params.toTime === undefined || typeof params.toTime === 'string') ); }