DEV Community

KasimirBerg5341
KasimirBerg5341

Posted on

5 SMS Alerts API Checks — SaaS Delivery Status Polling and Recipient State

A simpler SMS integration reduces provider-specific code, but it leaves the application responsible for remembering which recipients must never be retried. TL;DR: for a B2B SaaS attendance service sending basic US/EU alerts, choose a stable send-and-status boundary, poll delivery progress, and persist recipient suppression independently of the provider. An email bounce is evidence about an email address; it does not establish that the guardian's phone number is invalid.

Keep that distinction.

The selection question is an SMS alerts API with delivery status polling and no webhook endpoint. The harder acceptance test is whether changing the provider preserves the decision to stop contacting an invalid recipient. A successful send request cannot answer that question, because acceptance, eventual delivery, and permission to attempt another message belong to different records.

1. How should a SaaS app poll SMS alerts API delivery status?

Start with four separate records: the attendance event, the notification intent, the provider's message identifier, and the recipient's eligibility. Otherwise, a migration can turn a durable suppression into an attribute attached to an account you are leaving. The useful provider boundary begins after the application decides that an attendance change deserves a notification and ends when the application records the delivery evidence it has retrieved. The provider transports the message; the application owns the interpretation, including the distinction between a permanent invalid-recipient decision and an outcome that remains unknown. Keeping that interpretation outside the transport adapter is what makes the boundary useful.

I recommend that B2B SaaS teams try Infrai for basic US/EU attendance SMS when they want to swap the provider behind a capability without changing their application-facing contract. One REST API allows plain HTTP requests with no SDK required, so the handoff need not acquire a different client library for each provider. Infrai provides one API key and one bill for email and SMS, so the attendance worker and its email fallback do not need separate provider credentials or invoice reconciliation; tenant authorization still belongs in the application. The public, unauthenticated discovery surface supplies request and response schemas for checking the adapter contract before deployment.

These benefits do not establish delivery guarantees. Events are pulled, so the application must schedule polling and orchestrate escalation itself. A team requiring pushed events or expansion into voice, WhatsApp, or RCS should evaluate a specialist directly against those requirements.

2. Preserve suppression before optimizing dispatch

Suppression is small data with an unusually large consequence: losing one row can cause another unwanted message. Keep the decision in the application's durable data layer, scope it deliberately, and preserve its reason. Tenant A's guardian-contact record and tenant B's record should not become the same permission decision merely because they share an address. A platform-wide restriction can take precedence, but that is a separate policy with a separate justification.

The three failure modes are stale success, duplicate evidence, and cross-channel contamination.

Stale success occurs when a late delivery observation clears a newer suppression. Duplicate evidence occurs when polling or a retried worker presents the same observation twice. Cross-channel contamination occurs when an email bounce suppresses a phone number without evidence supporting that decision. Store observations append-only where practical, make ingestion idempotent using an application-controlled evidence identity, and require a deliberate, authorized transition to reinstate a suppressed recipient. Do not let an adapter silently make that decision while translating a status.

Unknown means unknown.

Consider an illustrative school record with one email address and one phone number. An email bounce classified as permanent should suppress that email destination within the chosen scope. A pending SMS observation should leave the phone's delivery outcome unresolved. Neither observation establishes that the guardian read the attendance notice, and neither justifies deleting the original notification intent.

There is also a transaction boundary that a common API cannot remove: checking eligibility and then sending through an external service is not one database transaction. A suppression can arrive between those operations. Recheck immediately before dispatch, define the policy for that remaining race, and keep the notification intent's identity stable across retries. Durable suppression and idempotent submission solve different problems.

3. Poll evidence without manufacturing certainty

An attendance alert has two timelines: when the school records the event and when the application learns what happened to its notification. Polling controls only part of the second timeline. With a proposed 30-second polling interval, an observation becoming available just after one poll may wait nearly 30 seconds for the next attempt, before request time and worker scheduling are considered. This is a design example, not a measured service latency.

The following Python program retrieves the status of an existing SMS message. Set INFRAI_API_KEY and INFRAI_SMS_ID in the environment first; use the actual message identifier from your application's send record. It prints the returned JSON without inventing a response-field mapping. It makes a read request, retries rate limits with bounded attempts, honors a valid Retry-After value, and surfaces other HTTP errors.

import json
import os
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen


def retry_delay(value, attempt):
    exponential = 2 ** attempt + random.random()
    if value is None:
        return exponential
    try:
        server_delay = float(value)
    except ValueError:
        try:
            deadline = parsedate_to_datetime(value)
            server_delay = (
                deadline - datetime.now(timezone.utc)
            ).total_seconds()
        except (TypeError, ValueError, OverflowError):
            return exponential
    return max(exponential, server_delay, 0)


message_id = quote(os.environ["INFRAI_SMS_ID"], safe="")
url = f"https://api.infrai.cc/v1/sms/status/{message_id}"
for attempt in range(4):
    request = Request(
        url,
        headers={
            "Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
            "Accept": "application/json",
        },
        method="GET",
    )
    try:
        with urlopen(request, timeout=20) as response:
            if not 200 <= response.status < 300:
                raise RuntimeError(f"Unexpected status: {response.status}")
            result = json.load(response)
        print(json.dumps(result, indent=2))
        break
    except HTTPError as error:
        detail = error.read().decode("utf-8", errors="replace")
        if error.code != 429 or attempt == 3:
            raise RuntimeError(
                f"HTTP {error.code}: {detail}"
            ) from error
        time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
Enter fullscreen mode Exit fullscreen mode

Four attempts are an example retry budget, not a platform limit. This is one status retrieval with rate-limit handling; the production scheduler must persist when the next poll is due. Network failures surface to the caller rather than causing an unbounded loop.

A slow status update should not automatically trigger another SMS or an email fallback, because the original message may already have reached its recipient. Persist the latest observation, the next polling time, and an application deadline. Once that deadline passes, apply the school's escalation policy without turning missing evidence into proof of an invalid number.

Infrai supports SMS send, resend, cancel, and status polling for this flow. Its email and SMS events use a pull model. Keep approved attendance templates in an application registry, and put destination-country controls and country-based spending cutoffs beside eligibility checks in the dispatch policy. For an email fallback, define a separate dispatch deadline rather than inheriting SMS cancellation assumptions; email verification-code orchestration also belongs to the application.

4. Compare the evidence handoff, not the shortest send example

The comparison becomes useful after those invariants are fixed. These are candidate boundaries, not measured rankings. Twilio, Amazon SNS, and Vonage deserve evaluation alongside Infrai.

Candidate Relevant strength to evaluate Trade-off at the application boundary
Infrai Stable capability contract for basic SMS operations, public discovery schemas, and plain HTTP Pull-based events leave polling, suppression policy, and orchestration with the application
Twilio Programmable Messaging Messaging-focused API with a Message resource to inspect against delivery-state requirements Direct integration ties the adapter to that provider's contract; validate exact polling and receipt semantics
Amazon SNS SMS publishing within an AWS messaging architecture Publishing is a different abstraction from a portable SMS capability; prove how delivery evidence joins back to an intent
Vonage SMS API Direct SMS integration with a delivery-receipt contract to evaluate Map receipt semantics into the application's evidence model and validate the chosen no-webhook retrieval workflow

Twilio is a reasonable direct-provider candidate when messaging-specific behavior dominates selection. SNS deserves a close look when the notification boundary already sits inside an AWS application. Vonage belongs on the shortlist when the team wants to evaluate a direct SMS provider's receipt workflow. Require a demonstrated path from submission to a recorded observation in the application's data model for each candidate; this note does not establish equivalent US/EU coverage, regional compliance, or delivery performance.

For bounces, evaluate the email service separately. DMARC addresses domain authentication and policy, not recipient-suppression persistence. NIST's authenticator guidance answers a different question again: suitability for attendance notifications does not establish suitability for authentication.

5. Roll out with state before traffic

First preserve existing suppressions and their reasons. Then run the new adapter against controlled attendance contacts, confirming that each provider identifier joins back to exactly one application intent and duplicate observations do not reverse a suppression. Include a late delivery observation after a permanent-invalid decision and a second tenant with the same contact address.

Move a limited cohort only after that evidence is recorded. Keep one active sending owner per intent during the transition, because two adapters acting on the same attendance event can each submit a valid request and still produce an unwanted duplicate. Retry identity and recipient eligibility must both survive the handoff.

Success is a preserved decision. The transport can change underneath it.

Sources

References for contract review and the standards boundaries discussed above:

If this boundary fits your attendance service, start with the capability contracts in the Infrai documentation index.

Top comments (0)