Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Get Automation Stats by ID



API Overview

api-overview page anchor

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.

(information)

Note

These endpoints provide stats for Marketing Campaigns only. For stats related to event tracking, please see the Stats API.


GET/v3/marketing/stats/automations/{id}

Base url: https://api.sendgrid.com

This endpoint allows you to retrieve stats for a single Automation using its ID.

Multiple Automation IDs can be retrieved using the "Get All Automation Stats" endpoint. Once you have an ID, this endpoint will return detailed stats for the single automation specified.

You may constrain the stats returned using the start_date and end_date query string parameters. You can also use the group_by and aggregated_by query string parameters to further refine the stats returned.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
idstringrequired

The ID of the Automation for which you want to retrieve statistics.

Property nameTypeRequiredDescription
group_byarray[enum<string>]Optional

Automations can have multiple steps. Including step_id as a group_by metric allows further granularity of stats.

Possible values:
step_id

step_idsarray[string<uuid>]Optional

Comma-separated list of step_ids that you want the link stats for.


aggregated_byenum<string>Optional

Dictates how the stats are time-sliced. Currently, "total" and "day" are supported.

Default: totalPossible values:
daytotal

start_datestring<date>Optional

Format: YYYY-MM-DD. If this parameter is included, the stats' start date is included in the search.

Default: 2021-01-01

end_datestring<date>Optional

Format: YYYY-MM-DD.If this parameter is included, the stats' end date is included in the search.

Default: 2021-12-31

timezonestringOptional

page_sizeintegerOptional

The number of elements you want returned on each page.

Minimum: 1Maximum: 50Default: 25

page_tokenstringOptional

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.

200400404
Schema
Property nameTypeRequiredDescriptionChild properties
resultsarray[object]

_metadataobject

Get Automation Stats by ID

get-automation-stats-by-id page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_25
const client = require('@sendgrid/client');
_25
client.setApiKey(process.env.SENDGRID_API_KEY);
_25
_25
const id = "ZGkrHSypTsudrGkmdpJJ";
_25
const queryParams = {
_25
"start_date": "2021-01-01",
_25
"end_date": "2021-12-31",
_25
"timezone": "UTC",
_25
"page_size": 25
_25
};
_25
_25
const request = {
_25
url: `/v3/marketing/stats/automations/${id}`,
_25
method: 'GET',
_25
qs: queryParams
_25
}
_25
_25
client.request(request)
_25
.then(([response, body]) => {
_25
console.log(response.statusCode);
_25
console.log(response.body);
_25
})
_25
.catch(error => {
_25
console.error(error);
_25
});


Rate this page: