Metrics

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.

Post query to get account metrics

post/v1/analytics/metrics

Gets filtered metrics for an account

SecuritybasicAuth
Request
Request Body schema: application/json
required
end
string

An end date (default: current time). Must be in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14

start
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

dimensions
Array of strings

Attributes of the metric data such as 'time' 'domain' 'ip' 'ip_pool' 'recipient_domain' 'tag' 'country' 'subaccount'.

resolution
string

A resolution in the format of 'day' 'hour' 'month'. Default is day.

object

Filters to apply to the query.

metrics
Array of strings

Name of the metrics to receive the stats for such as 'accepted_count' 'delivered_count' 'accepted_rate'.

include_aggregates
boolean

Include top-level aggregate metrics.

include_subaccounts
boolean

Include stats from all subaccounts.

duration
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.

Responses
200

A 200 response

Response Schema: application/json
required
Array of objects
end
string
object
duration
string
resolution
string
object
dimensions
Array of strings
start
string
400

A 400 response

Request samples
application/json
{
  • "start": "Mon, 13 Nov 2023 20:56:50 -0600",
  • "end": "Wed, 20 Dec 2023 20:56:50 -0600",
  • "metrics": [
    • "accepted_count",
    • "delivered_count",
    • "clicked_rate",
    • "opened_rate"
    ],
  • "filter": {
    • "AND": [
      ]
    },
  • "resolution": "month",
  • "include_aggregates": true,
  • "include_subaccounts": true,
  • "duration": "1m",
  • "dimensions": [
    • "time"
    ]
}
Response samples
application/json
{
  • "duration": "1m",
  • "items": [
    • {
      },
    • {
      }
    ],
  • "end": "Wed, 20 Dec 2023 20:56:50 -0600",
  • "start": "Mon, 13 Nov 2023 20:56:50 -0600",
  • "resolution": "month"
}