As a Marketing Campaigns customer, you have access to rich statistics about your Single Sends and Automations. The Marketing Campaigns Statistics API allows you to retrieve these statistics programmatically. for detailed information about the statistics available, see the Marketing Campaigns Stats Overview.
These endpoints provide stats for Marketing Campaigns only. For stats related to event tracking, please see the Stats API.
This endpoint allows you to export Single Send stats as .CSV data.
You can specify one Single Send or many: include as many Single Send IDs as you need, separating them with commas, as the value of the ids
query string parameter.
The data is returned as plain text response but in .CSV format, so your application making the call can present the information in whatever way is most appropriate, or just save the data as a .csv file.
Bearer <<YOUR_API_KEY_HERE>>
The IDs of Single Sends for which to export stats.
The IANA Area/Region string representing the timezone in which the stats are to be presented; i.e. "America/Chicago"
. This parameter changes the timezone format only; it does not alter which stats are returned.
UTC
string
CSV data
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const queryParams = {5timezone: "UTC",6};78const request = {9url: `/v3/marketing/stats/singlesends/export`,10method: "GET",11qs: queryParams,12};1314client15.request(request)16.then(([response, body]) => {17console.log(response.statusCode);18console.log(response.body);19})20.catch((error) => {21console.error(error);22});