API Documentation: SMS Messaging

Introduction

Welcome to our SMS messaging API documentation! This API provides a simple and efficient way to send text messages programmatically. Integrate it into your applications to automate notifications, confirm transactions, or create personalized user experiences.

To use this API, you'll need a unique API key. This key is automatically generated when you register and must be included in every request.

Endpoint

Send message: https://api.smstext.app/push

HTTP Method

POST

Authentication

Type: Basic Auth

Username: apikey

Password: [YOUR_API_KEY] (replace with your actual API key)

Request

Headers:

Body: (JSON format)

    
    [
      {
        "mobile": "+40763XXXXXX", // Recipient's phone number (international format)
        "text": "Your message"    // Message content
      }
    ]
    
    

Example cURL

    
    curl --location 'https://api.smstext.app/push' \
    --header 'Content-Type: application/json' \
    --data '[
      {
        "mobile": "+40763XXXXXX",
        "text": "Hello! This is a notification."
      }
    ]'
    
    

Response

HTTP Status Codes:

Format: The response typically does not contain additional data.

API Integration in Python and PHP

Understanding the API

The API is relatively simple, allowing you to send SMS messages via an HTTP POST request. Authentication uses Basic Auth, and data is formatted in JSON.

Python (using requests library)

    
    import requests

    def send_sms(api_key, phone_number, message):
      url = "https://api.smstext.app/push"
      headers = {
        "Authorization": f"Basic {api_key}",
        "Content-Type": "application/json"
      }
      data = [
        {
          "mobile": phone_number,
          "text": message
        }
      ]
      response = requests.post(url, headers=headers, json=data)
      if response.status_code == 200:
        print("Message sent successfully!")
      else:
        print(f"Error sending message: {response.text}")
    
    

PHP (using cURL)

    
    <?php
    function send_sms($api_key, $phone_number, $message) {
      $url = "https://api.smstext.app/push";
      $data = json_encode([
        [
          "mobile" => $phone_number,
          "text" => $message
        ]
      ]);

      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Authorization: Basic " . base64_encode($api_key . ":"),
        "Content-Type: application/json"
      ]);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      $response = curl_exec($ch);
      curl_close($ch);

      if ($response === false) {
        die('Error: "' . curl_error($ch) . '"');
      } else {
        echo $response;
      }
    }
    ?>