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

Responses
200

A 200 response

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

A 400 response

Request samples
application/json
{
  • "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": [
      ]
    },
  • "dimensions": [
    • "time"
    ],
  • "end": "Wed, 20 Dec 2023 20:56:50 -0600",
  • "include_subaccounts": true
}
Response samples
application/json
{
  • "items": [
    • {
      },
    • {
      }
    ],
  • "duration": "1m",
  • "end": "Wed, 20 Dec 2023 20:56:50 -0600",
  • "start": "Mon, 13 Nov 2023 20:56:50 -0600",
  • "resolution": "month"
}

Post query to get account usage metrics

post/v1/analytics/usage/metrics

Gets filtered usage metrics for an account

SecuritybasicAuth
Request
Request Body schema: application/json
required
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.

Responses
200

A 200 response

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

A 400 response

Request samples
application/json
{
  • "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": [
      ]
    },
  • "include_subaccounts": true,
  • "start": "Mon, 13 Nov 2023 20:56:50 -0600"
}
Response samples
application/json
{
  • "end": "Wed, 20 Dec 2023 20:56:50 -0600",
  • "resolution": "month",
  • "start": "Mon, 13 Nov 2023 20:56:50 -0600",
  • "duration": "1m",
  • "items": [
    • {
      },
    • {
      }
    ]
}