Sign inGet Started

Get bounces by SMTP error code

GET
/v1/email/stats/bounce-codes
const { data } = await bird.email.stats.byBounceCode({
  from: "2026-05-01",
  to: "2026-05-31",
  sort: "bounced",
  limit: 25,
});
for (const row of data) console.log(row.smtp_error_code, row.bounced);
Odpowiedź200
{
  "period": {
    "from": "2026-05-01",
    "to": "2026-05-25",
    "data_as_of": "2026-05-25T14:03:10Z"
  },
  "data": [
    {
      "smtp_error_code": "5.1.1",
      "bounced": 1240,
      "bounces": {
        "hard": 42,
        "soft": 48,
        "admin": 4,
        "block": 6,
        "undetermined": 1
      }
    }
  ],
  "total": 17,
  "next_cursor": "eyJ2IjoxLCJzIjoiXCIyMDI2LTA1LTI1VDE0OjAzOjEwWlwiIiwiaSI6IjAxOTJmM2IxLTRjN2UtN2EyYi05ZDYxLThmM2E1YzJlN2I0MCJ9",
  "prev_cursor": null,
  "refresh_cursor": "eyJ2IjoxLCJzIjoiXCIyMDI2LTA1LTI1VDE2OjQyOjAxWlwiIiwiaSI6IjAxOTJmM2IxLTllMDQtN2NkMy1iODE3LTJhNmY0ZDFjOGUwOSJ9"
}

Returns bounce counts for the requested period, grouped by the SMTP error code the receiving mail server returned. It answers the question of which SMTP responses are driving your bounces. Each row reports how many recipients bounced with that code, plus the hard, soft, admin, block, and undetermined split for that code.

This failure-only breakdown omits delivered, open, click, and rate fields because bounce codes occur only on bounce events.

Rows are ranked by the sort metric, bounced by default, and paginated with the requested limit (50 by default, 200 at most). They are computed against event time rather than send time. The window can span at most 365 days. Ask for more and you get a 422.

Parametry zapytania

starting_afterstring

Cursor from the next_cursor field of a previous list response. Returns items immediately after the cursor position in the current sort order.

ending_beforestring

Cursor from the prev_cursor or refresh_cursor field of a previous list response. Returns items immediately before the cursor position in the current sort order. prev_cursor returns the preceding page. refresh_cursor anchors at the first row of that response, which on a newest-first sort is how to fetch the items that have appeared since.

fromstring

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.

tostring

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.

timezonestring

IANA timezone identifier used to group statistics, for example Asia/Kathmandu. The default is UTC. Day and hour boundaries, including the default window when from and to are omitted, follow this timezone. When this parameter is set, pass from and to as calendar days or Z instants instead of timestamps with explicit UTC offsets.

categorystring

Not supported on breakdown endpoints. Supplying it returns 422. To compare categories, use GET /v1/email/stats/categories. The summary, daily, and hourly statistics accept category as a filter.

sortstring

Metric to rank rows by, applied descending. It defaults to bounced. Only the bounce counts are sortable here, because this breakdown has no rate fields.

Possible values: bounced, bounces.hard, bounces.soft, bounces.admin, bounces.block, bounces.undetermined

limitinteger

Maximum number of bounce-code rows to return, ranked by the sort field descending.

Treść odpowiedzi

period
object
wymagane

The date range the response covers (echoed back from the request), plus data_as_of, the freshness boundary the data is current to.

Pokaż atrybuty podrzędne
data
array of object
wymagane

Bounce-code breakdown rows, ranked by the sort metric (default bounced) descending. Empty when no bounces occurred in the period.

Pokaż atrybuty podrzędne
data.smtp_error_code
string
wymagane

The SMTP error code the receiving mail server returned for these bounces, as reported by that server (for example 5.1.1 for an unknown recipient, 4.2.2 for a full mailbox). The form varies by server, and the set of codes is open.

data.bounced
integer
wymagane

Distinct recipients whose delivery failed with this SMTP status code, approximately equal to the sum of the five bounces.* sub-counts. The two are computed independently, so they can differ slightly because of approximation.

data.bounces
object
wymagane
Pokaż atrybuty podrzędne
total
integer
wymagane

Total number of distinct SMTP error codes with activity in the period, regardless of limit. Pass next_cursor as starting_after to request the next page.

next_cursor
nullable string
wymagane

Cursor for the next page. Pass back as starting_after to advance forward. null when no next page exists.

prev_cursor
nullable string
wymagane

Cursor for the previous page. Pass back as ending_before to step backward. null when no previous page exists.

refresh_cursor
nullable string
wymagane

Refresh anchor, the first row of this response. Pass back as ending_before to fetch what precedes it in the current sort order. On a newest-first sort those are the items that have appeared since; on any other sort they are the items that sort earlier, so refreshing such a list means re-fetching it instead. Non-null whenever data is non-empty; null only on an empty page. Distinct from prev_cursor.

Przejdź do dokumentacji, przewodników i przykładów dotyczących tego tematu.