Issue
You may report that status callbacks configured in your Messaging Service are not being received when sending outbound messages through the API.
Product
Programmable Messaging
Environment
legacy Twilio Console
Cause
Even though the callback URL is correctly set under Messaging → Services → [Service] → Integration → Status Callback URL, no delivery status events (e.g., queued, sent, delivered, failed) are triggered at that endpoint.
When creating messages through the Twilio API, you can specify:
- A specific phone number using the
fromparameter - A Messaging Service using the
messaging_service_sidparameter, - Or both together.
If the messaging_service_sid is not included, the message is sent directly from the phone number, and Twilio will send status callbacks to the callback URL configured for that phone number, if one exists.
In this case, the Messaging Service’s callback URL is not used, even if the number belongs to the Messaging Service.
Resolution
To ensure status callbacks are sent to the Messaging Service’s callback URL, include the messaging_service_sid parameter when creating your messages.
You may still include the from parameter to specify which sender in the Messaging Service should be used, but the Messaging Service configuration will take precedence for callbacks and routing behavior.
Example
Incorrect Implementation
This message uses a phone number directly, so the Messaging Service callback will not be triggered:
from twilio.rest import Client
client = Client(account_sid, auth_token)
message = client.messages.create(
from_="+14155551234",
to="+14155556789",
body="Hello! This message may not trigger your Messaging Service callback."
)Correct Implementation
Including the messaging_service_sid ensures that callbacks go to your Messaging Service:
from twilio.rest import Client
client = Client(account_sid, auth_token)
message = client.messages.create(
messaging_service_sid="MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
from_="+14155551234", # Optional - must belong to the Messaging Service
to="+14155556789",
body="Hello! This message will use your Messaging Service callback."
)Additional Information
- Using both
fromandmessaging_service_sidis valid, the Messaging Service configuration determines callback behavior. - You can configure the Messaging Service status callback URL in the Twilio Console under:
Messaging → Services → [Your Service] → Integration → Status Callback URL - Reference: Create a Message Resource.
If you rely on Messaging Service callbacks, always include the messaging_service_sid parameter when sending outbound messages. This ensures consistent delivery reporting and that callbacks are sent to the intended endpoint.