Sign inGet Started

Get outbound SMS statistics by tag

GET
/v1/sms/stats/tags
const stats = await bird.sms.stats.byTag({ from: "2026-05-01", to: "2026-05-31" });
for (const row of stats.data ?? []) {
  // A message carrying several tags counts once under each, so rows do not sum
  // to the period total.
  console.log(row.tag, row.delivery);
}
Réponse200
{
  "period": {
    "from": "2026-05-01",
    "to": "2026-05-25",
    "data_as_of": "2026-05-25T14:03:10Z"
  },
  "data": [
    {
      "tag": "campaign:summer_sale",
      "delivery": {
        "accepted": 14820,
        "sent": 14810,
        "delivered": 14720,
        "undelivered": 60,
        "failed": 25,
        "rejected": 10,
        "expired": 5,
        "delivery_rate": 0.9932,
        "failure_rate": 0.0061
      },
      "latency": {
        "processing": {
          "p50_ms": 420,
          "p95_ms": 1820,
          "p99_ms": 4920
        },
        "delivery": {
          "p50_ms": 420,
          "p95_ms": 1820,
          "p99_ms": 4920
        },
        "total": {
          "p50_ms": 420,
          "p95_ms": 1820,
          "p99_ms": 4920
        }
      },
      "trend": [
        {
          "bucket": "2026-05-25",
          "delivery": {
            "accepted": 14820,
            "sent": 14810,
            "delivered": 14720,
            "undelivered": 60,
            "failed": 25,
            "rejected": 10,
            "expired": 5
          }
        }
      ]
    }
  ],
  "total": 18
}

Returns delivery and latency statistics grouped by tag (name:value). Rows sort by the selected metric in descending order and are capped by limit. The default sort is accepted; the default limit is 50 and the maximum is 200.

Only tagged messages appear. A message with several tags is counted once under each, so rows do not sum to the period total.

Rows use send-time attribution, so recent periods can under-report delivered while delivery reports arrive. A request may span up to 365 days; a longer window returns 422.

Paramètres de requête

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; with include_trend=true and trend_grain=hourly the default tightens to keep the window within the 720-hour trend cap.

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.

sortstring

Metric to rank rows by, applied descending. Any lifecycle count or derived rate in the response may be used; rows whose rate is undefined (zero denominator) sort last. Defaults to accepted.

Possible values: accepted, sent, delivered, undelivered, failed, rejected, expired, delivery_rate, failure_rate

limitinteger

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

include_trendboolean

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_grainstring

Bucket grain for the trend series. Has no effect unless include_trend=true.

Possible values: daily, hourly

Contenu de la réponse

period
object
obligatoire

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

Afficher les attributs enfants
data
array of object
obligatoire

Tag breakdown rows, ranked by the sort metric (default accepted) descending. Empty when no tagged messages were sent in the period.

Afficher les attributs enfants
data.tag
string
obligatoire

The tag this row aggregates, in name:value form. Each distinct name-and-value pair is its own row, and a message carrying several tags is counted once under each of them, so rows do not sum to the period total.

data.delivery
object
obligatoire
Afficher les attributs enfants
data.latency
object
obligatoire
Afficher les attributs enfants
data.trend
array of object

Per-bucket lifecycle-count series for this tag over the window, bucketed by trend_grain. Sparse, so only buckets with activity are present rather than zero-filled, unlike the daily and hourly series. Present only when include_trend=true.

Afficher les attributs enfants
total
integer
obligatoire

Total number of distinct tags 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.

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