How to Send an SMS via the DataPhone API #
Sending SMS messages using the DataPhone API is simple and efficient. Follow the steps below to send an SMS message through the API.
API Endpoint #
The endpoint to send an SMS is:
https://api.dataphone.cloud/messages/sms/send
HTTP Method #
POST
Request Headers #
- Content-Type:
application/json
- Authorization:
Bearer YOUR_API_KEY
(ReplaceYOUR_API_KEY
with your actual API key)
Request Body #
The body of the request should be in JSON format and include the following fields:
- from: The sender’s phone number in E.164 format (e.g.,
+1xxxxxxxxxx
) - to: The recipient’s phone number in E.164 format (e.g.,
+1xxxxxxxxxx
) - text: The message content (e.g.,
Test API
)
Example Request #
POST /messages/sms/send HTTP/1.1
Host: api.dataphone.cloud
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"from": "+1xxxxxxxxxx",
"to": "+1xxxxxxxxxx",
"text": "Test API"
}
Response #
A successful request will return a 200 OK
status. Note that the response may not include additional information in the body.
Error Handling #
If there are issues with the request, you will receive an HTTP status code indicating the type of error. Common status codes include:
- 400 Bad Request: Invalid request format or parameters.
- 401 Unauthorized: Authentication failure. Verify your API key.
- 403 Forbidden: Insufficient permissions.
- 404 Not Found: Endpoint or resource not found.
- 500 Internal Server Error: Server error. Try again later or contact support.
Troubleshooting #
- Verify API Key: Ensure your API key is valid and correctly included in the Authorization header.
- Check Phone Numbers: Confirm that both the sender’s and recipient’s phone numbers are in E.164 format.
- Monitor API Limits: Ensure you are within the limits of your API usage.
For more details or if you need further assistance, please contact our support team at support@dataphone.cloud.