Queries filtered metrics for an account
Security
basicAuth
A start date (default: 7 days before current time). Must be in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14
An end date (default: current time). Must be in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14
A duration in the format of '1d' '2h' '2m'. If duration is provided then it is calculated from the end date and overwrites the start date.
Attributes of the metric data such as 'subaccount'. See dimensions
Name of the metrics to receive the stats for such as 'processed_count'. See metrics
Filters to apply to the query.
- US Mailgunhttps://api.mailgun.net/v1/analytics/metrics
- EU Mailgunhttps://api.eu.mailgun.net/v1/analytics/metrics
- application/json
- none
curl -i -X POST \
-u '<username>:<password>' \
https://api.mailgun.net/v1/analytics/metrics \
-H 'Content-Type: application/json' \
-d '{
"start": "Mon, 13 Nov 2023 20:56:50 -0600",
"end": "Wed, 20 Dec 2023 20:56:50 -0600",
"resolution": "month",
"duration": "1m",
"dimensions": [
"time"
],
"metrics": [
"accepted_count",
"delivered_count",
"clicked_rate",
"opened_rate"
],
"filter": {
"AND": [
{
"attribute": "domain",
"comparator": "=",
"values": [
{
"label": "example.com",
"value": "example.com"
}
]
}
]
},
"include_subaccounts": true,
"include_aggregates": true
}'A 200 response
Response
{ "start": "Mon, 13 Nov 2023 20:56:50 -0600", "end": "Wed, 20 Dec 2023 20:56:50 -0600", "resolution": "month", "duration": "1m", "pagination": { "sort": "timestamp:asc", "skip": 1, "limit": 10, "total": 1000 }, "items": [ { … }, { … } ], "aggregates": { "metrics": {} } }