curl -X POST https://api.example.com/api/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"body": "Hello from the messaging API!",
"from": "+15559876543"
}'
const response = await fetch('https://api.example.com/api/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '+15551234567',
body: 'Hello from the messaging API!',
from: '+15559876543'
})
});
const data = await response.json();
import requests
response = requests.post(
'https://api.example.com/api/messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'to': '+15551234567',
'body': 'Hello from the messaging API!',
'from': '+15559876543'
}
)
data = response.json()
{
"sid": "SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"status": "queued"
}
Messaging
Send message
Send an SMS or MMS message through the messaging platform
POST
/
api
/
messages
curl -X POST https://api.example.com/api/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"body": "Hello from the messaging API!",
"from": "+15559876543"
}'
const response = await fetch('https://api.example.com/api/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '+15551234567',
body: 'Hello from the messaging API!',
from: '+15559876543'
})
});
const data = await response.json();
import requests
response = requests.post(
'https://api.example.com/api/messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'to': '+15551234567',
'body': 'Hello from the messaging API!',
'from': '+15559876543'
}
)
data = response.json()
{
"sid": "SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"status": "queued"
}
Authentication
This endpoint requires API key authentication. Include your API key in theAuthorization header.
Authorization: Bearer YOUR_API_KEY
Request Body
string
required
The destination phone number in E.164 format (e.g., +15551234567)
string
required
The text content of the message to send
string
The sender phone number. If not provided, the default messaging service number will be used
Response
string
The unique identifier for the sent message from the provider
string
The current status of the message (e.g., “queued”, “sent”, “delivered”)
{
"sid": "SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"status": "queued"
}
Error Responses
string
The error code indicating what went wrong
string
Additional details about the error
Error Codes
missing_params(400) - Required parameters are missing from the requestprovider_not_configured(400) - The workspace doesn’t have a messaging provider configuredsend_failed(500) - Message sending failed due to an internal error
curl -X POST https://api.example.com/api/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"body": "Hello from the messaging API!",
"from": "+15559876543"
}'
const response = await fetch('https://api.example.com/api/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '+15551234567',
body: 'Hello from the messaging API!',
from: '+15559876543'
})
});
const data = await response.json();
import requests
response = requests.post(
'https://api.example.com/api/messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'to': '+15551234567',
'body': 'Hello from the messaging API!',
'from': '+15559876543'
}
)
data = response.json()