Mailgun collects many different events and generates event metrics which are available in your Control Panel. This data is also available via our analytics metrics API endpoint.
Gets filtered metrics for an account
start required | string 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 |
end required | string An end date (default: current time). Must be in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 |
resolution required | string A resolution in the format of 'day' 'hour' 'month'. Default is day. |
duration required | string 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. |
dimensions required | Array of strings Attributes of the metric data such as 'subaccount'. |
metrics required | Array of strings Name of the metrics to receive the stats for such as 'processed_count'. |
required | object Filters to apply to the query. |
include_subaccounts required | boolean Include stats from all subaccounts. |
include_aggregates required | boolean Include top-level aggregate metrics. |
{- "resolution": "month",
- "metrics": [
- "accepted_count",
- "delivered_count",
- "clicked_rate",
- "opened_rate"
], - "include_aggregates": true,
- "start": "Mon, 13 Nov 2023 20:56:50 -0600",
- "duration": "1m",
- "filter": {
- "AND": [
- {
- "attribute": "domain",
- "comparator": "=",
- "values": [
- {
- "label": "example.com",
- "value": "example.com"
}
]
}
]
}, - "dimensions": [
- "time"
], - "end": "Wed, 20 Dec 2023 20:56:50 -0600",
- "include_subaccounts": true
}
{- "items": [
- {
- "dimensions": [
- {
- "dimension": "time",
- "display_value": "Wed, 01 Nov 2023 00:00:00 +0000",
- "value": "Wed, 01 Nov 2023 00:00:00 +0000"
}
], - "metrics": {
- "accepted_count": 40,
- "accepted_incoming_count": 10,
- "accepted_outgoing_count": 30,
- "clicked_count": 50,
- "clicked_rate": "0.8300",
- "delivered_count": 60,
- "delivered_http_count": 20,
- "delivered_optimized_count": 0,
- "delivered_smtp_count": 40,
- "opened_count": 55
}
}, - {
- "dimensions": [
- {
- "dimension": "time",
- "display_value": "Fri, 01 Dec 2023 00:00:00 +0000",
- "value": "Fri, 01 Dec 2023 00:00:00 +0000"
}
], - "metrics": {
- "accepted_count": 40,
- "accepted_incoming_count": 10,
- "accepted_outgoing_count": 30,
- "clicked_count": 50,
- "clicked_rate": "0.8300",
- "delivered_count": 60,
- "delivered_http_count": 20,
- "delivered_optimized_count": 0,
- "delivered_smtp_count": 40,
- "opened_count": 55
}
}
], - "duration": "1m",
- "end": "Wed, 20 Dec 2023 20:56:50 -0600",
- "start": "Mon, 13 Nov 2023 20:56:50 -0600",
- "resolution": "month"
}
Gets filtered usage metrics for an account
start required | string 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 |
end required | string An end date (default: current time). Must be in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 |
resolution required | string A resolution in the format of 'day' 'hour' 'month'. Default is day. |
duration required | string 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. |
dimensions required | Array of strings Attributes of the metric data such as 'subaccount'. |
metrics required | Array of strings Name of the metrics to receive the stats for such as 'processed_count'. |
required | object Filters to apply to the query. |
include_subaccounts required | boolean Include stats from all subaccounts. |
include_aggregates required | boolean Include top-level aggregate metrics. |
{- "metrics": [
- "email_preview_count",
- "email_preview_failed_count",
- "email_validation_bulk_count",
- "email_validation_count",
- "email_validation_list_count",
- "email_validation_mailgun_count",
- "email_validation_mailjet_count",
- "email_validation_public_count",
- "email_validation_single_count",
- "email_validation_valid_count",
- "link_validation_count",
- "link_validation_failed_count",
- "processed_count",
- "seed_test_count"
], - "duration": "1m",
- "dimensions": [
- "time"
], - "end": "Wed, 20 Dec 2023 20:56:50 -0600",
- "include_aggregates": true,
- "resolution": "month",
- "filter": {
- "AND": [
- {
- "attribute": "subaccount",
- "comparator": "=",
- "values": [
- {
- "label": "12345",
- "value": "12345"
}
]
}
]
}, - "include_subaccounts": true,
- "start": "Mon, 13 Nov 2023 20:56:50 -0600"
}
{- "end": "Wed, 20 Dec 2023 20:56:50 -0600",
- "resolution": "month",
- "start": "Mon, 13 Nov 2023 20:56:50 -0600",
- "duration": "1m",
- "items": [
- {
- "dimensions": [
- {
- "dimension": "time",
- "display_value": "Wed, 01 Nov 2023 00:00:00 +0000",
- "value": "Wed, 01 Nov 2023 00:00:00 +0000"
}
], - "metrics": {
- "email_preview_count": 60,
- "email_preview_failed_count": 16,
- "email_validation_bulk_count": 40,
- "email_validation_count": 50,
- "email_validation_list_count": 20,
- "email_validation_mailgun_count": 40,
- "email_validation_mailjet_count": 5,
- "email_validation_public_count": 55,
- "email_validation_single_count": 30,
- "email_validation_valid_count": 10,
- "link_validation_count": 5,
- "link_validation_failed_count": 7,
- "processed_count": 3,
- "seed_test_count": 9
}
}, - {
- "dimensions": [
- {
- "dimension": "time",
- "display_value": "Fri, 01 Dec 2023 00:00:00 +0000",
- "value": "Fri, 01 Dec 2023 00:00:00 +0000"
}
], - "metrics": {
- "email_preview_count": 60,
- "email_preview_failed_count": 16,
- "email_validation_bulk_count": 40,
- "email_validation_count": 50,
- "email_validation_list_count": 20,
- "email_validation_mailgun_count": 40,
- "email_validation_mailjet_count": 5,
- "email_validation_public_count": 55,
- "email_validation_single_count": 30,
- "email_validation_valid_count": 10,
- "link_validation_count": 5,
- "link_validation_failed_count": 7,
- "processed_count": 3,
- "seed_test_count": 9
}
}
]
}