Skip to contentSkip to navigationSkip to topbar
On this page

Retrieve the monthly email statistics for a single subuser



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/{subuser_name}/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 retrive the monthly email statistics for a specific subuser.

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
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
subuser_namestringrequired

The username of the Subuser.

Property nameTypeRequiredDescription
datestringrequired

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


sort_by_metricstringOptional

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: delivered

sort_by_directionenum<string>Optional

The direction you want to sort.

Default: descPossible values:
descasc

limitintegerOptional

Optional field to limit the number of results returned.

Default: 5

offsetintegerOptional

Optional beginning point in the list to retrieve from.

Default: 0
200
SchemaExample
Property nameTypeRequiredDescriptionChild properties
datestring

The date the statistics were gathered.


statsarray[object]

The list of statistics.

Retrieve the monthly email statistics for a single subuserLink to code sample: Retrieve the monthly email statistics for a single subuser
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const subuser_name = "Miss Christine Morgan";
5
const queryParams = {
6
date: "2010-01-22",
7
sort_by_metric: "delivered",
8
limit: 5,
9
};
10
11
const request = {
12
url: `/v3/subusers/${subuser_name}/stats/monthly`,
13
method: "GET",
14
qs: queryParams,
15
};
16
17
client
18
.request(request)
19
.then(([response, body]) => {
20
console.log(response.statusCode);
21
console.log(response.body);
22
})
23
.catch((error) => {
24
console.error(error);
25
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.