Skip to main content

Send SMS API

Send SMS messages to specific recipients, contacts, tags, or all contacts. Supports template-based messaging with variable substitution and optional scheduling.

Endpoint

POST /api/v1/sms/send

Headers

X-API-Key: sk_live_your_api_key
Content-Type: application/json

Quick Example

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "otp-sms",
"recipient_type": "direct_sms",
"direct_phone": "+1234567890",
"variables": {
"otp_code": "123456"
}
}'

Request Parameters

Required Fields

FieldTypeDescription
template_keystringSMS template identifier to use
recipient_typestringHow to target recipients: direct_sms, contact, tag, all

Recipient-Specific Fields

Recipient TypeRequired FieldTypeDescription
direct_smsdirect_phonestringPhone number in E.164 format (e.g., +1234567890)
contactcontact_external_idstringExternal ID of the contact
tagtagstring[]Array of tags to match
all(none)-Sends to all active contacts with SMS opt-in

Optional Fields for Direct SMS

FieldTypeDescription
direct_first_namestringRecipient's first name (for personalization)
direct_last_namestringRecipient's last name (for personalization)

Common Optional Fields

FieldTypeDescription
variablesobjectTemplate variables (key-value pairs)
metadataobjectCustom tracking data
triggerAtstringISO 8601 UTC timestamp for scheduled send
sms_identity_idstringSMS identity UUID (defaults to user's default)

Complete Examples

1. Send Direct SMS with OTP

Send to a specific phone number without requiring a contact record:

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "otp-sms",
"recipient_type": "direct_sms",
"direct_phone": "+1234567890",
"direct_first_name": "John",
"variables": {
"otp_code": "123456",
"app_name": "MyApp"
}
}'

Response:

{
"success": true,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"job_id": "123",
"message": "SMS queued successfully"
}

Use Cases:

  • OTP verification
  • One-time notifications
  • Messages to non-registered users
  • Quick transactional SMS

2. Send to Contact

Send to a specific contact using their external ID:

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "order-confirmation",
"recipient_type": "contact",
"contact_external_id": "user-123",
"variables": {
"order_id": "ORD-456",
"delivery_date": "March 15, 2026"
}
}'

Response:

{
"success": true,
"trigger_id": "abc123-def456-ghi789",
"job_id": "124",
"message": "SMS queued successfully"
}

Use Cases:

  • Order confirmations
  • Account notifications
  • User-specific updates
  • Personalized alerts

Auto-populated Variables: When sending to a contact, their data is automatically available:

  • {{contact_first_name}} - Contact's first name
  • {{contact_last_name}} - Contact's last name
  • {{contact_phone}} - Contact's phone number
  • {{contact_external_id}} - Contact's external ID

3. Send to Tagged Contacts

Send to all contacts with specific tags:

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "flash-sale",
"recipient_type": "tag",
"tag": ["premium", "vip"],
"variables": {
"sale_discount": "50%",
"sale_end_time": "6 PM today"
}
}'

Response:

{
"success": true,
"trigger_id": "pqr901-stu234-vwx567",
"job_id": "125",
"message": "SMS queued successfully"
}

Use Cases:

  • Targeted promotions
  • Segment-specific campaigns
  • VIP notifications
  • Customer tier-based messaging

4. Send to All Contacts

Broadcast to all active contacts with SMS opt-in:

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "system-announcement",
"recipient_type": "all",
"variables": {
"announcement": "System maintenance tonight at 2 AM",
"company_name": "MyApp"
}
}'

Response:

{
"success": true,
"trigger_id": "xyz789-abc123-mno456",
"job_id": "126",
"message": "SMS queued successfully"
}

Use Cases:

  • System maintenance notifications
  • Emergency communications
  • Major announcements
  • Company-wide updates

5. Scheduled SMS

Schedule an SMS for future delivery:

curl -X POST https://api.sendmator.com/api/v1/sms/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "appointment-reminder",
"recipient_type": "contact",
"contact_external_id": "user-123",
"variables": {
"appointment_date": "March 20, 2026",
"appointment_time": "2:00 PM"
},
"triggerAt": "2026-03-19T14:00:00Z"
}'

Response:

{
"success": true,
"trigger_id": "lmn012-opq345-rst678",
"job_id": "127",
"message": "SMS scheduled successfully",
"scheduled_for": "2026-03-19T14:00:00Z",
"delay_ms": 86400000
}

Use Cases:

  • Appointment reminders
  • Time-zone specific sends
  • Scheduled campaigns
  • Event notifications

Response Format

Success Response (201 Created)

{
"success": true,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"job_id": "123",
"message": "SMS queued successfully"
}
FieldTypeDescription
successbooleanAlways true for successful requests
trigger_idstringUnique ID to track this send operation
job_idstringJob queue ID for monitoring
messagestringHuman-readable status message

Error Responses

Missing Template (400)

{
"statusCode": 400,
"message": "Template 'otp-sms' not found for team",
"error": "Bad Request"
}

Contact Not Found (404)

{
"statusCode": 404,
"message": "Contact with external_id 'user-123' not found",
"error": "Not Found"
}

Insufficient Balance (400)

{
"statusCode": 400,
"message": "Insufficient wallet balance. Required: 10.50 USD, Available: 5.00 USD. Please recharge your wallet to continue.",
"error": "Bad Request"
}

Invalid Phone Format (400)

{
"statusCode": 400,
"message": "direct_phone must be in E.164 format (e.g., +1234567890)",
"error": "Bad Request"
}

SMS Templates

All SMS messages require a template. Templates must be created in the Sendmator dashboard before sending.

Template Variables

Use double curly braces for variable substitution:

Your OTP code is {{otp_code}}. Valid for 10 minutes. -{{company_name}}

Character Limits

  • Single SMS: 160 characters
  • Multi-part SMS: Automatically split (charged per segment)
  • Unicode characters: Reduce limit to 70 characters per segment

DLT Compliance (India)

For Indian numbers, templates must be:

  • Registered with DLT (Distributed Ledger Technology)
  • Approved by telecom operators
  • Include proper sender ID and template ID

Recipient Types Summary

TypeDescriptionRequired FieldUse Case
direct_smsSend to phone numberdirect_phoneOTP, one-time messages
contactSend to existing contactcontact_external_idPersonalized messages
tagSend to tagged contactstag (array)Targeted campaigns
allSend to all contacts(none)Broadcasts

Subscription Management

Sendmator automatically handles SMS subscription preferences:

  • Opt-in: Only contacts who have opted in receive SMS
  • Opt-out: Automatically filtered from recipient list
  • Compliance: Ensures adherence to SMS marketing regulations

Users can opt-out by replying "STOP" to any SMS.


Pricing

SMS pricing varies by destination country:

RegionPrice per SMS
USA/Canada~$0.0075
UK~$0.04
India~$0.0035
Australia~$0.05
OtherVaries

Note: Multi-part messages are charged per segment.


Best Practices

1. Keep Messages Concise

# ✅ Good: Clear, concise message under 160 characters
{
"template_key": "otp-short",
"variables": {
"otp_code": "123456"
}
}
# Message: "Your OTP: 123456. Valid for 10 minutes."

# ❌ Avoid: Long messages that split into multiple parts
# Message: "Hello! Your one-time password for logging into your account is 123456..."

2. Use Appropriate Templates

# ✅ Good: Transactional messages for OTP
{
"template_key": "otp-verification",
"recipient_type": "direct_sms"
}

# ⚠️ Marketing requires opt-in
{
"template_key": "promotional-offer",
"recipient_type": "tag",
"tag": ["marketing-opt-in"]
}

3. Include Opt-Out Information

All marketing SMS should include opt-out instructions:

Get 50% off today! Reply STOP to unsubscribe.

4. Test Before Broadcasting

# Step 1: Test with yourself
{
"recipient_type": "direct_sms",
"direct_phone": "+your-phone"
}

# Step 2: Test with small group
{
"recipient_type": "tag",
"tag": ["internal-team"]
}

# Step 3: Send to everyone
{
"recipient_type": "all"
}

Multi-Channel Messages

To send messages across multiple channels (Email, SMS, WhatsApp, Push) simultaneously, use the Multi-Channel Trigger API instead of /sms/send.


Next Steps