<Intro>

<EndpointHeader />

<Description>

Returns engagement counts (opens and clicks) grouped by the location they were recorded from, for the requested period. Use it to see where your audience engages -- for example the top countries by unique opens.
Location comes from open and click events only, so this breakdown reports engagement activity, not delivery: it has no delivery counts and no open/click rates, because delivery is reported by the receiving mail server without a recipient location and there is therefore no per-location delivered denominator.
Use `group_by` to choose the granularity: `country` (default), `region`, or `city`. Each row carries the location hierarchy down to the requested level (a `city` grouping also reports the row's region and country). Rows are ranked by the `sort` metric (default `unique_opens`) descending and capped at the requested `limit` (default 50, hard maximum 200).
Rows are computed against event time (not send time). The maximum window is 365 days; requesting a longer range returns 422.

</Description>

</Intro>

<Parameters in="query">

<Parameter name="from" type="string">

<Description>

Start date (inclusive) in YYYY-MM-DD, interpreted as a calendar day in `timezone` (a UTC day when `timezone` is omitted). Defaults to 30 days before `to` when omitted.

</Description>

</Parameter>

<Parameter name="to" type="string">

<Description>

End date (inclusive) in YYYY-MM-DD, interpreted as a calendar day in `timezone` (a UTC day when `timezone` is omitted). Defaults to today in that timezone when omitted. Window may not exceed 365 days.

</Description>

</Parameter>

<Parameter name="timezone" type="string">

<Description>

IANA timezone identifier (for example `Asia/Kathmandu` or `America/New_York`) to report the statistics in. It is the single source of timezone: day and hour boundaries, and the relative window defaults used when `from` and `to` are omitted, are computed in this timezone instead of UTC, so a timezone with a sub-hour offset (such as India at +05:30 or Nepal at +05:45) still gets correct local-day and local-hour totals. When it is set, a `from` or `to` given as a calendar day names a local day in this timezone, and one given as an instant stays an absolute point in time but is rounded down to its hour and bucketed in this timezone (so the hour boundaries are local, not UTC). To avoid specifying the zone twice, a `from` or `to` that carries its own numeric UTC offset (for example `+05:45`) is rejected when `timezone` is set; use a calendar day or a `Z` (UTC) instant instead. Defaults to UTC.

</Description>

</Parameter>

<Parameter name="category" type="string">

<Description>

Email statistics are aggregated across all categories. Per-category filtering is not yet available; supplying this parameter returns 422.

</Description>

</Parameter>

<Parameter name="group_by" type="string">

<Description>

Location granularity for each row. `country` (default) groups by country; `region` groups by region within country; `city` groups by city within region. Each row reports the location hierarchy down to the chosen level.

</Description>

</Parameter>

<Parameter name="sort" type="string">

<Description>

Metric to rank rows by, applied descending. Defaults to `unique_opens`. Only engagement counts are sortable; this breakdown has no rates.

</Description>

</Parameter>

<Parameter name="limit" type="integer">

<Description>

Maximum number of location rows to return, ranked by the `sort` field descending.

</Description>

</Parameter>

</Parameters>

<Payload kind="response">

<Field name="period" type="object" required>

<FieldChildren kind="response">

<Field name="from" type="string" prefix="period." required>

<Description>

Inclusive start date the response covers (YYYY-MM-DD).

</Description>

</Field>

<Field name="to" type="string" prefix="period." required>

<Description>

Inclusive end date the response covers (YYYY-MM-DD).

</Description>

</Field>

<Field name="data_as_of" type="nullable string" prefix="period.">

<Description>

The instant the statistics in this response are current to: events recorded up to roughly this time are reflected, while more recent events may not be yet. Statistics are served from a rolling aggregation that refreshes every few seconds, so a response is near-real-time but not live; use this field to label data freshness (for example "as of 14:03") rather than assuming the numbers are to-the-second. Null when the freshness boundary is not being reported.

</Description>

</Field>

</FieldChildren>

</Field>

<Field name="data" type="array of object" required>

<Description>

Location breakdown rows, ranked by the `sort` metric (default `unique_opens`) descending. Empty when no opens or clicks with a resolved location occurred in the period.

</Description>

<FieldChildren kind="response">

<Field name="country" type="string" prefix="data." required>

<Description>

The country this row aggregates, as a two-letter country code (ISO 3166-1 alpha-2) resolved from the open or click event. Always present.

</Description>

</Field>

<Field name="region" type="nullable string" prefix="data." required>

<Description>

The region (state or province) within the country. Populated when `group_by` is `region` or `city`; null at coarser groupings.

</Description>

</Field>

<Field name="city" type="nullable string" prefix="data." required>

<Description>

The city within the region. Populated when `group_by` is `city`; null at coarser groupings.

</Description>

</Field>

<Field name="engagement" type="object" prefix="data." required>

<FieldChildren kind="response">

<Field name="opens" type="integer" prefix="data.engagement." required>

<Description>

Distinct open events, counting repeat opens from the same recipient and opens auto-fetched by inbox privacy features (such as Apple Mail Privacy Protection and the Gmail image proxy).

</Description>

</Field>

<Field name="opens_non_prefetched" type="integer" prefix="data.engagement." required>

<Description>

Distinct open events excluding those auto-fetched by inbox privacy features. Same event-counting semantics as `opens`, with prefetched opens removed.

</Description>

</Field>

<Field name="unique_opens" type="integer" prefix="data.engagement." required>

<Description>

Distinct recipients who opened at least once, including opens auto-fetched by inbox privacy features.

</Description>

</Field>

<Field name="unique_opens_non_prefetched" type="integer" prefix="data.engagement." required>

<Description>

Distinct recipients who opened at least once, excluding opens auto-fetched by inbox privacy features.

</Description>

</Field>

<Field name="clicks" type="integer" prefix="data.engagement." required>

<Description>

Distinct click events, counting repeat clicks from the same recipient.

</Description>

</Field>

<Field name="unique_clicks" type="integer" prefix="data.engagement." required>

<Description>

Distinct recipients who clicked at least once.

</Description>

</Field>

</FieldChildren>

</Field>

</FieldChildren>

</Field>

<Field name="total" type="integer" required>

<Description>

Total number of distinct locations at the requested `group_by` level with activity in the period, regardless of `limit`. When it exceeds the number of rows returned, the ranking was capped; raise `limit` (up to 200) or narrow the window to see more.

</Description>

</Field>

</Payload>