Categories can help organize your email analytics by enabling you to group emails by type. Just as you can view the statistics on all your email activity, you can go a step further and view the statistics by a particular category.
Effective February 1, 2022, Twilio SendGrid will limit the number of stored category statistics available per user. Accounts on a paid plan will be allowed 1,000 categories daily. Accounts on a free plan will be allowed 100 categories daily. For more information about this change, see the Limitations section of our "Working with Categories" page.
Category statistics are available for the previous thirteen months only.
This endpoint allows you to retrieve the total sum of each email statistic for every category over the given date range.
If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10.
Bearer <<YOUR_API_KEY_HERE>>
Optional
The on-behalf-of
header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID (e.g., on-behalf-of: account-id <account-id>
). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., on-behalf-of: <subuser-username>
). See On Behalf Of for more information.
Optional
The metric that you want to sort by. Must be a single metric.
delivered
Optional
The direction you want to sort.
desc
Possible values: desc
asc
The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
Optional
The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
Optional
Limits the number of results returned.
5
Optional
The point in the list to begin retrieving results.
0
Optional
How to group the statistics. Must be either "day", "week", or "month".
day
week
month
The date the statistics were gathered.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const queryParams = {5sort_by_metric: "delivered",6start_date: "2010-01-22",7limit: 5,8};910const request = {11url: `/v3/categories/stats/sums`,12method: "GET",13qs: queryParams,14};1516client17.request(request)18.then(([response, body]) => {19console.log(response.statusCode);20console.log(response.body);21})22.catch((error) => {23console.error(error);24});