Send a message
Create and queue an outbound message for delivery. The channel is determined by the from number:
- SMS/MMS when
fromis a purchased SignalWire phone number or shortcode. The message is MMS whenmediais present orsend_as_mmsis set, otherwise SMS. - WhatsApp when
fromis awhatsapp:-prefixed WhatsApp number. Setmessage_typefor a content message, ortemplate_idfor an approved template. Free-form WhatsApp content is only allowed within the 24-hour customer service window.
Use this SignalWire REST operation for JSON requests. Integrations built around form-encoded requests and Message SIDs can use the Compatibility API’s Create message operation instead.
Permissions
The API token used to authenticate must have the following scope(s) enabled to make a successful request: Messaging.
Authentication
SignalWire Basic Authentication using Project ID and API Token.
The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password.
Example:
Authorization: Basic base64(project_id:token)
Request
A WhatsApp content message. The message_type field determines the shape of body.
Send an approved WhatsApp template. Use this to reach a customer for the first time or outside the 24-hour window. Do not include body or message_type.
Response
The unique ID of the message. This is the MessageSegment ID, consistent with the dashboard and the /api/messaging/logs endpoint.
Provider-specific error code if delivery failed. Null when no error occurred.
Human-readable error message if delivery failed. Null when no error occurred.
Relative URL for retrieving the message via the /api/messaging/logs endpoint.