smartlead_get_campaign_statistics_by_date
Retrieve email campaign performance metrics for a specific date range to analyze engagement and track marketing effectiveness.
Instructions
Fetch campaign statistics for a specific date range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to fetch statistics for | |
| end_date | Yes | End date in YYYY-MM-DD format | |
| start_date | Yes | Start date in YYYY-MM-DD format |
Implementation Reference
- src/handlers/statistics.ts:97-140 (handler)The core handler function that validates input parameters using isCampaignStatisticsByDateParams, makes an authenticated API call to Smartlead's /campaigns/{campaign_id}/analytics-by-date endpoint with start_date and end_date query parameters, and returns the JSON response or formatted error.async function handleCampaignStatisticsByDate( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isCampaignStatisticsByDateParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_get_campaign_statistics_by_date' ); } const { campaign_id, start_date, end_date } = args; try { const response = await withRetry( async () => apiClient.get(`/campaigns/${campaign_id}/analytics-by-date`, { params: { start_date, end_date } }), 'get campaign statistics by date' ); 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/statistics.ts:44-66 (schema)Defines the tool metadata including name, description, category, and input schema with required parameters: campaign_id (number), start_date (string YYYY-MM-DD), end_date (string YYYY-MM-DD).export const CAMPAIGN_STATISTICS_BY_DATE_TOOL: CategoryTool = { name: 'smartlead_get_campaign_statistics_by_date', description: 'Fetch campaign statistics for a specific date range.', category: ToolCategory.CAMPAIGN_STATISTICS, inputSchema: { type: 'object', properties: { campaign_id: { type: 'number', description: 'ID of the campaign to fetch statistics for', }, start_date: { type: 'string', description: 'Start date in YYYY-MM-DD format', }, end_date: { type: 'string', description: 'End date in YYYY-MM-DD format', }, }, required: ['campaign_id', 'start_date', 'end_date'], }, };
- src/index.ts:212-214 (registration)Bulk registers all statistics tools (including smartlead_get_campaign_statistics_by_date via statisticsTools array) to the ToolRegistry if the campaignStatistics feature category is enabled.if (enabledCategories.campaignStatistics) { toolRegistry.registerMany(statisticsTools); }
- src/handlers/statistics.ts:27-29 (registration)Dispatches tool calls matching the name to the specific handler function handleCampaignStatisticsByDate within the statistics tool handler.case 'smartlead_get_campaign_statistics_by_date': { return handleCampaignStatisticsByDate(args, apiClient, withRetry); }