Sign inGet Started

Query email delivery and engagement metrics

POST
/v1/email/stats/query
const { data } = await bird.email.stats.query({
  from: "2026-09-23",
  to: "2026-09-24",
  metrics: ["delivered", "bounce_rate"],
  group_by: "recipient_domain",
  grain: "week",
  limit: 25,
});
for (const group of data) {
  console.log(group.dimensions, group.metrics, group.series);
}
Réponse200
{
  "data": [
    {
      "dimensions": {
        "recipient_domain": "gmail.com"
      },
      "metrics": {
        "delivered": 12,
        "bounce_rate": 0.2
      },
      "series": [
        {
          "bucket": "2026-09-21T00:00:00Z",
          "metrics": {
            "delivered": 12,
            "bounce_rate": 0.2
          }
        }
      ]
    }
  ],
  "period": {
    "from": "2026-09-23T00:00:00Z",
    "to": "2026-09-25T00:00:00Z",
    "timezone": "UTC",
    "grain": "week"
  },
  "data_as_of": null,
  "next_cursor": null,
  "prev_cursor": null,
  "refresh_cursor": "eyJ2IjoxLCJ3b3Jrc3BhY2UiOiJ3c18wMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMCIsInF1ZXJ5IjoiYjM3MDNiMWVmNDNkZjExZDNlYzcwMGY2MmViNTdlZGIwYjAzODI4Yzk5ZTkxYzY4MzJhYWNjYTIwMzZhNDc3MSIsIm51bGwiOmZhbHNlLCJpbnRlZ2VyIjoxMiwia2V5IjoiZ21haWwuY29tIn0"
}

Returns selected delivery, engagement, and latency metrics for the workspace. Combine filters, one grouping dimension, and a time grain for reports such as weekly deliveries by recipient domain for a campaign. Events are selected and bucketed by when they occurred. An open in the window can belong to a message sent earlier; later outcomes outside the window are excluded. Ungrouped requests return one summary; grouped pages retain each group's complete series. Counts deduplicate by each metric's identity; event counts are not audience sizes. Undefined rates or empty latency samples return null.

Dates include whole local days. Instants include the quarter-hour containing the requested end. Responses echo normalized UTC bounds with an exclusive end. Follow cursors using the original body and replace the cursor fields. Requests can cover up to 365 local days or 720 hours for instant bounds, subject to available history. Unsupported combinations, unavailable history, or query-size limits return 422; a failed query returns no partial report.

Idempotency is best-effort replay. Responses up to 256 KiB may be replayed while retained; larger valid responses up to 4 MiB are read again on retry. A key does not freeze an analytics snapshot. SDK iterators use your explicit key for the first page and a fresh automatic key per continuation page, reusing that page's key across retries. For a fresh read, omit the key or use a new one.

Corps de la requête

from
string
obligatoire

Inclusive start, as a calendar date or RFC 3339 instant. Use the same form for from and to. Instants round down to a local quarter-hour; use Z when timezone is supplied.

to
string
obligatoire

Inclusive end. Dates include the whole local day; instants round down to a local quarter-hour and include that quarter-hour. Dates allow up to 365 local days; instants allow up to 720 hours, subject to available history. Preserve this original bound when following cursors.

timezone
string

IANA timezone for dates and bucket boundaries. Defaults to UTC.

metrics
array of string
obligatoire

Distinct metrics to return. Unselected metrics are absent. delivered and unique engagement counts estimate distinct message recipients. opens, opens_non_prefetched, clicks, unsubscribes, and oob_bounces estimate deduplicated events. effective_delivered and all_bounces are derived counts. Counts need not add up across buckets or groups. unique_opens and unique_clicks count message recipients, not distinct people across messages. Use returned period metrics; do not reconstruct totals from buckets or average rates or percentiles.

delivered counts message recipients with a delivery event without subtracting later bounces. effective_delivered is max(delivered - oob_bounces, 0). open_rate uses unique_opens_non_prefetched divided by effective_delivered; click_rate uses unique_clicks divided by effective_delivered. bounce_rate uses min(bounced + oob_bounces, delivered + bounced) divided by (delivered + bounced). complaint_rate and unsubscribe_rate use complained and unsubscribes, respectively, divided by effective_delivered. Undefined rates are null. Engagement rates can exceed 1 across event-time windows.

An unknown prefetch flag is treated as false. confirmed_unique_opens is the union of message recipients with opens or clicks; confirmed_unique_opens_non_prefetched excludes prefetched opens from that union. Differences between estimated distinct counts cannot establish exact audience overlaps or explain missing opens. Neither confirmation nor prefetch exclusion establishes a count or range of real people who engaged.

Latency percentiles describe eligible measured logical events, excluding missing latency values and including zero. A percentile is null when no eligible samples exist. delivered is not the latency sample count. Report percentile values without inferring the unmeasured population or the distribution between them. They do not establish maxima or exact threshold counts; multiplying delivered by percentile fractions or subtracting processing and delivery percentiles cannot determine slow-message counts or a stage's latency.

group_by
string

Group by one recorded event dimension. Omit for a single ungrouped summary with optional series. Grouping by tag requires filters.tag.name. Missing values form a null group when the metric supports that dimension. A null value means the event lacks that attribution; it does not explain how the message was created or establish membership in another dimension such as a campaign.

Every selected metric must support the grouping dimension and every filter dimension. Unsupported combinations return validation error E04074, even when the workspace has no events.

  • sending_domain, category, template_id, tag: all metrics.
  • recipient_domain, ip_pool_id, broadcast_id: all metrics except sends_accepted.
  • mailbox_provider, mailbox_provider_region: all metrics except sends_accepted, accepted, and rejected.
  • sending_ip: delivered, bounced, hard_bounced, soft_bounced, admin_bounced, block_bounced, undetermined_bounced, deferred, oob_bounces, effective_delivered, all_bounces, delivery_rate, bounce_rate, deferral_rate, oob_rate, total_p50_ms, total_p95_ms, and total_p99_ms.
  • country, region, city, agent_family, os_family, device_family: opens, opens_non_prefetched, clicks, unique_opens, unique_opens_non_prefetched, unique_clicks, confirmed_unique_opens, and confirmed_unique_opens_non_prefetched.
  • smtp_error_code: bounced, hard_bounced, soft_bounced, admin_bounced, block_bounced, and undetermined_bounced.
  • feedback_type: complained.

Possible values: sending_domain, category, template_id, tag, recipient_domain, mailbox_provider, mailbox_provider_region, sending_ip, ip_pool_id, broadcast_id, country, region, city, agent_family, os_family, device_family, smtp_error_code, feedback_type

grain
string

Time buckets in the requested timezone. Weeks start on Monday; months start on the first day. Half days start at midnight and noon. Edge buckets count events inside the normalized period.

Possible values: quarter_hour, hour, half_day, day, week, month

filters
object

Filter recorded event context with include/exclude predicates. Include values combine with OR; dimensions combine with AND. Exclude-only predicates retain missing values. Tag filters require one case-sensitive name; a name without values requires presence. Each predicate accepts at most 20 distinct values across include and exclude. Every selected metric must support every filter dimension, using the same compatibility rules as group_by. Resolve template and IP-pool names to IDs before filtering. Broadcast filters use IDs. Current names do not establish historical attribution.

Afficher les paramètres enfants
filters.sending_domain
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.category
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.template_id
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.tag
object

Select one case-sensitive tag name. A name without values requires that tag to exist. Exclude-only predicates retain events without that tag. Include and exclude together accept at most 20 distinct normalized values with no overlap.

Afficher les paramètres enfants
filters.recipient_domain
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.mailbox_provider
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.mailbox_provider_region
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.sending_ip
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.ip_pool_id
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.broadcast_id
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.country
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.region
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.region.include
array of string
filters.region.exclude
array of string
filters.city
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.agent_family
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.os_family
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.device_family
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.smtp_error_code
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
filters.feedback_type
object

Match recorded values using include or exclude. Include values combine with OR; exclusions remove matches. Missing values survive exclude-only predicates. Supply a nonempty array; at most 20 distinct values across both arrays are accepted after normalization, with no overlap.

Afficher les paramètres enfants
sort
string

Grouped requests only. Rank groups by this selected metric; defaults to the first metrics entry. Undefined values sort last in either direction. Ties use the dimension value ascending, with null last.

Possible values: sends_accepted, accepted, processed, delivered, bounced, hard_bounced, soft_bounced, admin_bounced, block_bounced, undetermined_bounced, complained, deferred, rejected, oob_bounces, opens, opens_non_prefetched, clicks, unsubscribes, unique_opens, unique_opens_non_prefetched, unique_clicks, confirmed_unique_opens, confirmed_unique_opens_non_prefetched, effective_delivered, all_bounces, delivery_rate, bounce_rate, complaint_rate, deferral_rate, open_rate, click_rate, unsubscribe_rate, oob_rate, processing_p50_ms, processing_p95_ms, processing_p99_ms, total_p50_ms, total_p95_ms, total_p99_ms

order
string

Grouped requests only. Defaults to desc.

Possible values: asc, desc

limit
integer

Grouped requests only. Maximum groups per page; defaults to 25. Each group retains its complete series.

starting_after
string

Grouped requests only. Opaque next_cursor from the previous response. Mutually exclusive with ending_before.

ending_before
string

Grouped requests only. Opaque prev_cursor for backward navigation, or refresh_cursor to read groups before the anchor in the current sort order. Mutually exclusive with starting_after.

Contenu de la réponse

data
array of object
obligatoire
Afficher les attributs enfants
period
object
obligatoire

Normalized half-open period. The response end is exclusive; replay the original inclusive request bounds when following cursors.

Afficher les attributs enfants
data_as_of
nullable string
obligatoire

Always null for this endpoint. It does not report a refresh boundary, claim completeness, or record request time.

next_cursor
nullable string
obligatoire

Pass as starting_after for the next grouped page. Null when no next page exists or the request is ungrouped.

prev_cursor
nullable string
obligatoire

Pass as ending_before for the previous grouped page. Null when no previous page exists or the request is ungrouped.

refresh_cursor
nullable string
obligatoire

Anchor for the first group. Pass as ending_before to read groups sorting before it. Null for empty or ungrouped results. Ranking can change between reads; refresh by repeating the original query.

Poursuivez avec la documentation, les guides et les exemples sur ce sujet.