Documentation
Sign inGet started

SMS stats by error code

GET
/v1/sms/stats/error-codes
const stats = await bird.sms.stats.byErrorCode({ from: "2026-05-01", to: "2026-05-31" });
for (const row of stats.data ?? []) {
  // The same value as the error_code filter on bird.sms.list.
  console.log(row.error_code, row.delivery);
}
Returns aggregate delivery and latency stats grouped by the Bird-normalized failure reason for the requested period -- the deliverability-debugging view that answers "which failure reasons are driving my failures". The grouping key is the same normalized reason as the error_code filter on the message list, so a row joins directly to those messages; it is not a raw carrier code. Rows are ranked by the sort metric (default failed) descending and capped at the requested limit (default 50, hard maximum 200). Rows are attributed to send time, not event time: a delivery confirmed during the period for a message accepted earlier counts against the earlier period, not this one. A recent period therefore under-reports delivered while its delivery reports are still arriving, and its counts only ever grow toward the truth. The maximum window is 365 days; requesting a longer range returns 422.
Abfrageparameter
from
string
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; with include_trend=true and trend_grain=hourly the default tightens to keep the window within the 720-hour trend cap.
to
string
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.
timezone
string
IANA timezone identifier (for example Asia/Kathmandu) to report in; defaults to UTC. Day and hour boundaries and the default window when from and to are omitted both follow it, so a calendar-day from or to names a local day. A from or to carrying its own UTC offset is rejected while this is set: pass a calendar day or a Z instant.
sort
string
Metric to rank rows by, applied descending. Defaults to failed. Only lifecycle counts are sortable; this breakdown has no rates.
Possible values: accepted, sent, delivered, undelivered, failed, rejected, expired
limit
integer
Maximum number of error-code rows to return, ranked by the sort field descending.
include_trend
boolean
When true, each row also carries a trend array: a short per-bucket lifecycle-count series for that row over the window. Returned only when limit is 50 or fewer and the window is at most 90 days (trend_grain=daily) or 720 hours (trend_grain=hourly); a larger request returns 422.
trend_grain
string
Bucket grain for the trend series. Has no effect unless include_trend=true.
Possible values: daily, hourly
Antwort-Payload
period
object
erforderlich
The date range the response covers (echoed back from the request), plus data_as_of, the freshness boundary the data is current to.
Untergeordnete Attribute anzeigen
period.from
string
erforderlich
Inclusive start of the window the response covers -- a calendar day (YYYY-MM-DD) for day windows, or an hour boundary (RFC 3339) for hour windows.
period.to
string
erforderlich
Inclusive end of the window the response covers -- a calendar day (YYYY-MM-DD) for day windows, or an hour boundary (RFC 3339) for hour windows.
period.data_as_of
nullable string
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.
data
array of object
erforderlich
Error-code breakdown rows, ranked by the sort metric (default failed) descending. Empty when no delivery failures occurred in the period.
Untergeordnete Attribute anzeigen
data.error_code
string
erforderlich
The Bird-normalized failure reason this row aggregates, joinable with the error_code message-list filter.
data.delivery
object
erforderlich
Untergeordnete Attribute anzeigen
data.delivery.accepted
integer
erforderlich
Distinct messages accepted for sending after admission checks. This is the denominator for delivery_rate and failure_rate.
data.delivery.sent
integer
erforderlich
Distinct messages handed off to the carrier for delivery.
data.delivery.delivered
integer
erforderlich
Distinct messages the carrier confirmed as delivered to the handset.
data.delivery.undelivered
integer
erforderlich
Distinct messages the carrier reported as not delivered.
data.delivery.failed
integer
erforderlich
Distinct messages that failed during sending.
data.delivery.rejected
integer
erforderlich
Distinct messages rejected before any send attempt, for example by sending policy or a message-generation failure.
data.delivery.expired
integer
erforderlich
Distinct messages that could not be delivered within their validity window and expired.
data.delivery.delivery_rate
nullable number
erforderlich
Share of accepted messages that were delivered, computed as delivered / accepted. Null when no messages were accepted in scope.
data.delivery.failure_rate
nullable number
erforderlich
Share of accepted messages that ultimately failed, computed as (undelivered + failed + expired) / accepted. Null when no messages were accepted in scope.
data.latency
object
erforderlich
Untergeordnete Attribute anzeigen
data.latency.processing
object
p50, p95, and p99 latency percentiles in milliseconds for one latency family over the scope. Percentiles are approximate (computed from a high-volume aggregation pipeline). All three are null together when no qualifying event contributed a latency measurement in scope.
Untergeordnete Attribute anzeigen
data.latency.processing.p50_ms
nullable integer
erforderlich
Median (50th percentile) latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.processing.p95_ms
nullable integer
erforderlich
95th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.processing.p99_ms
nullable integer
erforderlich
99th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.delivery
object
p50, p95, and p99 latency percentiles in milliseconds for one latency family over the scope. Percentiles are approximate (computed from a high-volume aggregation pipeline). All three are null together when no qualifying event contributed a latency measurement in scope.
Untergeordnete Attribute anzeigen
data.latency.delivery.p50_ms
nullable integer
erforderlich
Median (50th percentile) latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.delivery.p95_ms
nullable integer
erforderlich
95th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.delivery.p99_ms
nullable integer
erforderlich
99th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.total
object
p50, p95, and p99 latency percentiles in milliseconds for one latency family over the scope. Percentiles are approximate (computed from a high-volume aggregation pipeline). All three are null together when no qualifying event contributed a latency measurement in scope.
Untergeordnete Attribute anzeigen
data.latency.total.p50_ms
nullable integer
erforderlich
Median (50th percentile) latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.total.p95_ms
nullable integer
erforderlich
95th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.latency.total.p99_ms
nullable integer
erforderlich
99th percentile latency in milliseconds. Null when no qualifying event contributed a measurement.
data.trend
array of object
Per-bucket lifecycle-count series for this error code over the window, bucketed by trend_grain. Sparse -- only buckets with activity are present, not zero-filled, unlike the daily/hourly series. Present only when include_trend=true.
Untergeordnete Attribute anzeigen
data.trend.bucket
string
erforderlich
The day (YYYY-MM-DD) or hour (RFC 3339, on the hour) this point covers, matching the period's grain.
data.trend.delivery
object
erforderlich
Untergeordnete Attribute anzeigen
data.trend.delivery.accepted
integer
erforderlich
Distinct messages accepted for sending after admission checks.
data.trend.delivery.sent
integer
erforderlich
Distinct messages handed off to the carrier for delivery.
data.trend.delivery.delivered
integer
erforderlich
Distinct messages the carrier confirmed as delivered to the handset.
data.trend.delivery.undelivered
integer
erforderlich
Distinct messages the carrier reported as not delivered.
data.trend.delivery.failed
integer
erforderlich
Distinct messages that failed during sending.
data.trend.delivery.rejected
integer
erforderlich
Distinct messages rejected before any send attempt, for example by sending policy or a message-generation failure.
data.trend.delivery.expired
integer
erforderlich
Distinct messages that could not be delivered within their validity window and expired.
total
integer
erforderlich
Total number of distinct error codes 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.