SMS Messaging
Programmatic global SMS dispatch via Twilio with E.164 normalization, idempotency, and delivery lifecycle tracking.
Deliver transactional SMS messages using Sendrin's direct Twilio adapter with per-request idempotency.
⚡ Integrate with AI1. Prerequisites & Phone Format (E.164)
Before sending SMS notifications:
- Twilio Provider: Configure your Twilio Account SID, Auth Token, and Sender Phone Number or Messaging Service SID in the Sendrin Console.
- Active Event Key: Create and publish an event (e.g.
order_shipped) with an SMS template containing your variable placeholders (e.g.{{customer_name}},{{tracking_code}}).
All mobile phone numbers must strictly comply with the international E.164 standard:
- Include the country code with a leading
+sign. - Omit dashes, spaces, and leading zeroes.
- Examples:
+14155552671(US),+442071838750(UK),+919876543210(India). Numbers failing this format return422 invalid_recipient.
2. Dispatching an SMS (POST /api/v1/notifications)
Sendrin decouples event triggering from transport. Pass your event_key, the target phone in the recipient object, and template variables in data. Always include a unique Idempotency-Key header to safely retry without duplicate sends.
curl -X POST "https://api.gns.iitdeveloper.com/api/v1/notifications" \
-H "Authorization: Bearer gns_live_sk_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7b3e2189-9a28-48b0-a541-6945df84b802" \
-d '{
"event_key": "order_shipped",
"channel": "sms",
"recipient": {
"phone": "+14155552671"
},
"data": {
"customer_name": "Alex",
"tracking_code": "TRK-98174",
"eta": "today between 2:00 PM and 4:00 PM"
}
}'3. Asynchronous Acceptance Response (202 Accepted)
The API responds with 202 Accepted. This confirms that the request passed schema validation and was safely committed to the transactional outbox for background delivery workers. It does not indicate instant carrier delivery.
4. Delivery Callbacks vs Outbound Webhooks
- Twilio Provider Callbacks: Twilio posts status updates (
sent,delivered,undelivered,failed) back toPOST /api/v1/callbacks/twilio/sms. Sendrin verifies Twilio HMAC signatures and transitions the internal state machine. - Customer Outbound Webhooks: To receive real-time delivery confirmations in your application backend, subscribe an endpoint under Outbound Webhooks. Sendrin will dispatch signed JSON payloads (
notification.deliveredornotification.failed).
5. Common Error Responses
| Status Code | Error Code | Cause & Remediation |
|---|---|---|
422 Unprocessable | invalid_recipient | phone missing in recipient object or failed E.164 regex pattern. |
422 Unprocessable | channel_not_allowed | The referenced event does not have SMS enabled in its allowed_channels. |
404 Not Found | event_not_found | event_key does not match an active event for the authenticated application. |
409 Conflict | idempotency_conflict | The same Idempotency-Key was re-used with a conflicting payload body. |
403 Forbidden | permission_denied | The API key lacks the notifications:send credential permission. |