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

Retrieve monthly stats for all subusers



API Overview

api-overview page anchor

Subuser statistics enable you to view specific segments of your statistics, as compared to the general overview of all email activity on your account. SendGrid tracks your subusers' emails sent, bounces, and spam reports. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.

For more information, see our Subusers documentation. You can also access Subuser Statistics in the SendGrid console(link takes you to an external page).


GET/v3/subusers/stats/monthly

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

This endpoint allows you to retrieve the monthly email statistics for all subusers over the given date range.

When using the sort_by_metric to sort your stats by a specific metric, you can not sort by the following metrics: bounce_drops, deferred, invalid_emails, processed, spam_report_drops, spam_reports, or unsubscribe_drops.


Authentication

authentication page anchor
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
datestringrequired

The date of the month to retrieve statistics for. Must be formatted YYYY-MM-DD


subuserstring

A substring search of your subusers.


sort_by_metricenum<string>

The metric that you want to sort by. Metrics that you can sort by are: blocks, bounces, clicks, delivered, opens, requests, unique_clicks, unique_opens, and unsubscribes.'

Default: deliveredPossible values:
blocksbouncesclicksdeliveredopensrequestsunique_clicksunique_opensunsubscribes

sort_by_directionenum<string>

The direction you want to sort.

Default: descPossible values:
descasc

limitinteger

Optional field to limit the number of results returned.

Default: 5

offsetinteger

Optional beginning point in the list to retrieve from.

Default: 0
200
SchemaExample
datestring

The date the statistics were gathered.


statsarray[object]

The list of statistics.

Retrieve monthly stats for all subusers

retrieve-monthly-stats-for-all-subusers page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_24
const client = require('@sendgrid/client');
_24
client.setApiKey(process.env.SENDGRID_API_KEY);
_24
_24
const queryParams = {
_24
"date": "2010-01-22",
_24
"sort_by_metric": "delivered",
_24
"sort_by_direction": "desc",
_24
"limit": 5
_24
};
_24
_24
const request = {
_24
url: `/v3/subusers/stats/monthly`,
_24
method: 'GET',
_24
qs: queryParams
_24
}
_24
_24
client.request(request)
_24
.then(([response, body]) => {
_24
console.log(response.statusCode);
_24
console.log(response.body);
_24
})
_24
.catch(error => {
_24
console.error(error);
_24
});


Rate this page: