123eworld Knowledge Hub → Transactional SMS → Page 65
Transactional SMS API Webhooks and Delivery Receipts: Complete Developer Implementation Guide
A detailed guide to implementing SMS delivery webhooks and delivery receipts, covering callback security, event mapping, idempotency, status transitions, retries, database design, monitoring and reconciliation.
Why delivery callbacks matter
The initial SMS API response usually confirms submission, not final handset delivery. Delivery receipts provide a later status that can improve customer support and operational reporting.
The callback system should therefore be designed as a separate inbound event-processing pipeline.
Webhook endpoint design
Expose a dedicated HTTPS endpoint for provider callbacks. Validate authentication or signatures supported by the provider and reject malformed requests.
The endpoint should acknowledge quickly and place heavier processing onto an internal queue when callback volume is high.
Mapping provider statuses
Providers may use different status names. Normalize them into an internal model such as submitted, delivered, failed or expired.
Retain the original provider status for diagnostics, but keep application logic based on the normalized state.
Idempotent callback processing
Providers may retry callbacks if they do not receive an acknowledgement. The same callback can therefore arrive multiple times.
Store the provider event ID or a reliable deduplication key and make status updates idempotent. Reprocessing the same callback should not create duplicate billing events or duplicate customer actions.
Status transition rules
Define which status transitions are valid. A message should not move from delivered back to queued merely because a late callback uses an old status.
A timestamp and event sequence can help determine which callback represents the latest valid state.
Database design
A practical model can separate the message record from delivery events. The message table stores current state while a delivery-event table stores the provider events required for audit and troubleshooting.
Indexes should support searches by internal message ID, provider message ID and business reference.
Webhook security
Validate signatures, timestamps or tokens according to provider capabilities. Protect the endpoint from replay and unauthorized requests.
Never trust a callback merely because it reaches the correct URL. The data should be authenticated and validated before changing message state.
Retries and dead letters
If callback processing fails because of a temporary database or queue problem, the event should be retried safely.
If processing continues to fail, move the callback to a dead-letter path for investigation rather than silently dropping it.
Monitoring
Monitor callback request volume, processing latency, invalid signatures, duplicate callbacks, processing failures and backlog.
A sudden drop in callbacks can indicate a provider configuration problem even when outbound submission continues to look healthy.
Reconciliation
Periodically compare submitted message records with provider delivery events. Reconciliation can identify messages that remain in an uncertain state or expose integration gaps.
The reconciliation process should not blindly resend messages because an absent callback does not necessarily prove non-delivery.
Implementation checklist
Secure the endpoint, normalize statuses, implement idempotency, define valid transitions, store provider references, queue heavy processing, monitor callback health and document reconciliation procedures.
Callback payload validation
A delivery webhook should validate required fields, data types, message references and event timestamps before processing. Unknown status values should be recorded safely rather than causing an uncontrolled application error.
Validation is important because callback endpoints are exposed to external traffic and can become a source of corrupted message state if input is trusted blindly.
Out-of-order callbacks
Delivery events may not always arrive in the order they were generated. A failed or expired event arriving after a delivered event should not automatically overwrite the final delivered state.
Use provider timestamps, sequence numbers where available and explicit transition rules to determine whether a callback should change current state.
Callback scaling
Large messaging systems may receive many delivery receipts. The public webhook should remain lightweight and hand validated events to an internal queue.
Workers can then update databases and analytics systems independently. This prevents a slow reporting query from causing the provider to retry callbacks.
Provider migration
When changing providers, the callback model should preserve the internal message identifier so support can continue to trace communication regardless of which provider handled it.
Provider-specific IDs should be stored alongside the internal ID rather than replacing it.
Production test plan
Test valid callbacks, duplicate callbacks, invalid signatures, unknown message IDs, out-of-order status events, database failure, queue failure and callback bursts. Confirm that message state remains correct and that failed callback processing is recoverable.
Monitoring webhook health
Monitor callback volume, processing latency, duplicate rates, invalid signatures, unknown message IDs and dead-letter events. A sudden drop in callbacks can be as important as a rise in errors.
Compare outbound submission volume with inbound delivery events over an appropriate time window. Large unexplained gaps should trigger investigation rather than automatic resend.
Knowledge-base cross-reference
Connect this guide to the transactional SMS API, error handling, authentication and enterprise gateway pages. Delivery receipts are one part of the complete message lifecycle and should be designed together with outbound processing.
Final review
Before publishing, verify metadata, canonical URL, internal links, callback security, status-transition rules and reconciliation guidance.
Reference implementation flow
The provider sends a signed delivery callback to the HTTPS endpoint. The endpoint validates the request and records the callback event. It then acknowledges the provider quickly and places the event on an internal queue.
A callback worker validates the message reference and status transition, updates the current message state and records the delivery event. Analytics can consume the same event without slowing callback processing.
If the worker fails, the queue retries the event. If processing repeatedly fails, the callback enters a dead-letter path for investigation.
Operational handoff
Document callback authentication, provider status mapping, valid state transitions, duplicate handling, dead-letter recovery and reconciliation procedures. Support should know how to distinguish missing callbacks from actual delivery failures.
Practical troubleshooting case
If the provider reports delivery but the internal system remains pending, compare the provider callback reference with the internal message record. If the callback was rejected because of signature validation or an unknown ID, fix callback processing rather than resending the SMS.
A missing internal status update does not prove that the customer did not receive the message.
Production readiness
Test valid and invalid callbacks, duplicate events, out-of-order statuses, callback bursts, database failures and dead-letter recovery. Confirm that no callback can create a duplicate customer message.
Final developer checklist
Verify callback authentication, status normalization, idempotency, out-of-order handling, queue processing, dead letters, reconciliation, monitoring and internal links.
Capacity planning
Estimate callback volume from peak outbound message throughput and ensure the callback endpoint and internal workers can absorb bursts without provider retries.
Detailed implementation considerations
Delivery receipts should never be treated as an afterthought. They affect support, analytics, billing, retry decisions and customer-service workflows.
Keep the inbound callback path independent from outbound SMS processing. A provider may deliver a large burst of receipts after recovering from an outage, and the system must absorb that burst without affecting new message submissions.
Store raw provider events for appropriate diagnostic retention while maintaining a clean normalized message state for application use.
Developer decision guide
Use asynchronous callback processing when delivery volume can spike. Keep the public webhook fast, validate every callback, normalize provider states and use idempotent updates. If delivery receipts influence billing or customer actions, retain sufficient event history to audit those decisions.
Final implementation note
Delivery receipts complete the message lifecycle. A production platform should be able to trace one business event from message creation through provider submission and final delivery state without relying on manual provider-dashboard searches.
Practical rule
Never treat the absence of a delivery receipt as proof of non-delivery. Reconcile provider state and internal records before considering any resend.
Final architecture reminder
Keep delivery callbacks independent from outbound workers so reporting traffic cannot block new customer messages.
Final quality note
For billing or SLA reporting, preserve the original provider event and timestamp so later status normalization does not erase the evidence needed for reconciliation.
Final production reminder
Before production, verify that callback authentication, duplicate protection and status-transition rules remain correct when the provider sends callbacks in unexpected order or repeats them.
Final delivery checklist
Confirm callback authentication, normalized statuses, idempotent processing, out-of-order handling, reconciliation and monitoring before launch.
Need transactional SMS integration?
123eworld.com provides Bulk SMS and API-based business communication solutions for enterprises and software applications.