Portal setup
Follow the setup guide to configure your Portal for sending and receiving messages.Development environment setup
Check out the Development Environment Setup guide to acquire your API Key. You can paste the below snippets into your Terminal on Mac and Linux computers. Windows users should install bash on Windows.Send an SMS or MMS with Telnyx
Follow the steps below to send SMS and MMS messages.- Using the SMS or MMS examples below, write a
curlcommand that will submit an outbound message request. Include your API Key in theAuthorizationrequest header, and add the source (from) and destination (to) phone number, and the message’s content (text) into the payload. Optionally, your payload may include awebhook_urlorwebhook_failover_url(or both).
- Don’t forget to update
YOUR_API_KEYin the below commands. - Make sure that the source (
from) is eligible to send messages towards the destination (to) phone number. Read more about this here. - If you are sending a message internationally from an A2P enabled longcode, we will automatically fail over to alphanumeric routes using a generic
SenderID. - If sending an alphanumeric message, make sure to specify the
messaging_profile_idparameter in the body of the request.
Send SMS
Example response
- Make sure you’re using the full +E.164 formatted number for your
toandfromnumbers. In the US and Canada, this typically means adding +1 to the beginning of your 10-digit phone number. - The webhook URLs for this message are taken from the messaging profile.
If you want to override them, use the
webhook_urlandwebhook_failover_urlrequest fields.
Send MMS
For MMS messages, the structure of the send request differs, in order to accommodate different types of media Send a message with an image URL:- The
fromnumber here must be MMS enabled. - Passing an empty array to the
media_urlsparameter will result in
- Media URLs must be publicly accessible.
- While the
subjectparameter can be included in your request as shown in the example, this field is not returned in the API response. The subject field only applies to MMS messages, and when provided, the subject will be sent instead of the text content.
- Replace the
fromnumber with your Telnyx number. Be sure to remove any delimiters like dashes or spaces. - Replace the
tonumber with the number you want to send a message to. Make sure you’re using the full +E.164 formatted number. In the US and Canada, this typically means adding +1 to the beginning of your 10-digit phone number. - Run the updated command.