Send Single SMS
This end points allows users and apps to send a single SMS and outbox feature.
Overview
This endpoint sends a single SMS and logs all SMS activities in an Outbox. If an SMS fails to send, the user can resend it from the outbox. Each outbox entry contains timestamps, statuses, and SMS cost details for reconciliation and auditing.
Endpoint: Send Single SMS
Method:
POST
URL:
/api/sms/send
Request Body
Outbox Data Structure
The Outbox will store all sent SMS with the following fields:
Field
Type
Description
outboxId
string
Unique identifier for the outbox entry.
userId
string
The user who initiated the SMS.
recipientPhoneNumber
string
The phone number of the recipient.
message
string
The SMS content.
senderId
string
The sender ID used for the SMS.
messageId
string
Unique identifier for the message.
smsUnitsUsed
number
Number of SMS units charged for the message.
costPerUnit
number
Cost of each SMS unit (retrieved from SMS cost model).
totalCost
number
Total cost for sending the SMS.
status
string
Status of the SMS (sent
, failed
, pending
).
timestamps
object
Includes createdAt
, sentAt
, and lastAttemptAt
.
retryCount
number
Number of retry attempts for the SMS.
errorDetails
string
Optional: Reason for failure, if applicable.
tags
array<string>
Tags for tracking the SMS (e.g., notification
, OTP
).
customData
object
Optional metadata (e.g., purpose
, linkedTransactionId
).
SMS Status Management
Statuses:
sent
: The SMS was successfully delivered to the recipient.failed
: The SMS could not be sent (e.g., network error).pending
: The SMS is scheduled or queued for sending.
Retries:
Users can resend failed SMS directly from the outbox using a separate endpoint.
The system caps retries at a configurable limit (e.g., 3 attempts).
Timestamps:
createdAt
: When the SMS was logged in the outbox.sentAt
: When the SMS was successfully sent.lastAttemptAt
: The timestamp of the most recent attempt to send the SMS.
Send SMS Response
The response now includes the Outbox entry details.
Features and Enhancements
Outbox Tracking:
All SMS are logged in the Outbox, regardless of status (
sent
,failed
,pending
).Each log includes the SMS details, costs, status, and timestamps.
Retry Mechanism:
Failed SMS can be retried via the Outbox Resend Endpoint.
Maximum retry attempts are configurable to prevent abuse.
Cost Tracking:
Costs are calculated per unit and stored in the Outbox for each SMS transaction.
This ensures reconciliation and transparency for both users and admins.
Alerts and Notifications:
Users receive notifications for failed SMS or low SMS balances.
Configurable alert thresholds and retry limits.
Detailed Metadata:
Optional fields (
tags
,customData
) allow for flexible tracking and categorization of SMS.
Resend SMS Endpoint
Method:
POST
URL:
/api/sms/outbox/resend
Request Body:
Response: