SMS
SMS Analytics Integration Guide
SMS Analytics Integration Guide
This guide explains how to consume SMS analytics from the Tech231 Platform API.
Overview
The SMS Analytics API provides time-series metrics for your messaging activity. All data is:
- Tenant-scoped: You only see your own data
- Aggregated: No individual message details, just counts and rates
- Time-partitioned: Organized by UTC date or period
Authentication
All analytics endpoints require Zitadel authentication:
Code
Endpoints
GET /api/v2/sms/analytics/timeseries/daily
Get daily SMS analytics for your tenant.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| startDate | DateOnly | Yes | Start of date range (inclusive) |
| endDate | DateOnly | Yes | End of date range (inclusive) |
| direction | string | No | Filter by direction: 'outbound' or 'inbound' |
Example Request:
Code
Example Response:
Code
GET /api/v2/sms/analytics/timeseries/period
Get aggregated SMS analytics for a period (week/month/quarter/year).
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| startDate | DateOnly | Yes | Start of date range (inclusive) |
| endDate | DateOnly | Yes | End of date range (inclusive) |
| granularity | string | Yes | Aggregation level: 'week', 'month', 'quarter', 'year' |
| direction | string | No | Filter by direction: 'outbound' or 'inbound' |
Example Request:
Code
Example Response:
Code
Metrics Explained
| Metric | Description |
|---|---|
| attemptedCount | Total SMS messages submitted for sending |
| processedCount | Messages that reached the SMSC (gateway) |
| deliveredCount | Messages confirmed delivered to recipients |
| failedCount | Messages that failed to deliver |
| uniqueRecipientCount | Distinct phone numbers messaged |
| avgSendToFinalStatusSeconds | Average time from send to final status |
| deliveryRatePercent | (delivered / processed) × 100 |
| failureRatePercent | (failed / processed) × 100 |
Date Range Limits
- Maximum date range: 90 days for daily, 365 days for period
- All dates are in UTC
- Start date must be before or equal to end date
Rate Limiting
Analytics endpoints are subject to rate limiting:
- 100 requests per minute per tenant
- Rate limit headers included in response
Migration from Legacy Analytics
If you were using the legacy /api/v2/analytics/* endpoints (Orleans grain-based), migrate to the new TimescaleDB endpoints:
| Legacy Endpoint | New Endpoint |
|---|---|
/api/v2/analytics/daily | /api/v2/sms/analytics/timeseries/daily |
/api/v2/analytics/weekly | /api/v2/sms/analytics/timeseries/period?granularity=week |
/api/v2/analytics/monthly | /api/v2/sms/analytics/timeseries/period?granularity=month |
The new endpoints provide:
- Better performance: TimescaleDB hypertables and continuous aggregates
- Longer retention: 12 months of daily data
- More granularities: Quarterly and yearly aggregates
- Lower latency: Optimized indexing and compression
Error Codes
| Status | Error | Description |
|---|---|---|
| 400 | Invalid date range | startDate > endDate or range exceeds limit |
| 401 | Unauthorized | Missing or invalid authentication |
| 403 | Forbidden | Tenant does not have analytics access |
| 429 | Too Many Requests | Rate limit exceeded |
Code Examples
C# / .NET
Code
Python
Code
JavaScript / Node.js
Code
See Also
Last modified on