Get outbound SMS statistics by cost center
/v1/sms/stats/cost-centersconst stats = await bird.sms.stats.byCostCenter({ from: "2026-05-01", to: "2026-05-31" });
for (const row of stats.data) {
// Messages sent without a cost center are not counted, so rows do not sum to
// the period total.
console.log(row.cost_center, row.delivery);
}stats = client.sms.stats.by_cost_center(from_="2026-05-01", to="2026-05-31")
for row in stats.data:
# Messages sent without a cost center are not counted, so rows do not
# sum to the period total.
print(row.cost_center, row.delivery)stats, err := client.Sms.Stats.ByCostCenter(context.Background(), bird.SmsStatsByCostCenterParams{
From: time.Now().AddDate(0, -1, 0),
To: time.Now(),
})
if err != nil {
log.Fatal(err)
}
for _, row := range stats.Data {
// Messages sent without a cost center are not counted, so rows do not
// sum to the period total.
fmt.Println(row.CostCenter, *row.Delivery.Accepted)
}$byCostCenter = $bird->sms->stats->byCostCenter(['from' => '2026-05-01', 'to' => '2026-05-31']);
foreach ($byCostCenter->getData() ?? [] as $row) {
// Messages sent without a cost center are not counted, so rows do not sum to
// the period total.
echo $row->getCostCenter(), ' ', $row->getDelivery()?->getAccepted(), PHP_EOL;
}bird sms stats by-cost-centercurl -X GET "https://us1.platform.bird.com/v1/sms/stats/cost-centers" \
-H "Authorization: Bearer $TOKEN" \
--url-query "sort=accepted" \
--url-query "limit=50" \
--url-query "include_trend=false" \
--url-query "trend_grain=daily"{
"period": {
"from": "2026-05-01",
"to": "2026-05-25",
"data_as_of": "2026-05-25T14:03:10Z"
},
"data": [
{
"cost_center": "CC001234",
"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": 8
}
Returns aggregate delivery and latency stats grouped by the cost_center messages were sent with, for the requested period. Messages sent without a cost center are not counted, so rows do not sum to the period total. Rows are ranked by the sort metric (default accepted) descending and capped at the requested limit (default 50, hard maximum 200).
Rows use send-time attribution. A delivery confirmed during the period for a message accepted earlier counts against the earlier period. A recent period therefore under-reports delivered while delivery reports are still arriving, and its counts grow as reports arrive.
The maximum window is 365 days; requesting a longer range returns 422.
Parâmetros de consulta
fromstringStart 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.
tostringEnd 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.
timezonestringIANA 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.
sortstringMetric 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
limitintegerMaximum number of cost center rows to return, ranked by the sort field descending.
include_trendbooleanWhen 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_grainstringBucket grain for the trend series. Has no effect unless include_trend=true.
Possible values: daily, hourly
Payload de resposta
periodThe date range the response covers (echoed back from the request), plus data_as_of, the freshness boundary the data is current to.
Mostrar atributos secundários
period.fromInclusive start of the window, as a calendar day (YYYY-MM-DD) or an RFC 3339 hour boundary.
period.toInclusive end of the window, as a calendar day (YYYY-MM-DD) or an RFC 3339 hour boundary.
period.data_as_ofLatest time reflected in the statistics. More recent events might not be included yet. Null when the freshness boundary is unavailable.
dataCost center breakdown rows, ranked by the sort metric (default accepted) descending. Empty when no messages with a cost center were sent in the period.
totalTotal number of distinct cost centers 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.
Recursos relacionados
Continue com a documentação, guias e exemplos sobre este tópico.