Insert

From
Revision as of 03:07, 17 June 2024 by Ndemme (talk | contribs) (Protected "Insert" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  1. API Documentation: Insert SMS Message

Overview

The insert endpoint of the smart-devtext API allows you to insert a new SMS message into the database.

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));