curl -X POST "https://api.magpipe.ai/functions/v1/send-sms" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+14155551234",
"from": "+16045551234",
"body": "Your appointment is confirmed for tomorrow at 2pm. Reply YES to confirm or NO to reschedule."
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/send-sms',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '+14155551234',
from: '+16045551234',
body: 'Your appointment is confirmed for tomorrow at 2pm.',
}),
}
);
const data = await response.json();
console.log(data.message_id);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/send-sms',
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
},
json={
'to': '+14155551234',
'from': '+16045551234',
'body': 'Your appointment is confirmed for tomorrow at 2pm.',
}
)
data = response.json()
print(data['message_id'])
{
"success": true,
"message_id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
"status": "sent",
"segments": 1,
"from_number": "+16045551234",
"to_number": "+14155551234",
"created_at": "2024-01-15T10:30:00.000Z"
}
Messages
Send SMS
Send an SMS message from your Magpipe number
POST
/
send-sms
curl -X POST "https://api.magpipe.ai/functions/v1/send-sms" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+14155551234",
"from": "+16045551234",
"body": "Your appointment is confirmed for tomorrow at 2pm. Reply YES to confirm or NO to reschedule."
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/send-sms',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '+14155551234',
from: '+16045551234',
body: 'Your appointment is confirmed for tomorrow at 2pm.',
}),
}
);
const data = await response.json();
console.log(data.message_id);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/send-sms',
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
},
json={
'to': '+14155551234',
'from': '+16045551234',
'body': 'Your appointment is confirmed for tomorrow at 2pm.',
}
)
data = response.json()
print(data['message_id'])
{
"success": true,
"message_id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
"status": "sent",
"segments": 1,
"from_number": "+16045551234",
"to_number": "+14155551234",
"created_at": "2024-01-15T10:30:00.000Z"
}
Overview
Sends an SMS text message to a phone number using one of your Magpipe numbers as the sender.Request
Headers
string
required
Bearer token for authentication.
string
required
Must be
application/jsonBody Parameters
string
required
Recipient phone number in E.164 format.Example:
"+14155551234"Constraints:- Must start with
+followed by country code - 10-15 digits total
string
required
Your Magpipe phone number to send from. Must be SMS-enabled.Example:
"+16045551234"string
required
The message content.Example:
"Your appointment is confirmed for tomorrow at 2pm."Constraints:- Maximum 1600 characters
- Messages over 160 characters are sent as multiple segments
array
Array of URLs for MMS media attachments.Example:
["https://example.com/image.jpg"]Constraints:- Maximum 10 media items
- Supported formats: jpg, png, gif, pdf
- Maximum 5MB per file
string
ISO 8601 timestamp to schedule the message for later delivery.Example:
"2024-01-16T10:00:00Z"Constraints:- Must be in the future
- Maximum 7 days ahead
Response
boolean
Whether the message was sent/queued successfully.
string
Unique identifier for the message.
string
Current message status:
queued- Message is queued for deliverysent- Message sent to carrierscheduled- Message scheduled for future delivery
integer
Number of SMS segments the message was split into.
string
ISO 8601 timestamp.
Example Request
curl -X POST "https://api.magpipe.ai/functions/v1/send-sms" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+14155551234",
"from": "+16045551234",
"body": "Your appointment is confirmed for tomorrow at 2pm. Reply YES to confirm or NO to reschedule."
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/send-sms',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '+14155551234',
from: '+16045551234',
body: 'Your appointment is confirmed for tomorrow at 2pm.',
}),
}
);
const data = await response.json();
console.log(data.message_id);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/send-sms',
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
},
json={
'to': '+14155551234',
'from': '+16045551234',
'body': 'Your appointment is confirmed for tomorrow at 2pm.',
}
)
data = response.json()
print(data['message_id'])
Example Response
{
"success": true,
"message_id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
"status": "sent",
"segments": 1,
"from_number": "+16045551234",
"to_number": "+14155551234",
"created_at": "2024-01-15T10:30:00.000Z"
}
Error Responses
{
"error": {
"code": "INVALID_PHONE_NUMBER",
"message": "The 'to' field must be a valid E.164 phone number"
}
}
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or expired access token"
}
}
{
"error": {
"code": "SMS_NOT_ENABLED",
"message": "The 'from' number does not have SMS capability"
}
}
Message Status Webhook
When the message status changes, a webhook is sent to your configured URL:{
"event": "message.status_changed",
"message_id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
"status": "delivered",
"to_number": "+14155551234",
"from_number": "+16045551234",
"timestamp": "2024-01-15T10:30:05.000Z"
}
Message Status Values
| Status | Description |
|---|---|
queued | Message queued for sending |
sent | Message sent to carrier |
delivered | Confirmed delivered to recipient |
undelivered | Could not be delivered |
failed | Failed to send |
SMS Segment Calculation
SMS messages are split into segments:| Character Set | Characters per Segment |
|---|---|
| GSM-7 (standard) | 160 characters |
| Unicode (emojis, etc.) | 70 characters |