Retrieve monthly stats for all subusers
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.
GET/v3/subusers/stats/monthly
Base url: https://api.sendgrid.com (for global users and subusers)
Base url: https://api.eu.sendgrid.com (for EU regional subusers)
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.
Bearer <<YOUR_API_KEY_HERE>>The date of the month to retrieve statistics for. Must be formatted YYYY-MM-DD
Optional
A substring search of your subusers.
Optional
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.'
deliveredPossible values: blocksbouncesclicksdeliveredopensrequestsunique_clicksunique_opensunsubscribesOptional
The direction you want to sort.
descPossible values: descascOptional
Optional field to limit the number of results returned.
5Optional
Optional beginning point in the list to retrieve from.
0Optional
The date the statistics were gathered.
Optional
The list of statistics.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const queryParams = {5date: "2009-07-06",6limit: 5,7sort_by_direction: "desc",8sort_by_metric: "delivered",9};1011const request = {12url: `/v3/subusers/stats/monthly`,13method: "GET",14qs: queryParams,15};1617client18.request(request)19.then(([response, body]) => {20console.log(response.statusCode);21console.log(response.body);22})23.catch((error) => {24console.error(error);25});