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 retrieve stats for all your Automations.
By default, all of your Automations will be returned, but you can specify a selection by passing in a comma-separated list of Automation IDs as the value of the query string parameter automation_ids
.
Responses are paginated. You can limit the number of responses returned per batch using the page_size
query string parameter. The default is 25, but you can specify a value between 1 and 50.
You can retrieve a specific page of responses with the page_token
query string parameter.
Bearer <<YOUR_API_KEY_HERE>>
This endpoint returns all automation IDs if no automation_ids
are specified.
The number of elements you want returned on each page.
1
Maximum: 50
Default: 25
The stats endpoints are paginated. To get the next page, call the passed _metadata.next
URL. If _metadata.prev
doesn't exist, you're at the first page. Similarly, if _metadata.next
is not present, you're at the last page.
1const client = require('@sendgrid/client');2client.setApiKey(process.env.SENDGRID_API_KEY);34const queryParams = {5"page_size": 256};78const request = {9url: `/v3/marketing/stats/automations`,10method: 'GET',11qs: queryParams12}1314client.request(request)15.then(([response, body]) => {16console.log(response.statusCode);17console.log(response.body);18})19.catch(error => {20console.error(error);21});