Send SMS
Use Case
Send a SMS to the target phone number.
Request
curl --location 'https://api.twilio.com/2010-04-01/Accounts/ACde26cba4f90fab17cc43cc66fbbe28ae/Messages.json'
--header 'Content-Type: application/x-www-form-urlencoded'
--header 'Authorization: Basic QUNkZTI2Y2JhNGY5MGZhYjE3Y2M0M2NjNjZmYmJlMjhhZTozZDU2ZmVjNzNiNzk0NjUzMzUxYjMwNzQ4ZGNiNzllMQ=='
--data-urlencode 'To=+34649485975'
--data-urlencode 'From=+15005550006'
--data-urlencode 'Body=Test'
Success Response
{
"body": "Test",
"num_segments": "1",
"direction": "outbound-api",
"from": "+15005550006",
"date_updated": "Wed, 29 Nov 2023 12:34:47 +0000",
"price": null,
"error_message": null,
"uri": "/2010-04-01/Accounts/ACde26cba4f90fab17cc43cc66fbbe28ae/Messages/SM4be68cd3efe67988b3800c6a0b08b47d.json",
"account_sid": "ACde26cba4f90fab17cc43cc66fbbe28ae",
"num_media": "0",
"to": "+34649485975",
"date_created": "Wed, 29 Nov 2023 12:34:47 +0000",
"status": "queued",
"sid": "SM4be68cd3efe67988b3800c6a0b08b47d",
"date_sent": null,
"messaging_service_sid": null,
"error_code": null,
"price_unit": "USD",
"api_version": "2010-04-01",
"subresource_uris": {
"media": "/2010-04-01/Accounts/ACde26cba4f90fab17cc43cc66fbbe28ae/Messages/SM4be68cd3efe67988b3800c6a0b08b47d/Media.json"
}
}
Error Response
This is a sample error response not related to the request above.
{
"code": 21212,
"message": "The 'From' number +15005550001 is not a valid phone number, shortcode, or alphanumeric sender ID.",
"more_info": "https://www.twilio.com/docs/errors/21212",
"status": 400
}
Credentials
- Account SID: ACde26cba4f90fab17cc43cc66fbbe28ae
- Secret: 3d56fec73b794653351b30748dcb79e1