Insert
- API Documentation: Insert SMS Message
Contents
Overview
The insert endpoint of the Smart-DevText API allows you to insert a new SMS message into the database. This endpoint is designed for use with the Smart-DevText Android app and requires specific details such as the recipient's phone number, the message text, and an API key ID for authentication.
Endpoint
POST https://smart-devtext.com/api/android/devtext/insert
Request
Headers
- Content-Type: application/json
Body Parameters
Parameter | Type | Description | Required |
---|---|---|---|
phoneNumber | string | The recipient's phone number. | Yes |
text | string | The text message to be sent. | Yes |
apiKeyId | string | The API key ID for authenticating the request. | Yes |
Example Request Body
{ "phoneNumber": "+1234567890", "text": "Hello, this is a test message.", "apiKeyId": "your-api-key-id" }
Response
Success Response
- Status Code: 201 Created
- Content-Type: application/json
- Body:
{ "success": "Message inserted successfully" }
Error Responses
Missing Data
- Status Code: 400 Bad Request
- Content-Type: application/json
- Body:
{ "error": "Missing data. Please provide phone number, text, and API key ID." }
Database Insertion Error
- Status Code: 500 Internal Server Error
- Content-Type: application/json
- Body:
{ "error": "Failed to insert the message" }
Database Connection Error
- Status Code: 500 Internal Server Error
- Content-Type: application/json
- Body:
{ "error": "Database insertion error" }
Usage Example
CURL
curl -X POST https://smart-devtext.com/api/android/devtext/insert \ -H "Content-Type: application/json" \ -d '{ "phoneNumber": "+1234567890", "text": "Hello, this is a test message.", "apiKeyId": "your-api-key-id" }'
JavaScript (fetch)
fetch('https://smart-devtext.com/api/android/devtext/insert', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ phoneNumber: '+1234567890', text: 'Hello, this is a test message.', apiKeyId: 'your-api-key-id' }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));