Handle Twilio SMS status callback
curl --request POST \
--url https://your-instance.example.com/api/webhook/twilio/sms-status \
--header 'Content-Type: application/json' \
--data '
{
"MessageSid": "SM5f7b1c2e8a1d4e0012c3b4a5",
"MessageStatus": "delivered",
"To": "+14165550100",
"From": "+12362320246"
}
'import requests
url = "https://your-instance.example.com/api/webhook/twilio/sms-status"
payload = {
"MessageSid": "SM5f7b1c2e8a1d4e0012c3b4a5",
"MessageStatus": "delivered",
"To": "+14165550100",
"From": "+12362320246"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
MessageSid: 'SM5f7b1c2e8a1d4e0012c3b4a5',
MessageStatus: 'delivered',
To: '+14165550100',
From: '+12362320246'
})
};
fetch('https://your-instance.example.com/api/webhook/twilio/sms-status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/webhook/twilio/sms-status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'MessageSid' => 'SM5f7b1c2e8a1d4e0012c3b4a5',
'MessageStatus' => 'delivered',
'To' => '+14165550100',
'From' => '+12362320246'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/webhook/twilio/sms-status"
payload := strings.NewReader("{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-instance.example.com/api/webhook/twilio/sms-status")
.header("Content-Type", "application/json")
.body("{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/webhook/twilio/sms-status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}"
response = http.request(request)
puts response.read_body"OK"{
"error": "Webhook processing failed"
}Webhooks
Handle Twilio SMS status callback
Status callback posted by Twilio for outbound SMS/MMS as the message transitions through queued / sent / delivered / failed. Updates the corresponding Message document and broadcasts a socket event so the org sees the latest delivery state.
POST
/
api
/
webhook
/
twilio
/
sms-status
Handle Twilio SMS status callback
curl --request POST \
--url https://your-instance.example.com/api/webhook/twilio/sms-status \
--header 'Content-Type: application/json' \
--data '
{
"MessageSid": "SM5f7b1c2e8a1d4e0012c3b4a5",
"MessageStatus": "delivered",
"To": "+14165550100",
"From": "+12362320246"
}
'import requests
url = "https://your-instance.example.com/api/webhook/twilio/sms-status"
payload = {
"MessageSid": "SM5f7b1c2e8a1d4e0012c3b4a5",
"MessageStatus": "delivered",
"To": "+14165550100",
"From": "+12362320246"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
MessageSid: 'SM5f7b1c2e8a1d4e0012c3b4a5',
MessageStatus: 'delivered',
To: '+14165550100',
From: '+12362320246'
})
};
fetch('https://your-instance.example.com/api/webhook/twilio/sms-status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/webhook/twilio/sms-status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'MessageSid' => 'SM5f7b1c2e8a1d4e0012c3b4a5',
'MessageStatus' => 'delivered',
'To' => '+14165550100',
'From' => '+12362320246'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/webhook/twilio/sms-status"
payload := strings.NewReader("{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-instance.example.com/api/webhook/twilio/sms-status")
.header("Content-Type", "application/json")
.body("{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/webhook/twilio/sms-status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"MessageSid\": \"SM5f7b1c2e8a1d4e0012c3b4a5\",\n \"MessageStatus\": \"delivered\",\n \"To\": \"+14165550100\",\n \"From\": \"+12362320246\"\n}"
response = http.request(request)
puts response.read_body"OK"{
"error": "Webhook processing failed"
}Body
application/json
Twilio-assigned message identifier whose status is being reported.
Delivery state: queued, sent, delivered, failed, undelivered.
Recipient phone number for the outbound message.
Tether-provisioned Twilio number the message was sent from.
Twilio error code when delivery failed (e.g. 30003).
Human-readable error description paired with ErrorCode.
Response
Plain-text acknowledgement (Twilio only checks the 2xx status).
The response is of type string.
Example:
"OK"
⌘I