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

Retrieve sums of email stats for each category



API Overview

api-overview page anchor

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.

(warning)

Warning

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.

(information)

Info

Category statistics are available for the previous thirteen months only.


GET/v3/categories/stats/sums

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

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.


Authentication

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

on-behalf-ofstringOptional

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.

Property nameTypeRequiredDescription
sort_by_metricstringOptional

The metric that you want to sort by. Must be a single metric.

Default: delivered

sort_by_directionenum<string>Optional

The direction you want to sort.

Default: descPossible values:
descasc

start_datestringrequired

The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.


end_datestringOptional

The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.


limitintegerOptional

Limits the number of results returned.

Default: 5

offsetintegerOptional

The point in the list to begin retrieving results.

Default: 0

aggregated_byenum<string>Optional

How to group the statistics. Must be either "day", "week", or "month".

Possible values:
dayweekmonth
200
SchemaExample
Property nameTypeRequiredDescriptionChild properties
datestring

The date the statistics were gathered.


statsarray[object]

Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?]

retrieve-sums-of-email-stats-for-each-category-needs-stats-object-defined-has-category-id 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
"sort_by_metric": "delivered",
_24
"sort_by_direction": "desc",
_24
"start_date": "2010-01-22",
_24
"limit": 5
_24
};
_24
_24
const request = {
_24
url: `/v3/categories/stats/sums`,
_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: